]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Suppress duplicate media sizes (Issue #4933)
authorMichael Sweet <michael.r.sweet@gmail.com>
Wed, 14 Dec 2016 14:39:28 +0000 (09:39 -0500)
committerMichael Sweet <michael.r.sweet@gmail.com>
Wed, 14 Dec 2016 14:39:28 +0000 (09:39 -0500)
CHANGES.txt
cups/ppd-cache.c
cups/pwg-media.c

index 00dd75252cccf021c64457065ac856ee029c3e81..21ce4f98d049f9c6f4922bbe91b5636aff724daa 100644 (file)
@@ -1,11 +1,11 @@
-CHANGES.txt - 2.2.2 - 2016-11-18
+CHANGES.txt - 2.2.2 - 2016-12-14
 --------------------------------
 
 CHANGES IN CUPS V2.2.2
 
        - Fixed some issues with the Zebra ZPL printer driver (Issue #4898)
        - Fixed some issues with IPP Everywhere printer support (Issue #4893,
-         Issue #4909, Issue #4916, Issue #4921)
+         Issue #4909, Issue #4916, Issue #4921, Issue #4933)
        - The cups-lpd program did not catch all legacy usage of ISO-8859-1
           (Issue #4899)
         - Fixed builds on systems without a working poll() implementation
index cec0606543a18e9f6c686c93c2fbf71d72d786b2..c035fbecb6752c9a255f3637fcdf9af40f4d9b43 100644 (file)
@@ -2931,6 +2931,7 @@ _ppdCreateFromIPP(char   *buffer, /* I - Filename buffer */
                  ipp_t  *response)     /* I - Get-Printer-Attributes response */
 {
   cups_file_t          *fp;            /* PPD file */
+  cups_array_t         *sizes;         /* Media sizes we've added */
   ipp_attribute_t      *attr,          /* xxx-supported */
                        *defattr,       /* xxx-default */
                        *x_dim, *y_dim; /* Media dimensions */
@@ -3185,6 +3186,9 @@ _ppdCreateFromIPP(char   *buffer, /* I - Filename buffer */
     cupsFilePrintf(fp, "*OpenUI *PageSize: PickOne\n"
                       "*OrderDependency: 10 AnySetup *PageSize\n"
                        "*DefaultPageSize: %s\n", ppdname);
+
+    sizes = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+
     for (i = 0, count = ippGetCount(attr); i < count; i ++)
     {
       if (ippGetValueTag(attr) == IPP_TAG_BEGIN_COLLECTION)
@@ -3203,6 +3207,14 @@ _ppdCreateFromIPP(char   *buffer,        /* I - Filename buffer */
         char   twidth[256],            /* Width string */
                tlength[256];           /* Length string */
 
+        if (cupsArrayFind(sizes, (void *)pwg->ppd))
+        {
+          cupsFilePrintf(fp, "*%% warning: Duplicate size '%s' reported by printer.\n", pwg->ppd);
+          continue;
+        }
+
+        cupsArrayAdd(sizes, (void *)pwg->ppd);
+
         _cupsStrFormatd(twidth, twidth + sizeof(twidth), pwg->width * 72.0 / 2540.0, loc);
         _cupsStrFormatd(tlength, tlength + sizeof(tlength), pwg->length * 72.0 / 2540.0, loc);
 
@@ -3211,6 +3223,9 @@ _ppdCreateFromIPP(char   *buffer, /* I - Filename buffer */
     }
     cupsFilePuts(fp, "*CloseUI: *PageSize\n");
 
+    cupsArrayDelete(sizes);
+    sizes = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+
     cupsFilePrintf(fp, "*OpenUI *PageRegion: PickOne\n"
                        "*OrderDependency: 10 AnySetup *PageRegion\n"
                        "*DefaultPageRegion: %s\n", ppdname);
@@ -3232,6 +3247,11 @@ _ppdCreateFromIPP(char   *buffer,        /* I - Filename buffer */
         char   twidth[256],            /* Width string */
                tlength[256];           /* Length string */
 
+        if (cupsArrayFind(sizes, (void *)pwg->ppd))
+          continue;
+
+        cupsArrayAdd(sizes, (void *)pwg->ppd);
+
         _cupsStrFormatd(twidth, twidth + sizeof(twidth), pwg->width * 72.0 / 2540.0, loc);
         _cupsStrFormatd(tlength, tlength + sizeof(tlength), pwg->length * 72.0 / 2540.0, loc);
 
@@ -3240,6 +3260,9 @@ _ppdCreateFromIPP(char   *buffer, /* I - Filename buffer */
     }
     cupsFilePuts(fp, "*CloseUI: *PageRegion\n");
 
+    cupsArrayDelete(sizes);
+    sizes = cupsArrayNew3((cups_array_func_t)strcmp, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_func_t)free);
+
     cupsFilePrintf(fp, "*DefaultImageableArea: %s\n"
                       "*DefaultPaperDimension: %s\n", ppdname, ppdname);
     for (i = 0, count = ippGetCount(attr); i < count; i ++)
@@ -3264,6 +3287,11 @@ _ppdCreateFromIPP(char   *buffer,        /* I - Filename buffer */
                twidth[256],            /* Width string */
                tlength[256];           /* Length string */
 
+        if (cupsArrayFind(sizes, (void *)pwg->ppd))
+          continue;
+
+        cupsArrayAdd(sizes, (void *)pwg->ppd);
+
         _cupsStrFormatd(tleft, tleft + sizeof(tleft), left * 72.0 / 2540.0, loc);
         _cupsStrFormatd(tbottom, tbottom + sizeof(tbottom), bottom * 72.0 / 2540.0, loc);
         _cupsStrFormatd(tright, tright + sizeof(tright), (pwg->width - right) * 72.0 / 2540.0, loc);
@@ -3275,6 +3303,8 @@ _ppdCreateFromIPP(char   *buffer, /* I - Filename buffer */
         cupsFilePrintf(fp, "*PaperDimension %s: \"%s %s\"\n", pwg->ppd, twidth, tlength);
       }
     }
+
+    cupsArrayDelete(sizes);
   }
   else
     goto bad_ppd;
index a064d2f9734a64475bb9b4a2acd6975824cefa56..1bdf68e9ee95f8899f0409c46dcfe5ec0e551aea 100644 (file)
@@ -226,13 +226,13 @@ static pwg_media_t const cups_pwg_media[] =
   _PWG_MEDIA_IN("oe_photo-l_3.5x5in", NULL, "3.5x5", 3.5, 5),
 
   /* Other Metric Standard Sheet Media Sizes */
-  _PWG_MEDIA_MM("om_small-photo_100x150mm", NULL, "om_small-photo", 100, 150),
+  _PWG_MEDIA_MM("om_small-photo_100x150mm", NULL, "100x150mm", 100, 150),
   _PWG_MEDIA_MM("om_italian_110x230mm", NULL, "EnvItalian", 110, 230),
-  _PWG_MEDIA_MM("om_large-photo_200x300", NULL, "om_large-photo", 200, 300),
+  _PWG_MEDIA_MM("om_large-photo_200x300", NULL, "200x300mm", 200, 300),
   _PWG_MEDIA_MM("om_folio_210x330mm", "folio", "Folio", 210, 330),
   _PWG_MEDIA_MM("om_folio-sp_215x315mm", NULL, "FolioSP", 215, 315),
   _PWG_MEDIA_MM("om_invite_220x220mm", NULL, "EnvInvite", 220, 220),
-  _PWG_MEDIA_MM("om_small-photo_100x200mm", NULL, "om_wide-photo", 100, 200),
+  _PWG_MEDIA_MM("om_small-photo_100x200mm", NULL, "100x200mm", 100, 200),
 
   /* Disc Sizes */
   _PWG_MEDIA_MM("disc_standard_40x118mm", NULL, "Disc", 118, 118)