home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / postscript / patches < prev    next >
Encoding:
Text File  |  1989-01-05  |  91.0 KB  |  3,291 lines

  1. This is a patch for Crispin Goswell's postscript interpreter, which
  2. was posted to comp.sources.unix a while back.  If you don't have the
  3. interpreter, you can get it from one of the comp.sources.unix
  4. archives.
  5.  
  6. Soon after the interpreter was posted, I posted these fixes to
  7. comp.sources.bugs, but they unfortunately had lines wrapped by our
  8. mailer.  This first patch is equivalent to that posting (modulo line
  9. wrapping) and if you successfully applied that posting, you can skip
  10. to the next patch.
  11.  
  12. To install this, you need the 'patch' program which is also available
  13. from the comp.sources.unix archives.
  14.  
  15. Change directories to the top-level postscript directory (the one with
  16. the file "MANIFEST" in it) and apply this patch with the command:
  17.  
  18. patch -p0 <ps.diff.v1
  19.  
  20.                 _.John G. Myers
  21.                 jm36+@andrew.cmu.edu
  22.  
  23. *** /dev/null    Mon Jul 25 01:14:13 1988
  24. --- CHANGES.JGM    Thu Jul 28 12:24:55 1988
  25. ***************
  26. *** 0 ****
  27. --- 1,47 -----
  28. + Here is a patch that makes several bug fixes and enhancements to the Postscript
  29. + interpreter recently posted.  The changes are:
  30. + Bugs fixed:
  31. + Half-implemented the missing operator "vmstatus".  The number of savelevels is
  32. + correct (as far as the broken implementation of "save" and "restore" allow),
  33. + but the amount of memory used and free is a lie.
  34. + Implemented the missing operator "noaccess".
  35. + Fixed a bug in the operator "stopped".  Previously it only worked on arrays,
  36. + but now it works on any executable object.
  37. + Fixed the parsing bug for reals with a trailing period (e.g. "4.") which
  38. + resulted in the "undefined in operater exec" errors reported to the net.
  39. + Changed an occurance of the variable "signed" to "signedp" as the former is an
  40. + ANSI C keyword.
  41. + Added a version of the missing file postscript/demos/buildcachefont.ps
  42. + Enhancements made:
  43. + Macroized PanicIf()
  44. + Changed "undefined in operator exec" errors to instead report 
  45. + "undefined in operator foo", where "foo" is the operator that was undefined.
  46. + Fixed imagemask to deal better with images that have to be shrunk.  Bitmapped
  47. + fonts intended for 300 dpi printers look much better now.
  48. + (Change courtesy of Christopher Cox, cc4b@andrew.cmu.edu)
  49. + Tweaked makefile to deal better with sun3.
  50. + Added "getenv" operator.  The syntax is:
  51. +     <string> getenv <string> <true>
  52. + if the environment variable exists, or
  53. +     <string> getenv <false>
  54. + if it does not.
  55. +                 John G. Myers
  56. +                 jm36@andrew.cmu.edu
  57. +                 jgm@k.gp.cs.cmu.edu
  58. diff -cr orig/postscript/psrc ./postscript/psrc
  59. *** orig/postscript/psrc    Sun Jan  3 14:22:51 1988
  60. --- ./postscript/psrc    Sun Dec 13 22:58:09 1987
  61. ***************
  62. *** 10,17 ****
  63.   
  64.   /bind {} def
  65.   
  66. ! /save { gsave /save } def
  67. ! /restore { grestore pop } def
  68.   /raise { errordict exch get exec } def
  69.   
  70.   /beep ( ) dup 0 7 put def
  71. --- 10,21 ----
  72.   
  73.   /bind {} def
  74.   
  75. ! %% Start mods by jgm
  76. ! /$$SAVELEVEL 0 def
  77. ! /save { gsave /save /$$SAVELEVEL $$SAVELEVEL 1 add def } def
  78. ! /restore { grestore pop /$$SAVELEVEL $$SAVELEVEL 1 sub def } def
  79. ! /vmstatus { $$SAVELEVEL 10000 10000 } def
  80. ! %% End mods by jgm
  81.   /raise { errordict exch get exec } def
  82.   
  83.   /beep ( ) dup 0 7 put def
  84. diff -cr orig/source/array.c ./source/array.c
  85. *** orig/source/array.c    Sun Jan  3 14:21:55 1988
  86. --- ./source/array.c    Sat Dec 12 01:05:28 1987
  87. ***************
  88. *** 17,22 ****
  89. --- 17,23 ----
  90.   
  91.   static int forAll (), ForAll (), PReadOnly (), PExecOnly (), PrCheck (), PwCheck ();
  92.   static int PutInterval (), GetInterval (), Put (), Get (), Length (), Copy (), Eq ();
  93. + static int PNoAccess (); /*jgm*/
  94.   
  95.   int ExecArray ();
  96.   Object Marker;
  97. ***************
  98. *** 53,58 ****
  99. --- 54,60 ----
  100.        TypeInstallOp (Array, "length",         PLength,    1, 1, 0, 0, Array);
  101.        TypeInstallOp (Array, "copy",         Copy,        2, 0, 0, 0, Array, Array);
  102.        TypeInstallOp (Array, "forall",     ForAll,        2, 0, 0, 4, Array, Array);
  103. +      TypeInstallOp (Array, "noaccess",     PNoAccess,    1, 1, 0, 0, Array); /*jgm*/
  104.        TypeInstallOp (Array, "executeonly",     PExecOnly,    1, 1, 0, 0, Array);
  105.        TypeInstallOp (Array, "readonly",     PReadOnly,    1, 1, 0, 0, Array);
  106.        TypeInstallOp (Array, "rcheck",     PrCheck,    1, 1, 0, 0, Array);
  107. ***************
  108. *** 385,390 ****
  109. --- 387,398 ----
  110.                 body[i] = Pop (OpStack);
  111.             return Push (OpStack, array);
  112.         }
  113. +  }
  114. + /* PNoAccess by jgm */
  115. + static int PNoAccess (item) Object item;
  116. +  {
  117. +      return Push (OpStack, NoAccess (item));
  118.    }
  119.   
  120.   static int PExecOnly (item) Object item;
  121. diff -cr orig/source/cache.c ./source/cache.c
  122. *** orig/source/cache.c    Sun Jan  3 14:22:42 1988
  123. --- ./source/cache.c    Thu Dec 10 21:26:47 1987
  124. ***************
  125. *** 501,512 ****
  126.       if ((ccache = SearchCache (m, BodyFontID (DictLoad (gstate->font, Fid)))) == NULL)
  127.            return Error (PInvFont);
  128.        
  129. -       Message (disk_name);
  130.       VOID sprintf (disk_name,
  131.            "%s/cache/%.*s/%3d%3d%3d%3d",
  132.            library,
  133.            lengthName (font_name), BodyName (font_name),
  134.            (int) right.vx, (int) right.vy, (int) bottom.vx, (int) bottom.vy);
  135.        
  136.        if ((fp = fopen (disk_name, "w")) == NULL)
  137.            return Error (PInvFileAccess);
  138. --- 501,512 ----
  139.       if ((ccache = SearchCache (m, BodyFontID (DictLoad (gstate->font, Fid)))) == NULL)
  140.            return Error (PInvFont);
  141.        
  142.       VOID sprintf (disk_name,
  143.            "%s/cache/%.*s/%3d%3d%3d%3d",
  144.            library,
  145.            lengthName (font_name), BodyName (font_name),
  146.            (int) right.vx, (int) right.vy, (int) bottom.vx, (int) bottom.vy);
  147. +       Message (disk_name); /* moved from before to after prev line -- jgm */
  148.        
  149.        if ((fp = fopen (disk_name, "w")) == NULL)
  150.            return Error (PInvFileAccess);
  151. diff -cr orig/source/config.c ./source/config.c
  152. *** orig/source/config.c    Sun Jan  3 14:19:54 1988
  153. --- ./source/config.c    Fri Jan  1 13:58:10 1988
  154. ***************
  155. *** 87,91 ****
  156.        Install ("polytype",        DictFrom (Poly));
  157.       Install ("fonttype",        DictFrom (FontID));
  158.       
  159. !     Install ("version",    StringFrom ("Version 1.4"));
  160.    }
  161. --- 87,91 ----
  162.        Install ("polytype",        DictFrom (Poly));
  163.       Install ("fonttype",        DictFrom (FontID));
  164.       
  165. !     Install ("version",    StringFrom ("Version 1.4 with mods by jgm")); /* jgm */
  166.    }
  167. diff -cr orig/source/control.c ./source/control.c
  168. *** orig/source/control.c    Sun Jan  3 14:26:55 1988
  169. --- ./source/control.c    Sun Dec 13 23:13:46 1987
  170. ***************
  171. *** 65,71 ****
  172.        InstallOp ("loop",    PLoop,        1, 0, 0, 4, Array);
  173.       InstallOp ("exit",    PExit,        0, 0, 0, 0);
  174.        InstallOp ("stop",    PStop,        0, 1, 0, 0);
  175. !      InstallOp ("stopped",    PStopped,    1, 1, 0, 3, Array);
  176.        InstallOp ("quit",    PQuit,         0, 0, 0, 0);
  177.        InstallOp ("start",    PStart,     0, 0, 0, 0);
  178.        InstallOp ("countexecstack",
  179. --- 65,72 ----
  180.        InstallOp ("loop",    PLoop,        1, 0, 0, 4, Array);
  181.       InstallOp ("exit",    PExit,        0, 0, 0, 0);
  182.        InstallOp ("stop",    PStop,        0, 1, 0, 0);
  183. !     /* Changed from "Array" to "Poly" --jgm*/
  184. !      InstallOp ("stopped",    PStopped,    1, 1, 0, 3, Poly);
  185.        InstallOp ("quit",    PQuit,         0, 0, 0, 0);
  186.        InstallOp ("start",    PStart,     0, 0, 0, 0);
  187.        InstallOp ("countexecstack",
  188. diff -cr orig/source/dictionary.c ./source/dictionary.c
  189. *** orig/source/dictionary.c    Sun Jan  3 14:22:55 1988
  190. --- ./source/dictionary.c    Sat Dec 12 01:06:49 1987
  191. ***************
  192. *** 23,28 ****
  193. --- 23,29 ----
  194.   static int PDict (), PBegin (), PEnd (), PDef (), PStore (), PKnown (), PLoad ();
  195.   static int PrCheck (), PwCheck (), PReadOnly (), EqDict (); 
  196.   static int PWhere (), PMaxLength (), PCurrentDict (); 
  197. + static int PNoAccess (); /*jgm*/
  198.   
  199.   static int hash_tries = 0, hash_collisions = 0, hash_attempts = 0;
  200.   static int PHashStats (), PDictHash ();
  201. ***************
  202. *** 57,62 ****
  203. --- 58,64 ----
  204.       TypeInstallOp (Dictionary, "length",     LengthDict,    1, 1, 0, 0, Dictionary);
  205.       TypeInstallOp (Dictionary, "copy",     CopyDict,    2, 0, 0, 0, Dictionary, Dictionary);
  206.       TypeInstallOp (Dictionary, "forall",     ForDict,    2, 0, 0, 4, Dictionary, Array);
  207. +      TypeInstallOp (Dictionary, "noaccess",     PNoAccess,    1, 1, 0, 0, Dictionary); /*jgm*/
  208.        TypeInstallOp (Dictionary, "readonly",     PReadOnly,    1, 1, 0, 0, Dictionary);
  209.        TypeInstallOp (Dictionary, "rcheck",     PrCheck,    1, 1, 0, 0, Dictionary);
  210.        TypeInstallOp (Dictionary, "wcheck",     PwCheck,    1, 1, 0, 0, Dictionary);
  211. ***************
  212. *** 511,516 ****
  213. --- 513,524 ----
  214.   static int PCurrentDict ()
  215.    {
  216.         return Push (OpStack, Top (DictStack));
  217. +  }
  218. + /* PNoAccess by jgm */
  219. + static int PNoAccess (item) Object item;
  220. +  {
  221. +      return Push (OpStack, NoAccess (item));
  222.    }
  223.   
  224.   static int PReadOnly (item) Object item;
  225. diff -cr orig/source/image.c ./source/image.c
  226. *** orig/source/image.c    Sun Jan  3 14:22:32 1988
  227. --- ./source/image.c    Mon Dec 28 18:17:04 1987
  228. ***************
  229. *** 353,363 ****
  230.       else
  231.        {
  232.            middle2 = NewBitmapHardware (dwidth, h);
  233. !         for (i = 0; i < dwidth; i++)
  234. !             BitBlt (from,     middle2,
  235. !                 NewDevicePoint ((int) (i/xscale), 0), NewDevicePoint (i, 0),
  236.                   NewDevicePoint (1, h),
  237.                   ROP_OR);
  238.        }
  239.       
  240.       if (dheight > h)
  241. --- 353,365 ----
  242.       else
  243.        {
  244.            middle2 = NewBitmapHardware (dwidth, h);
  245. !         /* begin changes by cc4b --jgm */
  246. !         for (i = 0; i < w; i++)
  247. !             BitBlt( from,  middle2,
  248. !                 NewDevicePoint (i, 0), NewDevicePoint( (int) (i * xscale), 0),
  249.                   NewDevicePoint (1, h),
  250.                   ROP_OR);
  251. +         /* end changes by cc4b --jgm */
  252.        }
  253.       
  254.       if (dheight > h)
  255. ***************
  256. *** 382,392 ****
  257.       else
  258.        {
  259.           high2 = NewBitmapHardware (dwidth, dheight);
  260. !         for (i = 0; i < dheight; i++)
  261. !             BitBlt (middle2, high2,
  262. !                 NewDevicePoint (0, (int) (i/yscale)), NewDevicePoint (0, i),
  263.                   NewDevicePoint (dwidth, 1),
  264.                   ROP_OR);
  265.        }
  266.        return high2;
  267.    }
  268. --- 384,397 ----
  269.       else
  270.        {
  271.           high2 = NewBitmapHardware (dwidth, dheight);
  272. !         /* begin changes by cc4b --jgm */
  273. !         for (i = 0; i < h; i++ )
  274. !             BitBlt( middle2, high2,
  275. !                 NewDevicePoint (0, i), NewDevicePoint( 0, (int) (i * yscale)),
  276.                   NewDevicePoint (dwidth, 1),
  277.                   ROP_OR);
  278. +         /* end changes by cc4b  --jgm */
  279.        }
  280.        return high2;
  281.    }
  282. diff -cr orig/source/integer.c ./source/integer.c
  283. *** orig/source/integer.c    Sun Jan  3 14:21:32 1988
  284. --- ./source/integer.c    Thu Dec 10 20:44:17 1987
  285. ***************
  286. *** 72,80 ****
  287.   
  288.   int StrictMul (a, b) int a, b;
  289.    {
  290. !      int atop, abot, btop, bbot, sum, signed;
  291.        
  292. !      signed = (a < 0) != (b < 0);
  293.        a = a < 0 ? -a : a;
  294.        b = b < 0 ? -b : b;
  295.        abot = a & LowMask;
  296. --- 72,81 ----
  297.   
  298.   int StrictMul (a, b) int a, b;
  299.    {
  300. !     /* Variable signed changed to signedp by jgm for ANSI C */
  301. !      int atop, abot, btop, bbot, sum, signedp;
  302.        
  303. !      signedp = (a < 0) != (b < 0);
  304.        a = a < 0 ? -a : a;
  305.        b = b < 0 ? -b : b;
  306.        abot = a & LowMask;
  307. ***************
  308. *** 86,92 ****
  309.        sum = ((unsigned) sum >> Word2) + atop * btop;
  310.        if (sum != 0 || a * b < 0)
  311.            kill (getpid (), SIGFPE);
  312. !      return signed ? -a * b : a * b;
  313.    }
  314.   
  315.   int StrictAdd (a, b) int a, b;
  316. --- 87,93 ----
  317.        sum = ((unsigned) sum >> Word2) + atop * btop;
  318.        if (sum != 0 || a * b < 0)
  319.            kill (getpid (), SIGFPE);
  320. !      return signedp ? -a * b : a * b;
  321.    }
  322.   
  323.   int StrictAdd (a, b) int a, b;
  324. diff -cr orig/source/main.c ./source/main.c
  325. *** orig/source/main.c    Sun Jan  3 14:22:13 1988
  326. --- ./source/main.c    Sun Dec 13 00:40:04 1987
  327. ***************
  328. *** 187,210 ****
  329.                  Object newitem;
  330.                  
  331.                  newitem = Load (item);
  332. !                if (TypeOf (newitem) != Condition)
  333. !                     item = newitem;
  334. !                
  335. !                if (!xCheck (item))
  336. !                  res = Push (OpStack, item);
  337. !               else if (TypeOf (item) == Operator)
  338. !                   res = ExecOperator (item);
  339. !               else if (TypeOf (item) == Array)
  340. !                   res = ExecArray (item);
  341. !               else if (TypeOf (item) == File)
  342. !                   res = ExecFile (item);
  343. !             else
  344. !                {
  345. !                   res = Push (OpStack, item);
  346. !                    exop = Lookup (TypeOf (item), execName);
  347. !                    if (TypeOf (exop) != Condition)
  348. !                        VOID Push (ExecStack, exop);
  349. !                 }
  350.               }
  351.             else
  352.              {
  353. --- 187,216 ----
  354.                  Object newitem;
  355.                  
  356.                  newitem = Load (item);
  357. !             /* begin jgm */
  358. !             if (TypeOf (newitem) == Condition) {
  359. !                 VOID Push(OpStack, item);
  360. !                 res = Push(ExecStack, DictLoad(ErrorDict,PUndefined));
  361. !             } else {
  362. !                 /* end jgm */
  363. !                 item = newitem;
  364. !                 if (!xCheck (item))
  365. !                 res = Push (OpStack, item);
  366. !                 else if (TypeOf (item) == Operator)
  367. !                 res = ExecOperator (item);
  368. !                 else if (TypeOf (item) == Array)
  369. !                 res = ExecArray (item);
  370. !                 else if (TypeOf (item) == File)
  371. !                 res = ExecFile (item);
  372. !                 else
  373. !                 {
  374. !                 res = Push (OpStack, item);
  375. !                 exop = Lookup (TypeOf (item), execName);
  376. !                 if (TypeOf (exop) != Condition)
  377. !                     VOID Push (ExecStack, exop);
  378. !                 }
  379. !             } /* jgm */
  380.               }
  381.             else
  382.              {
  383. ***************
  384. *** 340,350 ****
  385.            return TRUE;
  386.    }
  387.   
  388. ! PanicIf (cond, s) int cond; char *s;
  389. !  {
  390. !      if (cond)
  391. !          Panic (s);
  392. !  }
  393.   
  394.   Panic (s) char *s;
  395.    {
  396. --- 346,358 ----
  397.            return TRUE;
  398.    }
  399.   
  400. ! #ifdef needed /* Macroized --jgm */
  401. ! XPanicIf (cond, s) int cond; char *s;
  402. ! X {
  403. ! X     if (cond)
  404. ! X         Panic (s);
  405. ! X }
  406. ! #endif
  407.   
  408.   Panic (s) char *s;
  409.    {
  410. ***************
  411. *** 392,397 ****
  412. --- 400,416 ----
  413.       return o;
  414.    }
  415.   
  416. + /* NoAccess by jgm */
  417. + Object NoAccess (o) Object o;
  418. +  {
  419. +      if (o.type == Dictionary)
  420. +          o.u.Dictionary->dict_flags &= ~(READABLE | WRITEABLE | EXECUTABLE);
  421. +      else
  422. +          o.flags &= ~(READABLE | WRITEABLE | EXECUTABLE);
  423. +      return o;
  424. +  }
  425.   Object ExecOnly (o) Object o;
  426.    {
  427.        if (o.type == Dictionary)
  428. ***************
  429. *** 398,404 ****
  430.            o.u.Dictionary->dict_flags &= ~(READABLE | WRITEABLE);
  431.        else
  432.            o.flags &= ~(READABLE | WRITEABLE);
  433. !      return ReadOnly (o);
  434.    }
  435.   
  436.   Object ReadOnly (o) Object o;
  437. --- 417,423 ----
  438.            o.u.Dictionary->dict_flags &= ~(READABLE | WRITEABLE);
  439.        else
  440.            o.flags &= ~(READABLE | WRITEABLE);
  441. !      return o;   /* Removed redundant call to ReadOnly -- jgm */
  442.    }
  443.   
  444.   Object ReadOnly (o) Object o;
  445. diff -cr orig/source/main.h ./source/main.h
  446. *** orig/source/main.h    Sun Jan  3 14:19:59 1988
  447. --- ./source/main.h    Sat Dec 12 00:58:43 1987
  448. ***************
  449. *** 74,79 ****
  450. --- 74,80 ----
  451.        Object overflow, underflow, *stack_body;
  452.    } *Stack, StackOb;
  453.    
  454. + Object NoAccess (); /* jgm */
  455.   Object SameFlags (), MakeObject (), Cvx (), Cvlit (), ReadOnly (), WriteOnly (), ExecOnly ();
  456.   int OpCheck (), min (), rCheck (), wCheck (), xCheck ();
  457.   Object MakeArray (), ParseArray (), getArray (), getIArray (), *BodyArray ();
  458. ***************
  459. *** 164,166 ****
  460. --- 165,170 ----
  461.       ((getchbuf = getc (BodyFile(file)->f.f_ptr)), \
  462.           ((getchbuf != EOF) ? getchbuf : ((BodyFile(file)->available = 0), Close (file), EOF))) \
  463.       : GeneralGetch (file))
  464. + /* Next line --jgm */
  465. + #define PanicIf(flag,s) do { if (flag) Panic(s); } while (0)
  466. diff -cr orig/source/math.c ./source/math.c
  467. *** orig/source/math.c    Sun Jan  3 14:20:43 1988
  468. --- ./source/math.c    Fri Dec 11 22:54:46 1987
  469. ***************
  470. *** 108,113 ****
  471. --- 108,115 ----
  472.         {
  473.             int olength = length, dval;
  474.             
  475. +         if (length == 0) return MakeReal (sign * (double)ival); /*jgm*/
  476.           fval = ival;
  477.            dval = ParseInteger (&s, &length, 10);
  478.            fval += dval * pow (10.0, (float)(length - olength));
  479. diff -cr orig/source/makefile ./source/makefile
  480. *** orig/source/makefile    Sun Jan  3 14:19:33 1988
  481. --- ./source/makefile    Sun Jan  3 15:37:00 1988
  482. ***************
  483. *** 4,16 ****
  484.   LIBS=libww.a -lsuntool -lsunwindow -lpixrect -g
  485.   GRAPHICS=cache.o colour.o device.o fill.o font.o gsave.o image.o mat.o matrix.o\
  486.       pat.o path.o state.o stroke.o
  487.   CFLAGS=-O
  488.   
  489.   PS:    $(OBJECTS) $(GRAPHICS) hard.o canon.a
  490.       cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) hard.o canon.a -lm `libs` -o PS
  491.   
  492. ! sunPS:    $(OBJECTS) $(GRAPHICS) hard.o canon.a pixrect
  493. !     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) hard.o canon.a -lm -lpixrect -o sunPS
  494.   
  495.   CPS:    $(OBJECTS) $(GRAPHICS) colour-ww.o trapezoid.o canon.o
  496.       cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) colour-ww.o canon.o trapezoid.o -lm `libs` -o CPS
  497. --- 4,23 ----
  498.   LIBS=libww.a -lsuntool -lsunwindow -lpixrect -g
  499.   GRAPHICS=cache.o colour.o device.o fill.o font.o gsave.o image.o mat.o matrix.o\
  500.       pat.o path.o state.o stroke.o
  501. + # For SUN with 68881
  502. + #CFLAGS=-O -f68881
  503. + # For others
  504.   CFLAGS=-O
  505.   
  506. + #default: sunPS
  507.   PS:    $(OBJECTS) $(GRAPHICS) hard.o canon.a
  508.       cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) hard.o canon.a -lm `libs` -o PS
  509.   
  510. ! sunPS:    $(OBJECTS) $(GRAPHICS) pixrect.o canon.a
  511. !     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) pixrect.o canon.a -lm -lpixrect -o sunPS
  512.   
  513.   CPS:    $(OBJECTS) $(GRAPHICS) colour-ww.o trapezoid.o canon.o
  514.       cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) colour-ww.o canon.o trapezoid.o -lm `libs` -o CPS
  515. ***************
  516. *** 31,39 ****
  517.   all:    PS postscript viewer
  518.   
  519.   ww:    ww.o wwlib installww
  520. - pixrect:    pixrect.o
  521. -     cp pixrect.o hard.o
  522.   
  523.   sun:    ww wwsun
  524.   
  525. --- 38,43 ----
  526. diff -cr orig/source/misc.c ./source/misc.c
  527. *** orig/source/misc.c    Sun Jan  3 14:19:36 1988
  528. --- ./source/misc.c    Sun Dec 13 22:03:56 1987
  529. ***************
  530. *** 17,27 ****
  531. --- 17,29 ----
  532.   #endif
  533.   
  534.   static int PUserTime ();
  535. + static int PGetEnv (); /*jgm*/
  536.        
  537.   InitMisc ()
  538.    {
  539.         InstallOp ("usertime",    PUserTime,    0, 1, 0, 0);
  540.        InstallOp ("==",     PolyFirst,     1, 1, 0, 0, Poly);
  541. +     InstallOp ("getenv",    PGetEnv,    1, 1, 0, 0, String); /*jgm*/
  542.     }
  543.   
  544.   static int PUserTime ()
  545. ***************
  546. *** 32,34 ****
  547. --- 34,50 ----
  548.       times (&tbuf);
  549.        return Push (OpStack, MakeInteger ((int) (tbuf.tms_utime * 1000 / HZ)));
  550.    }
  551. + /* PGetEnv by jgm */
  552. + static int PGetEnv(string) Object string;
  553. + {
  554. +     char *s, *getenv();
  555. +     s = getenv(BodyString(string));
  556. +     if (s != NULL) {
  557. +     VOID Push(OpStack, MakeString(s, strlen(s)));
  558. +     }
  559. +     return Push(OpStack, MakeBoolean(s != NULL));
  560. + }
  561. diff -cr orig/source/string.c ./source/string.c
  562. *** orig/source/string.c    Sun Jan  3 14:23:16 1988
  563. --- ./source/string.c    Sat Dec 12 01:32:44 1987
  564. ***************
  565. *** 22,27 ****
  566. --- 22,28 ----
  567.   static int Exec (), Token (), PString (), Search (), AnchorSearch (), Copy (), EqEq ();
  568.   static int Length (), ForAll (), Get (), Put (), GetInterval (), PutInterval (), Eq (), Lt (), Le (), Gt (), Ge (), PrCheck (), PwCheck ();
  569.   static int Cvi (), Cvr (), Cvs (), PReadOnly (), PExecOnly ();
  570. + static int PNoAccess (); /* jgm */
  571.   
  572.   InitString ()
  573.    {
  574. ***************
  575. *** 45,50 ****
  576. --- 46,52 ----
  577.        TypeInstallOp (String, "put",         Put,        3, 0, 0, 0, String, Integer, Integer);
  578.        TypeInstallOp (String, "getinterval",     GetInterval,    3, 1, 0, 0, String, Integer, Integer);
  579.        TypeInstallOp (String, "putinterval",     PutInterval,    3, 0, 0, 0, String, Integer, String);
  580. +      TypeInstallOp (String, "noaccess",     PNoAccess,    1, 1, 0, 0, String); /*jgm*/
  581.        TypeInstallOp (String, "executeonly",     PExecOnly,    1, 1, 0, 0, String);
  582.        TypeInstallOp (String, "readonly",     PReadOnly,    1, 1, 0, 0, String);
  583.        TypeInstallOp (String, "rcheck",     PrCheck,    1, 1, 0, 0, String);
  584. ***************
  585. *** 530,535 ****
  586. --- 532,543 ----
  587.       VOID Push (OpStack, False);
  588.       
  589.       return TRUE;
  590. +  }
  591. + /* PNoAccess by jgm */
  592. + static int PNoAccess (item) Object item;
  593. +  {
  594. +      return Push (OpStack, NoAccess (item));
  595.    }
  596.   
  597.   static int PExecOnly (item) Object item;
  598. diff -cr orig/source/viewer.c ./source/viewer.c
  599. *** orig/source/viewer.c    Sun Jan  3 14:21:58 1988
  600. --- ./source/viewer.c    Thu Dec 10 23:12:55 1987
  601. ***************
  602. *** 310,318 ****
  603.        return res;
  604.    }
  605.   
  606. ! PanicIf (flag, s) int flag; char *s;
  607.    {
  608. -      if (flag)
  609.            fprintf (stderr, "Viewer panic: %s\n", s),
  610.            exit (1);
  611.    }
  612. --- 310,318 ----
  613.        return res;
  614.    }
  615.   
  616. ! /* Removed conditional & changed PanicIf to Panic --jgm */
  617. ! Panic (s) char *s;
  618.    {
  619.            fprintf (stderr, "Viewer panic: %s\n", s),
  620.            exit (1);
  621.    }
  622. *** /dev/null    Mon Jul 25 01:14:13 1988
  623. --- postscript/demos/buildcachefont.ps    Thu Jul 28 12:25:02 1988
  624. ***************
  625. *** 0 ****
  626. --- 1,19 -----
  627. + %!
  628. + %% Build the font cache
  629. + %% By John G. Myers
  630. + % fontname pointsize cachefont --
  631. + /cachefont {
  632. +     exch findfont exch scalefont setfont
  633. +     5 5 moveto
  634. +     ( !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ) show
  635. +     ([\\]^_`abcdefghijklmnopqrstuvwxyz{|}~) show
  636. +     (\251\252\256\257\261\267\272\320) show
  637. +     savecurrentfont
  638. +     erasepage
  639. + } def
  640. + [  /Times-Roman /Helvetica /Times-Bold /Times-Italic /Helvetica-Oblique ]
  641. + { dup 10 cachefont dup 12 cachefont 14 cachefont }
  642. + forall
  643. Make sure you have already applied either 'ps.diff.v1' or my
  644. original posting to comp.sources.bugs.
  645.  
  646. To apply this, you need the 'patch' program which is available from
  647. the comp.sources.unix archives.
  648.  
  649. Change directories to the top-level postscript directory (the one with
  650. the file "MANIFEST" in it) and apply this patch with the command:
  651.  
  652. patch -p0 <ps.diff.v2
  653.  
  654.                 _.John G. Myers
  655.                 jm36+@andrew.cmu.edu
  656.  
  657. *** /usr/tmp/ps/CHANGES.JGM    Thu Jul 28 13:53:12 1988
  658. --- ./CHANGES.JGM    Thu Jul 28 14:58:10 1988
  659. ***************
  660. *** 1,6 ****
  661. ! Here is a patch that makes several bug fixes and enhancements to the Postscript
  662.   interpreter recently posted.  The changes are:
  663.   
  664.   
  665.   Bugs fixed:
  666.   
  667. --- 1,7 ----
  668. ! These patches make several bug fixes and enhancements to the Postscript
  669.   interpreter recently posted.  The changes are:
  670.   
  671. +                   Version 1:
  672.   
  673.   Bugs fixed:
  674.   
  675. ***************
  676. *** 41,46 ****
  677. --- 42,64 ----
  678.       <string> getenv <false>
  679.   if it does not.
  680.   
  681. +                   Version 2:
  682. + Bugs fixed:
  683. + Fixed operators kshow, translate, scale, rotate, reversepath
  684. + Casted NULL to appropriate type when it was passed as a parameter.
  685. + Removed unused variables.
  686. + Enhancements made:
  687. + Each driver must now define the character pointer "DriverType".  The
  688. + value of this variable is placed in the string produced by the
  689. + "version" operator.
  690. + Added operators letter, note, and legal.
  691.   
  692.                   John G. Myers
  693.                   jm36@andrew.cmu.edu
  694. diff -cr ./doc/hard-interface /cmu/math/jm36/src/ps/doc/hard-interface
  695. *** ./doc/hard-interface    Fri Apr  1 22:41:07 1988
  696. --- /cmu/math/jm36/src/ps/doc/hard-interface    Mon Mar 28 20:25:28 1988
  697. ***************
  698. *** 15,20 ****
  699. --- 15,29 ----
  700.    *    may be expected to be NULL.
  701.    */
  702.   
  703. + /* Begin jgm */
  704. + /*
  705. +  *    DriverType contains a pointer to a string naming the device that this
  706. +  *     is a driver for.  The given string will show up in the "version"
  707. +  *    operator.
  708. +  */
  709. + char *DriverType = "";
  710. + /* End jgm */
  711.   /************************* CREATION OF WINDOWS AND BITMAPS *******************/
  712.   
  713.   struct hardware *InitHardware () {}
  714. diff -cr ./doc/hard-interface.c /cmu/math/jm36/src/ps/doc/hard-interface.c
  715. *** ./doc/hard-interface.c    Fri Apr  1 22:42:05 1988
  716. --- /cmu/math/jm36/src/ps/doc/hard-interface.c    Mon Mar 28 20:24:19 1988
  717. ***************
  718. *** 17,22 ****
  719. --- 17,31 ----
  720.    *    of access that PostScript is interested in. Any Hardware parameter may be expected to be NULL.
  721.    */
  722.   
  723. + /* Begin jgm */
  724. + /*
  725. +  *    DriverType contains a pointer to a string naming the device that this
  726. +  *     is a driver for.  The given string will show up in the "version"
  727. +  *    operator.
  728. +  */
  729. + char *DriverType = "";
  730. + /* End jgm */
  731.   /*********************************** CREATION OF WINDOWS AND BITMAPS *******************/
  732.   
  733.   struct hardware *InitHardware () {}
  734. diff -cr ./postscript/psrc /cmu/math/jm36/src/ps/postscript/psrc
  735. *** ./postscript/psrc    Fri Apr  1 22:48:12 1988
  736. --- /cmu/math/jm36/src/ps/postscript/psrc    Wed Mar 23 23:05:53 1988
  737. ***************
  738. *** 125,130 ****
  739. --- 141,148 ----
  740.   } def
  741.   
  742.   /kshow {
  743. +     exch    % jgm
  744.       showdict begin /p exch def
  745.           dup length 0 ne {
  746.               dup 0 get /last exch def
  747. ***************
  748. *** 132,137 ****
  749. --- 150,156 ----
  750.               dup length 1 sub 1 exch getinterval {
  751.                   last exch dup /last exch def
  752.                   /p load exec
  753. +                 ( ) dup 0 last put show  % jgm
  754.               } forall
  755.           } if
  756.       end
  757. ***************
  758. *** 467,472 ****
  759. --- 493,526 ----
  760.       [ 0 f f 0 0 0] w h [] framedevice
  761.       end
  762.   } def
  763. + % Begin additions --jgm
  764. + /letter {
  765. +     5 dict begin
  766. +     /m [1.13889 0 0 -1.13889 0 0] def
  767. +     /f m 0 get def
  768. +     /h 11 72 mul f mul cvi def
  769. +     /w 8.5 72 mul f mul 8 div cvi def
  770. +     m 5 h put
  771. +     m w h [] framedevice
  772. +     end
  773. + } def
  774. + /note { letter } def
  775. + /legal {
  776. +     5 dict begin
  777. +     /m [1.13889 0 0 -1.13889 0 0] def
  778. +     /f m 0 get def
  779. +     /h 14 72 mul f mul cvi def
  780. +     /w 8.5 72 mul f mul 8 div cvi def
  781. +     m 5 h put
  782. +     m w h [] framedevice
  783. +     end
  784. + } def
  785. + % End additions --jgm
  786.   
  787.   /ascii-set ( !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~) def
  788.   
  789. diff -cr ./source/X.c /cmu/math/jm36/src/ps/source/X.c
  790. *** ./source/X.c    Fri Apr  1 22:44:35 1988
  791. --- /cmu/math/jm36/src/ps/source/X.c    Fri Mar 11 23:39:36 1988
  792. ***************
  793. *** 17,22 ****
  794. --- 17,24 ----
  795.   #define TRANSFER_SIZE    256
  796.   #define XMAX        65535
  797.   
  798. + char *DriverType = "X10"; /* jgm */
  799.   static int transfer [TRANSFER_SIZE + 1];
  800.   
  801.   static unsigned char reverse [0x100];
  802. diff -cr ./source/array.c /cmu/math/jm36/src/ps/source/array.c
  803. *** ./source/array.c    Fri Apr  1 22:48:17 1988
  804. --- /cmu/math/jm36/src/ps/source/array.c    Sun Mar  6 17:16:25 1988
  805. ***************
  806. *** 85,94 ****
  807. --- 85,96 ----
  808.        return res;
  809.    }
  810.   
  811. + #ifdef notdef /* jgm */
  812.   static Object *Body (item) Object item;
  813.    {
  814.        return item.u.Array;
  815.    }
  816. + #endif /* jgm */
  817.   
  818.   #define Body(a) ((a).u.Array)
  819.   
  820. diff -cr ./source/config.c /cmu/math/jm36/src/ps/source/config.c
  821. *** ./source/config.c    Fri Apr  1 22:48:20 1988
  822. --- /cmu/math/jm36/src/ps/source/config.c    Sat Mar 12 00:08:51 1988
  823. ***************
  824. *** 20,30 ****
  825.   Type Real, Name, Operator, String, Poly, Float, FontID;
  826.   
  827.   extern Object Absent, Nil, SysDict;
  828.   
  829. ! char default_library[] = "/usr/ral/lib/postscript";
  830.   
  831.   Init ()
  832.    {    
  833.       Nil     = MakeObject ((Type) 0);
  834.       Null          = Nil.type = MakeType (SizeNull);
  835.       EmptyDict (Null);    /* needed because of this recursion */
  836. --- 20,33 ----
  837.   Type Real, Name, Operator, String, Poly, Float, FontID;
  838.   
  839.   extern Object Absent, Nil, SysDict;
  840. + extern char *DriverType;
  841.   
  842. ! char default_library[] = "/usr/ral/lib/postscript";
  843.   
  844.   Init ()
  845.    {    
  846. +     char versionbuf[1024]; /* --jgm */
  847.       Nil     = MakeObject ((Type) 0);
  848.       Null          = Nil.type = MakeType (SizeNull);
  849.       EmptyDict (Null);    /* needed because of this recursion */
  850. ***************
  851. *** 87,91 ****
  852.        Install ("polytype",        DictFrom (Poly));
  853.       Install ("fonttype",        DictFrom (FontID));
  854.       
  855. !     Install ("version",    StringFrom ("Version 1.4 with mods by jgm")); /* jgm */
  856.    }
  857. --- 90,98 ----
  858.        Install ("polytype",        DictFrom (Poly));
  859.       Install ("fonttype",        DictFrom (FontID));
  860.       
  861. !     /* Begin jgm */
  862. !     strcpy(versionbuf, DriverType);
  863. !     strcat(versionbuf, " version 1.4 with jgm mods v2");
  864. !     Install ("version",    StringFrom (versionbuf));
  865. !     /* End jgm */
  866.    }
  867. diff -cr ./source/device.c /cmu/math/jm36/src/ps/source/device.c
  868. *** ./source/device.c    Fri Apr  1 22:41:29 1988
  869. --- /cmu/math/jm36/src/ps/source/device.c    Sun Mar  6 17:29:48 1988
  870. ***************
  871. *** 200,206 ****
  872.            UnlinkDevice (d);
  873.         }
  874.        else
  875. !          */BitBlt (NULL, res->dev, NewDevicePoint (0, 0), NewDevicePoint (0, 0), ex, ROP_FALSE);
  876.        
  877.        return res;
  878.    }
  879. --- 200,206 ----
  880.            UnlinkDevice (d);
  881.         }
  882.        else
  883. !          */BitBlt ((struct hardware *)NULL, res->dev, NewDevicePoint (0, 0), NewDevicePoint (0, 0), ex, ROP_FALSE); /* cast NULL --jgm */
  884.        
  885.        return res;
  886.    }
  887. diff -cr ./source/file.c /cmu/math/jm36/src/ps/source/file.c
  888. *** ./source/file.c    Fri Apr  1 22:45:31 1988
  889. --- /cmu/math/jm36/src/ps/source/file.c    Sun Mar  6 17:16:15 1988
  890. ***************
  891. *** 168,184 ****
  892. --- 168,188 ----
  893.   
  894.   #define Getc(a) getc(a)
  895.   
  896. + #ifdef notdef /* jgm */
  897.   static int Getchar ()
  898.    {
  899.        return Getc (stdin);
  900.    }
  901. + #endif /* jgm */
  902.   
  903.   #define Getchar getchar
  904.   
  905. + #ifdef notdef /* jgm */
  906.   static int Status (file) Object file;
  907.    {
  908.        return Body (file)->available;
  909.    }
  910. + #endif /* jgm */
  911.   
  912.   #define Status(f) (Body(f)->available)
  913.   
  914. ***************
  915. *** 306,312 ****
  916.        Cbreak (FALSE);
  917.    }
  918.   
  919. ! static cbreak = FALSE, echoing = TRUE;
  920.   
  921.   /*ARGSUSED*/
  922.   Cbreak (cond) int cond;
  923. --- 310,316 ----
  924.        Cbreak (FALSE);
  925.    }
  926.   
  927. ! static /* cbreak = FALSE, (removed --jgm) */ echoing = TRUE;
  928.   
  929.   /*ARGSUSED*/
  930.   Cbreak (cond) int cond;
  931. diff -cr ./source/fill.c /cmu/math/jm36/src/ps/source/fill.c
  932. *** ./source/fill.c    Fri Apr  1 22:44:44 1988
  933. --- /cmu/math/jm36/src/ps/source/fill.c    Sun Mar  6 17:46:45 1988
  934. ***************
  935. *** 149,155 ****
  936.        UnlinkDevice (gstate->clipdevice);
  937.         gstate->clipdevice = NULL;
  938.         
  939. !      SetClipHardware (gstate->device->dev, NULL);
  940.       
  941.       return TRUE;
  942.    }
  943. --- 149,155 ----
  944.        UnlinkDevice (gstate->clipdevice);
  945.         gstate->clipdevice = NULL;
  946.         
  947. !      SetClipHardware (gstate->device->dev, (struct hardware *)NULL); /* cast NULL --jgm */
  948.       
  949.       return TRUE;
  950.    }
  951. ***************
  952. *** 226,232 ****
  953.   static int FillIt (path_a, rule_a, path_b, rule_b, emitfn)
  954.       Path path_a, path_b; int (*rule_a)(), (*rule_b)(); void (*emitfn)();
  955.    {
  956. !     Path new;
  957.       static int edgecmp ();
  958.       static void Trapezoids (), BuildEdgeList ();
  959.       
  960. --- 226,232 ----
  961.   static int FillIt (path_a, rule_a, path_b, rule_b, emitfn)
  962.       Path path_a, path_b; int (*rule_a)(), (*rule_b)(); void (*emitfn)();
  963.    {
  964. !     /* Path new; (unused --jgm) */
  965.       static int edgecmp ();
  966.       static void Trapezoids (), BuildEdgeList ();
  967.       
  968. ***************
  969. *** 288,298 ****
  970.    {
  971.       struct edge *up_edge;
  972.       int i, count_a = 0, count_b = 0;
  973. !     static void RemoveEdges ();
  974.       
  975.       for (i = 0; i < ninteresting; i++)
  976.        {
  977. !          static void Emit ();
  978.            int d_a = 0, d_b = 0;
  979.            
  980.            if (interesting[i]->clip)
  981. --- 288,298 ----
  982.    {
  983.       struct edge *up_edge;
  984.       int i, count_a = 0, count_b = 0;
  985. !     /* static void RemoveEdges (); (unused --jgm) */
  986.       
  987.       for (i = 0; i < ninteresting; i++)
  988.        {
  989. !          /* static void Emit (); (unused --jgm) */
  990.            int d_a = 0, d_b = 0;
  991.            
  992.            if (interesting[i]->clip)
  993. diff -cr ./source/font.c /cmu/math/jm36/src/ps/source/font.c
  994. *** ./source/font.c    Fri Apr  1 22:45:11 1988
  995. --- /cmu/math/jm36/src/ps/source/font.c    Sun Mar  6 17:11:46 1988
  996. ***************
  997. *** 535,541 ****
  998.        for (;;)
  999.        {
  1000.            int code = *++s;
  1001. !          HardPoint offset, cp;
  1002.            
  1003.            offset = Adjust (DExtToInt (last_width), code);
  1004.           loc.hx += offset.hx;
  1005. --- 535,541 ----
  1006.        for (;;)
  1007.        {
  1008.            int code = *++s;
  1009. !          HardPoint offset/* , cp (unused --jgm) */;
  1010.            
  1011.            offset = Adjust (DExtToInt (last_width), code);
  1012.           loc.hx += offset.hx;
  1013. diff -cr ./source/gsave.c /cmu/math/jm36/src/ps/source/gsave.c
  1014. *** ./source/gsave.c    Fri Apr  1 22:39:48 1988
  1015. --- /cmu/math/jm36/src/ps/source/gsave.c    Sun Mar  6 17:34:40 1988
  1016. ***************
  1017. *** 75,81 ****
  1018.                 SetScreen (gstate->screen.frequency, gstate->screen.rotation, gstate->screen.thresh);
  1019.             if (tflag)
  1020.                 SetTransfer (gstate->transfer.tran);
  1021. !           SetClipHardware (gstate->device->dev, (gstate->clipdevice ? gstate->clipdevice->dev : NULL));
  1022.        }
  1023.        
  1024.        return TRUE;
  1025. --- 75,81 ----
  1026.                 SetScreen (gstate->screen.frequency, gstate->screen.rotation, gstate->screen.thresh);
  1027.             if (tflag)
  1028.                 SetTransfer (gstate->transfer.tran);
  1029. !           SetClipHardware (gstate->device->dev, (gstate->clipdevice ? gstate->clipdevice->dev : (struct hardware *)NULL)); /* Cast NULL --jgm */
  1030.        }
  1031.        
  1032.        return TRUE;
  1033. diff -cr ./source/image.c /cmu/math/jm36/src/ps/source/image.c
  1034. *** ./source/image.c    Fri Apr  1 22:48:26 1988
  1035. --- /cmu/math/jm36/src/ps/source/image.c    Sun Mar  6 17:34:36 1988
  1036. ***************
  1037. *** 250,256 ****
  1038.                       FillMask (mask, i, dep);
  1039.                      
  1040.                      BitBlt (from, mask, NewDevicePoint (0, 0), NewDevicePoint (0, 0), HardwareExtent (from), ROP_NXOR);
  1041. !                    BitBlt (NULL, temp, NewDevicePoint (0, 0), NewDevicePoint (0, 0), HardwareExtent (temp), ROP_TRUE);
  1042.                       for (j = 0; j < dep; j++)
  1043.                           BitBlt (mask, temp, NewDevicePoint (j, 0), NewDevicePoint (0, 0), HardwareExtent (mask), ROP_AND);
  1044.                       for (j = 0; j < w; j++)
  1045. --- 250,256 ----
  1046.                       FillMask (mask, i, dep);
  1047.                      
  1048.                      BitBlt (from, mask, NewDevicePoint (0, 0), NewDevicePoint (0, 0), HardwareExtent (from), ROP_NXOR);
  1049. !                    BitBlt ((struct  hardware *)NULL, temp, NewDevicePoint (0, 0), NewDevicePoint (0, 0), HardwareExtent (temp), ROP_TRUE);  /* cast NULL --jgm */
  1050.                       for (j = 0; j < dep; j++)
  1051.                           BitBlt (mask, temp, NewDevicePoint (j, 0), NewDevicePoint (0, 0), HardwareExtent (mask), ROP_AND);
  1052.                       for (j = 0; j < w; j++)
  1053. diff -cr ./source/matrix.c /cmu/math/jm36/src/ps/source/matrix.c
  1054. *** ./source/matrix.c    Fri Apr  1 22:43:11 1988
  1055. --- /cmu/math/jm36/src/ps/source/matrix.c    Wed Mar 23 22:40:28 1988
  1056. ***************
  1057. *** 126,131 ****
  1058. --- 126,132 ----
  1059.   static int PTranslate ()
  1060.    {
  1061.        Object tx, ty, mat;
  1062. +     Matrix m;
  1063.        float x, y;
  1064.        
  1065.        if (!OpCheck (2, 1))
  1066. ***************
  1067. *** 136,141 ****
  1068. --- 137,144 ----
  1069.                 return Push (OpStack, mat), Error (PInvAccess);
  1070.            else if (lengthArray (mat) != 6)
  1071.                 return Push (OpStack, mat), Error (PRangeCheck);
  1072. +         else if    (!ExtractMatrix    (&m, mat))  /* --jgm */
  1073. +                 return Push (OpStack, mat), Error (PTypeCheck); /* --jgm */
  1074.            else
  1075.             {
  1076.                 ty = Pop (OpStack);
  1077. ***************
  1078. *** 153,159 ****
  1079.                 else
  1080.                      return Push (OpStack, tx), Push (OpStack, ty), Push (OpStack, mat), Error (PTypeCheck);
  1081.                
  1082. !               VOID AssignMatrix (mat, NewMatrix (1.0, 0.0, 0.0, 1.0, x, y));
  1083.                 
  1084.                 return Push (OpStack, mat);
  1085.             }
  1086. --- 156,164 ----
  1087.                 else
  1088.                      return Push (OpStack, tx), Push (OpStack, ty), Push (OpStack, mat), Error (PTypeCheck);
  1089.                
  1090. ! /*              VOID AssignMatrix (mat, NewMatrix (1.0, 0.0, 0.0, 1.0, x, y)); WRONG --jgm */
  1091. !               VOID AssignMatrix (mat, Translate(m, x, y)); /* --jgm */
  1092.                 
  1093.                 return Push (OpStack, mat);
  1094.             }
  1095. ***************
  1096. *** 178,184 ****
  1097.   static int PScale ()
  1098.    {
  1099.        Object tx, ty, mat;
  1100. !      float x, y;
  1101.        
  1102.        if (!OpCheck (2, 1))
  1103.            return FALSE;
  1104. --- 183,190 ----
  1105.   static int PScale ()
  1106.    {
  1107.        Object tx, ty, mat;
  1108. !     Matrix m; /* --jgm */
  1109. !     float x, y;
  1110.        
  1111.        if (!OpCheck (2, 1))
  1112.            return FALSE;
  1113. ***************
  1114. *** 188,193 ****
  1115. --- 194,201 ----
  1116.                 return Push (OpStack, mat), Error (PInvAccess);
  1117.            else if (lengthArray (mat) != 6)
  1118.                 return Push (OpStack, mat), Error (PRangeCheck);
  1119. +         else if    (!ExtractMatrix    (&m, mat))  /* --jgm */
  1120. +                 return Push (OpStack, mat), Error (PTypeCheck); /* --jgm */
  1121.            else
  1122.             {
  1123.                ty = Pop (OpStack);
  1124. ***************
  1125. *** 205,211 ****
  1126.                 else
  1127.                      return Push (OpStack, tx), Push (OpStack, ty), Push (OpStack, mat), Error (PTypeCheck);
  1128.                
  1129. !               VOID AssignMatrix (mat, NewMatrix (x, 0.0, 0.0, y, 0.0, 0.0));
  1130.                 
  1131.                 return Push (OpStack, mat);
  1132.             }
  1133. --- 213,220 ----
  1134.                 else
  1135.                      return Push (OpStack, tx), Push (OpStack, ty), Push (OpStack, mat), Error (PTypeCheck);
  1136.                
  1137. ! /*              VOID AssignMatrix (mat, NewMatrix (x, 0.0, 0.0, y, 0.0, 0.0)); WRONG --jgm */
  1138. !               VOID AssignMatrix (mat, Scale(m, x, y)); /* --jgm */
  1139.                 
  1140.                 return Push (OpStack, mat);
  1141.             }
  1142. ***************
  1143. *** 249,256 ****
  1144.                     a = BodyReal (ang);
  1145.                 else
  1146.                     return Push (OpStack, ang), Push (OpStack, mat), Error (PTypeCheck);
  1147. !               
  1148. !               VOID AssignMatrix (mat, NewMatrix (cos(a), sin(a), -sin(a), -cos(a), 0.0, 0.0));
  1149.                 
  1150.                 return Push (OpStack, mat);
  1151.             }
  1152. --- 258,265 ----
  1153.                     a = BodyReal (ang);
  1154.                 else
  1155.                     return Push (OpStack, ang), Push (OpStack, mat), Error (PTypeCheck);
  1156. !               a = Rad(a); /* jgm */
  1157. !               VOID AssignMatrix (mat, NewMatrix (cos(a), sin(a), -sin(a), cos(a), 0.0, 0.0)); /* last "-cos" changed to "cos" --jgm */
  1158.                 
  1159.                 return Push (OpStack, mat);
  1160.             }
  1161. diff -cr ./source/name.c /cmu/math/jm36/src/ps/source/name.c
  1162. *** ./source/name.c    Fri Apr  1 22:39:54 1988
  1163. --- /cmu/math/jm36/src/ps/source/name.c    Sun Mar  6 17:16:20 1988
  1164. ***************
  1165. *** 107,113 ****
  1166.   
  1167.   static int HashName (s, length) unsigned char *s; int length;
  1168.    {
  1169. !     int i, res = 0;
  1170.       
  1171.       while (length--)
  1172.           res += *s++;
  1173. --- 107,113 ----
  1174.   
  1175.   static int HashName (s, length) unsigned char *s; int length;
  1176.    {
  1177. !     int /* i, (unused --jgm) */ res = 0;
  1178.       
  1179.       while (length--)
  1180.           res += *s++;
  1181. diff -cr ./source/operator.c /cmu/math/jm36/src/ps/source/operator.c
  1182. *** ./source/operator.c    Fri Apr  1 22:41:54 1988
  1183. --- /cmu/math/jm36/src/ps/source/operator.c    Sun Mar  6 17:16:23 1988
  1184. ***************
  1185. *** 69,75 ****
  1186.    {
  1187.        Object res;
  1188.        struct op_struct *op;
  1189. !      int i;
  1190.        res = Cvx (MakeObject (Operator));
  1191.        res.u.Operator = op = (struct op_struct *) Malloc (sizeof (struct op_struct));
  1192.       
  1193. --- 69,75 ----
  1194.    {
  1195.        Object res;
  1196.        struct op_struct *op;
  1197. !      /* int i; (unused --jgm) */
  1198.        res = Cvx (MakeObject (Operator));
  1199.        res.u.Operator = op = (struct op_struct *) Malloc (sizeof (struct op_struct));
  1200.       
  1201. ***************
  1202. *** 130,139 ****
  1203. --- 130,141 ----
  1204.        TypeInstall (type, name, res);
  1205.    }
  1206.   
  1207. + #ifdef notdef /* jgm */
  1208.   static struct op_struct *Body (item) Object item;
  1209.    {
  1210.        return item.u.Operator;
  1211.    }
  1212. + #endif /* jgm */
  1213.   
  1214.   #define Body(op)    ((op).u.Operator)
  1215.   
  1216. diff -cr ./source/path.c /cmu/math/jm36/src/ps/source/path.c
  1217. *** ./source/path.c    Fri Apr  1 22:43:14 1988
  1218. --- /cmu/math/jm36/src/ps/source/path.c    Sat Mar 19 17:00:52 1988
  1219. ***************
  1220. *** 194,200 ****
  1221.        
  1222.        if ((res = ReversePath (gstate->path)) == NULL)
  1223.            return Error (PLimitCheck);
  1224. !       SetPath (&gstate->path, res);
  1225.        return TRUE;    
  1226.    }
  1227.   
  1228. --- 194,201 ----
  1229.        
  1230.        if ((res = ReversePath (gstate->path)) == NULL)
  1231.            return Error (PLimitCheck);
  1232. !       /* SetPath (&gstate->path, res); --jgm */
  1233. !     gstate->path = res; /* Don't free gstate->path twice. --jgm */
  1234.        return TRUE;    
  1235.    }
  1236.   
  1237. diff -cr ./source/pixrect.c /cmu/math/jm36/src/ps/source/pixrect.c
  1238. *** ./source/pixrect.c    Fri Apr  1 22:40:34 1988
  1239. --- /cmu/math/jm36/src/ps/source/pixrect.c    Fri Mar 11 23:35:16 1988
  1240. ***************
  1241. *** 15,20 ****
  1242. --- 15,22 ----
  1243.   #include "canon.h"
  1244.   #include <pixrect/pixrect_hs.h>
  1245.   
  1246. + char *DriverType = "Sun pixrect"; /* jgm */
  1247.   int rop_map [] =
  1248.    {
  1249.        PIX_SRC & PIX_NOT (PIX_SRC),
  1250. diff -cr ./source/state.c /cmu/math/jm36/src/ps/source/state.c
  1251. *** ./source/state.c    Fri Apr  1 22:43:34 1988
  1252. --- /cmu/math/jm36/src/ps/source/state.c    Sun Mar  6 17:33:19 1988
  1253. ***************
  1254. *** 114,120 ****
  1255.   
  1256.   int ErasePage ()
  1257.    {
  1258. !     Paint (NULL, gstate->device->dev,
  1259.           NewDevicePoint (0, 0), NewDevicePoint (0, 0),
  1260.           HardwareExtent (gstate->device->dev),
  1261.           White);
  1262. --- 114,120 ----
  1263.   
  1264.   int ErasePage ()
  1265.    {
  1266. !     Paint ((struct hardware *)NULL, gstate->device->dev, /* cast NULL --jgm */
  1267.           NewDevicePoint (0, 0), NewDevicePoint (0, 0),
  1268.           HardwareExtent (gstate->device->dev),
  1269.           White);
  1270. diff -cr ./source/ww.c /cmu/math/jm36/src/ps/source/ww.c
  1271. *** ./source/ww.c    Fri Apr  1 22:41:00 1988
  1272. --- /cmu/math/jm36/src/ps/source/ww.c    Fri Mar 11 23:39:23 1988
  1273. ***************
  1274. *** 14,19 ****
  1275. --- 14,21 ----
  1276.   #include "canon.h"
  1277.   #include "wwinfo.h"
  1278.   
  1279. + char *DriverType = "ww"; /* jgm */
  1280.   static void xxrasterop ();
  1281.   
  1282.   static struct hardware *NewHardware ();
  1283. Make sure you have already applied patch 'ps.diff.v2'.
  1284.  
  1285. If you already have the file "source/X11.c", move it to a safe place
  1286. before applying this patch.
  1287.  
  1288. To apply this, you need the 'patch' program which is available from
  1289. the comp.sources.unix archives.
  1290.  
  1291. Change directories to the top-level postscript directory (the one with
  1292. the file "MANIFEST" in it) and apply this patch with the command:
  1293.  
  1294. patch -p0 <ps.diff.v3
  1295.  
  1296.                 _.John G. Myers
  1297.                 jm36+@andrew.cmu.edu
  1298.  
  1299. *** /tmp/CHANGES.JGM.v2    Thu Jul 28 14:59:27 1988
  1300. --- ./CHANGES.JGM    Thu Jul 28 15:07:01 1988
  1301. ***************
  1302. *** 60,65 ****
  1303. --- 60,80 ----
  1304.   
  1305.   Added operators letter, note, and legal.
  1306.   
  1307. +                   Version 3:
  1308. + Bugs fixed:
  1309. + The fourth parameter to the "framedevice" is no longer ignored.  psrc
  1310. + has been modified so that if a driver defines the postscript operator
  1311. + "outputpage", it will be called instead of the "beep and wait for
  1312. + input" routine when the copypage or showpage command is executed.
  1313. + Enhancements made:
  1314. + Barry Shein's speedups have been incorporated.
  1315. + A version of the X11 driver is included.
  1316.                   John G. Myers
  1317.                   jm36@andrew.cmu.edu
  1318.                   jgm@k.gp.cs.cmu.edu
  1319. diff -cr /usr/tmp/ps/postscript/psrc ./postscript/psrc
  1320. *** /usr/tmp/ps/postscript/psrc    Thu Jul 28 14:00:59 1988
  1321. --- ./postscript/psrc    Thu Jul 28 14:17:45 1988
  1322. ***************
  1323. *** 69,84 ****
  1324.   %/tty (|cat -u </dev/tty) (r) file def
  1325.   
  1326.   /showpage {
  1327. !     copypage initgraphics
  1328. !     beep print flush
  1329. !     false echo
  1330. !     { tty read { pop } if } stopped
  1331. !     true echo
  1332. !     not {
  1333. !         erasepage
  1334. !     } if
  1335.   } def
  1336.   
  1337.   /run { { (r) file } stopped { pop stop } if cvx exec } def
  1338.   /prompt { (PS>) print } def
  1339.   
  1340. --- 69,87 ----
  1341.   %/tty (|cat -u </dev/tty) (r) file def
  1342.   
  1343.   /showpage {
  1344. !     copypage initgraphics erasepage
  1345.   } def
  1346.   
  1347. + systemdict /outputpage known not {
  1348. +     /outputpage {
  1349. +     beep print flush
  1350. +       false echo
  1351. +       { tty read { pop } if } stopped
  1352. +       true echo
  1353. +     pop
  1354. +     } def
  1355. + } if
  1356.   /run { { (r) file } stopped { pop stop } if cvx exec } def
  1357.   /prompt { (PS>) print } def
  1358.   
  1359. ***************
  1360. *** 423,429 ****
  1361.       /h 11 72 mul f mul cvi def
  1362.       /w 8.25 72 mul f mul 8 div cvi def
  1363.       m 5 h put
  1364. !     m w h [] framedevice
  1365.       end
  1366.   } def
  1367.   
  1368. --- 426,432 ----
  1369.       /h 11 72 mul f mul cvi def
  1370.       /w 8.25 72 mul f mul 8 div cvi def
  1371.       m 5 h put
  1372. !     m w h /outputpage load framedevice    % jgm
  1373.       end
  1374.   } def
  1375.   
  1376. ***************
  1377. *** 435,441 ****
  1378.       /h 11 72 mul f mul cvi def
  1379.       /w 8.25 72 mul f mul 8 div cvi def
  1380.       m 5 h put
  1381. !     m w h [] framedevice
  1382.       end
  1383.   } def
  1384.   
  1385. --- 438,444 ----
  1386.       /h 11 72 mul f mul cvi def
  1387.       /w 8.25 72 mul f mul 8 div cvi def
  1388.       m 5 h put
  1389. !     m w h /outputpage load framedevice    % jgm
  1390.       end
  1391.   } def
  1392.   
  1393. ***************
  1394. *** 446,452 ****
  1395.       /h 11 72 mul f mul cvi def
  1396.       /w 8.25 72 mul f mul 8 div cvi def
  1397.       m 5 h put
  1398. !     m w h [] framedevice
  1399.       end
  1400.   } def
  1401.   
  1402. --- 449,455 ----
  1403.       /h 11 72 mul f mul cvi def
  1404.       /w 8.25 72 mul f mul 8 div cvi def
  1405.       m 5 h put
  1406. !     m w h /outputpage load framedevice    % jgm
  1407.       end
  1408.   } def
  1409.   
  1410. ***************
  1411. *** 457,463 ****
  1412.       /h 8.25 72 mul f mul cvi def
  1413.       /w 11.75 2 div 72 mul f mul 8 div cvi def
  1414.       m 5 h put
  1415. !     m w h [] framedevice
  1416.       end
  1417.   } def
  1418.   
  1419. --- 460,466 ----
  1420.       /h 8.25 72 mul f mul cvi def
  1421.       /w 11.75 2 div 72 mul f mul 8 div cvi def
  1422.       m 5 h put
  1423. !     m w h /outputpage load framedevice    % jgm
  1424.       end
  1425.   } def
  1426.   
  1427. ***************
  1428. *** 467,473 ****
  1429.       /f m 0 get def
  1430.       /h 8.25 72 mul f mul cvi def
  1431.       /w 11.75 72 mul f mul 8 div cvi def
  1432. !     [ 0 f f 0 0 0] w h [] framedevice
  1433.       end
  1434.   } def
  1435.   
  1436. --- 470,476 ----
  1437.       /f m 0 get def
  1438.       /h 8.25 72 mul f mul cvi def
  1439.       /w 11.75 72 mul f mul 8 div cvi def
  1440. !     [ 0 f f 0 0 0] w h /outputpage load framedevice % jgm
  1441.       end
  1442.   } def
  1443.   
  1444. ***************
  1445. *** 480,486 ****
  1446.       /h 11 72 mul f mul cvi def
  1447.       /w 8.5 72 mul f mul 8 div cvi def
  1448.       m 5 h put
  1449. !     m w h [] framedevice
  1450.       end
  1451.   } def
  1452.   
  1453. --- 483,489 ----
  1454.       /h 11 72 mul f mul cvi def
  1455.       /w 8.5 72 mul f mul 8 div cvi def
  1456.       m 5 h put
  1457. !     m w h /outputpage load framedevice
  1458.       end
  1459.   } def
  1460.   
  1461. ***************
  1462. *** 493,499 ****
  1463.       /h 14 72 mul f mul cvi def
  1464.       /w 8.5 72 mul f mul 8 div cvi def
  1465.       m 5 h put
  1466. !     m w h [] framedevice
  1467.       end
  1468.   } def
  1469.   
  1470. --- 496,502 ----
  1471.       /h 14 72 mul f mul cvi def
  1472.       /w 8.5 72 mul f mul 8 div cvi def
  1473.       m 5 h put
  1474. !     m w h /outputpage load framedevice
  1475.       end
  1476.   } def
  1477.   
  1478. *** /usr/tmp/ps/source/makefile    Thu Jul 28 13:53:39 1988
  1479. --- ./source/makefile    Thu Jul 28 15:36:09 1988
  1480. ***************
  1481. *** 2,10 ****
  1482. --- 2,20 ----
  1483.       integer.o main.o math.o misc.o name.o operator.o\
  1484.       poly.o property.o real.o save.o stack.o string.o unix.o
  1485.   LIBS=libww.a -lsuntool -lsunwindow -lpixrect -g
  1486. + XLIB=/usr/lib/libX11.a
  1487.   GRAPHICS=cache.o colour.o device.o fill.o font.o gsave.o image.o mat.o matrix.o\
  1488.       pat.o path.o state.o stroke.o
  1489.   
  1490. + SOURCES=array.c boolean.c config.c control.c dictionary.c file.c\
  1491. +     integer.c main.c math.c misc.c name.c operator.c\
  1492. +     poly.c property.c real.c save.c stack.c string.c unix.c\
  1493. +     cache.c colour.c device.c fill.c font.c gsave.c image.c mat.c matrix.c\
  1494. +     pat.c path.c state.c stroke.c
  1495. + LINT=lint
  1496. + LFLAGS= -lm
  1497.   # For SUN with 68881
  1498.   #CFLAGS=-O -f68881
  1499.   
  1500. ***************
  1501. *** 11,39 ****
  1502.   # For others
  1503.   CFLAGS=-O
  1504.   
  1505. ! #default: sunPS
  1506.   
  1507.   PS:    $(OBJECTS) $(GRAPHICS) hard.o canon.a
  1508. !     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) hard.o canon.a -lm `libs` -o PS
  1509.   
  1510.   sunPS:    $(OBJECTS) $(GRAPHICS) pixrect.o canon.a
  1511. !     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) pixrect.o canon.a -lm -lpixrect -o sunPS
  1512.   
  1513.   CPS:    $(OBJECTS) $(GRAPHICS) colour-ww.o trapezoid.o canon.o
  1514. !     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) colour-ww.o canon.o trapezoid.o -lm `libs` -o CPS
  1515.   
  1516.   postscript:    $(OBJECTS) $(GRAPHICS) adapter.o protocol.o
  1517. !     cc $(CFLAGS) $(OBJECTS) $(GRAPHICS) adapter.o protocol.o -lm -o postscript
  1518.   
  1519.   XPS:    $(OBJECTS) $(GRAPHICS) X.o
  1520. !     cc $(CFLAGS)  $(OBJECTS) $(GRAPHICS) X.o -lm -lX -o XPS
  1521.   
  1522.   canon.a:    canon.o screen.o trapezoid.o paint.o
  1523.       ar ruv canon.a canon.o screen.o trapezoid.o paint.o
  1524.       ranlib canon.a
  1525.   
  1526.   viewer:    protocol.o viewer.o hard.o canon.a
  1527. !     cc protocol.o viewer.o hard.o canon.a `libs` -o viewer
  1528.   
  1529.   all:    PS postscript viewer
  1530.   
  1531. --- 21,56 ----
  1532.   # For others
  1533.   CFLAGS=-O
  1534.   
  1535. ! default: sunPS
  1536.   
  1537. + xps: $(OBJECTS) $(GRAPHICS) X11.o canon.a $(XLIB)
  1538. +     rm -f xps
  1539. +     $(CC) -o xps $(CFLAGS) $(OBJECTS) $(GRAPHICS) X11.o canon.a -lm $(XLIB)
  1540.   PS:    $(OBJECTS) $(GRAPHICS) hard.o canon.a
  1541. !     $(CC) $(CFLAGS)  $(OBJECTS) $(GRAPHICS) hard.o canon.a -lm `libs` -o PS
  1542.   
  1543.   sunPS:    $(OBJECTS) $(GRAPHICS) pixrect.o canon.a
  1544. !     $(CC) $(CFLAGS)  $(OBJECTS) $(GRAPHICS) pixrect.o canon.a -lm -lpixrect -o sunPS
  1545.   
  1546.   CPS:    $(OBJECTS) $(GRAPHICS) colour-ww.o trapezoid.o canon.o
  1547. !     $(CC) $(CFLAGS)  $(OBJECTS) $(GRAPHICS) colour-ww.o canon.o trapezoid.o -lm `libs` -o CPS
  1548.   
  1549.   postscript:    $(OBJECTS) $(GRAPHICS) adapter.o protocol.o
  1550. !     $(CC) $(CFLAGS) $(OBJECTS) $(GRAPHICS) adapter.o protocol.o -lm -o postscript
  1551.   
  1552.   XPS:    $(OBJECTS) $(GRAPHICS) X.o
  1553. !     $(CC) $(CFLAGS)  $(OBJECTS) $(GRAPHICS) X.o -lm -lX -o XPS
  1554.   
  1555. + lint:
  1556. +     $(LINT) $(LFLAGS) $(SOURCES) $(LINTFILTER)
  1557.   canon.a:    canon.o screen.o trapezoid.o paint.o
  1558.       ar ruv canon.a canon.o screen.o trapezoid.o paint.o
  1559.       ranlib canon.a
  1560.   
  1561.   viewer:    protocol.o viewer.o hard.o canon.a
  1562. !     $(CC) protocol.o viewer.o hard.o canon.a `libs` -o viewer
  1563.   
  1564.   all:    PS postscript viewer
  1565.   
  1566. ***************
  1567. *** 44,50 ****
  1568.   orion:    orion.o installorion orionlib
  1569.   
  1570.   X.o:    
  1571. !     cc -c X.c
  1572.   
  1573.   wwlib:
  1574.       if [ -f libww.a ]; \
  1575. --- 61,67 ----
  1576.   orion:    orion.o installorion orionlib
  1577.   
  1578.   X.o:    
  1579. !     $(CC) -c X.c
  1580.   
  1581.   wwlib:
  1582.       if [ -f libww.a ]; \
  1583. *** /dev/null    Thu Jul 28 10:26:48 1988
  1584. --- ./source/X11.c    Wed Jul 27 18:15:31 1988
  1585. ***************
  1586. *** 0 ****
  1587. --- 1,667 ----
  1588. + /*
  1589. +  * Copyright (C) Rutherford Appleton Laboratory 1987
  1590. +  * 
  1591. +  * This source may be copied, distributed, altered or used, but not sold for profit
  1592. +  * or incorporated into a product except under licence from the author.
  1593. +  * It is not in the public domain.
  1594. +  * This notice should remain in the source unaltered, and any changes to the source
  1595. +  * made by persons other than the author should be marked as such.
  1596. +  * 
  1597. +  *    Crispin Goswell @ Rutherford Appleton Laboratory caag@uk.ac.rl.vd
  1598. +  */
  1599. + #include "main.h"
  1600. + #include "graphics.h"
  1601. + #include <X11/Xlib.h>
  1602. + #include <X11/Xutil.h>
  1603. + #include <X11/Xatom.h>
  1604. + #include <stdio.h>
  1605. + #include "canon.h"
  1606. + char *DriverType = "X11"; /* jgm */
  1607. + static void Punt(str)
  1608. + char *str;
  1609. + {
  1610. +     fprintf(stderr, "%s\n", str);
  1611. +     exit(1);
  1612. + }
  1613. + static Display *dpy;
  1614. + typedef struct _HardwareRec {
  1615. +     Drawable w;
  1616. + } HardwareRec, *Hardware;
  1617. + #ifdef CANON
  1618. + struct hardware
  1619. + {
  1620. +     /*
  1621. +      * Each driver is expected to provide its own definition of this
  1622. +      * structure.  It is only ever used as a pointer and is never dereferenced
  1623. +      * outside the driver.
  1624. +      */
  1625. +     int pad;
  1626. + };
  1627. + #endif CANON
  1628. + /*
  1629. +  * This file describes the interface that PostScript requires to the graphics
  1630. +  * system at Version 1.4.
  1631. +  *     
  1632. +  * ''Hardware'' in this context refers to a pointer to windows and/or bitmaps
  1633. +  * and is the lowest level of access that PostScript is interested in. Any
  1634. +  * Hardware parameter may be expected to be NULL.
  1635. +  */
  1636. + /********************* CREATION OF WINDOWS AND BITMAPS *******************/
  1637. + #define SCREEN 0        /* What to use as our screen number. */
  1638. + #define MIN(x, y)    (((x) < (y)) ? (x) : (y))
  1639. + static GC fillgc[16];
  1640. + struct hardware *InitHardware ()
  1641. + {
  1642. +     XGCValues values;
  1643. +     int i;
  1644. +     if ((dpy = XOpenDisplay(dpy)) == NULL)
  1645. +     Punt("Could not open display");
  1646. +     InitTransfer(DisplayHeight(dpy, SCREEN) / 11);
  1647. +     /* This defines our screen as being 11 inches high, no matter what its */
  1648. +     /* real size.  What a hack. */
  1649. +     values.foreground = AllPlanes;
  1650. +     for (i=0 ; i<16 ; i++) {
  1651. +     values.function = i;
  1652. +     fillgc[i] = XCreateGC(dpy, RootWindow(dpy, SCREEN),
  1653. +                   GCFunction | GCForeground, &values);
  1654. +     }
  1655. + }
  1656. + /*
  1657. +  * InitHardware () returns a default device which PostScript may use
  1658. +  * immediately (or NULL if not appropriate).  Its size and shape are not
  1659. +  * defined. Most typically the user will want to start up another device
  1660. +  * before it is used anyway. No attempt will be made by PostScript to Destroy
  1661. +  * the resulting device.
  1662. +  */
  1663. + static struct hardware *NewHardware(width, height)
  1664. + int width, height;
  1665. + {
  1666. +     struct hardware *to;
  1667. +     Hardware hard;
  1668. +     to = (struct hardware *) malloc(sizeof(struct hardware));
  1669. +     hard = (Hardware) malloc(sizeof(HardwareRec));
  1670. +     to->hard.addr = (char *) hard;
  1671. +     to->flags = 0;
  1672. +     to->aux = to->clip = NULL;
  1673. +     to->extent = NewDevicePoint(width, height);
  1674. +     hard->w = NULL;
  1675. +     return to;
  1676. + }
  1677. + struct hardware *NewBitmapHardware (width, height)
  1678. + int width, height;
  1679. + {
  1680. +     struct hardware *to = NewHardware(width, height);
  1681. +     Hardware hard = (Hardware) to->hard.addr;
  1682. +     to->flags = NULL;
  1683. +     hard->w = XCreatePixmap(dpy, RootWindow(dpy, SCREEN), width, height,
  1684. +                 DefaultDepth(dpy, SCREEN));
  1685. +     XFillRectangle(dpy, hard->w, fillgc[GXclear], 0, 0, width, height);
  1686. + /*    {
  1687. +     static int y = 0;
  1688. +     XSetWindowAttributes attributes;
  1689. +     hard->w = XCreateSimpleWindow(dpy, RootWindow(dpy, SCREEN), 700, y,
  1690. +                   width, height, 1, BlackPixel(dpy, SCREEN),
  1691. +                   WhitePixel(dpy, SCREEN));
  1692. +     attributes.override_redirect = TRUE;
  1693. +     XChangeWindowAttributes(dpy, hard->w, CWOverrideRedirect, &attributes);
  1694. +     XMapWindow(dpy, hard->w);
  1695. +     y+=30;
  1696. +     }*/
  1697. +     return to;
  1698. + }
  1699. + struct hardware *NewWindowHardware (width, height)
  1700. + int width, height;
  1701. + {
  1702. +     struct hardware *to = NewHardware(width, height);
  1703. +     Hardware hard = (Hardware) to->hard.addr;
  1704. +     XEvent event;
  1705. +     unsigned long vmask;
  1706. +     XSetWindowAttributes xswa;
  1707. +     to->flags = ISWIN;
  1708. + /*
  1709. +     hard->w = XCreateSimpleWindow(dpy, RootWindow(dpy, SCREEN), 0, 0,
  1710. +                   width, height, 1, BlackPixel(dpy, SCREEN),
  1711. +                   0);
  1712. + */
  1713. +     vmask = CWBackPixel|CWBorderPixel|CWBackingStore|
  1714. +       CWBackingPlanes|CWSaveUnder;
  1715. +     xswa.background_pixel = WhitePixel(dpy,SCREEN);
  1716. +     xswa.border_pixel = BlackPixel(dpy,SCREEN);
  1717. +     xswa.backing_store = Always;
  1718. +     xswa.backing_planes = AllPlanes;
  1719. +     xswa.save_under = True;
  1720. +     hard->w = XCreateWindow(dpy,RootWindow(dpy,SCREEN),
  1721. +                 0,0,
  1722. +                 width,height,
  1723. +                 1,DefaultDepth(dpy,SCREEN),
  1724. +                 InputOutput,DefaultVisual(dpy,SCREEN),
  1725. +                 vmask,&xswa);
  1726. +     XChangeProperty(dpy,hard->w,XA_WM_NAME,XA_STRING,8,
  1727. +             PropModeReplace,"POSTSCRIPT",10);
  1728. +     XSelectInput(dpy, hard->w, ExposureMask);
  1729. +     XMapWindow(dpy, hard->w);
  1730. +     XNextEvent(dpy, &event);
  1731. +     XSelectInput(dpy, hard->w, 0);
  1732. +     return to;
  1733. + }
  1734. + /*
  1735. +  * NewBitmapHardware () is expected to create a new bitmap. Only one plane
  1736. +  * will be needed.
  1737. +  *     
  1738. +  * NewWindowHardware () is expected to create a window on the screen. On a
  1739. +  * colour system this will be expected to support full colour.
  1740. +  */
  1741. + #ifdef CANON
  1742. + int IsWindowHardware (h)
  1743. + struct hardware *h;
  1744. + {}
  1745. + #endif CANON
  1746. + /*
  1747. +  * IsWindowHardware () should return TRUE if the hardware is a window, FALSE
  1748. +  * otherwise.  NULL is a window.
  1749. +  */
  1750. + void DestroyHardware (h)
  1751. + struct hardware *h;
  1752. + {
  1753. +     if (h) {
  1754. +     Hardware hard = (Hardware) h->hard.addr;
  1755. +     if (IsWindowHardware(h))
  1756. +         XDestroyWindow(dpy, hard->w);
  1757. +     else
  1758. +         XFreePixmap(dpy, hard->w);
  1759. +     }
  1760. + }
  1761. + /*
  1762. +  *     
  1763. +  * DestroyHardware () should release the resources required by the hardware,
  1764. +  * bitmap or window.  This should cause a window device to vanish. NULL is not
  1765. +  * an error (does nothing).
  1766. +  */
  1767. + #ifdef CANON
  1768. + Matrix DeviceMatrix (width, height)
  1769. + int width, height;
  1770. + {}
  1771. + #endif CANON
  1772. + /*
  1773. +  *
  1774. +  * DeviceMatrix () should return a matrix appropriate to a device of the given
  1775. +  * height and width.  For a typical display with a graphics origin at the top
  1776. +  * left of a window, an appropriate definition would be:
  1777. +  *     
  1778. +  * Matrix DeviceMatrix (width, height)
  1779. +  * int width, height;
  1780. +  * {
  1781. +  *     return NewMatrix (PIXELS_PER_INCH / 72.0, 0.0, 0.0,
  1782. +  *                  -PIXELS_PER_INCH / 72.0, 0.0, (float) height);
  1783. +  * }
  1784. +  */
  1785. + #ifdef CANON
  1786. + DevicePoint HardwareExtent (h)
  1787. + struct hardware *h;
  1788. + {}
  1789. + #endif
  1790. + /*
  1791. +  * HardwareExtent () returns a DevicePoint describing the width and height of
  1792. +  * the argument.  NULL has extent NewDevicePoint (0, 0).
  1793. +  */
  1794. + /*************************** OUTPUT PRIMITIVES ******************************/    
  1795. + void BitBlt (from, to, fromPoint, toPoint, extent, rop)
  1796. + struct hardware *from, *to;
  1797. + DevicePoint toPoint, fromPoint, extent;
  1798. + int rop;
  1799. + {
  1800. +     Hardware fromhard, tohard;
  1801. +     static int count = 0;
  1802. +     if (to == NULL) return;
  1803. +     tohard = (Hardware) to->hard.addr;
  1804. +     if (from == NULL) {
  1805. +     XFillRectangle(dpy, tohard->w, fillgc[rop], toPoint.dx, toPoint.dy,
  1806. +                extent.dx, extent.dy);
  1807. +     } else {
  1808. +     fromhard = (Hardware) from->hard.addr;
  1809. +     XCopyArea(dpy, fromhard->w, tohard->w, fillgc[rop], fromPoint.dx,
  1810. +           fromPoint.dy, extent.dx, extent.dy, toPoint.dx, toPoint.dy);
  1811. +     }
  1812. +     if (count++ % 50 == 0) XSync(dpy, 0);
  1813. + }
  1814. + #ifdef CANON
  1815. + void Paint (from, to, fromPoint, toPoint, extent, colour)
  1816. + struct hardware *from, *to;
  1817. + DevicePoint toPoint, fromPoint, extent;
  1818. + Colour colour;
  1819. + {}
  1820. + #endif
  1821. + /*
  1822. +  *     
  1823. +  * BitBlt () is a full function RasterOp. The 'rop' argument will have values
  1824. +  * as described in the header file hard.h. If the from argument is NULL it is
  1825. +  * taken to be a bitmap full of ones the shape of the fromPoint and extent. If
  1826. +  * the to argument is NULL, this is a no-op.
  1827. +  *
  1828. +  * Paint () is an addition to BitBlt. Bits that are set in the source are
  1829. +  * Painted into the destination in the given colour with a copying rasterop so
  1830. +  * that they replace pixels previously there. If the machine does not support
  1831. +  * colour windows, half-toning should be performed.  Colour values have hue,
  1832. +  * saturation and brightness components. on a black and white or greyscale
  1833. +  * system the brightness value will be a FP value between 0.0 (black) and 1.1
  1834. +  * (white), which can be used as a grey level.
  1835. +  *     
  1836. +  * Paint is expected to mask with the clip mask. BitBlt is not,
  1837. +  */
  1838. + #ifdef CANON
  1839. + void BitBltTrapezoid(to, lefttop, leftbottom, righttop, rightbottom,
  1840. +              top, bottom, rop)
  1841. + struct hardware *to;
  1842. + DevicePoint lefttop, leftbottom, righttop, rightbottom;
  1843. + int top, bottom, rop;
  1844. + {}
  1845. + #endif CANON
  1846. + #ifdef CANON
  1847. + void PaintTrapezoid (to, lefttop, leftbottom, righttop, rightbottom,
  1848. +              top, bottom, colour)
  1849. + struct hardware *to;
  1850. + DevicePoint lefttop, leftbottom, righttop, rightbottom;
  1851. + int top, bottom;
  1852. + Colour colour;
  1853. + {}
  1854. + #endif CANON
  1855. + /*
  1856. +  * BitBltTrapezoid () and PaintTrapezoid () render a complete trapezoidal
  1857. +  * shape.  The corners of the trapezoid may lie far outside the range of
  1858. +  * interesting scan-lines, but the slope of the line should be clipped by the
  1859. +  * top and bottom. The coordinates are half-open.
  1860. +  */
  1861. + void BitBltLine (h, fromPoint, toPoint, rop)
  1862. + struct hardware *h;
  1863. + DevicePoint fromPoint, toPoint;
  1864. + int rop;
  1865. + {
  1866. +     if (h) {
  1867. +     Hardware hard = (Hardware) h->hard.addr;
  1868. +     XDrawLine(dpy, hard->w, fillgc[rop], fromPoint.dx, fromPoint.dy,
  1869. +           toPoint.dx, toPoint.dy);
  1870. +     }
  1871. + }
  1872. + #ifdef CANON
  1873. + void PaintLine (h, fromPoint, toPoint, colour)
  1874. + struct hardware *h;
  1875. + DevicePoint fromPoint, toPoint;
  1876. + Colour colour;
  1877. + {}
  1878. + #endif CANON
  1879. + /*
  1880. +  *     
  1881. +  *     BitBltLine () is expected to draw a line between the given points
  1882. +  *     with the given RasterOp and colour masking.
  1883. +  *     The line should be one pixel wide and half-open.
  1884. +  *     [Thicker lines are done with BitBlt.]
  1885. +  *     
  1886. +  *     PaintLine () is expected to Paint a line by analogy with Paint
  1887. +  *     and BitBlt.
  1888. +  */
  1889. + void BitBltBlob (to, top, height, left, right, rop)
  1890. + struct hardware *to;
  1891. + int top, height, *left, *right, rop;
  1892. + {
  1893. +     int i;
  1894. +     DevicePoint p1, p2;
  1895. +     for (i=0 ; i<height ; i++) {
  1896. +     p1.dx = left[i];
  1897. +     p2.dx = right[i];
  1898. +     p1.dy = p2.dy = top + i;
  1899. +     BitBltLine(to, p1, p2, rop);
  1900. +     }
  1901. + }
  1902. +  /*
  1903. +   * BitBltBlob () takes a set of pixel coordinates and fills the trapezon
  1904. +   * figure half open.
  1905. +   */
  1906. + #ifdef SLOWANDWRONG
  1907. + void RasterTile (from, to, toPoint, extent, rop)
  1908. + struct hardware *from, *to;
  1909. + DevicePoint toPoint, extent;
  1910. + int rop;
  1911. + {
  1912. +     Hardware fromhard, tohard;
  1913. +     DevicePoint p1, p2, p3;
  1914. +     int x, y;
  1915. +     if (to == NULL) return;
  1916. +     if (from == NULL)
  1917. +     Punt("Can only RasterTile from Hardware.");
  1918. +     fromhard = (Hardware) from->hard.addr;
  1919. +     tohard = (Hardware) to->hard.addr;
  1920. +     p1.dx = p1.dy = 0;
  1921. +     for (x=toPoint.dx ; x < toPoint.dx + extent.dx ; x+=from->extent.dx) {
  1922. +     for (y=toPoint.dy ; y < toPoint.dy + extent.dy ; y+=from->extent.dy) {
  1923. +         p2.dx = x;
  1924. +         p2.dy = y;
  1925. +         p3.dx = MIN(toPoint.dx + extent.dx - x, from->extent.dx);
  1926. +         p3.dy = MIN(toPoint.dy + extent.dy - y, from->extent.dy);
  1927. +         BitBlt(from, to, p1, p2, p3, rop);
  1928. +     }
  1929. +     }
  1930. + }
  1931. + #endif SLOWANDWRONG
  1932. + void RasterTile (from, to, toPoint, extent, rop)
  1933. + struct hardware *from, *to;
  1934. + DevicePoint toPoint, extent;
  1935. + int rop;
  1936. + {
  1937. +     Hardware fromhard, tohard;
  1938. +     static GC gc = NULL;
  1939. +     XGCValues values;
  1940. +     int valuemask;
  1941. +     if (to == NULL) return;
  1942. +     if (from == NULL || IsWindowHardware(from))
  1943. +     Punt("Can only RasterTile from Bitmap.");
  1944. +     fromhard = (Hardware) from->hard.addr;
  1945. +     tohard = (Hardware) to->hard.addr;
  1946. +     values.tile = fromhard->w;
  1947. +     values.fill_style = FillTiled;
  1948. +     values.function = rop;
  1949. +     valuemask = GCFunction | GCTile | GCFillStyle;
  1950. +     if (gc == NULL)
  1951. +     gc = XCreateGC(dpy, RootWindow(dpy, SCREEN), valuemask, &values);
  1952. +     else
  1953. +     XChangeGC(dpy, gc, valuemask, &values);
  1954. +     XFillRectangle(dpy, tohard->w, gc, toPoint.dx, toPoint.dy,
  1955. +            extent.dx, extent.dy);
  1956. + }
  1957. + /*
  1958. +  * RasterTile () replicates the whole of ``from'' over ``to'', but clipped by
  1959. +  * the rectangle bounded by ``toPoint'' and ``extent''.
  1960. +  */
  1961. + /******************* BRIGHTNESS TRANSFER FUNCTION ************************/
  1962. + #ifdef CANON
  1963. + int TransferSize ()
  1964. + {}
  1965. + #endif CANON
  1966. + #ifdef CANON
  1967. + void SetTransfer (vec)
  1968. + float *vec;
  1969. + {}
  1970. + #endif CANON
  1971. + /*
  1972. +  *     
  1973. +  * TransferSize () and SetTransfer () control the mapping function between
  1974. +  * user brightnesses and device brightnesses. The interface is expected to
  1975. +  * perform this mapping of brightnesses to a sufficient resolution.
  1976. +  * SetTransfer takes a table of floating point numbers between 0 and 1. User
  1977. +  * brightnesses are scaled to the size of this table and mapped through it.
  1978. +  * The argument table given to SetTransfer () will be deleted after use.
  1979. +  * TransferSize () simply enquires the required size of the table.
  1980. +  *     
  1981. +  * It may be appropriate to half-tone on a grayscale or colour device to
  1982. +  * improve rendering if it is not too expensive. TransferSize () returns the
  1983. +  * size of the pattern table.
  1984. +  */
  1985. + /********************** BITMAP CONVERSION ********************************/
  1986. + char *StringFromHardware (h)
  1987. + struct hardware *h;
  1988. + {
  1989. +     XImage *image;
  1990. +     Hardware hard;
  1991. +     unsigned char *result, *ptr, c;
  1992. +     int x, y, i;
  1993. +     if (h == NULL) return NULL;
  1994. +     hard = (Hardware) h->hard.addr;
  1995. +     image = XGetImage(dpy, hard->w, 0, 0, h->extent.dx, h->extent.dy,
  1996. +               AllPlanes, ZPixmap);
  1997. +     result = (unsigned char *) malloc(((h->extent.dx + 7) / 8) * h->extent.dy);
  1998. +     ptr = result;
  1999. +     for (y=0 ; y<h->extent.dy ; y++) {
  2000. +     for (x=0 ; x<h->extent.dx ; x+=8) {
  2001. +         c = 0;
  2002. +         for (i=0 ; i<8 ; i++) {
  2003. +         c = c << 1;
  2004. +         if (x+i < h->extent.dx)
  2005. +             c |= XGetPixel(image, x+i, y);
  2006. +         }
  2007. +     }
  2008. +     *ptr++ = c;
  2009. +     }
  2010. +     free((char *) image);
  2011. +     return (char *) result;
  2012. + }
  2013. + struct hardware *HardwareFromString (s, width, height)
  2014. + char *s;
  2015. + int width, height;
  2016. + {
  2017. +     struct hardware *h = NewBitmapHardware(width, height);
  2018. +     Hardware hard = (Hardware) h->hard.addr;
  2019. +     XImage *image;
  2020. +     if (s == NULL) Punt("HardwareFromString called with NULL string!");
  2021. +     image = XCreateImage(dpy, DefaultVisual(dpy, SCREEN),
  2022. +              DefaultDepth(dpy, SCREEN), ZPixmap, 0, s,
  2023. +              width, height, 8, 0);
  2024. +     image->bitmap_bit_order = MSBFirst;
  2025. +     XPutImage(dpy, hard->w, fillgc[GXcopy], image, 0, 0, 0, 0, width, height);
  2026. +     free((char *) image);
  2027. +     return h;
  2028. + }
  2029. + /*
  2030. +  *     
  2031. +  * StringFromHardware () produces a string from its argument which describes
  2032. +  * the bitmap.  The bitmap is returned in row-major order with the leftmost
  2033. +  * bit of each byte in the most significant position. Rows are padded to byte
  2034. +  * boundaries. Only single plane bitmaps are used.
  2035. +  *     
  2036. +  * HardwareFromString () performs the inverse mapping, generating a bitmap
  2037. +  * from a set of bits, given a width and height. Only single plane bitmaps are
  2038. +  * used.
  2039. +  */
  2040. + /************************* HALF-TONE SCREEN *******************************/
  2041. + #ifdef CANON
  2042. + int ScreenSize (freq, rotation)
  2043. + float freq, rotation;
  2044. + {}
  2045. + #endif CANON
  2046. + #ifdef CANON
  2047. + void BuildScreen (freq, rotation, x, y)
  2048. + float freq, rotation, *x, *y;
  2049. + {}
  2050. + #endif CANON
  2051. + #ifdef CANON
  2052. + void SetScreen (freq, rotation, thresh)
  2053. + float freq, rotation, *thresh;
  2054. + {}
  2055. + #endif CANON
  2056. + /*
  2057. +  * ScreenSize () allows PostScript to determine how large an array of sample
  2058. +  * points to expect.  It should return the length of the side of the sample
  2059. +  * square.
  2060. +  *     
  2061. +  * BuildScreen () returns a set of sampling coordinates to PostScript to hand
  2062. +  * to the users spot-function
  2063. +  *     
  2064. +  * SetScreen () allows PostScript to set the thresholds for each sample point
  2065. +  * so that half-tone bitmaps can be made.
  2066. +  */
  2067. + /************************* CLIPPING ******************************************/
  2068. + #ifdef CANON
  2069. + void SetClipHardware (h, clip)
  2070. + struct hardware *h, *clip;
  2071. + {}
  2072. + #endif
  2073. + /*
  2074. +  *     
  2075. +  * SetClipHardware sets hardware which is a clip mask for BitBlt. This mask
  2076. +  * should be ANDed with any output operation. If clip is NULL, masking will
  2077. +  * not be needed.
  2078. +  */
  2079. + /************************ UPDATE CONTROLS **********************************/
  2080. + void HardUpdate ()
  2081. + {
  2082. +     XFlush(dpy, 0);
  2083. + }
  2084. + /*
  2085. +  * HardUpdate is a hook to allow devices which do output buffering to flush
  2086. +  * that buffering when appropriate.  This allows an interactive user to see
  2087. +  * completed graphics between prompts (it is called as a side-effect of the
  2088. +  * PostScript flush operator). Typically is is a no-op.
  2089. +  */
  2090. + void UpdateControl (h, on)
  2091. + struct hardware *h;
  2092. + int on;
  2093. + {}
  2094. + /*
  2095. +  * This call can be used to enable batching of output operations.
  2096. +  * UpdateControl (h, FALSE) means ``start of batching'' UpdateControl (h,
  2097. +  * TRUE) means ``end of batching''. It is used to improve performance on
  2098. +  * machines where screen updates have a high locking overhead. It may be a
  2099. +  * no-op.  The operation should nest if batching is already in progress: FALSE
  2100. +  * increments a counter, TRUE decrements a counter. Display changes are
  2101. +  * allowed when the counter is non-zero.
  2102. +  */
  2103. + /********************************** CANONICAL IMPLEMENTATION LIBRARY ******************************/
  2104. + /*
  2105. +  * Some parts of the above interface can be supported by a canonical library.
  2106. +  * This library contains:
  2107. + SetClipHardware
  2108. + HardUpdate
  2109. + IsWindowHardware
  2110. + HardwareExtent
  2111. + PaintTrapezoid
  2112. + BitBltTrapezoid
  2113. + Paint
  2114. + PaintLine
  2115. + DeviceMatrix
  2116. + InitTransfer
  2117. + TransferSize
  2118. + SetTransfer
  2119. + ScreenSize
  2120. + BuildScreen
  2121. + SetScreen
  2122. +  *
  2123. +  * As the driver matures, the user may provide his own versions of the
  2124. +  * canonical routines.  This leaves the following for implementation by 
  2125. +  * the user.
  2126. +  *
  2127. + InitHardware
  2128. + NewBitmapHardware
  2129. + NewWindowHardware
  2130. + DestroyHardware
  2131. + HardwareFromString
  2132. + StringFromHardware
  2133. + UpdateControl
  2134. + RasterTile
  2135. + BitBlt
  2136. + BitBltLine
  2137. + BitBltBlob
  2138. +  * There is a pedagogical implementation in null.c
  2139. +  *    
  2140. +  * There are a number of interface issues concerning the canonical driver.
  2141. +  * Firstly, a canonical struct hardware is defined, which contains a union of
  2142. +  * a char * and an int handle. The remainder are expected to use this to store
  2143. +  * device specific information.
  2144. +  *
  2145. +  * InitTransfer() should be called during InitHardware with the number of 
  2146. +  * pixels per inch on the display as an argument.
  2147. +  */
  2148. + /* I tacked this lot on the end to avoid altering canon.c - CAAG */
  2149. + int pixels_per_inch;
  2150. + int single_rop [] =
  2151. +  {
  2152. +     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE,
  2153. +     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE,
  2154. +     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE,
  2155. +     ROP_FALSE, ROP_DEST, ROP_NOTDEST, ROP_TRUE
  2156. +  };
  2157. + /*ARGSUSED*/
  2158. + Matrix DeviceMatrix (width, height) int width, height;
  2159. +  {
  2160. +      return NewMatrix (pixels_per_inch / 72.0, 0.0, 0.0, -pixels_per_inch / 72.0, 0.0, (float) height);
  2161. +  }
  2162. + int IsWindowHardware (h) struct hardware *h;
  2163. +  {
  2164. +      return h->flags & ISWIN;
  2165. +  }
  2166. + #define IsWindowHardware(h) ((h)->flags & ISWIN)
  2167. + DevicePoint HardwareExtent (h) struct hardware *h;
  2168. +  {
  2169. +      if (h)
  2170. +          return h->extent;
  2171. +      else
  2172. +          return NewDevicePoint (0, 0);
  2173. +  }
  2174. + void SetClipHardware (h, clip) struct hardware *h, *clip;
  2175. +  {
  2176. +      if (h)
  2177. +         h->clip = clip;
  2178. +  }
  2179. diff -cr /usr/tmp/ps/source/array.c ./source/array.c
  2180. *** /usr/tmp/ps/source/array.c    Thu Jul 28 14:01:14 1988
  2181. --- ./source/array.c    Wed Jul 27 12:02:11 1988
  2182. ***************
  2183. *** 142,151 ****
  2184. --- 142,165 ----
  2185.   int ExecArray (item) Object item;
  2186.    {
  2187.        int l = lengthArray (item);
  2188. +     Object res;
  2189. +     register Object *rp = &res;
  2190.        
  2191.       if (l == 0)
  2192.            return TRUE;
  2193. +     /*
  2194. +      * BZS - try some open-coding here
  2195. +      *
  2196.        Push (ExecStack, SameFlags (item, Make (Body (item) + 1, l - 1)));
  2197. +     */
  2198. +     rp->type = Array;
  2199. +     rp->flags = READABLE | WRITEABLE;
  2200. +     rp->u.Integer = 0;
  2201. +     rp->u.Array = item.u.Array + 1;
  2202. +     rp->Length = l - 1;
  2203. +     rp->flags = item.flags;
  2204. +     Push(ExecStack,res);
  2205. +     /* end open-coding */
  2206.        if (TypeOf (Body (item) [0]) == Name || TypeOf (Body (item) [0]) == Operator)
  2207.            Push (ExecStack, Body (item) [0]);
  2208.        else
  2209. diff -cr /usr/tmp/ps/source/config.c ./source/config.c
  2210. *** /usr/tmp/ps/source/config.c    Thu Jul 28 14:01:20 1988
  2211. --- ./source/config.c    Thu Jul 28 14:07:25 1988
  2212. ***************
  2213. *** 92,98 ****
  2214.       
  2215.       /* Begin jgm */
  2216.       strcpy(versionbuf, DriverType);
  2217. !     strcat(versionbuf, " version 1.4 with jgm mods v2");
  2218.       Install ("version",    StringFrom (versionbuf));
  2219.       /* End jgm */
  2220.    }
  2221. --- 92,98 ----
  2222.       
  2223.       /* Begin jgm */
  2224.       strcpy(versionbuf, DriverType);
  2225. !     strcat(versionbuf, " version 1.4 with jgm/bzs mods v3");
  2226.       Install ("version",    StringFrom (versionbuf));
  2227.       /* End jgm */
  2228.    }
  2229. diff -cr /usr/tmp/ps/source/device.c ./source/device.c
  2230. *** /usr/tmp/ps/source/device.c    Thu Jul 28 14:01:23 1988
  2231. --- ./source/device.c    Sat Apr 30 17:45:35 1988
  2232. ***************
  2233. *** 25,31 ****
  2234.        struct hardware *h;
  2235.        DevicePoint extent;
  2236.        
  2237. !     InstallOp ("framedevice",    FrameDevice,         4, 0, 0, 0, Array, Integer, Integer, Array);
  2238.       InstallOp ("nulldevice",    NullDevice,        0, 0, 0, 0);
  2239.       InstallOp ("grabbits",        GrabBits,        4, 0, 0, 0, Float, Float, Float, Float);
  2240.       
  2241. --- 25,31 ----
  2242.        struct hardware *h;
  2243.        DevicePoint extent;
  2244.        
  2245. !     InstallOp ("framedevice",    FrameDevice,         4, 0, 0, 0, Array, Integer, Integer, Poly /* jgm */);
  2246.       InstallOp ("nulldevice",    NullDevice,        0, 0, 0, 0);
  2247.       InstallOp ("grabbits",        GrabBits,        4, 0, 0, 0, Float, Float, Float, Float);
  2248.       
  2249. ***************
  2250. *** 79,94 ****
  2251.        return TRUE;
  2252.    }
  2253.   
  2254. - /*ARGSUSED*/
  2255.   static int FrameDevice (mat, width, height, proc) Object mat, width, height, proc;
  2256.    {
  2257.        Matrix m;
  2258.        
  2259.        if (lengthArray (mat) != 6 || !ExtractMatrix (&m, mat))
  2260.            return Error (PTypeCheck);
  2261.        if (BodyInteger (width) < 0 || BodyInteger (height) < 0)
  2262.            return Error (PRangeCheck);
  2263. !      SetDevice (NewWindowDevice (BodyInteger (width) * 8, BodyInteger (height), m));
  2264.        ErasePage ();
  2265.        
  2266.       return TRUE;
  2267. --- 79,98 ----
  2268.        return TRUE;
  2269.    }
  2270.   
  2271.   static int FrameDevice (mat, width, height, proc) Object mat, width, height, proc;
  2272.    {
  2273.        Matrix m;
  2274. +     struct device *d;
  2275.        
  2276.        if (lengthArray (mat) != 6 || !ExtractMatrix (&m, mat))
  2277.            return Error (PTypeCheck);
  2278.        if (BodyInteger (width) < 0 || BodyInteger (height) < 0)
  2279.            return Error (PRangeCheck);
  2280. !     /* Begin jgm */
  2281. !      d = NewWindowDevice (BodyInteger (width) * 8, BodyInteger (height), m);
  2282. !     d->output_routine = proc;
  2283. !      SetDevice (d);
  2284. !     /* End jgm */
  2285.        ErasePage ();
  2286.        
  2287.       return TRUE;
  2288. ***************
  2289. *** 148,155 ****
  2290.        res->link_count = 0;
  2291.        res->default_clip = clip;
  2292.        res->default_matrix = m;
  2293.        res->dev = dev;
  2294. !      
  2295.        return res;
  2296.    }
  2297.   
  2298. --- 152,160 ----
  2299.        res->link_count = 0;
  2300.        res->default_clip = clip;
  2301.        res->default_matrix = m;
  2302. +     res->output_routine = Nil;
  2303.        res->dev = dev;
  2304. !     
  2305.        return res;
  2306.    }
  2307.   
  2308. diff -cr /usr/tmp/ps/source/device.h ./source/device.h
  2309. *** /usr/tmp/ps/source/device.h    Thu Jul 28 13:43:09 1988
  2310. --- ./source/device.h    Sat Apr 30 16:34:02 1988
  2311. ***************
  2312. *** 9,14 ****
  2313. --- 9,15 ----
  2314.        Matrix default_matrix;
  2315.        Path default_clip;
  2316.        int link_count;
  2317. +     Object output_routine; /* jgm */
  2318.        struct hardware *dev;
  2319.    };
  2320.   
  2321. diff -cr /usr/tmp/ps/source/dictionary.c ./source/dictionary.c
  2322. *** /usr/tmp/ps/source/dictionary.c    Thu Jul 28 13:53:28 1988
  2323. --- ./source/dictionary.c    Wed Jul 27 12:02:12 1988
  2324. ***************
  2325. *** 17,24 ****
  2326.   
  2327.   Object Absent, Nil, SysDict;
  2328.   
  2329. ! Object DictLookup (), MakeDict (), DictLoad ();
  2330.   
  2331.   static int LengthDict (), CopyDict (), forDict (), ForDict (), PutDict (), GetDict ();
  2332.   static int PDict (), PBegin (), PEnd (), PDef (), PStore (), PKnown (), PLoad ();
  2333.   static int PrCheck (), PwCheck (), PReadOnly (), EqDict (); 
  2334. --- 17,29 ----
  2335.   
  2336.   Object Absent, Nil, SysDict;
  2337.   
  2338. ! /* BZS - DictLoad open-coded */
  2339. ! #ifndef DictLoad
  2340. ! Object DictLoad();
  2341. ! #endif
  2342.   
  2343. + Object DictLookup (), MakeDict ();
  2344.   static int LengthDict (), CopyDict (), forDict (), ForDict (), PutDict (), GetDict ();
  2345.   static int PDict (), PBegin (), PEnd (), PDef (), PStore (), PKnown (), PLoad ();
  2346.   static int PrCheck (), PwCheck (), PReadOnly (), EqDict (); 
  2347. ***************
  2348. *** 166,171 ****
  2349. --- 171,182 ----
  2350.           (a.u.Integer == b.u.Integer || TypeOf (a) == Array && a.Length == 0);
  2351.    }
  2352.   
  2353. + /* BZS - open code Equal */
  2354. + #define Equal(A,B) ((TypeOf(A) == TypeOf(B)) && \
  2355. +             (A.Length == B.Length) && \
  2356. +             ((A.u.Integer == B.u.Integer)|| \
  2357. +              (TypeOf(A) == Array) && (A.Length == 0)))
  2358.   static DictReplace (hash, key, value, size, h) struct dict_entry *hash; Object key, value; int size, h;
  2359.    {
  2360.        int i;
  2361. ***************
  2362. *** 250,258 ****
  2363.       DictStore (SysDict, NameFrom (key), value);
  2364.    }
  2365.   
  2366. ! static Object DictFind (hash, key, size) struct dict_entry *hash; Object key; int size;
  2367.    {
  2368. !      int i, h;
  2369.        
  2370.        ++hash_attempts;
  2371.        
  2372. --- 261,272 ----
  2373.       DictStore (SysDict, NameFrom (key), value);
  2374.    }
  2375.   
  2376. ! /*
  2377. !  * BZS - add some register decls, make global for macrification (remove static)
  2378. !  */
  2379. ! Object DictFind (hash, key, size) struct dict_entry *hash; Object key; int size;
  2380.    {
  2381. !      register int i, h;
  2382.        
  2383.        ++hash_attempts;
  2384.        
  2385. ***************
  2386. *** 266,271 ****
  2387. --- 280,286 ----
  2388.        {
  2389.            if (TypeOf (hash[i].entry_key) == Null)
  2390.                return Absent;
  2391.            if (Equal (key, hash[i].entry_key))
  2392.             {
  2393.               ++hash_tries;
  2394. ***************
  2395. *** 279,289 ****
  2396. --- 294,308 ----
  2397.        }
  2398.       return Absent;
  2399.    }
  2400. + #undef Equal
  2401.   
  2402. + /* BZS - macro-ified */
  2403. + #ifndef DictLoad
  2404.   Object DictLoad (dict, key) Object dict, key;
  2405.    {
  2406.       return DictFind (Body (dict)->dict_body, key, Body (dict)->dict_size);
  2407.    }
  2408. + #endif
  2409.   
  2410.   Object Lookup (dict, key) Type dict; Object key;
  2411.    {
  2412. diff -cr /usr/tmp/ps/source/fill.c ./source/fill.c
  2413. *** /usr/tmp/ps/source/fill.c    Thu Jul 28 14:02:56 1988
  2414. --- ./source/fill.c    Wed Jul 27 12:02:15 1988
  2415. ***************
  2416. *** 35,41 ****
  2417.    *    pool
  2418.    */        
  2419.   
  2420. ! static struct edge
  2421.    {
  2422.       int topX, topY, bottomX, bottomY; short dir;
  2423.       struct edge *pair;
  2424. --- 35,41 ----
  2425.    *    pool
  2426.    */        
  2427.   
  2428. ! /* static (removed --jgm) */ struct edge
  2429.    {
  2430.       int topX, topY, bottomX, bottomY; short dir;
  2431.       struct edge *pair;
  2432. ***************
  2433. *** 70,75 ****
  2434. --- 70,126 ----
  2435.   static int FillIt ();
  2436.   static int EoRule (), NwRule ();
  2437.   
  2438. + /*
  2439. +  * BZS - Open Code
  2440. +  */
  2441. + #define NotThisBit(EDGE,WHERE,EMITFN) { \
  2442. +   if((EDGE)->pair != NULL) { \
  2443. +      (*EMITFN)((EDGE),(EDGE)->pair,(EDGE)->startingY,WHERE); \
  2444. +      (EDGE)->pair->startingY = WHERE; \
  2445. +      (EDGE)->pair->where = WHERE; \
  2446. +      (EDGE)->pair->pair = NULL; \
  2447. +      (EDGE)->pair = NULL; \
  2448. +    } \
  2449. +   (EDGE)->startingY = WHERE; \
  2450. +   (EDGE)->where = WHERE; \
  2451. + }
  2452. + #define ThisBit(LEFT,RIGHT,WHERE,EMITFN) { \
  2453. +    if((LEFT)->pair != (RIGHT) || (RIGHT)->up) { \
  2454. +      if((LEFT)->pair != NULL) { \
  2455. +         (*EMITFN)(LEFT,(LEFT)->pair,(LEFT)->startingY,(LEFT)->where); \
  2456. +         (LEFT)->pair->startingY = (LEFT)->pair->where; \
  2457. +       (LEFT)->pair->pair->startingY = (LEFT)->pair->pair->where; \
  2458. +       (LEFT)->pair->pair = NULL; \
  2459. +      } \
  2460. +      if ((RIGHT)->pair != NULL) { \
  2461. +         (*EMITFN) (RIGHT, (RIGHT)->pair, (RIGHT)->startingY, (RIGHT)->where); \
  2462. +     (RIGHT)->pair->startingY = (RIGHT)->pair->where; \
  2463. +       (RIGHT)->pair->pair->startingY = (RIGHT)->pair->pair->where; \
  2464. +       (RIGHT)->pair->pair = NULL; \
  2465. +      }  \
  2466. +      (LEFT)->pair = RIGHT; \
  2467. +      (RIGHT)->pair = LEFT; \
  2468. +      (LEFT)->startingY = (RIGHT)->startingY = WHERE; \
  2469. +    } \
  2470. +    (LEFT)->where = (RIGHT)->where = WHERE; \
  2471. +    (LEFT)->up = TRUE; \
  2472. +    (RIGHT)->up = FALSE; \
  2473. + }
  2474. + #define UpEdge(COUNT_A,COUNT_B,INC_A,INC_B,RULE_A,RULE_B) \
  2475. +   ((*RULE_B)(COUNT_B+INC_B) && !(*RULE_A)(COUNT_A) && \
  2476. +    (*RULE_A)(COUNT_A+INC_A)||(*RULE_A)(COUNT_A+INC_A) && \
  2477. +    !(*RULE_B)(COUNT_B) && (*RULE_B)(COUNT_B+INC_B))
  2478. + #define DownEdge(COUNT_A,COUNT_B,INC_A,INC_B,RULE_A,RULE_B) \
  2479. +   ((*RULE_B)(COUNT_B+INC_B) && (*RULE_A)(COUNT_A) && \
  2480. +    !(*RULE_A)(COUNT_A+INC_A)||(*RULE_A)(COUNT_A+INC_A) && \
  2481. +    (*RULE_B)(COUNT_B) && !(*RULE_B)(COUNT_B+INC_B))
  2482. + #define Xvalue(AX,AY,BX,BY,CY) \
  2483. +   ((BX)+((CY)-(BY))*((AX)-(BX))/(float)((AY)-(BY)))
  2484.   static void EmitTrapezoid (left, right, top, bottom) struct edge *left, *right; int top, bottom;
  2485.    {
  2486.        struct edge *temp;
  2487. ***************
  2488. *** 286,320 ****
  2489.   
  2490.   ProcessEdges (rule_a, rule_b, emitfn) int (*rule_a)(), (*rule_b)(); void (*emitfn)();
  2491.    {
  2492. !     struct edge *up_edge;
  2493. !     int i, count_a = 0, count_b = 0;
  2494. !     /* static void RemoveEdges (); (unused --jgm) */
  2495. !     
  2496. !     for (i = 0; i < ninteresting; i++)
  2497. !      {
  2498. !          /* static void Emit (); (unused --jgm) */
  2499. !          int d_a = 0, d_b = 0;
  2500. !          
  2501. !          if (interesting[i]->clip)
  2502. !              d_a = interesting[i]->dir;
  2503. !          else
  2504. !              d_b = interesting[i]->dir;
  2505.   
  2506. !          if (UpEdge (count_a, count_b, d_a, d_b, rule_a, rule_b))
  2507. !              up_edge = interesting[i];
  2508. !          else if (DownEdge (count_a, count_b, d_a, d_b, rule_a, rule_b))
  2509. !               ThisBit (up_edge, interesting[i], interestingY, emitfn);
  2510. !          else
  2511. !               NotThisBit (interesting[i], interestingY, emitfn);
  2512. !          
  2513. !          count_a += d_a;
  2514. !          count_b += d_b;
  2515. !      }
  2516. !     if (count_a || count_b)
  2517. !         fprintf (stderr, "count_a = %dcount_b = %d\n", count_a, count_b);
  2518. !     PanicIf (count_a || count_b, "something wrong in area fill");
  2519.    }
  2520.   
  2521.   ThisBit (left, right, where, emitfn) struct edge *left, *right; int where; void (*emitfn)();    
  2522.    {
  2523.        if (left->pair != right || right->up)
  2524. --- 337,379 ----
  2525.   
  2526.   ProcessEdges (rule_a, rule_b, emitfn) int (*rule_a)(), (*rule_b)(); void (*emitfn)();
  2527.    {
  2528. !     register struct edge **intp;
  2529. !         register struct edge *up_edge;
  2530. !     register int count_a = 0, count_b = 0;
  2531. !     register int i;
  2532.   
  2533. !     i = ninteresting;
  2534. !     intp = interesting;
  2535. !     while(i-- > 0) {
  2536. !       register int d_a = 0, d_b = 0;
  2537. !       if ((*intp)->clip)
  2538. !         d_a = (*intp)->dir;
  2539. !       else
  2540. !         d_b = (*intp)->dir;
  2541. !       if (UpEdge (count_a, count_b, d_a, d_b, rule_a, rule_b))
  2542. !         up_edge = *intp;
  2543. !       else if(DownEdge (count_a, count_b, d_a, d_b, rule_a, rule_b)){
  2544. !         ThisBit (up_edge,(*intp), interestingY, emitfn);
  2545. !       }
  2546. !       else {
  2547. !         NotThisBit ((*intp),interestingY,emitfn);
  2548. !       }
  2549. !       count_a += d_a;
  2550. !       count_b += d_b;
  2551. !       intp++;
  2552. !     }
  2553. !     if (count_a || count_b) {
  2554. !       fprintf (stderr, "count_a = %dcount_b = %d\n", count_a, count_b);
  2555. !       Panic("something wrong in area fill");
  2556. !     }
  2557.    }
  2558.   
  2559. + /* BZS - Open code */
  2560. + #ifndef ThisBit
  2561.   ThisBit (left, right, where, emitfn) struct edge *left, *right; int where; void (*emitfn)();    
  2562.    {
  2563.        if (left->pair != right || right->up)
  2564. ***************
  2565. *** 341,347 ****
  2566. --- 400,412 ----
  2567.        left->where = right->where = where;
  2568.        left->up = TRUE; right->up = FALSE;
  2569.    }
  2570. + #endif
  2571.   
  2572. + /*
  2573. +  * BZS - Open Code this, it can be called hundreds of thousands of times
  2574. +  * in even simple pictures. Mooreforms spend 50% of its time in this.
  2575. +  */
  2576. + #ifndef NotThisBit
  2577.   NotThisBit (edge, where, emitfn) struct edge *edge; int where; void (*emitfn)();    
  2578.    {
  2579.        if (edge->pair != NULL)
  2580. ***************
  2581. *** 355,364 ****
  2582.         edge->startingY = where;
  2583.        edge->where = where;
  2584.    }
  2585.   
  2586.   static void RemoveEdges (interestingY, emitfn) int interestingY; void (*emitfn)();
  2587.    {
  2588. !      int i, j = 0;
  2589.        
  2590.        for (i = 0; i < ninteresting; i++)
  2591.           if (interesting [i]->bottomY > interestingY)
  2592. --- 420,430 ----
  2593.         edge->startingY = where;
  2594.        edge->where = where;
  2595.    }
  2596. + #endif
  2597.   
  2598.   static void RemoveEdges (interestingY, emitfn) int interestingY; void (*emitfn)();
  2599.    {
  2600. !      register int i, j = 0;
  2601.        
  2602.        for (i = 0; i < ninteresting; i++)
  2603.           if (interesting [i]->bottomY > interestingY)
  2604. ***************
  2605. *** 368,385 ****
  2606.        ninteresting = j;
  2607.    }
  2608.   
  2609.   static int UpEdge (count_a, count_b, inc_a, inc_b, rule_a, rule_b) int count_a, count_b, inc_a, inc_b, (*rule_a) (), (*rule_b) ();
  2610.    {
  2611.        return (*rule_b)(count_b + inc_b) && !(*rule_a) (count_a) && (*rule_a) (count_a + inc_a) ||
  2612.            (*rule_a)(count_a + inc_a) && !(*rule_b) (count_b) && (*rule_b) (count_b + inc_b);
  2613.    }
  2614.   static int DownEdge (count_a, count_b, inc_a, inc_b, rule_a, rule_b) int count_a, count_b, inc_a, inc_b, (*rule_a) (), (*rule_b) ();
  2615.    {
  2616.        return (*rule_b)(count_b + inc_b) && (*rule_a) (count_a) && !(*rule_a) (count_a + inc_a) ||
  2617.            (*rule_a)(count_a + inc_a) && (*rule_b) (count_b) && !(*rule_b) (count_b + inc_b);
  2618.    }
  2619.   static int EoRule (n) int n;
  2620.    {
  2621.       return n & 1;
  2622. --- 434,453 ----
  2623.        ninteresting = j;
  2624.    }
  2625.   
  2626. + #ifndef UpEdge
  2627.   static int UpEdge (count_a, count_b, inc_a, inc_b, rule_a, rule_b) int count_a, count_b, inc_a, inc_b, (*rule_a) (), (*rule_b) ();
  2628.    {
  2629.        return (*rule_b)(count_b + inc_b) && !(*rule_a) (count_a) && (*rule_a) (count_a + inc_a) ||
  2630.            (*rule_a)(count_a + inc_a) && !(*rule_b) (count_b) && (*rule_b) (count_b + inc_b);
  2631.    }
  2632. ! #endif
  2633. ! #ifndef DownEdge
  2634.   static int DownEdge (count_a, count_b, inc_a, inc_b, rule_a, rule_b) int count_a, count_b, inc_a, inc_b, (*rule_a) (), (*rule_b) ();
  2635.    {
  2636.        return (*rule_b)(count_b + inc_b) && (*rule_a) (count_a) && !(*rule_a) (count_a + inc_a) ||
  2637.            (*rule_a)(count_a + inc_a) && (*rule_b) (count_b) && !(*rule_b) (count_b + inc_b);
  2638.    }
  2639. ! #endif
  2640.   static int EoRule (n) int n;
  2641.    {
  2642.       return n & 1;
  2643. ***************
  2644. *** 405,419 ****
  2645.       return num / denom;
  2646.    }
  2647.   
  2648.   static int Xvalue (ax, ay, bx, by, cy) int ax, ay, bx, by, cy;
  2649.    {
  2650.        return bx + (cy - by) * (ax - bx) / (float) (ay - by);
  2651.    }
  2652.   
  2653.   static int intercmp (aa, bb) char *aa, *bb;
  2654.    {
  2655. !      struct edge *a = *(struct edge **) aa, *b = *(struct edge **) bb;
  2656. !      int sign;
  2657.       
  2658.       sign = Xvalue (a->topX, a->topY, a->bottomX, a->bottomY, interestingY + 1) -
  2659.                Xvalue (b->topX, b->topY, b->bottomX, b->bottomY, interestingY + 1);
  2660. --- 473,489 ----
  2661.       return num / denom;
  2662.    }
  2663.   
  2664. + #ifndef Xvalue
  2665.   static int Xvalue (ax, ay, bx, by, cy) int ax, ay, bx, by, cy;
  2666.    {
  2667.        return bx + (cy - by) * (ax - bx) / (float) (ay - by);
  2668.    }
  2669. + #endif
  2670.   
  2671.   static int intercmp (aa, bb) char *aa, *bb;
  2672.    {
  2673. !    register struct edge *a = *(struct edge **) aa, *b = *(struct edge **) bb;
  2674. !    int sign;
  2675.       
  2676.       sign = Xvalue (a->topX, a->topY, a->bottomX, a->bottomY, interestingY + 1) -
  2677.                Xvalue (b->topX, b->topY, b->bottomX, b->bottomY, interestingY + 1);
  2678. ***************
  2679. *** 424,449 ****
  2680.   
  2681.   static void AddInteresting ()
  2682.    {
  2683. !     int i;
  2684.            
  2685.       nextY = infinity;
  2686.       for (; here < nedges && edge[here].topY <= interestingY; here++) /* look at each new interesting edge */
  2687.        {
  2688. !          int i, n;
  2689. !          
  2690. !         for (i = 0; i < ninteresting; i++) /* look at all possible intersections */
  2691.            {
  2692. !              int inter = Yintersect (&edge[here], interesting[i]);
  2693.                
  2694. !              if (inter >= interestingY && inter <= edge[here].bottomY && inter <= interesting[i]->bottomY)
  2695.                    AddLowest (inter);
  2696.            }
  2697.           n = ninteresting++;
  2698. !         interesting[n] = &edge[here];
  2699. !         interesting[n]->pair = NULL;
  2700. !         interesting[n]->up = FALSE;
  2701. !         interesting[n]->startingY = interesting[n]->where = edge[here].topY;
  2702. !         interesting[n]->name = names++;
  2703.        }
  2704.       i = NextLowest (interestingY);
  2705.       if (i)
  2706. --- 494,526 ----
  2707.   
  2708.   static void AddInteresting ()
  2709.    {
  2710. !     register int i;
  2711. !     register struct edge **intp;
  2712.            
  2713.       nextY = infinity;
  2714.       for (; here < nedges && edge[here].topY <= interestingY; here++) /* look at each new interesting edge */
  2715.        {
  2716. !          register int i, n;
  2717. !         i = ninteresting;
  2718. !         intp = interesting;
  2719. !         while(i-- > 0) /* look at all possible intersections */
  2720.            {
  2721. !              int inter = Yintersect (&edge[here], (*intp));
  2722.                
  2723. !              if (inter >= interestingY &&
  2724. !                 inter <= edge[here].bottomY &&
  2725. !                 inter <= (*intp)->bottomY)
  2726.                    AddLowest (inter);
  2727. +             intp++;
  2728.            }
  2729.           n = ninteresting++;
  2730. !         intp = &interesting[n];
  2731. !         *intp = &edge[here];
  2732. !         (*intp)->pair = NULL;
  2733. !         (*intp)->up = FALSE;
  2734. !         (*intp)->startingY = (*intp)->where = edge[here].topY;
  2735. !         (*intp)->name = names++;
  2736.        }
  2737.       i = NextLowest (interestingY);
  2738.       if (i)
  2739. ***************
  2740. *** 450,461 ****
  2741.           nextY = i;
  2742.       if (here != nedges && edge[here].topY < nextY)
  2743.           nextY = edge[here].topY;
  2744. !     for (i = 0; i < ninteresting; i++)
  2745. !      {
  2746. !         if (interesting[i]->topY > interestingY && interesting[i]->topY < nextY)
  2747. !             nextY = interesting[i]->topY;
  2748. !         if (interesting[i]->bottomY > interestingY && interesting[i]->bottomY < nextY)
  2749. !             nextY = interesting[i]->bottomY;
  2750.        }
  2751.       qsort ((char *) interesting, (unsigned) ninteresting, sizeof (struct edge *), intercmp);
  2752.    }
  2753. --- 527,541 ----
  2754.           nextY = i;
  2755.       if (here != nedges && edge[here].topY < nextY)
  2756.           nextY = edge[here].topY;
  2757. !     i = ninteresting;
  2758. !     intp = interesting;
  2759. !     while(i-- > 0)
  2760. !       {
  2761. !         if ((*intp)->topY > interestingY && (*intp)->topY < nextY)
  2762. !             nextY = (*intp)->topY;
  2763. !         if ((*intp)->bottomY > interestingY && (*intp)->bottomY < nextY)
  2764. !             nextY = (*intp)->bottomY;
  2765. !         intp++;
  2766.        }
  2767.       qsort ((char *) interesting, (unsigned) ninteresting, sizeof (struct edge *), intercmp);
  2768.    }
  2769. ***************
  2770. *** 462,468 ****
  2771.   
  2772.   static void FindInfinity ()
  2773.    {
  2774. !      int i;
  2775.        
  2776.       infinity = edge[0].topY;
  2777.       for (i = 0; i < nedges; i++)
  2778. --- 542,548 ----
  2779.   
  2780.   static void FindInfinity ()
  2781.    {
  2782. !      register int i;
  2783.        
  2784.       infinity = edge[0].topY;
  2785.       for (i = 0; i < nedges; i++)
  2786. ***************
  2787. *** 503,509 ****
  2788.   
  2789.   static void BuildEdgeList (path, clip) Path path; int clip;
  2790.    {
  2791. !      Path p;
  2792.        HardPoint move, here;
  2793.        
  2794.        for (p = path->next; p != path; p = p->next)
  2795. --- 583,589 ----
  2796.   
  2797.   static void BuildEdgeList (path, clip) Path path; int clip;
  2798.    {
  2799. !      register Path p;
  2800.        HardPoint move, here;
  2801.        
  2802.        for (p = path->next; p != path; p = p->next)
  2803. ***************
  2804. *** 533,539 ****
  2805.   static int NextLowest (y) int y;
  2806.    {
  2807.       int res;
  2808. !     struct lowest *p;
  2809.       
  2810.       for (p = lowest; p && p->e <= y; p = lowest)    /* delete any which are now irrelevent */
  2811.        {
  2812. --- 613,619 ----
  2813.   static int NextLowest (y) int y;
  2814.    {
  2815.       int res;
  2816. !     register struct lowest *p;
  2817.       
  2818.       for (p = lowest; p && p->e <= y; p = lowest)    /* delete any which are now irrelevent */
  2819.        {
  2820. ***************
  2821. *** 551,557 ****
  2822.   
  2823.   static void AddLowest (e) int e;
  2824.    {
  2825. !      struct lowest *res, *p, *q;
  2826.        
  2827.        for (p = lowest; p && p->e < e; q = p, p = p->higher)
  2828.            ;
  2829. --- 631,637 ----
  2830.   
  2831.   static void AddLowest (e) int e;
  2832.    {
  2833. !      register struct lowest *res, *p, *q;
  2834.        
  2835.        for (p = lowest; p && p->e < e; q = p, p = p->higher)
  2836.            ;
  2837. diff -cr /usr/tmp/ps/source/font.c ./source/font.c
  2838. *** /usr/tmp/ps/source/font.c    Thu Jul 28 14:02:59 1988
  2839. --- ./source/font.c    Wed Jul 27 12:02:18 1988
  2840. ***************
  2841. *** 362,372 ****
  2842.        else
  2843.            return NewVector (0.0, 0.0, 1.0);
  2844.    }
  2845.   static int BuildHershey (font, code) Object font, code;
  2846.    {
  2847.       Vector met;
  2848. !     Object *bbox, string, nm;
  2849.        unsigned char *s;
  2850.        Path p;
  2851.        int i, l;
  2852. --- 362,374 ----
  2853.        else
  2854.            return NewVector (0.0, 0.0, 1.0);
  2855.    }
  2856. ! /*
  2857. !  * BZS - some small changes to allow macrification of DictLoad()
  2858. !  */
  2859.   static int BuildHershey (font, code) Object font, code;
  2860.    {
  2861.       Vector met;
  2862. !     Object *bbox, string, nm, tmp;
  2863.        unsigned char *s;
  2864.        Path p;
  2865.        int i, l;
  2866. ***************
  2867. *** 373,381 ****
  2868. --- 375,391 ----
  2869.        
  2870.       bbox     = BodyArray (DictLoad (font, FontBBox));
  2871.       nm     = BodyArray (DictLoad (font, Encoding)) [BodyInteger (code)];
  2872. +     /*
  2873.       met     = GetMetrics (DictLoad (DictLoad (font, Metrics), nm));
  2874. +     */
  2875. +     tmp = DictLoad(font,Metrics);
  2876. +     met = GetMetrics(DictLoad(tmp,nm));
  2877.       met.vx -= 2; /* hershey bodge - they look better closer */
  2878. +     /*
  2879.       string     = DictLoad (DictLoad (font, CharStrings), nm);
  2880. +     */
  2881. +     tmp = DictLoad(font,CharStrings);
  2882. +     string = DictLoad(tmp,nm);
  2883.       
  2884.       SetCacheDevice (nm, NewPoint (met.vx, met.vy),
  2885.           BodyReal (bbox[0]), BodyReal (bbox[1]),
  2886. diff -cr /usr/tmp/ps/source/main.h ./source/main.h
  2887. *** /usr/tmp/ps/source/main.h    Thu Jul 28 13:53:36 1988
  2888. --- ./source/main.h    Wed Jul 27 12:02:21 1988
  2889. ***************
  2890. *** 166,170 ****
  2891. --- 166,176 ----
  2892.           ((getchbuf != EOF) ? getchbuf : ((BodyFile(file)->available = 0), Close (file), EOF))) \
  2893.       : GeneralGetch (file))
  2894.   
  2895. + /*
  2896. +  * BZS - macro-ify some things
  2897. +  */
  2898. + Object DictFind();
  2899. + #define DictLoad(DICT,KEY) DictFind((DICT.u.Dictionary)->dict_body,KEY,\
  2900. +                     (DICT.u.Dictionary)->dict_size)
  2901.   /* Next line --jgm */
  2902.   #define PanicIf(flag,s) do { if (flag) Panic(s); } while (0)
  2903. diff -cr /usr/tmp/ps/source/matrix.c ./source/matrix.c
  2904. *** /usr/tmp/ps/source/matrix.c    Thu Jul 28 14:03:05 1988
  2905. --- ./source/matrix.c    Wed Jul 27 12:02:22 1988
  2906. ***************
  2907. *** 393,400 ****
  2908.   HardPoint ExtToInt (p) Point p;
  2909.    {
  2910.       Vector v;
  2911. !     
  2912.       v = Transform (NewVector (p.x, p.y, 1.0), gstate->CTM);
  2913.       return NewHardPoint (v.vx, v.vy);
  2914.    }
  2915.   
  2916. --- 393,413 ----
  2917.   HardPoint ExtToInt (p) Point p;
  2918.    {
  2919.       Vector v;
  2920. !     register Vector *vp;
  2921. !     register Matrix *mp;
  2922. !     register Point *pp;
  2923. ! /*
  2924. !  * BZS - try open coding this
  2925. !  *    
  2926.       v = Transform (NewVector (p.x, p.y, 1.0), gstate->CTM);
  2927. +  */
  2928. +     mp = &gstate->CTM;
  2929. +     vp = &v;
  2930. +     pp = &p;
  2931. +     vp->vx = pp->x * mp->A + pp->y * mp->C + mp->tx;
  2932. +     vp->vy = pp->x * mp->B + pp->y * mp->D + mp->ty;
  2933.       return NewHardPoint (v.vx, v.vy);
  2934.    }
  2935.   
  2936. diff -cr /usr/tmp/ps/source/misc.c ./source/misc.c
  2937. No differences encountered
  2938. diff -cr /usr/tmp/ps/source/operator.c ./source/operator.c
  2939. *** /usr/tmp/ps/source/operator.c    Thu Jul 28 14:03:10 1988
  2940. --- ./source/operator.c    Wed Jul 27 12:02:23 1988
  2941. ***************
  2942. *** 203,212 ****
  2943.    *
  2944.    */
  2945.   
  2946.   int ExecOperator (item) Object item;
  2947.    {
  2948. !     struct op_struct *op = Body (item);
  2949. !     int i, res, (*fn)() = op->fn;
  2950.       Object arg[7];
  2951.       
  2952.       Self = NameOperator (item);
  2953. --- 203,216 ----
  2954.    *
  2955.    */
  2956.   
  2957. + /*
  2958. +  * BZS - try to speed up a little
  2959. +  */
  2960.   int ExecOperator (item) Object item;
  2961.    {
  2962. !     register struct op_struct *op = Body (item);
  2963. !     register int i, res;
  2964. !     int (*fn)() = op->fn;
  2965.       Object arg[7];
  2966.       
  2967.       Self = NameOperator (item);
  2968. ***************
  2969. *** 219,225 ****
  2970.           arg[i] = Pop (OpStack);
  2971.       for (i = op->arguments - 1; i >= 0; i--)
  2972.        {
  2973. !          Type formal = op->argtypes[i], actual = TypeOf (arg[i]);
  2974.            
  2975.            if (formal == Float && actual == Integer)
  2976.                 arg[i] = RealInteger (arg[i]);
  2977. --- 223,229 ----
  2978.           arg[i] = Pop (OpStack);
  2979.       for (i = op->arguments - 1; i >= 0; i--)
  2980.        {
  2981. !          register Type formal = op->argtypes[i], actual = TypeOf (arg[i]);
  2982.            
  2983.            if (formal == Float && actual == Integer)
  2984.                 arg[i] = RealInteger (arg[i]);
  2985. diff -cr /usr/tmp/ps/source/screen.c ./source/screen.c
  2986. *** /usr/tmp/ps/source/screen.c    Thu Jul 28 13:44:08 1988
  2987. --- ./source/screen.c    Sat Apr 30 18:44:06 1988
  2988. ***************
  2989. *** 55,61 ****
  2990.        struct hardware *shade;
  2991.    } *screen = NULL;
  2992.   
  2993. ! static int screen_size, screen_side;
  2994.   
  2995.   static int FreqSize (freq) float freq;
  2996.    {
  2997. --- 55,61 ----
  2998.        struct hardware *shade;
  2999.    } *screen = NULL;
  3000.   
  3001. ! static int screen_size /* , screen_side (unused --jgm) */;
  3002.   
  3003.   static int FreqSize (freq) float freq;
  3004.    {
  3005. ***************
  3006. *** 121,127 ****
  3007.             free ((char *) screen);
  3008.         }
  3009.        p = screen = (struct screen *) Malloc ((unsigned) (((screen_size = size * size) + 1) * sizeof (struct screen)));
  3010. !      screen_side = size;
  3011.        for (i = 0; i < size; i++)
  3012.            for (j = 0; j < size; j++)
  3013.             {
  3014. --- 121,127 ----
  3015.             free ((char *) screen);
  3016.         }
  3017.        p = screen = (struct screen *) Malloc ((unsigned) (((screen_size = size * size) + 1) * sizeof (struct screen)));
  3018. !      /* screen_side = size; (unused --jgm) */
  3019.        for (i = 0; i < size; i++)
  3020.            for (j = 0; j < size; j++)
  3021.             {
  3022. diff -cr /usr/tmp/ps/source/state.c ./source/state.c
  3023. *** /usr/tmp/ps/source/state.c    Thu Jul 28 14:03:20 1988
  3024. --- ./source/state.c    Sat Apr 30 16:47:57 1988
  3025. ***************
  3026. *** 123,128 ****
  3027. --- 123,133 ----
  3028.   
  3029.   static int CopyPage ()
  3030.    {
  3031. +         /* Begin jgm */
  3032. +         if (TypeOf(gstate->device->output_routine) != Null) {
  3033. +         Push(ExecStack, gstate->device->output_routine);
  3034. +     }
  3035. +     /* End jgm */
  3036.        return TRUE;
  3037.    }
  3038.   
  3039. diff -cr /usr/tmp/ps/source/stroke.c ./source/stroke.c
  3040. *** /usr/tmp/ps/source/stroke.c    Thu Jul 28 13:48:04 1988
  3041. --- ./source/stroke.c    Sat Apr 30 18:26:27 1988
  3042. ***************
  3043. *** 358,364 ****
  3044.   int PStrokePath ()
  3045.    {
  3046.        Path p, new = NewPath ();
  3047. !      HardPoint prev, here, move;
  3048.        enum pelem_type last_type = EHeader;
  3049.        float angle, last_angle, width = gstate->line_width;
  3050.        
  3051. --- 358,364 ----
  3052.   int PStrokePath ()
  3053.    {
  3054.        Path p, new = NewPath ();
  3055. !      HardPoint /* prev, (unused --jgm) */ here, move;
  3056.        enum pelem_type last_type = EHeader;
  3057.        float angle, last_angle, width = gstate->line_width;
  3058.        
  3059. ***************
  3060. *** 370,376 ****
  3061.            switch (p->ptype)
  3062.             {
  3063.                  case EMove:
  3064. !                  prev = here;
  3065.                    move = here = p->pe.point;
  3066.                    break;
  3067.                    
  3068. --- 370,376 ----
  3069.            switch (p->ptype)
  3070.             {
  3071.                  case EMove:
  3072. !                  /* prev = here; (unused --jgm) */
  3073.                    move = here = p->pe.point;
  3074.                    break;
  3075.                    
  3076. ***************
  3077. *** 378,384 ****
  3078.                      if (last_type == EMove)
  3079.                          break;
  3080.                   angle = LineSegment (p, new, IntToExt (here), IntToExt (move), width, last_angle, last_type);
  3081. !                  prev = here;
  3082.                    here = move;
  3083.                    last_type = EHeader;
  3084.                    break;
  3085. --- 378,384 ----
  3086.                      if (last_type == EMove)
  3087.                          break;
  3088.                   angle = LineSegment (p, new, IntToExt (here), IntToExt (move), width, last_angle, last_type);
  3089. !                  /* prev = here; (unused --jgm) */
  3090.                    here = move;
  3091.                    last_type = EHeader;
  3092.                    break;
  3093. ***************
  3094. *** 385,391 ****
  3095.                    
  3096.                  case ELine:
  3097.                   angle = LineSegment (p, new, IntToExt (here), IntToExt (p->pe.point), width, last_angle, last_type);
  3098. !                  prev = here;
  3099.                    here = p->pe.point;
  3100.                      break;
  3101.                      
  3102. --- 385,391 ----
  3103.                    
  3104.                  case ELine:
  3105.                   angle = LineSegment (p, new, IntToExt (here), IntToExt (p->pe.point), width, last_angle, last_type);
  3106. !                  /* prev = here; (unused --jgm) */
  3107.                    here = p->pe.point;
  3108.                      break;
  3109.                      
  3110. *** /dev/null    Thu Jul 28 10:26:48 1988
  3111. --- wwinfo.h    Thu Jul 28 14:36:37 1988
  3112. ***************
  3113. *** 0 ****
  3114. --- 1,14 ----
  3115. + Now that I've gotten your attention...
  3116. + If your system doesn't have the wwinfo.h file, that probably means
  3117. + that you don't have the ww window manager, which is rumored to be
  3118. + available only to academic sites in the U.K.  In that case, a version
  3119. + of the Postscript Interpreter compiled to produce output for ww
  3120. + is probably worthless to you.
  3121. + Please examine the file source/makefile and select a version that is
  3122. + appropriate for you--possible choices include "sunPS", "XPS", and
  3123. + "xps".
  3124. +                 _.John G. Myers
  3125.