diff options
author | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2009-06-10 19:02:58 +0000 |
---|---|---|
committer | msweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be> | 2009-06-10 19:02:58 +0000 |
commit | 97c9a8d72271152cf71373b9c7fbdc6036b92e89 (patch) | |
tree | c5f3bf3b2358f9905597f0f258b244d38ce8d3c0 /ppdc/ppdc-source.cxx | |
parent | 393ac6abae820d62982c8ad9c871f3c1cc59568c (diff) |
Import changes from CUPS 1.4svn-r8704.
git-svn-id: svn+ssh://src.apple.com/svn/cups/easysw/current@1556 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'ppdc/ppdc-source.cxx')
-rw-r--r-- | ppdc/ppdc-source.cxx | 96 |
1 files changed, 83 insertions, 13 deletions
diff --git a/ppdc/ppdc-source.cxx b/ppdc/ppdc-source.cxx index 55f3058a5..5898997fc 100644 --- a/ppdc/ppdc-source.cxx +++ b/ppdc/ppdc-source.cxx @@ -128,8 +128,16 @@ ppdcSource::ppdcSource(const char *f, // I - File to read #else struct utsname name; // uname information - vars->add(new ppdcVariable("PLATFORM_NAME", name.sysname)); - vars->add(new ppdcVariable("PLATFORM_ARCH", name.machine)); + if (!uname(&name)) + { + vars->add(new ppdcVariable("PLATFORM_NAME", name.sysname)); + vars->add(new ppdcVariable("PLATFORM_ARCH", name.machine)); + } + else + { + vars->add(new ppdcVariable("PLATFORM_NAME", "unknown")); + vars->add(new ppdcVariable("PLATFORM_ARCH", "unknown")); + } #endif // WIN32 if (f) @@ -1556,6 +1564,7 @@ ppdcSource::get_option(ppdcFile *fp, // I - File to read ppdcOptSection section; // Option section float order; // Option order ppdcOption *o; // Option + ppdcGroup *mg; // Matching group, if any // Read the Option parameters: @@ -1626,7 +1635,7 @@ ppdcSource::get_option(ppdcFile *fp, // I - File to read order = get_float(fp); // See if the option already exists... - if ((o = d->find_option(name)) == NULL) + if ((o = d->find_option_group(name, &mg)) == NULL) { // Nope, add a new one... o = new ppdcOption(ot, name, text, section, order); @@ -1638,6 +1647,13 @@ ppdcSource::get_option(ppdcFile *fp, // I - File to read "%d of %s!\n"), name, fp->line, fp->filename); return (NULL); } + else if (g != mg) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on line " + "%d of %s!\n"), name, fp->line, fp->filename); + return (NULL); + } return (o); } @@ -2035,9 +2051,11 @@ ppdcSource::get_token(ppdcFile *fp, // I - File to read } else { - _cupsLangPrintf(stderr, - _("ppdc: Undefined variable (%s) on line %d of " - "%s.\n"), name, fp->line, fp->filename); + if (!(cond_state & PPDC_COND_SKIP)) + _cupsLangPrintf(stderr, + _("ppdc: Undefined variable (%s) on line %d of " + "%s.\n"), name, fp->line, fp->filename); + snprintf(bufptr, bufend - bufptr + 1, "$%s", name); bufptr += strlen(name) + 1; } @@ -2398,6 +2416,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read { ppdcDriver *d; // Current driver ppdcGroup *g, // Current group + *mg, // Matching group *general, // General options group *install; // Installable options group ppdcOption *o; // Current option @@ -2409,7 +2428,10 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read // Initialize things as needed... if (inc && td) + { d = td; + d->retain(); + } else d = new ppdcDriver(td); @@ -2468,7 +2490,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } cond_current ++; - if (get_integer(fp)) + if (get_integer(fp) > 0) *cond_current = PPDC_COND_SATISFIED; else { @@ -2490,7 +2512,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read get_integer(fp); *cond_current |= PPDC_COND_SKIP; } - else if (get_integer(fp)) + else if (get_integer(fp) > 0) { *cond_current |= PPDC_COND_SATISFIED; *cond_current &= ~PPDC_COND_SKIP; @@ -2839,13 +2861,22 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the cupsDarkness option... - if ((o = d->find_option("cupsDarkness")) == NULL) + if ((o = d->find_option_group("cupsDarkness", &mg)) == NULL) { // Create the cupsDarkness option... o = new ppdcOption(PPDC_PICKONE, "cupsDarkness", "Darkness", PPDC_SECTION_ANY, 10.0f); g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s!\n"), "cupsDarkness", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -2916,13 +2947,22 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the cupsFinishing option... - if ((o = d->find_option("cupsFinishing")) == NULL) + if ((o = d->find_option_group("cupsFinishing", &mg)) == NULL) { // Create the cupsFinishing option... o = new ppdcOption(PPDC_PICKONE, "cupsFinishing", "Finishing", PPDC_SECTION_ANY, 10.0f); g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s!\n"), "cupsFinishing", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -2998,7 +3038,8 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the InputSlot option... - if ((o = d->find_option("InputSlot")) == NULL) + + if ((o = d->find_option_group("InputSlot", &mg)) == NULL) { // Create the InputSlot option... o = new ppdcOption(PPDC_PICKONE, "InputSlot", "Media Source", @@ -3006,6 +3047,15 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s!\n"), "InputSlot", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -3122,7 +3172,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the MediaType option... - if ((o = d->find_option("MediaType")) == NULL) + if ((o = d->find_option_group("MediaType", &mg)) == NULL) { // Create the MediaType option... o = new ppdcOption(PPDC_PICKONE, "MediaType", "Media Type", @@ -3130,6 +3180,15 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s!\n"), "MediaType", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -3246,7 +3305,7 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read } // Add the choice to the Resolution option... - if ((o = d->find_option("Resolution")) == NULL) + if ((o = d->find_option_group("Resolution", &mg)) == NULL) { // Create the Resolution option... o = new ppdcOption(PPDC_PICKONE, "Resolution", NULL, PPDC_SECTION_ANY, @@ -3254,6 +3313,15 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read g = general; g->add_option(o); } + else if (mg != general) + { + _cupsLangPrintf(stderr, + _("ppdc: Option %s defined in two different groups on " + "line %d of %s!\n"), "Resolution", fp->line, + fp->filename); + c->release(); + continue; + } o->add_choice(c); @@ -3350,6 +3418,8 @@ ppdcSource::scan_file(ppdcFile *fp, // I - File to read drivers->add(d); } } + else if (inc && td) + td->release(); } |