]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix reporting of line numbers in PPD file - we didn't handle trailing
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 13 Feb 2003 21:02:29 +0000 (21:02 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 13 Feb 2003 21:02:29 +0000 (21:02 +0000)
newlines after a quoted string, so the line number would get out of sync.

git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@3355 7a7537e8-13f0-0310-91df-b6672ffda945

cups/ppd.c

index 10869988891aff0b12901c43d8b30108d56f87d2..779d8a680c5da1c014e954d52f773270a85176fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * "$Id: ppd.c,v 1.82 2003/01/29 17:03:37 mike Exp $"
+ * "$Id: ppd.c,v 1.83 2003/02/13 21:02:29 mike Exp $"
  *
  *   PPD file routines for the Common UNIX Printing System (CUPS).
  *
@@ -48,7 +48,7 @@
  *   ppd_compare_options() - Compare two options.
  *   ppd_decode()          - Decode a string value...
  *   ppd_fix()             - Fix WinANSI characters in the range 0x80 to
&                           0x9f to be valid ISO-8859-1 characters...
*                           0x9f to be valid ISO-8859-1 characters...
  *   ppd_free_group()      - Free a single UI group.
  *   ppd_free_option()     - Free a single option.
  *   ppd_get_group()       - Find or create the named group as needed.
@@ -95,7 +95,7 @@
 
 static ppd_status_t    ppd_status = PPD_OK;
                                        /* Status of last ppdOpen*() */
-static int             ppd_line = 1;   /* Current line number */
+static int             ppd_line = 0;   /* Current line number */
 
 
 /*
@@ -364,7 +364,7 @@ ppdOpen(FILE *fp)                   /* I - File to read from */
   */
 
   ppd_status = PPD_OK;
-  ppd_line   = 1;
+  ppd_line   = 0;
 
  /*
   * Range check input...
@@ -1709,10 +1709,10 @@ ppdOpenFd(int fd)                       /* I - File to read from */
 
 
  /*
-  * Set the line number to 1...
+  * Set the line number to 0...
   */
 
-  ppd_line = 1;
+  ppd_line = 0;
 
  /*
   * Range check input...
@@ -1759,10 +1759,10 @@ ppdOpenFile(const char *filename)       /* I - File to read from */
 
 
  /*
-  * Set the line number to 1...
+  * Set the line number to 0...
   */
 
-  ppd_line = 1;
+  ppd_line = 0;
 
  /*
   * Range check input...
@@ -2291,16 +2291,19 @@ ppd_read(FILE *fp,                      /* I - File to read from */
            */
 
            while ((ch = getc(fp)) != EOF)
-             if (ch == '\n')
-               break;
-             else if (ch == '\r')
+             if (ch == '\r' || ch == '\n')
              {
-               ch = getc(fp);
-               if (ch != '\n')
-                 ungetc(ch, fp);
+                ppd_line ++;
 
-               ch = '\n';
-               break;
+               if (ch == '\r')
+               {
+                 ch = getc(fp);
+                 if (ch != '\n')
+                   ungetc(ch, fp);
+
+                 ch = '\n';
+                 break;
+               }
              }
 
             break;
@@ -2333,6 +2336,8 @@ ppd_read(FILE *fp,                        /* I - File to read from */
          * Line feed or carriage return...
          */
 
+          ppd_line ++;
+
          if (ch == '\r')
          {
           /*
@@ -2476,5 +2481,5 @@ ppd_read(FILE *fp,                        /* I - File to read from */
 
 
 /*
- * End of "$Id: ppd.c,v 1.82 2003/01/29 17:03:37 mike Exp $".
+ * End of "$Id: ppd.c,v 1.83 2003/02/13 21:02:29 mike Exp $".
  */