/*-------------------------------------------------------------------------------------------------
This patch is taken from the community.
Details can be found at https://www.cups.org/str.php?L4627
---------------------------------------------------------------------------------------------------*/
--- ppdc/ppdpo.cxx 2009-04-03 10:35:17.000000000 -0700
+++ ppdc/ppdpo.cxx 2015-05-18 02:34:42.016321242 -0700
@@ -58,7 +58,7 @@
// Scan the command-line...
catalog = new ppdcCatalog("en");
- src = 0;
+ src = new ppdcSource();
verbose = 0;
outfile = 0;
@@ -123,24 +123,26 @@
_("ppdc: Loading driver information file \"%s\"...\n"),
argv[i]);
- src = new ppdcSource(argv[i]);
-
- // Add UI strings...
- for (d = (ppdcDriver *)src->drivers->first();
- d;
- d = (ppdcDriver *)src->drivers->next())
- {
- if (verbose)
- _cupsLangPrintf(stderr,
- _("ppdc: Adding/updating UI text from %s...\n"),
- argv[i]);
-
- add_ui_strings(d, catalog);
- }
+ src->read_file(argv[i]);
+ }
- // Delete the printer driver information...
- src->release();
+ // If no drivers have been loaded, display the program usage message.
+ if ((d = (ppdcDriver *)src->drivers->first()) != NULL)
+ {
+ // Add UI strings...
+ while (d != NULL)
+ {
+ if (verbose)
+ _cupsLangPrintf(stderr, _("ppdc: Adding/updating UI text from %s."), argv[i]);
+ add_ui_strings(d, catalog);
+ d = (ppdcDriver *)src->drivers->next();
}
+ }
+ else
+ usage();
+
+// Delete the printer driver information...
+ src->release();
// Write the message catalog...
if (!outfile)
@@ -150,10 +152,6 @@
catalog->release();
- // If no drivers have been loaded, display the program usage message.
- if (!src)
- usage();
-
// Return with no errors.
return (0);
}
--- ppdc/ppdhtml.cxx 2009-04-03 10:35:17.000000000 -0700
+++ ppdc/ppdhtml.cxx 2015-05-18 02:34:50.033654707 -0700
@@ -58,7 +58,7 @@
_cupsSetLocale(argv);
// Scan the command-line...
- src = 0;
+ src = new ppdcSource();
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
@@ -97,67 +97,75 @@
else
{
// Open and load the driver info file...
- src = new ppdcSource(argv[i]);
+ src->read_file(argv[i]);
+ }
+ if ((d = (ppdcDriver *)src->drivers->first()) != NULL)
+ {
// Create a composite group with all of the features from the
// drivers in the info file...
composite = new ppdcGroup("", "");
- for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next())
- for (g = (ppdcGroup *)d->groups->first(); g; g = (ppdcGroup *)d->groups->next())
- for (o = (ppdcOption *)g->options->first(); o; o = (ppdcOption *)g->options->next())
- {
- if ((compo = composite->find_option(o->name->value)) == NULL)
- composite->add_option(new ppdcOption(o));
- }
-
- puts("<html>");
- printf("<head><title>Driver Summary for %s</title></head>\n", argv[i]);
- printf("<body><h1>Driver Summary for %s</h1>\n", argv[i]);
- printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>");
- for (compo = (ppdcOption *)composite->options->first(); compo; compo = (ppdcOption *)composite->options->next())
- printf("<th>%s</th>", compo->text->value);
- puts("</tr></thead><tbody>");
-
- // Write HTML summary...
- for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next())
- {
- // Write the summary for this driver...
- printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d->model_name->value);
- for (size = (ppdcMediaSize *)d->sizes->first(); size;
- size = (ppdcMediaSize *)d->sizes->next())
- printf("%s<br>", size->text->value);
- printf("</td>");
-
- for (compo = (ppdcOption *)composite->options->first(); compo;
- compo = (ppdcOption *)composite->options->next())
- if ((o = d->find_option(compo->name->value)) != NULL)
- {
- printf("<td nowrap>");
- for (c = (ppdcChoice *)o->choices->first(); c;
- c = (ppdcChoice *)o->choices->next())
- printf("%s<br>", c->text->value);
- printf("</td>");
- }
- else
- printf("<td>N/A</td>");
-
- puts("</tr>");
- }
-
- puts("</tbody></table></p>");
- puts("</body>");
- puts("</html>");
- // Delete the printer driver information...
- composite->release();
- src->release();
+ while (d != NULL)
+ {
+ for (g = (ppdcGroup *)d->groups->first(); g; g = (ppdcGroup *)d->groups->next())
+ for (o = (ppdcOption *)g->options->first(); o; o = (ppdcOption *)g->options->next())
+ {
+ if ((compo = composite->find_option(o->name->value)) == NULL)
+ composite->add_option(new ppdcOption(o));
+ }
+ d = (ppdcDriver *)src->drivers->next();
}
+ puts("<html>");
+ printf("<head><title>Driver Summary for %s</title></head>\n", argv[i]);
+ printf("<body><h1>Driver Summary for %s</h1>\n", argv[i]);
+ printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>");
+ for (compo = (ppdcOption *)composite->options->first(); compo; compo = (ppdcOption *)composite->options->next())
+ printf("<th>%s</th>", compo->text->value);
+ puts("</tr></thead><tbody>");
- // If no drivers have been loaded, display the program usage message.
- if (!src)
+ // Write HTML summary...
+ for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next())
+ {
+ // Write the summary for this driver...
+ printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d->model_name->value);
+ for (size = (ppdcMediaSize *)d->sizes->first(); size;
+ size = (ppdcMediaSize *)d->sizes->next())
+ printf("%s<br>", size->text->value);
+ printf("</td>");
+
+ for (compo = (ppdcOption *)composite->options->first(); compo;
+ compo = (ppdcOption *)composite->options->next())
+ if ((o = d->find_option(compo->name->value)) != NULL)
+ {
+ printf("<td nowrap>");
+ for (c = (ppdcChoice *)o->choices->first(); c;
+ c = (ppdcChoice *)o->choices->next())
+ printf("%s<br>", c->text->value);
+ printf("</td>");
+ }
+ else
+ printf("<td>N/A</td>");
+
+ puts("</tr>");
+ }
+
+ puts("</tbody></table></p>");
+ puts("</body>");
+ puts("</html>");
+
+ // Delete the printer driver information...
+ composite->release();
+ }
+ else
+ {
+ // If no drivers have been loaded, display the program usage message.
usage();
+ }
+
+ src->release();
- // Return with no errors.
+// Return with no errors.
return (0);
}