OpenPrinting / cups

OpenPrinting CUPS Sources
https://openprinting.github.io/cups
Apache License 2.0
958 stars 174 forks source link

Filter pstops may ignore manual_copies or max_copies #918

Closed psz2036 closed 3 months ago

psz2036 commented 3 months ago

Filter pstops may ignore manual_copies or max_copies. Issue observed at version 2.4.2 in Debian bookworm, present still in current "master" version. Patch tested against Debian, but for current version, below (in plain-text and as attached file).

Cheers, Paul

Paul Szabo psz@maths.usyd.edu.au www.maths.usyd.edu.au/u/psz School of Mathematics and Statistics University of Sydney Australia

--- filter/pstops.c.ORIG    2024-03-31 08:36:24.256946521 +1100
+++ filter/pstops.c 2024-03-31 08:36:49.677092158 +1100
@@ -2550,18 +2550,20 @@

  /*
   * Now figure out if we have to force collated copies, etc.
+  * PSz 5 Mar 2024  Logic round here fixed
   */

-  if ((attr = ppdFindAttr(ppd, "cupsMaxCopies", NULL)) != NULL)
-    max_copies = atoi(attr->value);
-  else if (ppd && ppd->manual_copies)
+  if (ppd && !ppd->manual_copies)
     max_copies = 1;
+  else if ((attr = ppdFindAttr(ppd, "cupsMaxCopies", NULL)) != NULL)
+    max_copies = atoi(attr->value);
   else
     max_copies = 9999;

   if (doc->copies > max_copies)
-    doc->collate = 1;
-  else if (ppd && ppd->manual_copies && Duplex && doc->copies > 1)
+    doc->copies = max_copies;
+
+  if (Duplex && doc->copies > 1)
   {
    /*
     * Force collated copies when printing a duplexed document to

psz-patch.txt

michaelrsweet commented 3 months ago

This patch doesn't look correct.

pstops needs to produce copies when the number of copies requested is larger than the printer will support natively. But your change basically says "if cupsManualCopies is false, always produce copies".

psz2036 commented 3 months ago

Ignore max_copies must be a feature. (No, my change does not do that.) Your code, your bug.