Bug 691505 - writeobject writes tokens GS can't read back in
Summary: writeobject writes tokens GS can't read back in
Status: RESOLVED WORKSFORME
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: PS Interpreter (show other bugs)
Version: 8.71
Hardware: PC Linux
: P4 normal
Assignee: Alex Cherepanov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-28 00:09 UTC by Marek Kubica
Modified: 2010-07-28 03:04 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Kubica 2010-07-28 00:09:30 UTC
Hi,

I write some data to a file:

%!PS-3.0
(foo.ps) (w) file [ 1 2 3 ] 42 writeobject

When trying to read back the saved data using

$ gs foo.ps

I get

/syntaxerror in (bin obj seq, type=129, elements=1, size=36, non-zero unused field)

The same happens when trying to use

(foo.ps) (r) file token

Changing the object format does not change anything in this behaviour.

I am trying to embed Ghostscript into my own program, but I need bi-directional communication between the interpreter and my own program, so I thought I can serialize the stack somehow.
Comment 1 Alex Cherepanov 2010-07-28 03:04:51 UTC
Ghostscript works a designed.
PLRM p. 167 says:
  The scanner generates a syntaxerror when it encounters a binary
  object sequence that is malformed in any way. Possible causes include:
  ... an “unused” field that is not 0

PLRM p. 173 says:
  Accompanying the top-level object in the object sequence is a 1-byte
  tag, which is specified as an operand of printobject and writeobject.
  This tag is carried in the second byte of the object, which is
  otherwise unused (see Figure 3.3 on page 164).

I.e. writeobject with a tag other than 0 generates invalid binary object
sequence by Adobe design and Ghostscript implements this. The object can
read back by gs when the tag is 0.