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

alexcher at ghostscript.com alexcher at ghostscript.com
Wed Oct 25 10:01:49 PDT 2006


Author: alexcher
Date: 2006-10-25 10:01:48 -0700 (Wed, 25 Oct 2006)
New Revision: 7122

Modified:
   trunk/gs/src/int.mak
   trunk/gs/src/interp.c
   trunk/gs/src/interp.h
   trunk/gs/src/zimage.c
Log:
Add a routine to create and store [/key any] array in $error.errorinfo for
better conformance with Adobe PS interpreters. This routine will be called
from many places that reports errors in dictionary parameters. Use the new
routine to fix one case of error reporting in the inage operator.
Bug 688956.

DIFFERENCES:
None


Modified: trunk/gs/src/int.mak
===================================================================
--- trunk/gs/src/int.mak	2006-10-25 12:10:09 UTC (rev 7121)
+++ trunk/gs/src/int.mak	2006-10-25 17:01:48 UTC (rev 7122)
@@ -478,7 +478,7 @@
 
 $(PSOBJ)zimage.$(OBJ) : $(PSSRC)zimage.c $(OP) $(memory__h)\
  $(gscspace_h) $(gscssub_h) $(gsimage_h) $(gsmatrix_h) $(gsstruct_h)\
- $(gxiparam_h)\
+ $(gxiparam_h) $(interp_h)\
  $(estack_h) $(ialloc_h) $(ifilter_h) $(igstate_h) $(iimage_h) $(ilevel_h)\
  $(store_h) $(stream_h)
 	$(PSCC) $(PSO_)zimage.$(OBJ) $(C_) $(PSSRC)zimage.c

Modified: trunk/gs/src/interp.c
===================================================================
--- trunk/gs/src/interp.c	2006-10-25 12:10:09 UTC (rev 7121)
+++ trunk/gs/src/interp.c	2006-10-25 17:01:48 UTC (rev 7122)
@@ -725,6 +725,33 @@
     return 0;
 }
 
+/* Create and store [/key any] array in $error.errorinfo. */
+/* 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)
+{
+    int code;
+    ref pair, *aptr, key_name, *pderror;
+
+    code = name_ref(imemory_local, key, len, &key_name, 0);
+    if (code < 0)
+        return code;
+    code = gs_alloc_ref_array(imemory_local, &pair, a_readonly, 2, "gs_errorinfo_put_pair");
+    if (code < 0)
+        return code;
+    aptr = pair.value.refs;
+    ref_assign_new(aptr, &key_name);
+    ref_assign_new(aptr+1, any);
+    if (dict_find_string(systemdict, "$error", &pderror) <= 0 ||
+	!r_has_type(pderror, t_dictionary) ||
+	idict_put_string(pderror, "errorinfo", &pair) < 0
+	)
+	return_error(e_Fatal);
+    return 0;
+}
+
+
 /* Main interpreter. */
 /* If execution terminates normally, return e_InterpreterExit. */
 /* If an error occurs, leave the current object in *perror_object */

Modified: trunk/gs/src/interp.h
===================================================================
--- trunk/gs/src/interp.h	2006-10-25 12:10:09 UTC (rev 7121)
+++ trunk/gs/src/interp.h	2006-10-25 17:01:48 UTC (rev 7122)
@@ -61,6 +61,10 @@
 /* Put a string in $error /errorinfo. */
 int gs_errorinfo_put_string(i_ctx_t *, const char *);
 
+/* 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);
+
 /* Initialize the interpreter. */
 int gs_interp_init(i_ctx_t **pi_ctx_p, const ref *psystem_dict,
 		   gs_dual_memory_t *dmem);

Modified: trunk/gs/src/zimage.c
===================================================================
--- trunk/gs/src/zimage.c	2006-10-25 12:10:09 UTC (rev 7121)
+++ trunk/gs/src/zimage.c	2006-10-25 17:01:48 UTC (rev 7122)
@@ -27,6 +27,7 @@
 #include "gxiparam.h"
 #include "idict.h"
 #include "idparam.h"
+#include "interp.h"             /* for gs_errorinfo_put_pair() */
 #include "estack.h"		/* for image[mask] */
 #include "ialloc.h"
 #include "igstate.h"
@@ -297,8 +298,10 @@
 		break;
 	    default:
 		if (!r_is_proc(sources)) {
-    		    if (pie != NULL)
-		        gx_image_end(pie, false);    /* Clean up pie */
+    		    static const byte 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);
 		    return_error(e_typecheck);
 		}
 		check_proc(*pp);



More information about the gs-cvs mailing list