[gs-cvs] rev 7198 - trunk/gs/src
ray at ghostscript.com
ray at ghostscript.com
Mon Nov 13 11:05:23 PST 2006
Author: ray
Date: 2006-11-13 11:05:22 -0800 (Mon, 13 Nov 2006)
New Revision: 7198
Modified:
trunk/gs/src/gsfunc4.c
trunk/gs/src/zfunc4.c
Log:
Prevent 'repeat' extension from sneaking into FunctionType 4 of PDF's we
create.
DETAILS:
When the device is 'pdfwrite' we don't allow the 'repeat' control operator
in FunctionType 4 functions. The 'check_psc_function' will return a
rangecheck error if this is attempted. We don't need to worry about other
devices such as ps2write since it doesn't emit DeviceN tint transforms
(the only way we can currently get the 'repeat' operator into a PSC
function). To prevent indexing past the end of op_names in calc_put_ops,
we throw a rangecheck if one ever sneaks in.
Note that in theory, since we the opdfread uses the full PS interpreter
to process FunctionType 4, we *could* handle 'repeat', but the calc_put_ops
will prevent that (for now).
Note that this means that attempting to convert 09-31.ps or 09-34.ps into
PDF will not succeed in generating the FunctionType 4, and will throw a
rangecheck in the tint transform when trying to generate a sampled function
that is too large. All other devices, including ps2write, will show the
correct result since the FunctionType 4 tint transform is interpreted in
Ghostscript (which handles its own 'repeat' extension).
Modified: trunk/gs/src/gsfunc4.c
===================================================================
--- trunk/gs/src/gsfunc4.c 2006-11-13 17:05:42 UTC (rev 7197)
+++ trunk/gs/src/gsfunc4.c 2006-11-13 19:05:22 UTC (rev 7198)
@@ -633,6 +633,9 @@
spputc(s, '}');
return 1;
/*case PtCr_return:*/ /* not possible */
+ case PtCr_repeat: /* We shouldn't encounter this, but just in case */
+ case PtCr_repeat_end:
+ return_error(gs_error_rangecheck);
default: { /* must be < PtCr_NUM_OPS */
static const char *const op_names[] = {
/* Keep this consistent with opcodes in gsfunc4.h! */
Modified: trunk/gs/src/zfunc4.c
===================================================================
--- trunk/gs/src/zfunc4.c 2006-11-13 17:05:42 UTC (rev 7197)
+++ trunk/gs/src/zfunc4.c 2006-11-13 19:05:22 UTC (rev 7198)
@@ -25,6 +25,9 @@
#include "iname.h"
#include "dstack.h"
#include "ialloc.h"
+#include "gzstate.h" /* these are needed to check if device is pdfwrite */
+#include "gxdevcli.h" /* these are needed to check if device is pdfwrite */
+#include "string_.h" /* these are needed to check if device is pdfwrite */
/*
* FunctionType 4 functions are not defined in the PostScript language. We
* provide support for them because they are needed for PDF 1.3. In
@@ -242,6 +245,9 @@
return code;
/* Check for { proc } repeat | {proc} if | {proc1} {proc2} ifelse */
if (resolves_to_oper(i_ctx_p, &elt2, zrepeat)) {
+ /* We can't handle 'repeat' with pdfwrite since it emits FunctionType 4 */
+ if (strcmp(i_ctx_p->pgs->device->dname, "pdfwrite") == 0)
+ return_error(e_rangecheck);
if (ops) {
*p = PtCr_repeat;
psc_fixup(p, ops + *psize);
More information about the gs-cvs
mailing list