Fix for 687601, /undefined in PK, 2nd version

"Russell Lang" <[email protected]> Thu, 02 Sep 2004 21:47:44 +1000
Newsgroups gmane.comp.printing.ghostscript.patches
Message-ID <41379500.565.21A2236F@localhost>
Alex,

The redirected stdio stuff seems to work correctly now.

As Ray wrote in the bug report, that file is actually a ZIP file 
containing two PDF files, and the ZIP file can't be opened by 
Acrobat.  If you extract the two PDF files, one has some ascii text 
at the start, and the other has a MacBinary header.  Adobe Reader 6 
and Distiller 6 can read both files with the headers in place.  This 
means that Adobe is finding the %PDF- in the file, noting the offset 
from the start of the file, and offsetting all the values in the xref 
table.  With your patch, ghostscript will not read these two files.  

Am I correct in thinking that we need to deal with two situations?
1. garbage at the start and correct xref table
2. garbage at the start and the xref table needs to be adjusted by 
the length of the garbage (i.e. some garbage prepended to the PDF 
file).

Russell
(who has no authority whatsoever to review other people's code)


> This is a 2nd version of the patch. The buffers for %stdin% have
> been increased to allow 1K of looking ahead.
> 
> [Log message]
> Improve automatic PDF recognition in run operator. Following PDF 1.5
> Implementation Notes H.3.4.1 search first 1024 bytes for %PDF- string.
> Identify file as PDF if %PDF- is found but the file doesn't start with
> %! . Recognize %!PS-Adobe-N.n PDF-M.m but don't search for it yet.
> Make .peekstring return "() false" instead of /rangecheck for empty
> files. Increase the size of %stdin% buffers to 1024 bytes.
> Fix bug 687601 from the customer 562