[comp.lang.postscript] Bug workarounds, seeking recent release of PS/sunPS/xps

klm@cme.nbs.gov (Ken Manheimer) (02/11/89)

I've just been getting acquainted with a postscript interpretor that i
got off the net quite a while back, and i have a few questions about
it.  The name is PS and/or sunPS; unfortunately it's not entirely
clear to me where this system comes from, but i gather two primary
names that are associated with it - Mark Weiser and and Crispin
Goswell, with Barry Shein contributing to the x11 work ('xps').  The
version i'm using is 1.4, according to the runtime value of the
'version' variable.

First of all, i'd like to mention how much i appreciate this
interpretor.  It is, as far as i can tell, fairly thorough and robust.
When i finally got to playing around with postscript (recently), it's
definitely been the way to go.  (I had problems with ghostscript and
already had this, so didn't push too far into it.)  I encountered two
serious bugs, however, for which i've implemented postscript-level
workarounds.  I'd be interested to know whether there's a more recent
release of this software that i could get a hold of, and how it stacks
up against ghostscript if any of you have experience with both.  In
particular, it would be nice to have something that displays under X11
supporting a backing store, which the version of xps that i'm using
does not do.


The more interesting bug is in the interaction of the 'exit' and
'forall' operators, or rather in their mis-interaction.  'exit'
operates as advertised within the context of 'for' loops, for
instance, but it provokes an 'invalidexit in operator exit' error
within the scope of a 'forall' loop.  Eg, repeat by:

[1 2 3 4] { dup 3 eq { pop exit } { = } ifelse } forall

On cursory examination of the source code it appears that 'forall'
doesn't push a NIL on the execution stack as it ought.  My workaround
is redefine /forall so that the primitive is encapsulated in a trivial
(1 pass) 'for' loop, which does catch 'exit's.  Here's the code:

/forall
    { 1 1 1 5 3 roll		% push 'for' args just prior to 'forall' args
      systemdict begin /forall load end		% obtain primitive 'forall'
      [ 0 0 0 ] astore cvx	% package prim 'forall' + args into exe-array
      for pop } 		% apply trivial 'for' wrapper and pop residue.
def

This is one of my first postscript hacks, so i'd be interested to hear
if i've missed a better/more sensible way to accomplish this...

One other small bug - in this version the 'showpage' operator causes
the interpretor to crash.  I've isolated the problem to some
interaction between the 'read' and 'stopped' operators.  This problem
is small because it's easy to circumvent - i redefine 'showpage' very
similarly to the default definition, as follows:

/showpage { copypage
	    initgraphics
	    beep print flush false echo
	    { stdin read { pop } if }
	    exec false echo }
def

Any pointers to exceptional postscript interpretors that run on Suns
and interface to X are welcome.  (I'm already aware of the impending
release of sun's NeWS/X, and am looking forward to it...)

Thanks, 

Ken Manheimer		 	klm@cme.nbs.gov or ..!uunet!cme-durer!klm
National Institute of Standards and Technology
(Formerly "National Bureau of Standards")
CME Factory Automation Systems, Software Support

I mean, you tell one guy it's blue.  He tells his guy it's brown, and it
lands on the page sorta purple.				   - Wavy Gravy.