[gs-cvs] rev 6988 - in trunk/gs: lib src
alexcher at ghostscript.com
alexcher at ghostscript.com
Sat Aug 12 20:28:07 PDT 2006
Author: alexcher
Date: 2006-08-12 20:28:06 -0700 (Sat, 12 Aug 2006)
New Revision: 6988
Modified:
trunk/gs/lib/gs_img.ps
trunk/gs/src/zimage.c
Log:
Emulate sequential operand checking for colorimage operator.
Reject strings of different length as multiple date sources for sampled images.
Fix a typo in img_unbuild_image_dict procedure.
Modified: trunk/gs/lib/gs_img.ps
===================================================================
--- trunk/gs/lib/gs_img.ps 2006-08-11 19:44:11 UTC (rev 6987)
+++ trunk/gs/lib/gs_img.ps 2006-08-13 03:28:06 UTC (rev 6988)
@@ -309,6 +309,16 @@
}
.bind def
+%
+% Check the image types that can be used as data sources
+% <any> foo <bool>
+%
+/good_image_types mark
+ /filetype { pop //true } .bind
+ /stringtype 1 index
+ /arraytype //xcheck
+ /packedarraytype //xcheck
+.dicttomark readonly def
%
% <width> <height> <bits/component> <matrix> <dsrc0> ...
@@ -356,7 +366,27 @@
{ 1 add }
if
dup count 9 sub gt
- { /.colorimage cvx /stackunderflow signalerror }
+ {
+ % Adobe interpreters appear to test the arguments sequentially
+ % starting from the top of the stack and report the 1st error found.
+ % To satisfy CET test 12-02.PS we emulate this logic.
+ //true exch -1 1
+ { 3 add index
+ //good_image_types 1 index type .knownget
+ { exec and
+ }
+ { pop pop //false
+ }
+ ifelse
+ }
+ for
+ { /stackunderflow
+ }
+ { /typecheck
+ }
+ ifelse
+ /.colorimage cvx exch signalerror
+ }
if
% build the DataSource array in local VM
@@ -372,6 +402,7 @@
8 1 roll //img_params_ary //img_build_dict exec exch
}
.bind def
+currentdict /good_image_types .undef
%
% <?dict?>
@@ -392,7 +423,7 @@
1 index type /booleantype eq
{
1 index
- { 3 1 roll aload length 2 add -2 roll }
+ { 3 -1 roll aload length 2 add -2 roll }
if
}
if
Modified: trunk/gs/src/zimage.c
===================================================================
--- trunk/gs/src/zimage.c 2006-08-11 19:44:11 UTC (rev 6987)
+++ trunk/gs/src/zimage.c 2006-08-13 03:28:06 UTC (rev 6988)
@@ -87,13 +87,26 @@
return 1; /* no data source */
}
if (pip->MultipleDataSources) {
- long i, n = num_components + (has_alpha ? 1 : 0);
+ ref *ds = pip->DataSource;
+ long i, n = num_components + (has_alpha ? 1 : 0);
if (!r_is_array(pds))
return_error(e_typecheck);
if (r_size(pds) != n)
return_error(e_rangecheck);
for (i = 0; i < n; ++i)
- array_get(mem, pds, i, &pip->DataSource[i]);
+ array_get(mem, pds, i, &ds[i]);
+ if (r_type(&ds[0]) == t_string) {
+ /* We don't have a problem with the strings of different length
+ * but Adobe does and CET tast 12-02.ps reports this as an error.
+ */
+ if (has_alpha)
+ n--;
+ for (i = 1; i < n; ++i) {
+ if (r_type(&ds[i]) == t_string && r_size(&ds[i]) != r_size(&ds[0])) {
+ return_error(e_rangecheck);
+ }
+ }
+ }
} else
pip->DataSource[0] = *pds;
return 0;
More information about the gs-cvs
mailing list