]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Handle constraints against PageSize or PageRegion being equivalent.
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 14 Jan 2009 23:17:47 +0000 (23:17 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Wed, 14 Jan 2009 23:17:47 +0000 (23:17 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@8255 7a7537e8-13f0-0310-91df-b6672ffda945

cups/conflicts.c
cups/testconflicts.c

index 6376f69ef8b2732c517d0c5f908614214c7a97aa..1ee86b10e0ca167115bf38fb03d34f792611b412 100644 (file)
@@ -307,6 +307,7 @@ cupsResolveConflicts(
         int            j;              /* Looping var */
        ppd_choice_t    *cptr;          /* Current choice */
         cups_array_t   *test;          /* Test array for conflicts */
+        ppd_size_t     *size;          /* Current page size */
 
 
         for (i = consts->num_constraints, constptr = consts->constraints;
@@ -324,7 +325,12 @@ cupsResolveConflicts(
          * Is this the option we are changing?
          */
 
-         if (option && !strcasecmp(constptr->option->keyword, option))
+         if (option &&
+             (!strcasecmp(constptr->option->keyword, option) ||
+              (!strcasecmp(option, "PageSize") &&
+               !strcasecmp(constptr->option->keyword, "PageRegion")) ||
+              (!strcasecmp(option, "PageRegion") &&
+               !strcasecmp(constptr->option->keyword, "PageSize"))))
            continue;
 
          /*
@@ -334,8 +340,26 @@ cupsResolveConflicts(
           if ((value = cupsGetOption(constptr->option->keyword, num_newopts,
                                     newopts)) == NULL)
           {
-           marked = ppdFindMarkedChoice(ppd, constptr->option->keyword);
-           value  = marked ? marked->choice : "";
+           if (!strcasecmp(constptr->option->keyword, "PageSize") ||
+               !strcasecmp(constptr->option->keyword, "PageRegion"))
+           {
+             if ((value = cupsGetOption("PageSize", num_newopts,
+                                        newopts)) == NULL)
+                value = cupsGetOption("PageRegion", num_newopts, newopts);
+
+              if (!value)
+             {
+               if ((size = ppdPageSize(ppd, NULL)) != NULL)
+                 value = size->name;
+               else
+                 value = "";
+             }
+           }
+           else
+           {
+             marked = ppdFindMarkedChoice(ppd, constptr->option->keyword);
+             value  = marked ? marked->choice : "";
+           }
          }
 
          /*
index 291739a2684a69908259dc5eefdea8a962ff954d..0d7531bdbb8e82038a615a66a560d7bc0804130e 100644 (file)
@@ -36,7 +36,10 @@ main(int  argc,                              /* I - Number of command-line arguments */
 {
   int          i;                      /* Looping var */
   ppd_file_t   *ppd;                   /* PPD file loaded from disk */
-  char         line[256];              /* Input buffer */
+  char         line[256],              /* Input buffer */
+               *ptr,                   /* Pointer into buffer */
+               *optr,                  /* Pointer to first option name */
+               *cptr;                  /* Pointer to first choice */
   int          num_options;            /* Number of options */
   cups_option_t        *options;               /* Options */
   char         *option,                /* Current option */
@@ -73,11 +76,12 @@ main(int  argc,                             /* I - Number of command-line arguments */
 
     if (!cupsResolveConflicts(ppd, option, choice, &num_options, &options))
       puts("Unable to resolve conflicts!");
-    else if (num_options > 0)
+    else if ((!option && num_options > 0) || (option && num_options > 1))
     {
       fputs("Resolved conflicts with the following options:\n   ", stdout);
       for (i = 0; i < num_options; i ++)
-       printf(" %s=%s", options[i].name, options[i].value);
+        if (!option || strcasecmp(option, options[i].name))
+         printf(" %s=%s", options[i].name, options[i].value);
       putchar('\n');
 
       cupsFreeOptions(num_options, options);
@@ -94,13 +98,20 @@ main(int  argc,                             /* I - Number of command-line arguments */
     if (!fgets(line, sizeof(line), stdin) || line[0] == '\n')
       break;
 
-    num_options = cupsParseOptions(line, 0, &options);
-    if (num_options > 0)
-    {
-      option = strdup(options[0].name);
-      choice = strdup(options[0].value);
-    }
+    for (ptr = line; isspace(*ptr & 255); ptr ++);
+    for (optr = ptr; *ptr && *ptr != '='; ptr ++);
+    if (!*ptr)
+      break;
+    for (*ptr++ = '\0', cptr = ptr; *ptr && !isspace(*ptr & 255); ptr ++);
+    if (!*ptr)
+      break;
+    *ptr++ = '\0';
+
+    option      = strdup(optr);
+    choice      = strdup(cptr);
+    num_options = cupsParseOptions(ptr, 0, &options);
 
+    ppdMarkOption(ppd, option, choice);
     if (cupsMarkOptions(ppd, num_options, options))
       puts("Options Conflict!");
     cupsFreeOptions(num_options, options);