Re: Fix for 687277, /undefined in token

"Igor V. Melichev" <[email protected]>
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <[email protected]>
IMO Ray should review it, but I'd like to bring some comments.

1. A separate user parameter looks fine, because PDFScanRules
looks made for a specific purpose. The important thing is
that PDFScanRules is being set on a special event.

2. Please ensure that NoImmediateEval is being properly
reset after a document completes or terminates by an error.

3. Please test with ///////////////////////////// .

Igor.


----- Original Message ----- 
From: "Alex Cherepanov" <[email protected]>
To: <[email protected]>
Sent: Tuesday, February 03, 2004 9:26 AM
Subject: [gs-code-review] Fix for 687277, /undefined in token


> Log message:
> Disable immediately evaluated named during PDF scanning because Acrobat
> Distiller for 5.0.5 for Mac generates PDF files that assume //Foo
> parsed as /and Foo
> Fix bug 687277 from customer 440
>
> This is a draft version.
> I'm not sure that we need another user parameter but the current
> usage of PDFScanRules is not compatible with catching syntax errors.
> Alternatively, we can set PDFScanRules before running the PDF file
> but this will prevent us from validating the PDF file.
>
> The change will be documented later if the fix is accepted in general.
>
> The fix was tested on a small set of files only.
>


----------------------------------------------------------------------------
----


> Index: gs/src/iscan.h
> ===================================================================
> RCS file: /cvs/ghostscript/gs/src/iscan.h,v
> retrieving revision 1.8
> diff -b -u -r1.8 iscan.h
> --- gs/src/iscan.h 16 Jun 2002 04:47:10 -0000 1.8
> +++ gs/src/iscan.h 3 Feb 2004 06:05:38 -0000
> @@ -117,6 +117,9 @@
>  #define SCAN_PDF_RULES 16 /* Special PDF scanning rules used */
>   /* This is for compatibility with Adobe */
>   /* Acrobat Reader */
> +#define SCAN_NO_IMMEDIATE_EVAL 32 /* Disable immediate evaluation. Scan
//Name */
> +                                /* as / and /Name. This is set for PDF
and */
> +                                /* can be useful for Level 1
compatibility */
>  void scanner_state_init_options(scanner_state *sstate, int options);
>  #define scanner_state_init_check(pstate, from_string, check_only)\
>    scanner_state_init_options(pstate,\
> Index: gs/src/iscan.c
> ===================================================================
> RCS file: /cvs/ghostscript/gs/src/iscan.c,v
> retrieving revision 1.16
> diff -b -u -r1.16 iscan.c
> --- gs/src/iscan.c 4 Dec 2003 12:35:35 -0000 1.16
> +++ gs/src/iscan.c 3 Feb 2004 06:05:38 -0000
> @@ -434,6 +434,7 @@
>      int sign;
>      const bool check_only = (pstate->s_options & SCAN_CHECK_ONLY) != 0;
>      const bool PDFScanRules = (i_ctx_p->scanner_options & SCAN_PDF_RULES)
!= 0;
> +    const bool no_immediate_eval = (i_ctx_p->scanner_options &
SCAN_NO_IMMEDIATE_EVAL) != 0;
>      scanner_state sstate;
>
>  #define pstack sstate.s_pstack
> @@ -679,8 +680,16 @@
>       ensure2(scanning_none);
>       c = scan_getc();
>       if (c == '/') {
> +         if (no_immediate_eval) {
> +     name_type = 1;
> +                    try_number = false;
> +                    da.base = da.limit = daptr = 0;
> +     da.is_dynamic = false;
> +     goto nx;
> +                } else {
>   name_type = 2;
>   c = scan_getc();
> +         }
>       } else
>   name_type = 1;
>       try_number = false;
> Index: gs/src/ztoken.c
> ===================================================================
> RCS file: /cvs/ghostscript/gs/src/ztoken.c,v
> retrieving revision 1.12
> diff -b -u -r1.12 ztoken.c
> --- gs/src/ztoken.c 15 May 2003 22:25:47 -0000 1.12
> +++ gs/src/ztoken.c 3 Feb 2004 06:05:38 -0000
> @@ -343,10 +343,11 @@
>   const char *pname;
>   int option;
>      } named_scanner_option_t;
> -    static const named_scanner_option_t named_options[3] = {
> +    static const named_scanner_option_t named_options[4] = {
>   {"ProcessComment", SCAN_PROCESS_COMMENTS},
>   {"ProcessDSCComment", SCAN_PROCESS_DSC_COMMENTS},
> - {"PDFScanRules", SCAN_PDF_RULES}
> + {"PDFScanRules", SCAN_PDF_RULES},
> +        {"NoImmediateEval", SCAN_NO_IMMEDIATE_EVAL}
>      };
>      int options = old_options;
>      int i;
> Index: gs/lib/pdf_main.ps
> ===================================================================
> RCS file: /cvs/ghostscript/gs/lib/pdf_main.ps,v
> retrieving revision 1.84
> diff -b -u -r1.84 pdf_main.ps
> --- gs/lib/pdf_main.ps 19 Jan 2004 16:52:32 -0000 1.84
> +++ gs/lib/pdf_main.ps 3 Feb 2004 06:05:39 -0000
> @@ -117,6 +117,7 @@
>   % This is counter-intuitive, and we don't understand why it happens,
>   % but the improvement is significant.
>     /PDFTopSave save def
> +   << /NoImmediateEval true >> setuserparams
>     0 setobjectformat
>     /Page# null def
>     /Page null def
> Index: gs/lib/pdf_draw.ps
> ===================================================================
> RCS file: /cvs/ghostscript/gs/lib/pdf_draw.ps,v
> retrieving revision 1.79
> diff -b -u -r1.79 pdf_draw.ps
> --- gs/lib/pdf_draw.ps 22 Oct 2003 08:55:44 -0000 1.79
> +++ gs/lib/pdf_draw.ps 3 Feb 2004 06:05:39 -0000
> @@ -984,6 +984,7 @@
>    DOPS
>     {
>       //_dops_save 0 save put
> +     << /NoImmediateEval false >> setuserparams
>       true resolvestream cvx exec
>       //_dops_save 0 get restore
>     }
>


----------------------------------------------------------------------------
----


> _______________________________________________
> gs-code-review mailing list
> [email protected]
> http://www.ghostscript.com/mailman/listinfo/gs-code-review
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.