[gs-code-review] Partial fix for CET 12-14a
Alex Cherepanov
alexcher at quadnet.net
Sat Oct 28 07:27:44 PDT 2006
Fix decoding of the indexed color space in the smooth shading.
Adjust error codes to match CET 12-14a.ps and CPSI 3017.
Change gs_errorinfo_put_pair() to take char* instead of byte* a
more common type.
DIFFERENCES:
None
-------------- next part --------------
Index: gs/src/int.mak
===================================================================
--- gs/src/int.mak (revision 7132)
+++ gs/src/int.mak (working copy)
@@ -1755,7 +1755,7 @@
$(gscolor2_h) $(gscolor3_h) $(gscspace_h) $(gsfunc3_h)\
$(gsptype2_h) $(gsshade_h) $(gsstruct_h) $(gsuid_h)\
$(stream_h)\
- $(files_h)\
+ $(files_h) $(interp_h)\
$(ialloc_h) $(idict_h) $(idparam_h) $(ifunc_h) $(igstate_h) $(ipcolor_h)\
$(store_h)
$(PSCC) $(PSO_)zshade.$(OBJ) $(C_) $(PSSRC)zshade.c
Index: gs/src/zshade.c
===================================================================
--- gs/src/zshade.c (revision 7132)
+++ gs/src/zshade.c (working copy)
@@ -31,6 +31,7 @@
#include "idparam.h"
#include "ifunc.h"
#include "igstate.h"
+#include "interp.h" /* for gs_errorinfo_put_pair() */
#include "ipcolor.h"
#include "store.h"
@@ -289,9 +290,15 @@
* Adobe interpreters follow PLRM in this respect and we follow them.
*/
private int
-check_indexed_vs_function(const gs_color_space *pcs, const gs_function_t *foo)
-{ if (foo && gs_color_space_get_index(pcs) == gs_color_space_index_Indexed)
- return_error(e_rangecheck);
+check_indexed_vs_function(i_ctx_t *i_ctx_p, const ref *op,
+ const gs_color_space *pcs, const gs_function_t *foo)
+{ if (foo && gs_color_space_get_index(pcs) == gs_color_space_index_Indexed) {
+ static const char fn[] = "Function";
+ ref *f;
+ if (dict_find_string(op, fn, &f) > 0)
+ gs_errorinfo_put_pair(i_ctx_p, fn, sizeof(fn) - 1, f);
+ return_error(e_typecheck); /* CET 12-14a */
+ }
return 0;
}
@@ -316,7 +323,7 @@
(dict_find_string(op, "Matrix", &pmatrix) > 0 &&
(code = read_matrix(imemory, pmatrix, ¶ms.Matrix)) < 0) ||
(code = build_shading_function(i_ctx_p, op, ¶ms.Function, 2, mem)) < 0 ||
- (code = check_indexed_vs_function(params.ColorSpace, params.Function)) < 0 ||
+ (code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = gs_shading_Fb_init(ppsh, ¶ms, mem)) < 0
) {
gs_free_object(mem, params.Function, "Function");
@@ -385,7 +392,7 @@
if ((code = build_directional_shading(i_ctx_p, op, params.Coords, 4,
params.Domain, ¶ms.Function,
params.Extend, mem)) < 0 ||
- (code = check_indexed_vs_function(params.ColorSpace, params.Function)) < 0 ||
+ (code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = gs_shading_A_init(ppsh, ¶ms, mem)) < 0
) {
gs_free_object(mem, params.Function, "Function");
@@ -411,7 +418,7 @@
if ((code = build_directional_shading(i_ctx_p, op, params.Coords, 6,
params.Domain, ¶ms.Function,
params.Extend, mem)) < 0 ||
- (code = check_indexed_vs_function(params.ColorSpace, params.Function)) < 0 ||
+ (code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = gs_shading_R_init(ppsh, ¶ms, mem)) < 0
) {
gs_free_object(mem, params.Function, "Function");
@@ -540,7 +547,7 @@
if ((code =
build_mesh_shading(i_ctx_p, op, (gs_shading_mesh_params_t *)¶ms,
¶ms.Decode, ¶ms.Function, mem)) < 0 ||
- (code = check_indexed_vs_function(params.ColorSpace, params.Function)) < 0 ||
+ (code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = flag_bits_param(op, (gs_shading_mesh_params_t *)¶ms,
¶ms.BitsPerFlag)) < 0 ||
(code = gs_shading_FfGt_init(ppsh, ¶ms, mem)) < 0
@@ -569,7 +576,7 @@
if ((code =
build_mesh_shading(i_ctx_p, op, (gs_shading_mesh_params_t *)¶ms,
¶ms.Decode, ¶ms.Function, mem)) < 0 ||
- (code = check_indexed_vs_function(params.ColorSpace, params.Function)) < 0 ||
+ (code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = dict_int_param(op, "VerticesPerRow", 2, max_int, 0,
¶ms.VerticesPerRow)) < 0 ||
(code = gs_shading_LfGt_init(ppsh, ¶ms, mem)) < 0
@@ -598,7 +605,7 @@
if ((code =
build_mesh_shading(i_ctx_p, op, (gs_shading_mesh_params_t *)¶ms,
¶ms.Decode, ¶ms.Function, mem)) < 0 ||
- (code = check_indexed_vs_function(params.ColorSpace, params.Function)) < 0 ||
+ (code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = flag_bits_param(op, (gs_shading_mesh_params_t *)¶ms,
¶ms.BitsPerFlag)) < 0 ||
(code = gs_shading_Cp_init(ppsh, ¶ms, mem)) < 0
@@ -627,7 +634,7 @@
if ((code =
build_mesh_shading(i_ctx_p, op, (gs_shading_mesh_params_t *)¶ms,
¶ms.Decode, ¶ms.Function, mem)) < 0 ||
- (code = check_indexed_vs_function(params.ColorSpace, params.Function)) < 0 ||
+ (code = check_indexed_vs_function(i_ctx_p, op, params.ColorSpace, params.Function)) < 0 ||
(code = flag_bits_param(op, (gs_shading_mesh_params_t *)¶ms,
¶ms.BitsPerFlag)) < 0 ||
(code = gs_shading_Tpp_init(ppsh, ¶ms, mem)) < 0
Index: gs/src/zimage.c
===================================================================
--- gs/src/zimage.c (revision 7132)
+++ gs/src/zimage.c (working copy)
@@ -298,7 +298,7 @@
break;
default:
if (!r_is_proc(sources)) {
- static const byte ds[] = "DataSource";
+ static const char ds[] = "DataSource";
if (pie != NULL)
gx_image_end(pie, false); /* Clean up pie */
gs_errorinfo_put_pair(i_ctx_p, ds, sizeof(ds) - 1, pp);
Index: gs/src/interp.c
===================================================================
--- gs/src/interp.c (revision 7132)
+++ gs/src/interp.c (working copy)
@@ -729,12 +729,12 @@
/* The key must be a permanently allocated C string. */
/* This routine is here because of the proximity to the error handler. */
int
-gs_errorinfo_put_pair(i_ctx_t *i_ctx_p, const byte *key, int len, const ref *any)
+gs_errorinfo_put_pair(i_ctx_t *i_ctx_p, const char *key, int len, const ref *any)
{
int code;
ref pair, *aptr, key_name, *pderror;
- code = name_ref(imemory_local, key, len, &key_name, 0);
+ code = name_ref(imemory_local, (const byte *)key, len, &key_name, 0);
if (code < 0)
return code;
code = gs_alloc_ref_array(iimemory_local, &pair, a_readonly, 2, "gs_errorinfo_put_pair");
Index: gs/src/interp.h
===================================================================
--- gs/src/interp.h (revision 7132)
+++ gs/src/interp.h (working copy)
@@ -63,7 +63,7 @@
/* Create and store [/key any] array in $error /errorinfo. */
/* The key must be a permanently allocated C string. */
-int gs_errorinfo_put_pair(i_ctx_t *, const byte *key, int len, const ref *any);
+int gs_errorinfo_put_pair(i_ctx_t *, const char *key, int len, const ref *any);
/* Initialize the interpreter. */
int gs_interp_init(i_ctx_t **pi_ctx_p, const ref *psystem_dict,
Index: gs/src/gxshade.c
===================================================================
--- gs/src/gxshade.c (revision 7132)
+++ gs/src/gxshade.c (working copy)
@@ -241,16 +241,20 @@
if (index == gs_color_space_index_Indexed) {
int ncomp = gs_color_space_num_components(gs_cspace_base_space(pcs));
- uint ci;
- int code = cs->get_value(cs, num_bits, &ci);
- gs_client_color cc;
+ int ci;
+ float cf;
+ int code = cs->get_decoded(cs, num_bits, decode, &cf);
+ gs_client_color cc;
int i;
if (code < 0)
return code;
- if (ci >= gs_cspace_indexed_num_entries(pcs))
+ if (cf < 0)
return_error(gs_error_rangecheck);
- code = gs_cspace_indexed_lookup(&pcs->params.indexed, (int)ci, &cc);
+ ci = (int)cf;
+ if (ci >= gs_cspace_indexed_num_entries(pcs))
+ return_error(gs_error_rangecheck);
+ code = gs_cspace_indexed_lookup(&pcs->params.indexed, ci, &cc);
if (code < 0)
return code;
for (i = 0; i < ncomp; ++i)
More information about the gs-code-review
mailing list