[gs-cvs] rev 6970 - in trunk/gs: lib src

lpd at ghostscript.com lpd at ghostscript.com
Fri Aug 4 21:33:12 PDT 2006


Author: lpd
Date: 2006-08-04 21:33:11 -0700 (Fri, 04 Aug 2006)
New Revision: 6970

Modified:
   trunk/gs/lib/gs_dps.ps
   trunk/gs/lib/gs_dps2.ps
   trunk/gs/lib/gs_init.ps
   trunk/gs/src/gserrors.h
   trunk/gs/src/ierrors.h
   trunk/gs/src/interp.c
Log:
For greater Adobe compatibility, moves all non-standard entries out of
errordict: the handler for unknownerror to a new gserrordict (known to the
interpreter), and .GShandleerror to systemdict.  Similarly, moves making
errordict entries for optional features (including Level 2) to the feature
implementation file, so that e.g. the DPS entries don't appear in non-DPS
systems.


Modified: trunk/gs/lib/gs_dps.ps
===================================================================
--- trunk/gs/lib/gs_dps.ps	2006-08-05 03:17:54 UTC (rev 6969)
+++ trunk/gs/lib/gs_dps.ps	2006-08-05 04:33:11 UTC (rev 6970)
@@ -16,6 +16,11 @@
 % $Id$
 % Initialization file for Display PostScript functions.
 
+% ------ Errors ------ %
+
+% These errors are only defined in DPS.
+{ /invalidcontext /invalidid } { .registererror } forall
+
 % ------ Contexts ------ %
 
 % To create a context with private local VM, we use the .localfork

Modified: trunk/gs/lib/gs_dps2.ps
===================================================================
--- trunk/gs/lib/gs_dps2.ps	2006-08-05 03:17:54 UTC (rev 6969)
+++ trunk/gs/lib/gs_dps2.ps	2006-08-05 04:33:11 UTC (rev 6970)
@@ -19,6 +19,12 @@
 
 level2dict begin
 
+% ------ Errors ------ %
+
+% These errors are only defined in Level 2 and DPS.
+{ /configurationerror /undefinedresource /unregistered }
+{ .registererror } forall
+
 % ------ Halftones ------ %
 
 /.makestackdict

Modified: trunk/gs/lib/gs_init.ps
===================================================================
--- trunk/gs/lib/gs_init.ps	2006-08-05 03:17:54 UTC (rev 6969)
+++ trunk/gs/lib/gs_init.ps	2006-08-05 04:33:11 UTC (rev 6970)
@@ -461,7 +461,7 @@
 % won't cause nested errors (Unexpected Error conditions).
 /handleerror
 	JOBSERVER {
-	  { /errordict .systemvar /.GShandleerror get .internalstopped pop } bind % always use .GShandleerror.
+	  { //systemdict /.GShandleerror get .internalstopped pop } bind % always use .GShandleerror.
 	} {
 	  { /errordict .systemvar /handleerror get .internalstopped pop } bind % PLRM standard errorhandling
 	} ifelse def
@@ -937,9 +937,7 @@
        % Genoa issue of setting /handleerror, and then calling it, without an error
        % being set.  We were erroring in this case, due to /command load failing.
 
-       /errordict .systemvar dup /handleerror get exch
-         //JOBSERVER { /.GShandleerror } { /handleerror } ifelse
-         get ne
+       /errordict .systemvar /handleerror /.GShandleerror .systemvar ne
          { /errordict .systemvar begin /handleerror load .internalstopped pop end
          }
          if
@@ -1055,11 +1053,30 @@
 %   files require it to have at least one empty slot.
 /errordict ErrorNames length 3 add dict
 .forcedef		% errordict is local, systemdict is global
-.setglobal		% contents of errordict are global
+.setglobal		% back to global VM
+% For greater Adobe compatibility, we put all non-standard errors in a
+%   separate dictionary, gserrordict.  It does not need to be in local VM,
+%   because PostScript programs do not access it.
+%   NOTE: the name gserrordict is known to the interpreter.
+/gserrordict 5 dict def
+% Register an error in errordict.  We make this a procedure because we only
+% register the Level 1 errors here: the rest are registered by "feature"
+% files.  However, ErrorNames contains all of the error names regardless of
+% what features are included, so we have to "know" that VMerror is the last
+% Level 1 error.
+/.registererror		% <name> .registererror -
+ { errordict exch .registererror2
+ } bind def
+/.registererror2	% <dict> <name> .registererror -
+ { .currentglobal true .setglobal	% create procs in global VM
+   3 1 roll
+   mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx put
+   .setglobal
+ } bind def
+ErrorNames
+ { dup .registererror /VMerror eq {exit} if
+ } forall
 errordict begin
-  ErrorNames
-   { mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx def
-   } forall
 % The handlers for interrupt and timeout are special; there is no
 % 'current object', so they push their own name.
    { /interrupt /timeout }
@@ -1068,13 +1085,15 @@
 /handleerror	% this key is 'well known' and some PS may redefine it
  { /.printerror .systemvar exec
  } bind def
-	% a private entry that we will always use under JOBSERVER mode
-/.GShandleerror
- { /.printerror .systemvar exec
- } bind def
- 
-end
+end		% errordict
 
+% Put non-standard errors in gserrordict.
+gserrordict /unknownerror errordict /unknownerror get put
+errordict /unknownerror .undef
+% Define a stable private copy of handleerror that we will always use under
+% JOBSERVER mode.
+/.GShandleerror errordict /handleerror get def
+
 % Define the [write]==[only] procedures.
 /.dict 8 dict dup
 begin def

Modified: trunk/gs/src/gserrors.h
===================================================================
--- trunk/gs/src/gserrors.h	2006-08-05 03:17:54 UTC (rev 6969)
+++ trunk/gs/src/gserrors.h	2006-08-05 04:33:11 UTC (rev 6970)
@@ -36,7 +36,7 @@
 #define gs_error_undefinedfilename (-22)
 #define gs_error_undefinedresult (-23)
 #define gs_error_VMerror (-25)
-#define gs_error_unregistered (-29)
+#define gs_error_unregistered (-28)
 
 #define gs_error_hit_detected (-99)
 

Modified: trunk/gs/src/ierrors.h
===================================================================
--- trunk/gs/src/ierrors.h	2006-08-05 03:17:54 UTC (rev 6969)
+++ trunk/gs/src/ierrors.h	2006-08-05 04:33:11 UTC (rev 6970)
@@ -62,7 +62,7 @@
 #define e_undefinedfilename (-22)
 #define e_undefinedresult (-23)
 #define e_unmatchedmark (-24)
-#define e_VMerror (-25)
+#define e_VMerror (-25)		/* must be the last Level 1 error */
 
 #define LEVEL1_ERROR_NAMES\
  "unknownerror", "dictfull", "dictstackoverflow", "dictstackunderflow",\
@@ -72,22 +72,28 @@
  "stackunderflow", "syntaxerror", "timeout", "typecheck", "undefined",\
  "undefinedfilename", "undefinedresult", "unmatchedmark", "VMerror"
 
-		/* ------ Additional Level 2 and DPS errors ------ */
+	/* ------ Additional Level 2 errors (also in DPS) ------ */
 
 #define e_configurationerror (-26)
-#define e_invalidcontext (-27)
-#define e_undefinedresource (-28)
-#define e_unregistered (-29)
+#define e_undefinedresource (-27)
+#define e_unregistered (-28)
+
+#define LEVEL2_ERROR_NAMES\
+ "configurationerror", "undefinedresource", "unregistered"
+
+	/* ------ Additional DPS errors ------ */
+
+#define e_invalidcontext (-29)
 /* invalidid is for the NeXT DPS extension. */
 #define e_invalidid (-30)
 
-#define LEVEL2_ERROR_NAMES\
- "configurationerror", "invalidcontext", "undefinedresource",\
- "unregistered", "invalidid"
+#define DPS_ERROR_NAMES\
+ "invalidcontext", "invalidid"
 
-#define ERROR_NAMES   LEVEL1_ERROR_NAMES, LEVEL2_ERROR_NAMES
+#define ERROR_NAMES\
+ LEVEL1_ERROR_NAMES, LEVEL2_ERROR_NAMES, DPS_ERROR_NAMES
 
-		/* ------ Pseudo-errors used internally ------ */
+	/* ------ Pseudo-errors used internally ------ */
 
 /*
  * Internal code for a fatal error.

Modified: trunk/gs/src/interp.c
===================================================================
--- trunk/gs/src/interp.c	2006-08-05 03:17:54 UTC (rev 6969)
+++ trunk/gs/src/interp.c	2006-08-05 04:33:11 UTC (rev 6970)
@@ -624,8 +624,14 @@
 	return code;
     if (gs_errorname(i_ctx_p, code, &error_name) < 0)
 	return code;		/* out-of-range error code! */
+    /*
+     * For greater Adobe compatibility, only the standard PostScript errors
+     * are defined in errordict; the rest are in gserrordict.
+     */
     if (dict_find_string(systemdict, "errordict", &perrordict) <= 0 ||
-	dict_find(perrordict, &error_name, &epref) <= 0
+	(dict_find(perrordict, &error_name, &epref) <= 0 &&
+	 (dict_find_string(systemdict, "gserrordict", &perrordict) <= 0 ||
+	  dict_find(perrordict, &error_name, &epref) <= 0))
 	)
 	return code;		/* error name not in errordict??? */
     doref = *epref;



More information about the gs-cvs mailing list