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

lpd at ghostscript.com lpd at ghostscript.com
Mon Jan 8 17:54:00 PST 2007


Author: lpd
Date: 2007-01-08 17:54:00 -0800 (Mon, 08 Jan 2007)
New Revision: 7587

Modified:
   trunk/gs/lib/gs_pdfwr.ps
   trunk/gs/src/iscan.c
Log:
Changes the token scanner so that ^D is not a self-delimiting character when
scanning a string.  This still treats ^D as a self-delimiting end-of-job
marker when reading from a file, while matching CPSI on PS3 CET 21-11-2.


Modified: trunk/gs/lib/gs_pdfwr.ps
===================================================================
--- trunk/gs/lib/gs_pdfwr.ps	2007-01-09 01:39:44 UTC (rev 7586)
+++ trunk/gs/lib/gs_pdfwr.ps	2007-01-09 01:54:00 UTC (rev 7587)
@@ -360,7 +360,8 @@
     % no way to do this.  The pdf_scan_token procedure in the C code of
     % the pdfwrite driver is currently the only place that recognizes
     % this convention.
-    dup .namestring (\000\011\012\014\015 %()/<>[]{}) .stringbreak null ne {
+    % Note that \004 may be self-delimiting in gs, but is not in standard PS.
+    dup .namestring (\000\004\011\012\014\015 %()/<>[]{}) .stringbreak null ne {
       dup .namestring (\000) .stringbreak null ne {
 	/rangecheck signalerror
       } if

Modified: trunk/gs/src/iscan.c
===================================================================
--- trunk/gs/src/iscan.c	2007-01-09 01:39:44 UTC (rev 7586)
+++ trunk/gs/src/iscan.c	2007-01-09 01:54:00 UTC (rev 7587)
@@ -414,7 +414,13 @@
   if ( osp >= osbot ) osp--;\
   else ref_stack_pop(&o_stack, 1)
     int max_name_ctype =
-    (recognize_btokens()? ctype_name : ctype_btoken);
+	(recognize_btokens()? ctype_name : ctype_btoken);
+    /*
+     * The following is a hack so that ^D will be self-delimiting in files
+     * (to compensate for bugs in some PostScript-generating applications)
+     * but not in strings (to match CPSI on the CET).
+     */
+    int ctrld = (pstate->s_options & SCAN_FROM_STRING ? 0x04 : 0xffff);
 
 #define scan_sign(sign, ptr)\
   switch ( *ptr ) {\
@@ -503,7 +509,9 @@
 	case char_EOL:
 	case char_NULL:
 	    goto top;
-        case 0x4:	/* ^D is a self-delimiting token */
+	case 0x04:		/* see ctrld above */
+	    if (c == ctrld)	/* treat as ordinary name char */
+		goto begin_name;
 	case '[':
 	case ']':
 	    s1[0] = (byte) c;
@@ -709,6 +717,8 @@
 		     * that handled these specially.)
 		     */
 		case ctype_other:
+		    if (c == ctrld) /* see above */
+			goto do_name;
 		    da.base = da.limit = daptr = 0;
 		    da.is_dynamic = false;
 		    goto nx;
@@ -956,10 +966,11 @@
 	case 'z':
 	case '|':
 	case '~':
+	  begin_name:
 	    /* Common code for scanning a name. */
 	    /* try_number and name_type are already set. */
-	    /* We know c has ctype_name (or maybe ctype_btoken) */
-	    /* or is a digit. */
+	    /* We know c has ctype_name (or maybe ctype_btoken, */
+	    /* or is ^D) or is a digit. */
 	    name_type = 0;
 	    try_number = false;
 	  do_name:
@@ -975,7 +986,7 @@
 		    if (sptr >= endp1)	/* stop 1 early! */
 			goto dyn_name;
 		}
-		while (decoder[*++sptr] <= max_name_ctype);	/* digit or name */
+		while (decoder[*++sptr] <= max_name_ctype || *sptr == ctrld);	/* digit or name */
 	    }
 	    /* Name ended within the buffer. */
 	    daptr = (byte *) sptr;
@@ -1000,7 +1011,7 @@
 	    /* Enter here to continue scanning a name. */
 	    /* daptr must be set. */
 	  cont_name:scan_begin_inline();
-	    while (decoder[c = scan_getc()] <= max_name_ctype) {
+	    while (decoder[c = scan_getc()] <= max_name_ctype || c == ctrld) {
 		if (daptr == da.limit) {
 		    retcode = dynamic_grow(&da, daptr,
 					   name_max_string);
@@ -1017,8 +1028,10 @@
 		*daptr++ = c;
 	    }
 	  nx:switch (decoder[c]) {
+		case ctype_other:
+		    if (c == ctrld) /* see above */
+			break;
 		case ctype_btoken:
-		case ctype_other:
 		    scan_putback();
 		    break;
 		case ctype_space:



More information about the gs-cvs mailing list