[comp.windows.news] psview bug

marshall@software.ORG (Eric Marshall) (10/05/88)

	There is a bug in psview which appears when displaying
many of the files generated by psroff.  The error only occurs
when attempting to display the first page of a document.  Psh'ing
the program generated by psroff executes correctly.  Included
is the troff input file (no macros necessary), the NeWS error,
and the psroff output file.

	I am running on a Sun 3/160 with NeWS 1.1 under SunOS 3.4.


Eric Marshall
Software Productivity Consortium
1880 North Campus Commons Drive
Reston, VA 22091
(703) 391-1838

CSNET: marshall@software.org
ARPANET: marshall%software.org@relay.cs.net  OR
         @relay.cs.net:marshall@software.org

------------------------------------------------------------------------------
			  	  The OSF.
				Just say NO.
------------------------------------------------------------------------------


Troff input file ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< -----
.\"  A two page document
.ce
This is the centered line on page one.
.bp
.ce
This is the centered line on page two.


NeWS error ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----
Process: 0x10E3A4   Error: nocurrentpoint
Stack: dictionary[42] dictionary[42] dictionary[2100] /FrameEventMgr
/MenuEventMgr event(0x203634) /PaintProcess (d) 96
Executing: 'currentpoint'
At: {'exch' *'currentpoint' 'pop' 'exch' 'moveto' 'show'}
In: {/@DictHeight 'countdictstack' 'def' @Dicts 'length' 1 'sub' -1 0 array{4}
'for' 10 s 0 xH 0 xS 1 f 10 f 96 (d) *Y 4280 (d) X 1 f 2114 768 (This) N 2276
(is) X 2349 (a) X 2405 (centered) X 2698 (line.) X 2 p array{6} 'loop'}
In: {PSCanvas 'setcanvas' 'initmatrix' 'clippath' 'pathbbox' 792 'div' 'exch'
612 'div' 'min' 'dup' 'scale' 'pop' 'pop' 'pathbbox' 2 'div' 'exch' 2 'div'
'exch' 'translate' 'pop' 'pop' 306 'neg' 396 'neg' 'translate' FG `setcolor'
DoBox array{15} 'if' /paint PSItem `send' FrameBorderColor strokecanvas
startmatrix `concat' *PGC}
In: {*ps_paint}
In: {'gsave' FrameCanvas 'setcanvas' FixClient? array{2} 'if' PaintFrame?
array{1} 'if' ClientCanvas 'null' 'ne' array{2} 'if' *PaintClient FixClient?
array{4} 'if' /PaintProcess 'null' 'store' 'grestore'}
In: {`newprocessgroup' *CallPaintProcs}


Psroff output file ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< -----
%!PS-Adobe-1.0
%%Creator: spc-np1:marshall (Eric Marshall,260J,3911838,4815067)
%%Title: stdin (ditroff)
%%CreationDate: Thu Sep 29 08:16:49 1988
%%EndComments
% lib/psdit.pro -- prolog for psdit (ditroff) files
% Copyright (c) 1984, 1985 Adobe Systems Incorporated. All Rights Reserved.
% last edit: shore Sat Nov 23 20:28:03 1985
% RCSID: $Header: psdit.pro,v 2.1 85/11/24 12:19:43 shore Rel $

/$DITroff 140 dict def $DITroff begin
/fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def
/xi {0 72 11 mul translate 72 resolution div dup neg scale 0 0 moveto
  /fontnum 1 def /fontsize 10 def /fontheight 10 def /fontslant 0 def F
  /pagesave save def}def
/PB{save /psv exch def currentpoint translate 
  resolution 72 div dup neg scale 0 0 moveto}def
/PE{psv restore}def
/arctoobig 90 def /arctoosmall .05 def
/m1 matrix def /m2 matrix def /m3 matrix def /oldmat matrix def
/tan{dup sin exch cos div}def
/point{resolution 72 div mul}def
/dround	{transform round exch round exch itransform}def
/xT{/devname exch def}def
/xr{/mh exch def /my exch def /resolution exch def}def
/xp{}def
/xs{docsave restore end}def
/xt{}def
/xf{/fontname exch def /slotno exch def fontnames slotno get fontname eq not
 {fonts slotno fontname findfont put fontnames slotno fontname put}if}def
/xH{/fontheight exch def F}def
/xS{/fontslant exch def F}def
/s{/fontsize exch def /fontheight fontsize def F}def
/f{/fontnum exch def F}def
/F{fontheight 0 le {/fontheight fontsize def}if
   fonts fontnum get fontsize point 0 0 fontheight point neg 0 0 m1 astore
   fontslant 0 ne{1 0 fontslant tan 1 0 0 m2 astore m3 concatmatrix}if
   makefont setfont .04 fontsize point mul 0 dround pop setlinewidth}def
/X{exch currentpoint exch pop moveto show}def
/N{3 1 roll moveto show}def
/Y{exch currentpoint pop exch moveto show}def
/S{show}def
/ditpush{}def/ditpop{}def
/AX{3 -1 roll currentpoint exch pop moveto 0 exch ashow}def
/AN{4 2 roll moveto 0 exch ashow}def
/AY{3 -1 roll currentpoint pop exch moveto 0 exch ashow}def
/AS{0 exch ashow}def
/MX{currentpoint exch pop moveto}def
/MY{currentpoint pop exch moveto}def
/MXY{moveto}def
/cb{pop}def	% action on unknown char -- nothing for now
/n{}def/w{}def
/p{pop showpage pagesave restore /pagesave save def}def
/abspoint{currentpoint exch pop add exch currentpoint pop add exch}def
/distance{dup mul exch dup mul add sqrt}def
/dstroke{currentpoint stroke moveto}def
/Dl{2 copy gsave rlineto stroke grestore rmoveto}def
/arcellipse{/diamv exch def /diamh exch def oldmat currentmatrix pop
 currentpoint translate 1 diamv diamh div scale /rad diamh 2 div def
 currentpoint exch rad add exch rad -180 180 arc oldmat setmatrix}def
/Dc{dup arcellipse dstroke}def
/De{arcellipse dstroke}def
/Da{/endv exch def /endh exch def /centerv exch def /centerh exch def
 /cradius centerv centerv mul centerh centerh mul add sqrt def
 /eradius endv endv mul endh endh mul add sqrt def
 /endang endv endh atan def
 /startang centerv neg centerh neg atan def
 /sweep startang endang sub dup 0 lt{360 add}if def
 sweep arctoobig gt
 {/midang startang sweep 2 div sub def /midrad cradius eradius add 2 div def
  /midh midang cos midrad mul def /midv midang sin midrad mul def
  midh neg midv neg endh endv centerh centerv midh midv Da
  currentpoint moveto Da}
 {sweep arctoosmall ge
  {/controldelt 1 sweep 2 div cos sub 3 sweep 2 div sin mul div 4 mul def
  centerv neg controldelt mul centerh controldelt mul
  endv neg controldelt mul centerh add endh add
  endh controldelt mul centerv add endv add
  centerh endh add centerv endv add rcurveto dstroke}
 {centerh endh add centerv endv add rlineto dstroke}ifelse}ifelse}def

/Barray 200 array def % 200 values in a wiggle
/D~{mark}def
/D~~{counttomark Barray exch 0 exch getinterval astore /Bcontrol exch def pop
 /Blen Bcontrol length def Blen 4 ge Blen 2 mod 0 eq and
 {Bcontrol 0 get Bcontrol 1 get abspoint /Ycont exch def /Xcont exch def
  Bcontrol 0 2 copy get 2 mul put Bcontrol 1 2 copy get 2 mul put
  Bcontrol Blen 2 sub 2 copy get 2 mul put
  Bcontrol Blen 1 sub 2 copy get 2 mul put
  /Ybi /Xbi currentpoint 3 1 roll def def 0 2 Blen 4 sub
  {/i exch def
   Bcontrol i get 3 div Bcontrol i 1 add get 3 div
   Bcontrol i get 3 mul Bcontrol i 2 add get add 6 div
   Bcontrol i 1 add get 3 mul Bcontrol i 3 add get add 6 div
   /Xbi Xcont Bcontrol i 2 add get 2 div add def
   /Ybi Ycont Bcontrol i 3 add get 2 div add def
   /Xcont Xcont Bcontrol i 2 add get add def
   /Ycont Ycont Bcontrol i 3 add get add def
   Xbi currentpoint pop sub Ybi currentpoint exch pop sub rcurveto
  }for dstroke}if}def
end
/ditstart{$DITroff begin
 /nfonts 60 def			% NFONTS makedev/ditroff dependent!
 /fonts[nfonts{0}repeat]def
 /fontnames[nfonts{()}repeat]def
/docsave save def
}def

% character outcalls
/oc {/pswid exch def /cc exch def /name exch def
   /ditwid pswid fontsize mul resolution mul 72000 div def
   /ditsiz fontsize resolution mul 72 div def
   ocprocs name known{ocprocs name get exec}{name cb}
   ifelse}def
/fractm [.65 0 0 .6 0 0] def
/fraction
 {/fden exch def /fnum exch def gsave /cf currentfont def
  cf fractm makefont setfont 0 .3 dm 2 copy neg rmoveto
  fnum show rmoveto currentfont cf setfont(\244)show setfont fden show 
  grestore ditwid 0 rmoveto} def
/oce {grestore ditwid 0 rmoveto}def
/dm {ditsiz mul}def
/ocprocs 50 dict def ocprocs begin
(14){(1)(4)fraction}def
(12){(1)(2)fraction}def
(34){(3)(4)fraction}def
(13){(1)(3)fraction}def
(23){(2)(3)fraction}def
(18){(1)(8)fraction}def
(38){(3)(8)fraction}def
(58){(5)(8)fraction}def
(78){(7)(8)fraction}def
(sr){gsave 0 .06 dm rmoveto(\326)show oce}def
(is){gsave 0 .15 dm rmoveto(\362)show oce}def
(->){gsave 0 .02 dm rmoveto(\256)show oce}def
(<-){gsave 0 .02 dm rmoveto(\254)show oce}def
(==){gsave 0 .05 dm rmoveto(\272)show oce}def
end

% an attempt at a PostScript FONT to implement ditroff special chars
% this will enable us to 
%	cache the little buggers
%	generate faster, more compact PS out of psdit
%	confuse everyone (including myself)!
50 dict dup begin
/FontType 3 def
/FontName /DIThacks def
/FontMatrix [.001 0 0 .001 0 0] def
/FontBBox [-260 -260 900 900] def% a lie but ...
/Encoding 256 array def
0 1 255{Encoding exch /.notdef put}for
Encoding
 dup 8#040/space put %space
 dup 8#110/rc put %right ceil
 dup 8#111/lt put %left  top curl
 dup 8#112/bv put %bold vert
 dup 8#113/lk put %left  mid curl
 dup 8#114/lb put %left  bot curl
 dup 8#115/rt put %right top curl
 dup 8#116/rk put %right mid curl
 dup 8#117/rb put %right bot curl
 dup 8#120/rf put %right floor
 dup 8#121/lf put %left  floor
 dup 8#122/lc put %left  ceil
 dup 8#140/sq put %square
 dup 8#141/bx put %box
 dup 8#142/ci put %circle
 dup 8#143/br put %box rule
 dup 8#144/rn put %root extender
 dup 8#145/vr put %vertical rule
 dup 8#146/ob put %outline bullet
 dup 8#147/bu put %bullet
 dup 8#150/ru put %rule
 dup 8#151/ul put %underline
 pop
/DITfd 100 dict def
/BuildChar{0 begin
 /cc exch def /fd exch def
 /charname fd /Encoding get cc get def
 /charwid fd /Metrics get charname get def
 /charproc fd /CharProcs get charname get def
 charwid 0 fd /FontBBox get aload pop setcachedevice
 2 setlinejoin 40 setlinewidth
 newpath 0 0 moveto gsave charproc grestore
 end}def
/BuildChar load 0 DITfd put
%/UniqueID 5 def
/CharProcs 50 dict def
CharProcs begin
/space{}def
/.notdef{}def
/ru{500 0 rls}def
/rn{0 840 moveto 500 0 rls}def
/vr{0 800 moveto 0 -770 rls}def
/bv{0 800 moveto 0 -1000 rls}def
/br{0 750 moveto 0 -1000 rls}def
/ul{0 -140 moveto 500 0 rls}def
/ob{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath stroke}def
/bu{200 250 rmoveto currentpoint newpath 200 0 360 arc closepath fill}def
/sq{80 0 rmoveto currentpoint dround newpath moveto
    640 0 rlineto 0 640 rlineto -640 0 rlineto closepath stroke}def
/bx{80 0 rmoveto currentpoint dround newpath moveto
    640 0 rlineto 0 640 rlineto -640 0 rlineto closepath fill}def
/ci{500 360 rmoveto currentpoint newpath 333 0 360 arc
    50 setlinewidth stroke}def

/lt{0 -200 moveto 0 550 rlineto currx 800 2cx s4 add exch s4 a4p stroke}def
/lb{0 800 moveto 0 -550 rlineto currx -200 2cx s4 add exch s4 a4p stroke}def
/rt{0 -200 moveto 0 550 rlineto currx 800 2cx s4 sub exch s4 a4p stroke}def
/rb{0 800 moveto 0 -500 rlineto currx -200 2cx s4 sub exch s4 a4p stroke}def
/lk{0 800 moveto 0 300 -300 300 s4 arcto pop pop 1000 sub
    0 300 4 2 roll s4 a4p 0 -200 lineto stroke}def
/rk{0 800 moveto 0 300 s2 300 s4 arcto pop pop 1000 sub
    0 300 4 2 roll s4 a4p 0 -200 lineto stroke}def
/lf{0 800 moveto 0 -1000 rlineto s4 0 rls}def
/rf{0 800 moveto 0 -1000 rlineto s4 neg 0 rls}def
/lc{0 -200 moveto 0 1000 rlineto s4 0 rls}def
/rc{0 -200 moveto 0 1000 rlineto s4 neg 0 rls}def
end

/Metrics 50 dict def Metrics begin
/.notdef 0 def
/space 500 def
/ru 500 def
/br 0 def
/lt 416 def
/lb 416 def
/rt 416 def
/rb 416 def
/lk 416 def
/rk 416 def
/rc 416 def
/lc 416 def
/rf 416 def
/lf 416 def
/bv 416 def
/ob 350 def
/bu 350 def
/ci 750 def
/bx 750 def
/sq 750 def
/rn 500 def
/ul 500 def
/vr 0 def
end

DITfd begin
/s2 500 def /s4 250 def /s3 333 def
/a4p{arcto pop pop pop pop}def
/2cx{2 copy exch}def
/rls{rlineto stroke}def
/currx{currentpoint pop}def
/dround{transform round exch round exch itransform} def
end
end
/DIThacks exch definefont pop
ditstart
(psc)xT
576 1 1 xr
1(Times-Roman)xf 1 f
2(Times-Italic)xf 2 f
3(Times-Bold)xf 3 f
4(Times-BoldItalic)xf 4 f
5(Helvetica)xf 5 f
6(Helvetica-Bold)xf 6 f
7(Courier)xf 7 f
8(Courier-Bold)xf 8 f
9(Symbol)xf 9 f
10(DIThacks)xf 10 f
10 s
1 f
xi
%%EndProlog

%%Page: 1 1
10 s 0 xH 0 xS 1 f
10 f
96(d)Y
4280(d)X
1 f
2114 768(This)N
2276(is)X
2349(a)X
2405(centered)X
2698(line.)X

2 p
%%Page: 2 2
10 s 0 xH 0 xS 1 f
3 f
10 f
0 90(d)N
4280(d)X
1 f
748 768(This)N
910(is)X
983(the)X
1101(centered)X
1394(line)X
1534(on)X
1634(page)X
1806(two.)X
10 f
0 6424(d)N
4280(d)X

2 p
%%Trailer
xt

xs

earle@MAHENDO.JPL.NASA.GOV (Greg Earle) (10/08/88)

This is because apparently `psview' has no notion of currentpoint when it
enters the first page.  It blows up when it first tries to execute the `X'
definition (which is nearly almost immediate in `psdit' output).

If you insert a
	0 0 moveto
immediately below the
	%%Page: 1 1
(i.e., before the actual code)
then `psview' will work, and no ill effects are incurred.

Obviously, one would rather not have to edit the PostScript output file 
every time one wants to use `psview', so I reported it (rather casually, as
opposed to formally) to Steve Evans on the vendor exhibit floor at June Usenix
(I told you I reported it casually (^: ).  I've no idea what the fix is;
I hope Steve had an Elephantine memory enough so that someone could check into
it.

	- Greg Earle
	  Sun Los Angeles Consulting
	  earle@Sun.COM
	  earle@mahendo.JPL.NASA.GOV	(Guest account)

msc@canth.SGI.COM (Mark Callow) (10/10/88)

In article <8809300237.AA23796@brillig.umd.edu>, marshall@software.ORG (Eric Marshall) writes:
> 
> 	There is a bug in psview which appears when displaying
> many of the files generated by psroff.  The error only occurs
> when attempting to display the first page of a document.  Psh'ing
> 
> NeWS error ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----- 8< ----
> Process: 0x10E3A4   Error: nocurrentpoint


We had this problem as well so I fixed it.  I asumed that our psroff must
be different from the one they use at Sun since it clearly worked for
them.  The fix is to add the line 

	0 0 moveto

to psview.cps as shown below

    cdef ps_startpage()
	/@DictHeight countdictstack def
	@Dicts length 1 sub -1 0 { @Dicts exch get begin } for
	PGC {
	    /@DictHeight countdictstack def
	    @Dicts length 1 sub -1 0 { @Dicts exch get begin } for
*	    200 dict begin
******	    0 0 moveto
    cdef ps_endpage()
*	    end
	.
	.
	.

You might also want to add the lines

	200 dict begin
	.
	.
	end

as shown above since there are many PS programs that define lots of
things on each page.  I have sent these changes to Sun.  Hopefully
they will be included in the next psview.
--
From the TARDIS of Mark Callow
msc@sgi.sgi.com, ...{ames,decwrl,sun}!sgi!msc
"There is much virtue in a window.  It is to a human being as a frame is to
a painting, as a proscenium to a play.  It strongly defines its content."