The fix for 12-07c -- new errorinfo function.
Alex Cherepanov <[email protected]> Mon, 14 Aug 2006 21:39:40 -0400
| Newsgroups | gmane.comp.printing.ghostscript.patches |
|---|---|
| Message-ID | <[email protected]> |
This is a multi-part message in MIME format.
--------------080404060607060805030308
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Reviewers,
Adobe interpreters often put a 2-element array in $error dictionary
as the value of /errorinfo . The array represent an offending key-value
pair in the dictionary argument.
Many CET tests examine the value of /errorinfo and include it in the
checksum. It looks like the proposed patch is the first to address this
issue.
Please help me with the memory allocators. I'm not sure that they are
used correctly. Probably, the array should be local regardless of the
current allocation mode.
Regards,
Alex Cherepanov
--------------080404060607060805030308
Content-Type: text/plain;
name="12-07c.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="12-07c.diff"
Index: gs/src/interp.c
===================================================================
--- gs/src/interp.c (revision 6987)
+++ gs/src/interp.c (working copy)
@@ -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, key, len, &key_name, 0);
+ if (code < 0)
+ return code;
+ code = ialloc_ref_array(&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 */
Index: gs/src/interp.h
===================================================================
--- gs/src/interp.h (revision 6987)
+++ gs/src/interp.h (working copy)
@@ -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);
Index: gs/src/zimage.c
===================================================================
--- gs/src/zimage.c (revision 6988)
+++ gs/src/zimage.c (working copy)
@@ -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);
Index: gs/src/int.mak
===================================================================
--- gs/src/int.mak (revision 6987)
+++ gs/src/int.mak (working copy)
@@ -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
--------------080404060607060805030308
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
gs-code-review mailing list
[email protected]
http://www.ghostscript.com/mailman/listinfo/gs-code-review
--------------080404060607060805030308--