]> git.ipfire.org Git - thirdparty/cups-filters.git/commitdiff
libcupsfilters: In generate_sizes() consider all margin alternatives
authorTill Kamppeter <till.kamppeter@gmail.com>
Mon, 9 Jan 2023 22:24:47 +0000 (19:24 -0300)
committerTill Kamppeter <till.kamppeter@gmail.com>
Mon, 9 Jan 2023 22:24:47 +0000 (19:24 -0300)
generate_sizes() reads the available margin sizes from the
media-{left,right,top,bottom}-margin-supported printer IPP attributes
to use the minimum value as default for each margin.

In the case that there is more than one margin value, the first value
in the list did not get considered, often making borderless printing
support (zero margin as first in the list) staying undiscovered.

This commit fixes that and makes sure that always the minimum value is
ysed.

cupsfilters/ppdgenerator.c

index 23d519d1b837189c85a26aee52a88f98aa23fab9..77defec08d39754baedcac5a84034a814fa518ab 100644 (file)
@@ -1190,7 +1190,7 @@ cups_array_t* generate_sizes(ipp_t *response,
                               IPP_TAG_INTEGER)) != NULL) {
     for (i = 1, *bottom = ippGetInteger(attr, 0), count = ippGetCount(attr);
         i < count; i ++)
-      if (i == 1 || ippGetInteger(attr, i) < *bottom)
+      if (ippGetInteger(attr, i) < *bottom)
         *bottom = ippGetInteger(attr, i);
   } else
     *bottom = 1270;
@@ -1199,7 +1199,7 @@ cups_array_t* generate_sizes(ipp_t *response,
                               IPP_TAG_INTEGER)) != NULL) {
     for (i = 1, *left = ippGetInteger(attr, 0), count = ippGetCount(attr);
         i < count; i ++)
-      if (i == 1 || ippGetInteger(attr, i) < *left)
+      if (ippGetInteger(attr, i) < *left)
         *left = ippGetInteger(attr, i);
   } else
     *left = 635;
@@ -1208,7 +1208,7 @@ cups_array_t* generate_sizes(ipp_t *response,
                               IPP_TAG_INTEGER)) != NULL) {
     for (i = 1, *right = ippGetInteger(attr, 0), count = ippGetCount(attr);
         i < count; i ++)
-      if (i == 1 || ippGetInteger(attr, i) < *right)
+      if (ippGetInteger(attr, i) < *right)
         *right = ippGetInteger(attr, i);
   } else
     *right = 635;
@@ -1217,7 +1217,7 @@ cups_array_t* generate_sizes(ipp_t *response,
                               IPP_TAG_INTEGER)) != NULL) {
     for (i = 1, *top = ippGetInteger(attr, 0), count = ippGetCount(attr);
         i < count; i ++)
-      if (i == 1 || ippGetInteger(attr, i) < *top)
+      if (ippGetInteger(attr, i) < *top)
         *top = ippGetInteger(attr, i);
   } else
     *top = 1270;