]> git.ipfire.org Git - thirdparty/cups.git/blobdiff - ppdc/ppdmerge.cxx
Merge changes from CUPS 1.5svn-r9567
[thirdparty/cups.git] / ppdc / ppdmerge.cxx
index 00bb181b6ad6eda7387172859bf6a5762beb1439..bd5be92ac6feb1dd00ccea606576bc8f638cf2e3 100644 (file)
@@ -3,7 +3,7 @@
 //
 //   PPD file merge utility for the CUPS PPD Compiler.
 //
-//   Copyright 2007-2008 by Apple Inc.
+//   Copyright 2007-2010 by Apple Inc.
 //   Copyright 2002-2007 by Easy Software Products.
 //
 //   These coded instructions, statements, and computer programs are the
 // Include necessary headers...
 //
 
+#include <cups/cups-private.h>
 #include <cups/ppd-private.h>
-#include <cups/cups.h>
 #include <cups/array.h>
-#include <cups/string.h>
-#include <cups/i18n.h>
-#include <errno.h>
 
 
 //
@@ -96,7 +93,7 @@ main(int  argc,                               // I - Number of command-line arguments
       // Open and load the PPD file...
       if ((infile = cupsFileOpen(argv[i], "r")) == NULL)
       {
-        _cupsLangPrintf(stderr, _("%s: Unable to open %s - %s\n"), "ppdmerge",
+        _cupsLangPrintf(stderr, _("%s: Unable to open %s: %s"), "ppdmerge",
                        argv[i], strerror(errno));
        return (1);
       }
@@ -105,28 +102,29 @@ main(int  argc,                           // I - Number of command-line arguments
       if ((ppd = ppdOpen2(infile)) == NULL)
       {
         ppd_status_t   status;         // PPD open status
-       int             linenum;        // Line number
+       int             curline,        // Current line
+                       linenum;        // Line number
        
        
         status = ppdLastError(&linenum);
        
-       _cupsLangPrintf(stderr, _("%s: Unable to open %s - %s on line %d.\n"),
-                       "ppdmerge", argv[i], ppdErrorString(status), linenum);
-       
-        _cupsLangPrintf(stderr, "%d: ", linenum);
+       _cupsLangPrintf(stderr,
+                       _("%s: Unable to open PPD file: %s on line %d."),
+                       "ppdmerge", ppdErrorString(status), linenum);
         cupsFileRewind(infile);
        
         line[0] = '\0';
+       curline = 0;
        
         while (cupsFileGets(infile, line, sizeof(line)))
        {
-         linenum --;
-         if (!linenum)
+         curline ++;
+         if (curline >= linenum)
            break;
        }
-       
-       _cupsLangPrintf(stderr, "%s\n", line);
-       
+
+       _cupsLangPrintf(stderr, "%d: %s", linenum, line);
+
         cupsFileClose(infile);
        return (1);
       }
@@ -135,7 +133,7 @@ main(int  argc,                             // I - Number of command-line arguments
       if ((locale = ppd_locale(ppd)) == NULL)
       {
         _cupsLangPrintf(stderr,
-                       _("ppdmerge: Bad LanguageVersion \"%s\" in %s!\n"),
+                       _("ppdmerge: Bad LanguageVersion \"%s\" in %s."),
                        ppd->lang_version, argv[i]);
         cupsFileClose(infile);
        ppdClose(ppd);
@@ -159,7 +157,7 @@ main(int  argc,                             // I - Number of command-line arguments
          if (rename(inname, bckname))
          {
            _cupsLangPrintf(stderr,
-                           _("ppdmerge: Unable to backup %s to %s- %s\n"),
+                           _("ppdmerge: Unable to backup %s to %s - %s"),
                            inname, bckname, strerror(errno));
            return (1);
          }
@@ -175,7 +173,7 @@ main(int  argc,                             // I - Number of command-line arguments
       else
       {
         // Don't need this PPD...
-       _cupsLangPrintf(stderr, _("ppdmerge: Ignoring PPD file %s...\n"),
+       _cupsLangPrintf(stderr, _("ppdmerge: Ignoring PPD file %s."),
                        argv[i]);
         ppdClose(ppd);
       }
@@ -366,11 +364,10 @@ ppd_locale(ppd_file_t *ppd)               // I - PPD file
 static void
 usage(void)
 {
-  _cupsLangPuts(stdout,
-                _("Usage: ppdmerge [options] filename.ppd "
-                 "[ ... filenameN.ppd ]\n"
-                 "Options:\n"
-                  "  -o filename.ppd[.gz]\n"));
+  _cupsLangPuts(stdout, _("Usage: ppdmerge [options] filename.ppd [ ... "
+                          "filenameN.ppd ]"));
+  _cupsLangPuts(stdout, _("Options:"));
+  _cupsLangPuts(stdout, _("  -o filename.ppd[.gz]"));
 
   exit(1);
 }