//
// 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>
//
// 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);
}
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);
}
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);
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);
}
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);
}
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);
}