🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.postscript
Article #937

PostScript interpreter in PostScript bug fix

#937
From: Don Hopkins
Date: Sun, 27 Aug 1989 22:41
33 lines
1504 bytes
Oops, the interpreter did the wrong thing in the case that the
last object in an executable array was another executable array,
in an attempt to be properly tail-recursive.

The function that needs to be fixed is /arraytype, defined in the 
iexec-types dictionary. In the case that the array length is 1, it
should call iexec-token instead of PushExec on the element of 
the array, since there is a difference between what PostScript does 
when it executes an array, and what it does when it encounters an 
array during the execution of a containing array.

I found this bug by using the interpreter to trace through itsself.
(It was failing on the nullproc function.)

	-Don

  /arraytype { % array => ...
    dup length dup 0 eq { % array length
      pop pop %
    } { % array length
      1 eq { % array
        0 get %
%	PushExec % XXX causes tail recursion bug
	iexec-token %
      } { % array
        dup 0 get % array head
	% push rest of array to execute later
	exch 1 1 index length 1 sub getinterval % head tail
	PushExec % head
        iexec-token %
      } ifelse
    } ifelse
  } def
Technical Details
Message-ID: <8908272241.AA19645@tumtum.cs.umd.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!tut.cis.ohio-state.edu!ucbvax!TUMTUM.CS.UMD.EDU!don

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!purdue!tut.cis.ohio-state.edu!ucbvax!TUMTUM.CS.UMD.EDU!don
From: don@TUMTUM.CS.UMD.EDU (Don Hopkins)
Newsgroups: comp.lang.postscript
Subject: PostScript interpreter in PostScript bug fix
Message-ID: <8908272241.AA19645@tumtum.cs.umd.edu>
Date: 27 Aug 89 22:41:48 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Lines: 33