--- cupsys-1.3.7/filter/pstops.c 2008-01-14 16:12:58.000000000 -0600 +++ cupsys-1.3.7-sbalneav/filter/pstops.c 2008-05-22 14:41:47.000000000 -0500 @@ -1512,6 +1512,54 @@ doc_puts(doc, "%%BeginPageSetup\n"); + /* + * Copy page setup commands as needed... + */ + + if (!strncmp(line, "%%BeginPageSetup", 16)) + { + int feature = 0; /* In a Begin/EndFeature block? */ + + while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0) + { + if (!strncmp(line, "%%EndPageSetup", 14)) + break; + else if (!strncmp(line, "%%BeginFeature:", 15)) + { + feature = 1; + + if (doc->number_up > 1 || doc->fitplot) + continue; + } + else if (!strncmp(line, "%%EndFeature", 12)) + { + feature = 0; + + if (doc->number_up > 1 || doc->fitplot) + continue; + } + else if (!strncmp(line, "%%IncludeFeature:", 17)) + { + pageinfo->num_options = include_feature(ppd, line, + pageinfo->num_options, + &(pageinfo->options)); + continue; + } + else if (!strncmp(line, "%%Include", 9)) + continue; + + if (!feature || (doc->number_up == 1 && !doc->fitplot)) + doc_write(doc, line, linelen); + } + + /* + * Skip %%EndPageSetup... + */ + + if (linelen > 0) + linelen = cupsFileGetLine(fp, line, linesize); + } + if (pageinfo->num_options > 0) { int i; /* Looping var */ @@ -1581,48 +1629,6 @@ start_nup(doc, number, 1, bounding_box); /* - * Copy page setup commands as needed... - */ - - if (!strncmp(line, "%%BeginPageSetup", 16)) - { - int feature = 0; /* In a Begin/EndFeature block? */ - - - while ((linelen = cupsFileGetLine(fp, line, linesize)) > 0) - { - if (!strncmp(line, "%%EndPageSetup", 14)) - break; - else if (!strncmp(line, "%%BeginFeature:", 15)) - { - feature = 1; - - if (doc->number_up > 1 || doc->fitplot) - continue; - } - else if (!strncmp(line, "%%EndFeature", 12)) - { - feature = 0; - - if (doc->number_up > 1 || doc->fitplot) - continue; - } - else if (!strncmp(line, "%%Include", 9)) - continue; - - if (!feature || (doc->number_up == 1 && !doc->fitplot)) - doc_write(doc, line, linelen); - } - - /* - * Skip %%EndPageSetup... - */ - - if (linelen > 0) - linelen = cupsFileGetLine(fp, line, linesize); - } - - /* * Finish the PageSetup section as needed... */ @@ -1789,8 +1795,6 @@ doc_puts(doc, "%%BeginSetup\n"); - do_setup(doc, ppd); - if (!strncmp(line, "%%BeginSetup", 12)) { while (strncmp(line, "%%EndSetup", 10)) @@ -1820,6 +1824,8 @@ fputs(_("ERROR: Missing %%EndSetup!\n"), stderr); } + do_setup(doc, ppd); + doc_puts(doc, "%%EndSetup\n"); return (linelen);