[gs-cvs] rev 7206 - trunk/gs/src

leonardo at ghostscript.com leonardo at ghostscript.com
Thu Nov 16 03:12:37 PST 2006


Author: leonardo
Date: 2006-11-16 03:12:36 -0800 (Thu, 16 Nov 2006)
New Revision: 7206

Modified:
   trunk/gs/src/zfunc3.c
Log:
Fix (functions) : Provide a tolerance for insuffitient Domain elements 
(CPSI compatibility mode only).

DETAILS :

This change has no effect without "true .setCPSImode".
When it is executed, the missed Domain elements are padded with zeros,
extra elements are silently ignored.
Patch from Alex inproved by Leo. 

EXPECTED DIFFERENCES :

None.


Modified: trunk/gs/src/zfunc3.c
===================================================================
--- trunk/gs/src/zfunc3.c	2006-11-16 10:38:44 UTC (rev 7205)
+++ trunk/gs/src/zfunc3.c	2006-11-16 11:12:36 UTC (rev 7206)
@@ -69,6 +69,7 @@
 {
     gs_function_1ItSg_params_t params;
     int code;
+    extern bool CPSI_mode;
 
     *(gs_function_params_t *) & params = *mnDR;
     params.Functions = 0;
@@ -96,10 +97,37 @@
 		goto fail;
 	}
     }
-    if ((code = fn_build_float_array(op, "Bounds", true, false, &params.Bounds, mem)) != params.k - 1 ||
-	(code = fn_build_float_array(op, "Encode", true, true, &params.Encode, mem)) != 2 * params.k
-	)
+    if ((code = fn_build_float_array(op, "Bounds", true, false, &params.Bounds, mem)) != params.k - 1)
 	goto fail;
+    if (CPSI_mode) {
+	/* Adobe implementation doesn't check the Encode length. */
+	/* Extra elements are ignored; missing elements are filled with 0. */
+	/* CET 12-14m.ps depends on this bug */
+	uint sz, k2 = 2 * params.k;
+	ref *encode;
+	float *p = (float *)gs_alloc_byte_array(mem, k2, sizeof(float), "Encode");
+
+	params.Encode = p;
+	if (p == 0) {
+	    code = gs_note_error(e_VMerror);
+	    goto fail;
+	}
+	if (dict_find_string(op, "Encode", &encode) <= 0) {
+	    code = gs_note_error(e_undefined);
+	    goto fail;
+	}
+	if (!r_is_array(encode)) {
+	    code = gs_note_error(e_typecheck);
+	    goto fail;
+	}
+	sz =  min(k2, r_size(encode));
+	code = process_float_array(mem, encode, sz, p);
+	if (code < 0)
+	    goto fail;
+	while (sz < k2)
+	    p[sz++] = 0.0;
+    } else if ((code = fn_build_float_array(op, "Encode", true, true, &params.Encode, mem)) != 2 * params.k)
+	goto fail;
     if (params.Range == 0)
 	params.n = params.Functions[0]->params.n;
     code = gs_function_1ItSg_init(ppfn, &params, mem);



More information about the gs-cvs mailing list