home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume10 / thack.p6 < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  18.8 KB

  1. From decwrl!sun-barr!cs.utexas.edu!uunet!allbery Sun Jan 14 10:52:32 PST 1990
  2. Article 1274 of comp.sources.misc:
  3. Path: decwrl!sun-barr!cs.utexas.edu!uunet!allbery
  4. From: everson%compsci.bristol.ac.uk@NSFnet-Relay.AC.UK
  5. Newsgroups: comp.sources.misc
  6. Subject: v10i004: Official Patch #6 to thack (troff->ps filter)
  7. Message-ID: <76294@uunet.UU.NET>
  8. Date: 9 Jan 90 01:18:50 GMT
  9. Sender: allbery@uunet.UU.NET
  10. Lines: 782
  11. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  12.  
  13. Posting-number: Volume 10, Issue 4
  14. Submitted-by: everson%compsci.bristol.ac.uk@NSFnet-Relay.AC.UK
  15. Archive-name: thack.p6
  16.  
  17. This is to introduce official patch #6 (it might be #7 by now, I seem
  18. to have lost count) to thack, a troff to postscript filter.
  19. [It's #6.  ++bsa]
  20.  
  21. I would appreicate it if anyone who makes modifications to this or any other 
  22. program would send me the output of a 'diff -c' with a known version of the 
  23. software rather a full copy from which I have to extract your modifications
  24. myself. We can reduce network traffic and also make official patch creation
  25. easier when there is more than one group working on the code at the same time. 
  26.  
  27. Here are the changes:
  28.  
  29. --------------------------------------------------------------------------
  30.  
  31. I got thack to work under OpenWindows 1.0 as part of a manual page previewer.
  32. Here are some changes to thack that I found needed or helpful.
  33.  
  34.     Permit 'thack filename'; this is required if we want to use thack in
  35.     Sun's 'man -t' command by setting the environment variable TCAT to
  36.     'thack'.
  37.  
  38.     Upgrade to (my limited understanding of) PS-Adobe-2.0 EPSF-2.0 format.
  39.  
  40.     Put 'thack: ' in the front of error messages.
  41.     (It isolates them better in a pipeline.)
  42.  
  43.     Keep better track of errors for thack's exit status.
  44.  
  45.     Fix minor spacing and font problems in man page.
  46.  
  47. -- Paul Eggert <eggert@twinsun.com>
  48.  
  49. --------------------------------------------------------------------------
  50.  
  51. The main fix is to generate smaller output; on a large computer science paper
  52. ("Eli: A Complete, Flexible Compiler Construction System") the new output is
  53. 28% smaller than the old.  On the thack man page itself, the savings is only
  54. 21% because the output is so small.  The savings comes from outputting smaller
  55. numbers, and from eliminating some unneeded newlines, turning some blanks into
  56. newlines so that no long lines are generated.  For example, where the old thack
  57. generated
  58.  
  59.     60 TR F
  60.     (T)270 4533 P
  61.     (H)307 X
  62.     (A)350 X
  63.     (C)393 X
  64.     (K)433 X
  65.  
  66. the new thack generates
  67.  
  68.     60 TR(T)270 1511
  69.     P(H)37
  70.     X(A)43
  71.     X(C)43
  72.     X(K)40
  73.     X
  74.  
  75. A minor fix: npages is now unsigned.
  76.  
  77. -- Paul Eggert <eggert@twinsun.com>
  78.  
  79. ----------------------------------------------------------------------------
  80.  
  81. Here is a patch to thack that adds support for the characters circle, 1/4, 1/2,
  82. 3/4, and Bell System logo.  For the logo, I use the same character that Adobe
  83. TranScript uses; it displays as an Apple logo on our LaserWriter (and on Sun's
  84. OpenWindows 1.0).  Also, the square is patched to look more like a square.
  85. While I was at it I put the prolog text into a table; this should make things a
  86. tad smaller and/or faster.
  87.  
  88. -- Paul Eggert <eggert@twinsun.com>
  89.  
  90.  
  91.  
  92. Thanks
  93.  
  94. Phillip G. Everson
  95. ----------------------------------------------------------------------------
  96. Medical Imaging                      Senior Software Engineer
  97. Dept Comp Sci                        Philips Radiotherapy Systems
  98. University of Bristol, UK            Horfield Road, Bristol, UK
  99.  
  100. *** README    Mon Jan  8 08:49:53 1990
  101. --- README.orig    Mon Jan  8 08:35:08 1990
  102. ***************
  103. *** 14,21 ****
  104.   
  105.   It does not claim to be perfect, but I personally have used it for
  106.   printing many documents in the past, especially manual pages and found
  107. ! it very useful. It has also been used under OpenWindows1.0 aspart of a 
  108. ! manual page previewer.
  109.   
  110.   It was written under SunOS3.5, but has been run on a 3B2 running System V
  111.   and produces particularly nice output under SunOS4.0 or later as Sun
  112. --- 14,20 ----
  113.   
  114.   It does not claim to be perfect, but I personally have used it for
  115.   printing many documents in the past, especially manual pages and found
  116. ! it very useful.
  117.   
  118.   It was written under SunOS3.5, but has been run on a 3B2 running System V
  119.   and produces particularly nice output under SunOS4.0 or later as Sun
  120. *** thack.1    Mon Jan  8 08:45:52 1990
  121. --- thack.1.orig    Mon Jan  8 08:35:08 1990
  122. ***************
  123. *** 1,5 ****
  124.   .\" .TH name section cent-foot
  125. ! .TH THACK 1 "8 January 1990"
  126.   .SH NAME
  127.   .\" name \- function
  128.   thack \- hack about with TROFF output
  129. --- 1,5 ----
  130.   .\" .TH name section cent-foot
  131. ! .TH THACK 1 "28 August 1987"
  132.   .SH NAME
  133.   .\" name \- function
  134.   thack \- hack about with TROFF output
  135. ***************
  136. *** 6,14 ****
  137.   .SH SYNOPSIS
  138.   .\" Bold keywords, Italic variables, [] options, | alternatives.
  139.   .B thack
  140. - [
  141. - .IR filename .\|.\|.
  142. - ]
  143.   .SH DESCRIPTION
  144.   .\" Italic files, commands, IR manual-entry (manual-section)
  145.   .I Thack
  146. --- 6,11 ----
  147. ***************
  148. *** 15,21 ****
  149.   is a hack to
  150.   convert
  151.   .IR troff (1)
  152. ! output into
  153.   postscript.
  154.   The postscript it
  155.   produces is not highly
  156. --- 12,18 ----
  157.   is a hack to
  158.   convert
  159.   .IR troff (1)
  160. ! output into 
  161.   postscript.
  162.   The postscript it
  163.   produces is not highly
  164. ***************
  165. *** 37,45 ****
  166.   that an uncatered for code has been
  167.   sent (24 have yet to be identified).
  168.   More interesting messages such
  169. ! as `Sequence Bell Logo is not allowed'
  170. ! are also printed.  There are five of these
  171. ! cases.  However, some illegal sequences are
  172.   intercepted and used
  173.   as additional font information.
  174.   .SH BUGS
  175. --- 34,42 ----
  176.   that an uncatered for code has been
  177.   sent (24 have yet to be identified).
  178.   More interesting messages such
  179. ! as 'Sequence Bell Logo is not allowed'
  180. ! are also printed. There are five of these
  181. ! cases. However, some illegal sequences are 
  182.   intercepted and used
  183.   as additional font information.
  184.   .SH BUGS
  185. ***************
  186. *** 50,56 ****
  187.   .br
  188.   Many Special characters are Wrong.
  189.   .br
  190. ! .IR Eqn (1)
  191. ! and
  192. ! .IR tbl (1)
  193. ! are not 100% compatible.
  194. --- 47,50 ----
  195.   .br
  196.   Many Special characters are Wrong.
  197.   .br
  198. ! Eqn(1) & Tbl(1) are not 100% compatible.
  199. *** thack.c    Mon Jan  8 08:37:29 1990
  200. --- thack.c.orig    Mon Jan  8 08:35:08 1990
  201. ***************
  202. *** 1,8 ****
  203.   #include "th.h"
  204.   
  205. ! int error;
  206. ! unsigned npages;
  207. ! int xpos, ypos, cx, cy;
  208.   int font, cfont, size, csize, tfont, tsize;
  209.   char *pstr, *cstr();
  210.   
  211. --- 1,7 ----
  212.   #include "th.h"
  213.   
  214. ! int npages;
  215. ! int xpos, ypos, cy;
  216.   int font, cfont, size, csize, tfont, tsize;
  217.   char *pstr, *cstr();
  218.   
  219. ***************
  220. *** 21,50 ****
  221.   #define Y_INITIAL ((int)(PAGELENGTH*144 + 0.5))
  222.   #endif
  223.   
  224. ! #define POINTS_PER_INCH 72
  225. ! int
  226. ! main(argc, argv)
  227. ! int argc;
  228. ! char **argv;
  229.   {
  230. -     if (argc <= 1)
  231. -         thack();
  232. -     else {
  233. -         char **a = argv;
  234. -         while (*++a)
  235. -             if (freopen(*a, "r", stdin))
  236. -                 thack();
  237. -             else {
  238. -                 fprintf(stderr, "thack: %s: cannot open\n", *a);
  239. -                 error = 1;
  240. -             }
  241. -     }
  242. -     return error || ferror(stdout);
  243. - }
  244. - thack()
  245. - {
  246.       int c;
  247.       int sflag;
  248.       int hdist, vdist;
  249. --- 20,27 ----
  250.   #define Y_INITIAL ((int)(PAGELENGTH*144 + 0.5))
  251.   #endif
  252.   
  253. ! main()
  254.   {
  255.       int c;
  256.       int sflag;
  257.       int hdist, vdist;
  258. ***************
  259. *** 57,63 ****
  260.       tsize = size = 12;
  261.       esc = lead = 1;
  262.       cy = ypos = Y_INITIAL;
  263. !     cx = xpos = 0;
  264.       sflag = 0;
  265.       prolog();
  266.       newpage();
  267. --- 34,40 ----
  268.       tsize = size = 12;
  269.       esc = lead = 1;
  270.       cy = ypos = Y_INITIAL;
  271. !     xpos = 0;
  272.       sflag = 0;
  273.       prolog();
  274.       newpage();
  275. ***************
  276. *** 91,108 ****
  277.                                   pstr = "\\320";
  278.                                   break;    /* \(em */
  279.                               case 28:
  280. !                                 pstr = " (1)(4)R";
  281.                                   break;    /* \(14 */
  282.                               case 30:
  283. !                                 pstr = " (1)(2)R";
  284.                                   break;    /* \(12 */
  285.                               case 38:
  286. !                                 pstr = " (3)(4)R";
  287.                                   break;    /* \(34 */
  288.                               default:
  289. !                                 fprintf(stderr, "thack: >>>>> L%d/%d\n", font, c & 0x3f);
  290.                                   pstr = "?";
  291. -                                 error = 1;
  292.                               }
  293.                           else
  294.                               switch (c & 0x3f) {
  295. --- 68,84 ----
  296.                                   pstr = "\\320";
  297.                                   break;    /* \(em */
  298.                               case 28:
  299. !                                 illegal("1/4");
  300.                                   break;    /* \(14 */
  301.                               case 30:
  302. !                                 illegal("1/2");
  303.                                   break;    /* \(12 */
  304.                               case 38:
  305. !                                 illegal("3/4");
  306.                                   break;    /* \(34 */
  307.                               default:
  308. !                                 fprintf(stderr, ">>>>> L%d/%d\n", font, c & 0x3f);
  309.                                   pstr = "?";
  310.                               }
  311.                           else
  312.                               switch (c & 0x3f) {
  313. ***************
  314. *** 146,157 ****
  315.                                   fontps(3, size, "\\323");
  316.                                   break;    /* c'right */
  317.                               case 44:
  318. !                                 pstr = "  SQ";
  319. !                                 break;    /* square */
  320.                               default:
  321. !                                 fprintf(stderr, "thack: >>>>> U%d/%d\n", font, c & 0x3f);
  322.                                   pstr = "?";
  323. -                                 error = 1;
  324.                               }
  325.                       else if (fh == 0)
  326.                           switch (c & 0x3f) {
  327. --- 122,132 ----
  328.                                   fontps(3, size, "\\323");
  329.                                   break;    /* c'right */
  330.                               case 44:
  331. !                                 pstr = "\\250";
  332. !                                 break;    /* square ? */
  333.                               default:
  334. !                                 fprintf(stderr, ">>>>> U%d/%d\n", font, c & 0x3f);
  335.                                   pstr = "?";
  336.                               }
  337.                       else if (fh == 0)
  338.                           switch (c & 0x3f) {
  339. ***************
  340. *** 177,183 ****
  341.                               fontps(0, size, "\\\\");
  342.                               break;    /* Backslash ! */
  343.                           case 35:
  344. !                             pstr = "\\360";
  345.                               break;    /* Bell Logo */
  346.                           case 36:
  347.                               pstr = "\\245";
  348. --- 152,158 ----
  349.                               fontps(0, size, "\\\\");
  350.                               break;    /* Backslash ! */
  351.                           case 35:
  352. !                             illegal("Bell Logo");
  353.                               break;    /* Bell Logo */
  354.                           case 36:
  355.                               pstr = "\\245";
  356. ***************
  357. *** 222,230 ****
  358.                               pstr = "\\273";
  359.                               break;    /* ~= */
  360.                           default:
  361. !                             fprintf(stderr, "thack: >>>>> L%d/%d\n", font, c & 0x3f);
  362.                               pstr = "?";
  363. -                             error = 1;
  364.                           }
  365.                       else
  366.                           switch (c & 0x3f) {
  367. --- 197,204 ----
  368.                               pstr = "\\273";
  369.                               break;    /* ~= */
  370.                           default:
  371. !                             fprintf(stderr, ">>>>> L%d/%d\n", font, c & 0x3f);
  372.                               pstr = "?";
  373.                           }
  374.                       else
  375.                           switch (c & 0x3f) {
  376. ***************
  377. *** 316,322 ****
  378.                               pstr = "\\315";
  379.                               break;    /* impr. subset */
  380.                           case 41:
  381. !                             pstr = "  O";
  382.                               break;    /* circle */
  383.                           case 44:
  384.                               pstr = "\\256";
  385. --- 290,296 ----
  386.                               pstr = "\\315";
  387.                               break;    /* impr. subset */
  388.                           case 41:
  389. !                             illegal("circle");
  390.                               break;    /* circle */
  391.                           case 44:
  392.                               pstr = "\\256";
  393. ***************
  394. *** 325,333 ****
  395.                               fontps(0, size, "\\247");
  396.                               break;    /* section */
  397.                           default:
  398. !                             fprintf(stderr, "thack: >>>>> U%d/%d\n", font, c & 0x3f);
  399.                               pstr = "?";
  400. -                             error = 1;
  401.                           }
  402.                   }
  403.                   else {
  404. --- 299,306 ----
  405.                               fontps(0, size, "\\247");
  406.                               break;    /* section */
  407.                           default:
  408. !                             fprintf(stderr, ">>>>> U%d/%d\n", font, c & 0x3f);
  409.                               pstr = "?";
  410.                           }
  411.                   }
  412.                   else {
  413. ***************
  414. *** 394,401 ****
  415.                   size = 36;
  416.                   break;
  417.               default:
  418. !                 fprintf(stderr, "thack: Size: %x\n", c & 0x0f);
  419. !                 error = 1;
  420.               }
  421.               crsize(csize, size);
  422.               tsize = size;
  423. --- 367,373 ----
  424.                   size = 36;
  425.                   break;
  426.               default:
  427. !                 fprintf(stderr, "Size: %x\n", c & 0x0f);
  428.               }
  429.               crsize(csize, size);
  430.               tsize = size;
  431. ***************
  432. *** 403,409 ****
  433.           else if ((c & 0xf0) == 0x40) {
  434.               c &= 0xf;
  435.               switch (c) {
  436. !             case 0:/* fputs("thack: INIT\n", stderr); error = 1; */
  437.                   break;
  438.               case 1:
  439.                   font &= 30;
  440. --- 375,381 ----
  441.           else if ((c & 0xf0) == 0x40) {
  442.               c &= 0xf;
  443.               switch (c) {
  444. !             case 0:/* fprintf(stderr,"INIT\n"); */
  445.                   break;
  446.               case 1:
  447.                   font &= 30;
  448. ***************
  449. *** 429,435 ****
  450.               case 8:
  451.                   esc = -1;
  452.                   break;
  453. !             case 9:/* fputs("thack: STOP\n", stderr); error = 1; */
  454.                   break;
  455.               case 10:
  456.                   lead = 1;
  457. --- 401,407 ----
  458.               case 8:
  459.                   esc = -1;
  460.                   break;
  461. !             case 9:/* fprintf(stderr,"STOP\n"); */
  462.                   break;
  463.               case 10:
  464.                   lead = 1;
  465. ***************
  466. *** 444,451 ****
  467.                   font &= 27;
  468.                   break;
  469.               default:
  470. !                 fputs( "thack: ILLEGAL\n", stderr );
  471. !                 error = 1;
  472.                   break;
  473.               }
  474.               tfont = font;
  475. --- 416,422 ----
  476.                   font &= 27;
  477.                   break;
  478.               default:
  479. !                 fputs( "ILLEGAL\n", stderr );
  480.                   break;
  481.               }
  482.               tfont = font;
  483. ***************
  484. *** 454,535 ****
  485.       if (sflag)
  486.           endpage();
  487.       epilog();
  488.   }
  489.   
  490.   tprint()
  491.   {
  492.       if (font != cfont || size != csize) {
  493. !         char *fontname;
  494.           switch (font) {
  495.           case 0:
  496. !             fontname = "TR";
  497.               break;
  498.           case 1:
  499. !             fontname = "TI";
  500.               break;
  501.           case 2:
  502. !             fontname = "TB";
  503.               break;
  504.           case 3:
  505. !             fontname = "S";
  506.               break;
  507.           case 8:
  508. !             fontname = "H";
  509.               break;
  510.           case 9:
  511. !             fontname = "HO";
  512.               break;
  513.           case 10:
  514. !             fontname = "HB";
  515.               break;
  516.           case 11:
  517. !             fontname = "S";
  518.               break;
  519.           case 16:
  520. !             fontname = "C";
  521.               break;
  522.           case 17:
  523. !             fontname = "CO";
  524.               break;
  525.           case 18:
  526. !             fontname = "CB";
  527.               break;
  528.           case 19:
  529. !             fontname = "S";
  530.               break;
  531.           case 24:
  532. !             fontname = "TBI";
  533.               break;
  534.           case 25:
  535. !             fontname = "HBO";
  536.               break;
  537.           case 26:
  538. !             fontname = "CBO";
  539.               break;
  540.           case 27:
  541. !             fontname = "S";
  542.               break;
  543.           default:
  544. !             fprintf(stderr, "thack: Illegal Font %d\n", font);
  545. !             error = 1;
  546. !             fontname = "TR";
  547.           }
  548. !         printf("\n%d %s", size * 6, fontname);
  549.           cfont = font;
  550.           csize = size;
  551.       }
  552. !     if (*pstr == ' ')
  553. !         printf(" %d %d\nM%s", xpos, ypos, pstr+1);
  554. !     else if (ypos != cy)
  555. !         printf("(%s)%d %d\nP", pstr, xpos, ypos);
  556. !     else {
  557. !         int dx = xpos - cx;
  558. !         if (dx < 0)
  559. !             printf("(%s)%d\nx", pstr, -dx);
  560. !         else
  561. !             printf("(%s)%d\nX", pstr, dx);
  562. !     }
  563. !     cx = xpos;
  564.       cy = ypos;
  565.   }
  566.   
  567. --- 425,498 ----
  568.       if (sflag)
  569.           endpage();
  570.       epilog();
  571. +     return 0;
  572.   }
  573.   
  574.   tprint()
  575.   {
  576.       if (font != cfont || size != csize) {
  577. !         printf("%d ", size * 6);
  578.           switch (font) {
  579.           case 0:
  580. !             fputs("TR", stdout);
  581.               break;
  582.           case 1:
  583. !             fputs("TI", stdout);
  584.               break;
  585.           case 2:
  586. !             fputs("TB", stdout);
  587.               break;
  588.           case 3:
  589. !             fputs("S", stdout);
  590.               break;
  591.           case 8:
  592. !             fputs("H", stdout);
  593.               break;
  594.           case 9:
  595. !             fputs("HO", stdout);
  596.               break;
  597.           case 10:
  598. !             fputs("HB", stdout);
  599.               break;
  600.           case 11:
  601. !             fputs("S", stdout);
  602.               break;
  603.           case 16:
  604. !             fputs("C", stdout);
  605.               break;
  606.           case 17:
  607. !             fputs("CO", stdout);
  608.               break;
  609.           case 18:
  610. !             fputs("CB", stdout);
  611.               break;
  612.           case 19:
  613. !             fputs("S", stdout);
  614.               break;
  615.           case 24:
  616. !             fputs("TBI", stdout);
  617.               break;
  618.           case 25:
  619. !             fputs("HBO", stdout);
  620.               break;
  621.           case 26:
  622. !             fputs("CBO", stdout);
  623.               break;
  624.           case 27:
  625. !             fputs("S", stdout);
  626.               break;
  627.           default:
  628. !             fprintf(stderr, "Illegal Font %d\n", font);
  629. !             fputs("TR", stdout);
  630.           }
  631. !         fputs(" F\n", stdout);
  632.           cfont = font;
  633.           csize = size;
  634.       }
  635. !     if (ypos == cy)
  636. !         printf("(%s)%d X\n", pstr, xpos);
  637. !     else
  638. !         printf("(%s)%d %d P\n", pstr, xpos, 3 * ypos);
  639.       cy = ypos;
  640.   }
  641.   
  642. ***************
  643. *** 541,546 ****
  644. --- 504,516 ----
  645.       font = f1;
  646.   }
  647.   
  648. + illegal(s)
  649. + char *s;
  650. + {
  651. +     pstr = s;
  652. +     fprintf(stderr, "Sequence \\(%s is not allowed\n", s);
  653. + }
  654.   crsize(old, new)
  655.   {
  656.       if ((old == 16 || old >= 20) && (new != 16 && new < 20))
  657. ***************
  658. *** 562,637 ****
  659.   newpage()
  660.   {
  661.       ++npages;
  662. !     printf("\n%%%%Page: %u %u\nsave", npages, npages);
  663.   }
  664.   
  665. - static char *prolog_text[] = {
  666. -     "%%Title: troff output",
  667. -     "%%Creator: (thack - contact <everson@cs.bris.ac.uk>)",
  668. -     "%%Pages: (atend)",
  669. -     "%%DocumentFonts: Times-Roman Times-Italic Times-Bold \
  670. - Symbol Helvetica Helvetica-Oblique Helvetica-Bold Courier \
  671. - Courier-Oblique Courier-Bold Times-BoldItalic Helvetica-BoldOblique \
  672. - Courier-BoldOblique",
  673. -     "%%EndComments",
  674. -     "/M{3 mul moveto}bind def",
  675. -     "/P{M gsave show grestore}bind def",
  676. -     "/X{0 rmoveto gsave show grestore}bind def",
  677. -     "/x{neg X}bind def",
  678. -     "/F{findfont exch scalefont setfont}bind def",
  679. -     "/TR{/Times-Roman F}bind def",
  680. -     "/TI{/Times-Italic F}bind def",
  681. -     "/TB{/Times-Bold F}bind def",
  682. -     "/S{/Symbol F}bind def",
  683. -     "/H{/Helvetica F}bind def",
  684. -     "/HO{/Helvetica-Oblique F}bind def",
  685. -     "/HB{/Helvetica-Bold F}bind def",
  686. -     "/C{/Courier F}bind def",
  687. -     "/CO{/Courier-Oblique F}bind def",
  688. -     "/CB{/Courier-Bold F}bind def",
  689. -     "/TBI{/Times-BoldItalic F}bind def",
  690. -     "/HBO{/Helvetica-BoldOblique F}bind def",
  691. -     "/CBO{/Courier-BoldOblique F}bind def",
  692. -     "/MR[.65 0 0 .6 0 0]def",
  693. -     "/1H{gsave newpath 0 0 moveto(1)true charpath flattenpath pathbbox",
  694. -     " 4 1 roll pop pop pop grestore}bind def",
  695. -     "/DR{gsave 1H 18 div setlinewidth currentpoint translate}bind def",
  696. -     "/Z{0 0 transform exch round exch round itransform moveto}bind def",
  697. -     "/O{DR newpath 1H 2 div dup dup 0 360 arc stroke grestore}bind def",
  698. -     "/SQ{DR Z newpath 0 0 moveto 1H 0 rlineto 0 1H rlineto 1H neg 0 rlineto",
  699. -     " closepath stroke grestore}bind def",
  700. -     "/R{gsave 0 1H .4 mul 2 copy rmoveto currentfont dup MR makefont dup",
  701. -     " setfont exch 6 -1 roll show setfont 3 1 roll neg rmoveto(\\244)show",
  702. -     " setfont show grestore}bind def",
  703. -     "1 6 div dup scale",
  704. -     "%%EndProlog",
  705. -     0
  706. - };
  707.   prolog()
  708.   {
  709.       time_t clock = time((time_t *)0);
  710. !     char **p;
  711.   
  712. !     printf("%s%s%s%g\n",
  713. !         "%!PS-Adobe-2.0 EPSF-2.0\n%%CreationDate: ", asctime(localtime(&clock)),
  714. !         "%%BoundingBox: 0 0 542.88 ", PAGELENGTH*POINTS_PER_INCH
  715. !     );
  716.   
  717. !     for (p = prolog_text;  *p;  p++)
  718. !         puts(*p);
  719. !     npages = 0;
  720.   }
  721.   
  722.   endpage()
  723.   {
  724. !     printf("\nshowpage\nrestore");
  725.       cfont = csize = -1;    /* Doing this will cause a new font message */
  726.   }
  727.   
  728.   epilog()
  729.   {
  730. !     printf("\n%%%%Trailer\n%%%%Pages: %u\n", npages);
  731.   }
  732. --- 532,587 ----
  733.   newpage()
  734.   {
  735.       ++npages;
  736. !     printf("%%%%Page: %d %d\n", npages, npages);
  737. !     printf("save\n");
  738.   }
  739.   
  740.   prolog()
  741.   {
  742.       time_t clock = time((time_t *)0);
  743. !       
  744. !     printf("%%!PS-Adobe-\n");
  745. !     printf("%%%%Creator: (thack - contact <everson@cs.bris.ac.uk>)\n");
  746. !     printf("%%%%Title: unknown\n");
  747. !     printf("%%%%CreationDate: %s", asctime (localtime (&clock)));
  748. !     printf("%%%%Pages: (atend)\n");
  749. !     printf("%%%%DocumentFonts: Times-Roman Times-Italic Times-Bold \
  750. ! Symbol Helvetica Helvetica-Oblique Helvetica-Bold Courier \
  751. ! Courier-Oblique Courier-Bold Times-BoldItalic Helvetica-BoldOblique \
  752. ! Courier-BoldOblique\n");
  753. !     printf("%%%%EndComments\n");
  754.   
  755. !     printf("/P {moveto show} bind def\n");
  756. !     printf("/X {currentpoint exch pop moveto show} bind def\n");
  757. !     printf("/F {findfont exch scalefont setfont} bind def\n");
  758. !     printf("/TR /Times-Roman def\n");
  759. !     printf("/TI /Times-Italic def\n");
  760. !     printf("/TB /Times-Bold def\n");
  761. !     printf("/S /Symbol def\n");
  762. !     printf("/H /Helvetica def\n");
  763. !     printf("/HO /Helvetica-Oblique def\n");
  764. !     printf("/HB /Helvetica-Bold def\n");
  765. !     printf("/C /Courier def\n");
  766. !     printf("/CO /Courier-Oblique def\n");
  767. !     printf("/CB /Courier-Bold def\n");
  768. !     printf("/TBI /Times-BoldItalic def\n");
  769. !     printf("/HBO /Helvetica-BoldOblique def\n");
  770. !     printf("/CBO /Courier-BoldOblique def\n");
  771. !     printf("1 6 div dup scale\n");
  772.   
  773. !     printf("%%%%EndProlog\n");
  774. !         npages = 0;
  775.   }
  776.   
  777.   endpage()
  778.   {
  779. !     printf("showpage\n");
  780. !     printf("restore\n");
  781.       cfont = csize = -1;    /* Doing this will cause a new font message */
  782.   }
  783.   
  784.   epilog()
  785.   {
  786. !   printf("%%%%Trailer\n");
  787. !   printf("%%%%Pages: %d\n", npages);
  788.   }
  789.  
  790.  
  791.