]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - filter/interpret.c
Update libcupsimage to properly use DEBUG_ macros.
[thirdparty/cups.git] / filter / interpret.c
index 380fa1d5587e2a76d882a1ddc8c7cf9cc5063dcc..c2bdc0315254069f0929ee221c0cc9f914b62247 100644 (file)
@@ -3,7 +3,7 @@
  *
  * PPD command interpreter for CUPS.
  *
- * Copyright 2007-2014 by Apple Inc.
+ * Copyright 2007-2015 by Apple Inc.
  * Copyright 1993-2007 by Easy Software Products.
  *
  * These coded instructions, statements, and computer programs are the
@@ -91,8 +91,8 @@ static int            setpagedevice(_cups_ps_stack_t *st,
                                        cups_page_header2_t *h,
                                        int *preferred_bits);
 #ifdef DEBUG
-static void            DEBUG_object(_cups_ps_obj_t *obj);
-static void            DEBUG_stack(_cups_ps_stack_t *st);
+static void            DEBUG_object(const char *prefix, _cups_ps_obj_t *obj);
+static void            DEBUG_stack(const char *prefix, _cups_ps_stack_t *st);
 #endif /* DEBUG */
 
 
@@ -547,8 +547,8 @@ _cupsRasterExecPS(
   while ((obj = scan_ps(st, &codeptr)) != NULL)
   {
 #ifdef DEBUG
-    DEBUG_printf(("_cupsRasterExecPS: Stack (%d objects)\n", st->num_objs));
-    DEBUG_object(obj);
+    DEBUG_printf(("_cupsRasterExecPS: Stack (%d objects)", st->num_objs));
+    DEBUG_object("_cupsRasterExecPS", obj);
 #endif /* DEBUG */
 
     switch (obj->type)
@@ -561,11 +561,11 @@ _cupsRasterExecPS(
           pop_stack(st);
 
          if (cleartomark_stack(st))
-           _cupsRasterAddError("cleartomark: Stack underflow!\n");
+           _cupsRasterAddError("cleartomark: Stack underflow.\n");
 
 #ifdef DEBUG
-          DEBUG_puts("    dup: ");
-         DEBUG_stack(st);
+          DEBUG_puts("1_cupsRasterExecPS:    dup");
+         DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           break;
 
@@ -577,7 +577,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
             DEBUG_puts("_cupsRasterExecPS: copy");
-           DEBUG_stack(st);
+           DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           }
           break;
@@ -588,7 +588,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
           DEBUG_puts("_cupsRasterExecPS: dup");
-         DEBUG_stack(st);
+         DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           break;
 
@@ -600,7 +600,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
             DEBUG_puts("_cupsRasterExecPS: index");
-           DEBUG_stack(st);
+           DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           }
           break;
@@ -611,7 +611,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
           DEBUG_puts("_cupsRasterExecPS: pop");
-         DEBUG_stack(st);
+         DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           break;
 
@@ -630,7 +630,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
               DEBUG_puts("_cupsRasterExecPS: roll");
-             DEBUG_stack(st);
+             DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
             }
          }
@@ -642,7 +642,7 @@ _cupsRasterExecPS(
 
 #ifdef DEBUG
           DEBUG_puts("_cupsRasterExecPS: setpagedevice");
-         DEBUG_stack(st);
+         DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
           break;
 
@@ -653,10 +653,9 @@ _cupsRasterExecPS(
          break;
 
       case CUPS_PS_OTHER :
-          _cupsRasterAddError("Unknown operator \"%s\"!\n", obj->value.other);
+          _cupsRasterAddError("Unknown operator \"%s\".\n", obj->value.other);
          error = 1;
-          DEBUG_printf(("_cupsRasterExecPS: Unknown operator \"%s\"!\n",
-                       obj->value.other));
+          DEBUG_printf(("_cupsRasterExecPS: Unknown operator \"%s\".", obj->value.other));
           break;
     }
 
@@ -675,8 +674,8 @@ _cupsRasterExecPS(
     error_stack(st, "Stack not empty:");
 
 #ifdef DEBUG
-    DEBUG_puts("_cupsRasterExecPS: Stack not empty:");
-    DEBUG_stack(st);
+    DEBUG_puts("_cupsRasterExecPS: Stack not empty");
+    DEBUG_stack("_cupsRasterExecPS", st);
 #endif /* DEBUG */
 
     delete_stack(st);
@@ -977,7 +976,7 @@ roll_stack(_cups_ps_stack_t *st,    /* I - Stack */
   int                  n;              /* Index into array */
 
 
-  DEBUG_printf(("    roll_stack(st=%p, s=%d, c=%d)\n", st, s, c));
+  DEBUG_printf(("3roll_stack(st=%p, s=%d, c=%d)", st, s, c));
 
  /*
   * Range check input...
@@ -1435,7 +1434,7 @@ setpagedevice(
   * Now pull /name and value pairs from the dictionary...
   */
 
-  DEBUG_puts("setpagedevice: Dictionary:");
+  DEBUG_puts("3setpagedevice: Dictionary:");
 
   for (obj ++; obj < end; obj ++)
   {
@@ -1450,8 +1449,8 @@ setpagedevice(
     obj ++;
 
 #ifdef DEBUG
-    DEBUG_printf(("setpagedevice: /%s ", name));
-    DEBUG_object(obj);
+    DEBUG_printf(("4setpagedevice: /%s ", name));
+    DEBUG_object("setpagedevice", obj);
 #endif /* DEBUG */
 
    /*
@@ -1601,7 +1600,7 @@ setpagedevice(
       * Ignore unknown name+value...
       */
 
-      DEBUG_printf(("    Unknown name (\"%s\") or value...\n", name));
+      DEBUG_printf(("4setpagedevice: Unknown name (\"%s\") or value...\n", name));
 
       while (obj[1].type != CUPS_PS_NAME && obj < end)
         obj ++;
@@ -1618,91 +1617,92 @@ setpagedevice(
  */
 
 static void
-DEBUG_object(_cups_ps_obj_t *obj)      /* I - Object to print */
+DEBUG_object(const char *prefix,       /* I - Prefix string */
+             _cups_ps_obj_t *obj)      /* I - Object to print */
 {
   switch (obj->type)
   {
     case CUPS_PS_NAME :
-       DEBUG_printf(("/%s\n", obj->value.name));
+       DEBUG_printf(("4%s: /%s\n", prefix, obj->value.name));
        break;
 
     case CUPS_PS_NUMBER :
-       DEBUG_printf(("%g\n", obj->value.number));
+       DEBUG_printf(("4%s: %g\n", prefix, obj->value.number));
        break;
 
     case CUPS_PS_STRING :
-       DEBUG_printf(("(%s)\n", obj->value.string));
+       DEBUG_printf(("4%s: (%s)\n", prefix, obj->value.string));
        break;
 
     case CUPS_PS_BOOLEAN :
        if (obj->value.boolean)
-         DEBUG_puts("true");
+         DEBUG_printf(("4%s: true", prefix));
        else
-         DEBUG_puts("false");
+         DEBUG_printf(("4%s: false", prefix));
        break;
 
     case CUPS_PS_NULL :
-       DEBUG_puts("null");
+       DEBUG_printf(("4%s: null", prefix));
        break;
 
     case CUPS_PS_START_ARRAY :
-       DEBUG_puts("[");
+       DEBUG_printf(("4%s: [", prefix));
        break;
 
     case CUPS_PS_END_ARRAY :
-       DEBUG_puts("]");
+       DEBUG_printf(("4%s: ]", prefix));
        break;
 
     case CUPS_PS_START_DICT :
-       DEBUG_puts("<<");
+       DEBUG_printf(("4%s: <<", prefix));
        break;
 
     case CUPS_PS_END_DICT :
-       DEBUG_puts(">>");
+       DEBUG_printf(("4%s: >>", prefix));
        break;
 
     case CUPS_PS_START_PROC :
-       DEBUG_puts("{");
+       DEBUG_printf(("4%s: {", prefix));
        break;
 
     case CUPS_PS_END_PROC :
-       DEBUG_puts("}");
+       DEBUG_printf(("4%s: }", prefix));
        break;
 
     case CUPS_PS_CLEARTOMARK :
-       DEBUG_puts("--cleartomark--");
+       DEBUG_printf(("4%s: --cleartomark--", prefix));
         break;
 
     case CUPS_PS_COPY :
-       DEBUG_puts("--copy--");
+       DEBUG_printf(("4%s: --copy--", prefix));
         break;
 
     case CUPS_PS_DUP :
-       DEBUG_puts("--dup--");
+       DEBUG_printf(("4%s: --dup--", prefix));
         break;
 
     case CUPS_PS_INDEX :
-       DEBUG_puts("--index--");
+       DEBUG_printf(("4%s: --index--", prefix));
         break;
 
     case CUPS_PS_POP :
-       DEBUG_puts("--pop--");
+       DEBUG_printf(("4%s: --pop--", prefix));
         break;
 
     case CUPS_PS_ROLL :
-       DEBUG_puts("--roll--");
+       DEBUG_printf(("4%s: --roll--", prefix));
         break;
 
     case CUPS_PS_SETPAGEDEVICE :
-       DEBUG_puts("--setpagedevice--");
+       DEBUG_printf(("4%s: --setpagedevice--", prefix));
         break;
 
     case CUPS_PS_STOPPED :
-       DEBUG_puts("--stopped--");
+       DEBUG_printf(("4%s: --stopped--", prefix));
         break;
 
     case CUPS_PS_OTHER :
-       DEBUG_printf(("--%s--\n", obj->value.other));
+       DEBUG_printf(("4%s: --%s--", prefix, obj->value.other));
        break;
   }
 }
@@ -1713,14 +1713,15 @@ DEBUG_object(_cups_ps_obj_t *obj)       /* I - Object to print */
  */
 
 static void
-DEBUG_stack(_cups_ps_stack_t *st)      /* I - Stack */
+DEBUG_stack(const char       *prefix,  /* I - Prefix string */
+            _cups_ps_stack_t *st)      /* I - Stack */
 {
   int                  c;              /* Looping var */
   _cups_ps_obj_t       *obj;           /* Current object on stack */
 
 
   for (obj = st->objs, c = st->num_objs; c > 0; c --, obj ++)
-    DEBUG_object(obj);
+    DEBUG_object(prefix, obj);
 }
 #endif /* DEBUG */