🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.ghostscript.bug
Article #497

Re: invalidrestore during "... {datasrc} image" in gs 2.5.2

#497
From: L. Peter Deutsch
Date: Thu, 12 Nov 1992 03:30
60 lines
2787 bytes
Re <9211120354.AA16255@raisin-nut>
<1992Nov11.231724.13211@dcs.warwick.ac.uk>:

> I thought I understood PostScript VM until I built the following
> example!  It prints the same image twice, on both the HP IIISi, and
> the LW+, but using gs gives me an invalidrestore during the second
> image, on sun and sgi kit.  All data and dimensions are
> inconsequential.  Could someone explain why under ghostscript only the
> first one works?
> 
> %! Here's the program:
> 
> 18 684 translate -90 rotate 540 540 scale
> 
> /srread {
> 	/srread { restore save currentfile 20 string readhexstring pop } def
> 	save
> 	currentfile 20 string readhexstring pop
> } def	
> 
> 10 10 8 [ 10 0 0 -10 0 10 ] 	% /A [ 10 0 0 -10 0 10 ] def   if you want
> {srread} image
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> restore
> showpage	
> 
> % here's a more direct way of printing the image
> % -- except it doesn't work with ghostscript
> 
> 18 684 translate -90 rotate 540 540 scale
> 
> 10 10 8 [ 10 0 0 -10 0 10 ] 
> {restore save currentfile 20 string readhexstring pop} save 6 1 roll image
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> bfbfbfbfc1c3c3c5c567bfbfbfbfc1c3c3c5c567
> restore
> showpage

Ghostscript's implementation of `image' allocates some state
information in VM, deallocating it when the image is complete.  The
`restore' inside the procedure gives an error because this
information cannot be deallocated while control is still inside the
`image' operator.

I may fix this eventually, but almost certainly not until I implement
garbage collection.

As I'm sure you realize, allocating a new string each time around the
loop is not good PostScript programming practice in any case.

L. Peter Deutsch :: Aladdin Enterprises :: P.O. box 60264, Palo Alto, CA 94306
ghost@aladdin.com, ...decwrl!aladdin!ghost ; voice 415-322-0103 ; fax 322-1734
	    "Implementation is the sincerest form of flattery."
Technical Details
Message-ID: <9211112030.1.UUL1.3#5127@aladdin.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!aladdin.COM!ghost
References: ghost@aladdin.COM (L. Peter Deutsch)

Show Full Headers
Complete Article Headers
Newsgroups: gnu.ghostscript.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!aladdin.COM!ghost
From: ghost@aladdin.COM (L. Peter Deutsch)
Subject: Re: invalidrestore during  "... {datasrc} image" in gs 2.5.2
Message-ID: <9211112030.1.UUL1.3#5127@aladdin.com>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
References: ghost@aladdin.COM (L. Peter Deutsch)
Distribution: gnu
Date: Thu, 12 Nov 1992 03:30:58 GMT
Approved: bug-ghostscript@prep.ai.mit.edu
Lines: 64