kopia lustrzana https://gitlab.com/sane-project/backends
* sanei/sanei_constrain_value.c:
if checked option is a range and the value is out of range the value is now corrected to the minimum or maximum allowed value and SANE_INFO_INEXACT is set. The old version returned with an error. This caused problems when the value was a little bit out of range because of rounding errors. Oliver RauchDEVEL_2_0_BRANCH-1
rodzic
070adee264
commit
bc7b3d76a5
|
@ -63,8 +63,23 @@ sanei_constrain_value (const SANE_Option_Descriptor * opt, void * value,
|
|||
w = *(SANE_Word *) value;
|
||||
range = opt->constraint.range;
|
||||
|
||||
if (w < range->min || w > range->max)
|
||||
return SANE_STATUS_INVAL; /* out of range */
|
||||
if (w < range->min)
|
||||
{
|
||||
*(SANE_Word *) value = range->min;
|
||||
if (info)
|
||||
{
|
||||
*info |= SANE_INFO_INEXACT;
|
||||
}
|
||||
}
|
||||
|
||||
if (w > range->max)
|
||||
{
|
||||
*(SANE_Word *) value = range->max;
|
||||
if (info)
|
||||
{
|
||||
*info |= SANE_INFO_INEXACT;
|
||||
}
|
||||
}
|
||||
|
||||
if (range->quant)
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue