home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume36 / psutils / patch03 < prev    next >
Encoding:
Text File  |  1993-04-03  |  20.1 KB  |  739 lines

  1. Newsgroups: comp.sources.misc
  2. From: ajcd@dcs.ed.ac.uk (Angus Duggan)
  3. Subject: v36i095:  psutils - Postscript document manipulation tools, Patch03
  4. Message-ID: <1993Apr4.222504.6468@sparky.imd.sterling.com>
  5. X-Md4-Signature: 5da466d7b7abd79955fb69d8c404e60d
  6. Date: Sun, 4 Apr 1993 22:25:04 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: ajcd@dcs.ed.ac.uk (Angus Duggan)
  10. Posting-number: Volume 36, Issue 95
  11. Archive-name: psutils/patch03
  12. Environment: UNIX, VMS
  13. Patch-To: psutils: Volume 35, Issue 8-11
  14.  
  15. This is patch 3 to psutils (c.s.m. volume 35), bringing it up to patchlevel
  16. 10. This patch does the following:
  17.  
  18. * all utilities use malloc to allocate space for page pointers, removing the
  19.   maximum page limit.
  20.  
  21. * improves psselect to allow pages to be given relative to the end of the
  22.   document.
  23.  
  24. * improves the arbitrary coordinate system support to work with GhostView
  25.  
  26. * alters fixwpps for WordPerfect 5.1 output
  27.  
  28. * miscellaneous changes to manual pages and Makefile
  29.  
  30. a.
  31. --
  32. Angus Duggan, Department of Computer Science,    | I'm pink, therefore I'm Spam.
  33. University of Edinburgh, The King's Buildings,  | PHONE: +44(0)31 650 5126
  34. Mayfield Road, Edinburgh EH9 3JZ, Scotland.    | INET: ajcd@dcs.ed.ac.uk
  35.  
  36.  
  37. diff -cr psutils-dist/Makefile psutils/Makefile
  38. *** psutils-dist/Makefile    Wed Mar 31 15:57:34 1993
  39. --- psutils/Makefile    Wed Mar 31 15:14:11 1993
  40. ***************
  41. *** 30,42 ****
  42.   pstops: pstops.o psutil.o
  43.       $(CC) $(CFLAGS) -o pstops psutil.o pstops.o
  44.   
  45. ! psbook.c: psutil.h patchlevel.h
  46.   
  47. ! pstops.c: psutil.h patchlevel.h
  48.   
  49. ! psutil.c: psutil.h patchlevel.h
  50.   
  51. ! psselect.c: psutil.h patchlevel.h
  52.   
  53.   psnup: psnup.sh patchlevel.h
  54.       r=`sed -n -e "s/^#define RELEASE \([0-9][0-9]*\)/\1/p" <patchlevel.h`; \
  55. --- 30,42 ----
  56.   pstops: pstops.o psutil.o
  57.       $(CC) $(CFLAGS) -o pstops psutil.o pstops.o
  58.   
  59. ! psbook.o: psutil.h patchlevel.h psbook.c
  60.   
  61. ! pstops.o: psutil.h patchlevel.h pstops.c
  62.   
  63. ! psutil.o: psutil.h patchlevel.h psutil.c
  64.   
  65. ! psselect.o: psutil.h patchlevel.h psselect.c
  66.   
  67.   psnup: psnup.sh patchlevel.h
  68.       r=`sed -n -e "s/^#define RELEASE \([0-9][0-9]*\)/\1/p" <patchlevel.h`; \
  69. diff -cr psutils-dist/fixwpps psutils/fixwpps
  70. *** psutils-dist/fixwpps    Fri Mar 19 14:48:40 1993
  71. --- psutils/fixwpps    Mon Mar 29 13:06:50 1993
  72. ***************
  73. *** 7,25 ****
  74.   
  75.   $page = 1;
  76.   while (<>) {
  77. !    s/(_[a-zA-Z]+)([0-9]+)/\1 \2/g;
  78.      if (/^_bp/) {
  79.         print STDOUT "%%Page: $page $page\n";
  80.         print STDOUT $_;
  81.         $page++;
  82. !    } elsif (/^([^\/].*\S.*)(_bp.*)/) {
  83.         print STDOUT "$1\n";
  84.         print STDOUT "%%Page: $page $page\n";
  85.         print STDOUT "$2\n";
  86.         $page++;
  87. !    } elsif (/^_ed/) {
  88.         print STDOUT "%%Trailer:\n";
  89. !       print STDOUT $_;
  90.      } else {
  91.         print STDOUT $_;
  92.      }
  93. --- 7,26 ----
  94.   
  95.   $page = 1;
  96.   while (<>) {
  97. ! #   s/([^\/]_[a-zA-Z]+)([0-9]+)/\1 \2/g;    # removed for wp 5.1
  98.      if (/^_bp/) {
  99.         print STDOUT "%%Page: $page $page\n";
  100.         print STDOUT $_;
  101.         $page++;
  102. !    } elsif (/^([^\/\s].*)\s(_bp.*)/) {
  103.         print STDOUT "$1\n";
  104.         print STDOUT "%%Page: $page $page\n";
  105.         print STDOUT "$2\n";
  106.         $page++;
  107. !    } elsif (/^(.*\s)?(_ed.*)/) {
  108. !       print STDOUT "$1\n" if defined($1);
  109.         print STDOUT "%%Trailer:\n";
  110. !       print STDOUT "$2\n";
  111.      } else {
  112.         print STDOUT $_;
  113.      }
  114. diff -cr psutils-dist/patchlevel.h psutils/patchlevel.h
  115. *** psutils-dist/patchlevel.h    Wed Mar 31 15:57:35 1993
  116. --- psutils/patchlevel.h    Wed Mar 31 15:11:24 1993
  117. ***************
  118. *** 1,2 ****
  119.   #define RELEASE 1
  120. ! #define PATCHLEVEL 9
  121. --- 1,2 ----
  122.   #define RELEASE 1
  123. ! #define PATCHLEVEL 10
  124. diff -cr psutils-dist/psbook.1 psutils/psbook.1
  125. *** psutils-dist/psbook.1    Mon Feb  8 11:33:45 1993
  126. --- psutils/psbook.1    Wed Mar 31 15:33:31 1993
  127. ***************
  128. *** 33,42 ****
  129.   .SH AUTHOR
  130.   Angus Duggan
  131.   .SH "SEE ALSO"
  132. ! psselect(1), pstops(1)
  133.   .SH TRADEMARKS
  134.   .B PostScript
  135.   is a trademark of Adobe Systems Incorporated.
  136.   .SH BUGS
  137.   .I Psbook
  138. ! cannot cope with documents longer than 5000 pages.
  139. --- 33,42 ----
  140.   .SH AUTHOR
  141.   Angus Duggan
  142.   .SH "SEE ALSO"
  143. ! psselect(1), pstops(1), psnup(1)
  144.   .SH TRADEMARKS
  145.   .B PostScript
  146.   is a trademark of Adobe Systems Incorporated.
  147.   .SH BUGS
  148.   .I Psbook
  149. ! does not accept all DSC comments.
  150. diff -cr psutils-dist/psbook.c psutils/psbook.c
  151. *** psutils-dist/psbook.c    Mon Feb  8 11:33:45 1993
  152. --- psutils/psbook.c    Wed Mar 31 17:47:59 1993
  153. ***************
  154. *** 72,78 ****
  155.   
  156.      /* rearrange pages */
  157.      writeheader(maxpage);
  158. !    writeprolog();
  159.      for (currentpg = 0; currentpg < maxpage; currentpg++) {
  160.         int actualpg = currentpg - currentpg%signature;
  161.         switch(currentpg%4) {
  162. --- 72,78 ----
  163.   
  164.      /* rearrange pages */
  165.      writeheader(maxpage);
  166. !    writeprolog("");
  167.      for (currentpg = 0; currentpg < maxpage; currentpg++) {
  168.         int actualpg = currentpg - currentpg%signature;
  169.         switch(currentpg%4) {
  170. diff -cr psutils-dist/psnup.1 psutils/psnup.1
  171. *** psutils-dist/psnup.1    Wed Mar 31 15:57:36 1993
  172. --- psutils/psnup.1    Wed Mar 31 15:33:22 1993
  173. ***************
  174. *** 27,54 ****
  175.   ]
  176.   [
  177.   .I infile
  178. ! ]
  179.   .SH DESCRIPTION
  180.   .I Psnup
  181.   is a script making the use of 
  182.   .I pstops 
  183.   easier.
  184. ! It sets up standard width and height parameters and 
  185.   .I Pstops
  186. ! rearranges pages from a PostScript document, creating a new PostScript file.
  187.   The input PostScript file should follow the Adobe Document Structuring
  188.   Conventions.
  189. - .I Pstops
  190. - can be used to perform a large number of arbitrary re-arrangements of
  191. - Documents, including arranging for printing 2-up, 4-up, booklets, reversing,
  192. - selecting front or back sides of documents, scaling, etc.
  193.   .PP
  194.   The
  195.   .I \-w
  196. ! option gives the width, the default is (21cm),
  197.   .I \-h
  198. ! option gives the height, the default is (29.7cm), 
  199. ! and are normally specified in
  200.   .B "cm"
  201.   or
  202.   .B "in"
  203. --- 27,53 ----
  204.   ]
  205.   [
  206.   .I infile
  207. ! [
  208. ! .I outfile
  209. ! ] ]
  210.   .SH DESCRIPTION
  211.   .I Psnup
  212.   is a script making the use of 
  213.   .I pstops 
  214.   easier.
  215. ! It uses
  216.   .I Pstops
  217. ! to put more than one logical page of a PostScript document on each physical
  218. ! page of output.
  219.   The input PostScript file should follow the Adobe Document Structuring
  220.   Conventions.
  221.   .PP
  222.   The
  223.   .I \-w
  224. ! option gives the paper width, and the
  225.   .I \-h
  226. ! option gives the paper height,
  227. ! normally specified in
  228.   .B "cm"
  229.   or
  230.   .B "in"
  231. ***************
  232. *** 72,81 ****
  233.   .BR \-8 ,
  234.   and
  235.   .BR \-9
  236. ! options print 2-,
  237. ! 4-,
  238. ! 8-,
  239. ! and 9-up.
  240.   .PP
  241.   The
  242.   .I \-b
  243. --- 71,80 ----
  244.   .BR \-8 ,
  245.   and
  246.   .BR \-9
  247. ! options put 2,
  248. ! 4,
  249. ! 8,
  250. ! or 9 logical pages on each physical page.
  251.   .PP
  252.   The
  253.   .I \-b
  254. ***************
  255. *** 111,120 ****
  256.   .br
  257.   brianc@labmed.ucsf.edu
  258.   .SH "SEE ALSO"
  259. ! psbook(1), pstops(1)
  260.   .SH TRADEMARKS
  261.   .B PostScript
  262.   is a trademark of Adobe Systems Incorporated.
  263.   .SH BUGS
  264.   .I Pstops
  265. ! cannot cope with documents longer than 5000 pages.
  266. --- 110,119 ----
  267.   .br
  268.   brianc@labmed.ucsf.edu
  269.   .SH "SEE ALSO"
  270. ! psbook(1), pstops(1), psselect(1)
  271.   .SH TRADEMARKS
  272.   .B PostScript
  273.   is a trademark of Adobe Systems Incorporated.
  274.   .SH BUGS
  275.   .I Pstops
  276. ! does not accept all DSC comments.
  277. diff -cr psutils-dist/psnup.sh psutils/psnup.sh
  278. *** psutils-dist/psnup.sh    Fri Mar 19 14:48:41 1993
  279. --- psutils/psnup.sh    Wed Mar 31 15:27:44 1993
  280. ***************
  281. *** 1,7 ****
  282.   #!/bin/sh
  283.   # psnup: put multiple pages onto one physical sheet of paper.
  284.   # usage:
  285. ! #       psnup [-w<dim>] [-h<dim>] [-ppaper] [-l] [-2|-4|-8|-9] [file...]
  286.   #               -w<dim> sets the paper width
  287.   #               -h<dim> sets the paper height
  288.   #               -ppaper sets the paper size (width and height) by name
  289. --- 1,7 ----
  290.   #!/bin/sh
  291.   # psnup: put multiple pages onto one physical sheet of paper.
  292.   # usage:
  293. ! #       psnup [-q] [-w<dim>] [-h<dim>] [-ppaper] [-l] [-2|-4|-8|-9] [in [out]]
  294.   #               -w<dim> sets the paper width
  295.   #               -h<dim> sets the paper height
  296.   #               -ppaper sets the paper size (width and height) by name
  297. ***************
  298. *** 21,27 ****
  299.           -8)     nup=8 ;;
  300.           -9)     nup=9 ;;
  301.           -s*)    xscale=`echo "$1" | sed "s/^-./@/"` ;;
  302. !         -v)     echo "psnup release @RELEASE@ patchlevel @PATCHLEVEL@" ; exit 1 ;;
  303.           *)      io="$io $1"
  304.           esac
  305.           shift
  306. --- 21,29 ----
  307.           -8)     nup=8 ;;
  308.           -9)     nup=9 ;;
  309.           -s*)    xscale=`echo "$1" | sed "s/^-./@/"` ;;
  310. !         -v)     echo "psnup release @RELEASE@ patchlevel @PATCHLEVEL@" 1>&2
  311. !                 echo "Usage: $0 [-w<dim>] [-h<dim>] [-ppaper] [-l] [-2|-4|-8|-9] [-q] [-b] [infile [outfile]]" 1>&2
  312. !                 exit 1 ;;
  313.           *)      io="$io $1"
  314.           esac
  315.           shift
  316. diff -cr psutils-dist/psselect.1 psutils/psselect.1
  317. *** psutils-dist/psselect.1    Mon Feb  8 11:33:46 1993
  318. --- psutils/psselect.1    Wed Mar 31 15:33:42 1993
  319. ***************
  320. *** 44,49 ****
  321. --- 44,52 ----
  322.   or a page range of the form \fIfirst\fR-\fIlast\fR. If \fIfirst\fR is omitted,
  323.   the
  324.   first page is assumed, and if \fIlast\fR is omitted, the last page is assumed.
  325. + The prefix character `_' indicates that the page number is relative to the end
  326. + of the document, counting backwards.
  327.   .PP
  328.   The 
  329.   .I \-r
  330. ***************
  331. *** 66,80 ****
  332.   .SH NOTES
  333.   The page number given to
  334.   .I psselect
  335. ! is the number of the page counting from the start of the file, starting at
  336. ! one. The actual page number in the document may be different.
  337.   .SH AUTHOR
  338.   Angus Duggan
  339.   .SH "SEE ALSO"
  340. ! psbook(1), pstops(1)
  341.   .SH TRADEMARKS
  342.   .B PostScript
  343.   is a trademark of Adobe Systems Incorporated.
  344.   .SH BUGS
  345.   .I Psselect
  346. ! cannot cope with documents longer than 5000 pages.
  347. --- 69,83 ----
  348.   .SH NOTES
  349.   The page number given to
  350.   .I psselect
  351. ! is the number of the page counting from the start or end of the file, starting
  352. ! at one. The actual page number in the document may be different.
  353.   .SH AUTHOR
  354.   Angus Duggan
  355.   .SH "SEE ALSO"
  356. ! psbook(1), pstops(1), psnup(1)
  357.   .SH TRADEMARKS
  358.   .B PostScript
  359.   is a trademark of Adobe Systems Incorporated.
  360.   .SH BUGS
  361.   .I Psselect
  362. ! does not accept all DSC comments.
  363. diff -cr psutils-dist/psselect.c psutils/psselect.c
  364. *** psutils-dist/psselect.c    Wed Mar 31 15:57:36 1993
  365. --- psutils/psselect.c    Wed Mar 31 17:59:40 1993
  366. ***************
  367. *** 48,55 ****
  368.        range *rp;
  369.   {
  370.      int first=0;
  371.      if (isdigit(*str)) {
  372. !       first = atoi(str);
  373.         while (isdigit(*str)) str++;
  374.      }
  375.      switch (*str) {
  376. --- 48,57 ----
  377.        range *rp;
  378.   {
  379.      int first=0;
  380. +    int sign;
  381. +    sign = (*str == '_' && ++str) ? -1 : 1;
  382.      if (isdigit(*str)) {
  383. !       first = sign*atoi(str);
  384.         while (isdigit(*str)) str++;
  385.      }
  386.      switch (*str) {
  387. ***************
  388. *** 64,71 ****
  389.      case '-':
  390.      case ':':
  391.         str++;
  392.         if (isdigit(*str)) {
  393. !      int last = atoi(str);
  394.        while (isdigit(*str)) str++;
  395.        if (!first)
  396.           first = 1;
  397. --- 66,74 ----
  398.      case '-':
  399.      case ':':
  400.         str++;
  401. +       sign = (*str == '_' && ++str) ? -1 : 1;
  402.         if (isdigit(*str)) {
  403. !      int last = sign*atoi(str);
  404.        while (isdigit(*str)) str++;
  405.        if (!first)
  406.           first = 1;
  407. ***************
  408. *** 77,83 ****
  409.              return (addrange(str+1, makerange(first, last, rp)));
  410.           }
  411.         } else if (*str == '\0')
  412. !      return (makerange(first, MAXPAGES, rp));
  413.      }
  414.      fprintf(stderr, "%s: invalid page range\n", prog);
  415.      fflush(stderr);
  416. --- 80,88 ----
  417.              return (addrange(str+1, makerange(first, last, rp)));
  418.           }
  419.         } else if (*str == '\0')
  420. !      return (makerange(first, -1, rp));
  421. !       else if (*str == ',')
  422. !      return (addrange(str+1, makerange(first, -1, rp)));
  423.      }
  424.      fprintf(stderr, "%s: invalid page range\n", prog);
  425.      fflush(stderr);
  426. ***************
  427. *** 162,177 ****
  428.      for (pass = 0; pass < 2; pass++) {
  429.         if (pass) {                           /* write header on second pass */
  430.        writeheader(maxpage);
  431. !      writeprolog();
  432.         }
  433.         if (pagerange) {
  434.        range *r;
  435.        for (r = pagerange; r; r = r->next) {
  436. !         if (pagerange->last == MAXPAGES)
  437. !            pagerange->last = pages;
  438.           if (reverse) {
  439.              for (currentpg = r->last; currentpg >= r->first; currentpg--) {
  440. !           if ((currentpg&1) ? (odd || all) : (even || all)) {
  441.                if (pass)
  442.               writepage(currentpg-1);
  443.                else
  444. --- 167,191 ----
  445.      for (pass = 0; pass < 2; pass++) {
  446.         if (pass) {                           /* write header on second pass */
  447.        writeheader(maxpage);
  448. !      writeprolog("");
  449.         }
  450.         if (pagerange) {
  451.        range *r;
  452.        for (r = pagerange; r; r = r->next) {
  453. !         if (pagerange->first < 0) {
  454. !            pagerange->first += pages + 1;
  455. !            if (pagerange->first < 0)
  456. !           pagerange->first = 0;
  457. !         }
  458. !         if (pagerange->last < 0) {
  459. !            pagerange->last += pages + 1;
  460. !            if (pagerange->last < 0)
  461. !           pagerange->last = 0;
  462. !         }
  463.           if (reverse) {
  464.              for (currentpg = r->last; currentpg >= r->first; currentpg--) {
  465. !           if (currentpg <= pages &&
  466. !               ((currentpg&1) ? (odd || all) : (even || all))) {
  467.                if (pass)
  468.               writepage(currentpg-1);
  469.                else
  470. ***************
  471. *** 180,186 ****
  472.              }
  473.           } else {
  474.              for (currentpg = r->first; currentpg <= r->last; currentpg++) {
  475. !           if ((currentpg&1) ? (odd || all) : (even || all)) {
  476.                if (pass)
  477.               writepage(currentpg-1);
  478.                else
  479. --- 194,201 ----
  480.              }
  481.           } else {
  482.              for (currentpg = r->first; currentpg <= r->last; currentpg++) {
  483. !           if (currentpg <= pages &&
  484. !               ((currentpg&1) ? (odd || all) : (even || all))) {
  485.                if (pass)
  486.               writepage(currentpg-1);
  487.                else
  488. diff -cr psutils-dist/pstops.1 psutils/pstops.1
  489. *** psutils-dist/pstops.1    Mon Feb  8 11:33:21 1993
  490. --- psutils/pstops.1    Wed Mar 31 15:33:55 1993
  491. ***************
  492. *** 42,48 ****
  493.   .I = spec[+specs][,specs]
  494.   .TP
  495.   .I spec
  496. ! .I = [-]pageno[@scale][L][R][U][(xoff,yoff)]
  497.   .RE
  498.   .sp
  499.   .I modulo
  500. --- 42,48 ----
  501.   .I = spec[+specs][,specs]
  502.   .TP
  503.   .I spec
  504. ! .I = [-]pageno[L][R][U][@scale][(xoff,yoff)]
  505.   .RE
  506.   .sp
  507.   .I modulo
  508. ***************
  509. *** 89,94 ****
  510. --- 89,98 ----
  511.   If there is only one page specification, with
  512.   .I pageno
  513.   zero, the \fIpageno\fR may be omitted.
  514. + The shift, rotation, and scaling are performed
  515. + in that order regardless of which order
  516. + they appear on the command line.
  517.   .PP
  518.   The
  519.   .I \-w
  520. ***************
  521. *** 137,146 ****
  522.   .SH AUTHOR
  523.   Angus Duggan
  524.   .SH "SEE ALSO"
  525. ! psbook(1), psselect(1)
  526.   .SH TRADEMARKS
  527.   .B PostScript
  528.   is a trademark of Adobe Systems Incorporated.
  529.   .SH BUGS
  530.   .I Pstops
  531. ! cannot cope with documents longer than 5000 pages.
  532. --- 141,150 ----
  533.   .SH AUTHOR
  534.   Angus Duggan
  535.   .SH "SEE ALSO"
  536. ! psbook(1), psselect(1), psnup(1)
  537.   .SH TRADEMARKS
  538.   .B PostScript
  539.   is a trademark of Adobe Systems Incorporated.
  540.   .SH BUGS
  541.   .I Pstops
  542. ! does not accept all DSC comments.
  543. diff -cr psutils-dist/pstops.c psutils/pstops.c
  544. *** psutils-dist/pstops.c    Wed Mar 31 15:57:37 1993
  545. --- psutils/pstops.c    Wed Mar 31 17:43:53 1993
  546. ***************
  547. *** 300,306 ****
  548.         writestring("/initmatrix lcvx/initclip lcvx /newpath lcvx\n");
  549.         writestring(" 0 0 /moveto lcvx\n");
  550.         sprintf(buffer,
  551. !           " %lf 0/rlineto lcvx 0 %lf/rlineto lcvx -%lf 0/rlineto lcvx\n",
  552.             width, height, width);
  553.         writestring(buffer);
  554.         writestring(" /clip lcvx /newpath lcvx /setmatrix lcvx /exec lcvx]\n");
  555. --- 300,306 ----
  556.         writestring("/initmatrix lcvx/initclip lcvx /newpath lcvx\n");
  557.         writestring(" 0 0 /moveto lcvx\n");
  558.         sprintf(buffer,
  559. !           " %lf 0/rlineto lcvx\n 0 %lf/rlineto lcvx\n -%lf 0/rlineto lcvx\n /closepath lcvx\n",
  560.             width, height, width);
  561.         writestring(buffer);
  562.         writestring(" /clip lcvx /newpath lcvx /setmatrix lcvx /exec lcvx]\n");
  563. ***************
  564. *** 312,321 ****
  565.      if (nobinding) /* desperation measures */
  566.         writestring("/bind{}def\n");
  567.      writestring("%%EndProcSet\n");
  568. -    writeprolog();
  569.      /* save transformation from original to current matrix */
  570. !    writestring("/pstopsxform pstopsmatrix matrix currentmatrix matrix\n");
  571. !    writestring("invertmatrix matrix concatmatrix matrix invertmatrix store\n");
  572.      for (thispg = 0; thispg < maxpage; thispg += modulo) {
  573.         int add_last = 0;
  574.         struct pagespec *ps;
  575. --- 312,319 ----
  576.      if (nobinding) /* desperation measures */
  577.         writestring("/bind{}def\n");
  578.      writestring("%%EndProcSet\n");
  579.      /* save transformation from original to current matrix */
  580. !    writeprolog("/pstopsxform pstopsmatrix matrix currentmatrix matrix invertmatrix matrix concatmatrix matrix invertmatrix store\n");
  581.      for (thispg = 0; thispg < maxpage; thispg += modulo) {
  582.         int add_last = 0;
  583.         struct pagespec *ps;
  584. ***************
  585. *** 353,358 ****
  586. --- 351,357 ----
  587.           }
  588.           writestring("pstopsxform concat\n");
  589.           writestring("/pstopsmatrix matrix currentmatrix def\n");
  590.        }
  591.        if (add_next) {
  592.           writestring("/showpage{}def/copypage{}def/erasepage{}def\n");
  593. diff -cr psutils-dist/psutil.c psutils/psutil.c
  594. *** psutils-dist/psutil.c    Wed Mar 31 15:57:37 1993
  595. --- psutils/psutil.c    Wed Mar 31 17:50:28 1993
  596. ***************
  597. *** 22,31 ****
  598. --- 22,34 ----
  599.   static long bytes = 0;
  600.   static long pagescmt = 0;
  601.   static long headerlen = 0;
  602. + static long endsetup = 0;
  603.   static int outputpage = 0;
  604.   static char pagelabel[BUFSIZ];
  605.   static int pageno;
  606.   static long pagelength;
  607. + static int maxpages = 100;
  608. + static long *pageptr;
  609.   
  610.   /* make a file seekable; trick stolen from Chris Torek's libdvi */
  611.   
  612. ***************
  613. *** 96,101 ****
  614. --- 99,109 ----
  615.      register long int this_record;
  616.   #endif
  617.   
  618. +    if ((pageptr = (long *)malloc(sizeof(long)*maxpages)) == NULL) {
  619. +       fprintf(stderr, "%s: out of memory\n", prog);
  620. +       fflush(stderr);
  621. +       exit(1);
  622. +    }
  623.      pages = 0;
  624.      fseek(infile, 0L, 0);
  625.   #ifdef VMS
  626. ***************
  627. *** 105,117 ****
  628.   #endif
  629.         if (*buffer == '%') {
  630.        if (buffer[1] == '%') {
  631. !         if (nesting == 0 && strncmp(comment, "Page:", 5) == 0)
  632.   #ifdef VMS
  633.              pageptr[pages++] = this_record;
  634.   #else
  635.              pageptr[pages++] = ftell(infile)-strlen(buffer);
  636.   #endif
  637. !         else if (headerlen == 0 && strncmp(comment, "Pages:", 6) == 0)
  638.   #ifdef VMS
  639.              pagescmt = this_record;
  640.   #else
  641. --- 113,134 ----
  642.   #endif
  643.         if (*buffer == '%') {
  644.        if (buffer[1] == '%') {
  645. !         if (nesting == 0 && strncmp(comment, "Page:", 5) == 0) {
  646. !            if (pages >= maxpages-1) {
  647. !           maxpages *= 2;
  648. !           if ((pageptr = (long *)realloc((char *)pageptr,
  649. !                          sizeof(long)*maxpages)) == NULL) {
  650. !              fprintf(stderr, "%s: out of memory\n", prog);
  651. !              fflush(stderr);
  652. !              exit(1);
  653. !           }
  654. !            }
  655.   #ifdef VMS
  656.              pageptr[pages++] = this_record;
  657.   #else
  658.              pageptr[pages++] = ftell(infile)-strlen(buffer);
  659.   #endif
  660. !         } else if (headerlen == 0 && strncmp(comment, "Pages:", 6) == 0)
  661.   #ifdef VMS
  662.              pagescmt = this_record;
  663.   #else
  664. ***************
  665. *** 128,133 ****
  666. --- 145,156 ----
  667.              nesting++;
  668.           else if (strncmp(comment, "EndBinary", 9) == 0)
  669.              nesting--;
  670. +         else if (nesting == 0 && strncmp(comment, "EndSetup", 8) == 0)
  671. + #ifdef VMS
  672. +            endsetup = this_record;
  673. + #else
  674. +            endsetup = ftell(infile)-strlen(buffer);
  675. + #endif
  676.           else if (nesting == 0 && strncmp(comment, "Trailer", 7) == 0) {
  677.   #ifdef VMS
  678.              fseek(infile, this_record, 0);
  679. ***************
  680. *** 149,154 ****
  681. --- 172,179 ----
  682.        headerlen = ftell(infile)-strlen(buffer);
  683.   #endif
  684.      pageptr[pages] = ftell(infile);
  685. +    if (endsetup == 0)
  686. +       endsetup = pageptr[0];
  687.   }
  688.   
  689.   seekpage(p)
  690. ***************
  691. *** 225,233 ****
  692.   }
  693.   
  694.   
  695. ! writeprolog()
  696.   {
  697. !    if (!fcopy(pageptr[0]-headerlen)) {
  698.         fprintf(stderr, "%s: I/O error in prologue\n", prog);
  699.         fflush(stderr);
  700.         exit(1);
  701. --- 250,265 ----
  702.   }
  703.   
  704.   
  705. ! writeprolog(setup)
  706. !      char *setup;
  707.   {
  708. !    if (!fcopy(endsetup-headerlen)) {
  709. !       fprintf(stderr, "%s: I/O error in prologue\n", prog);
  710. !       fflush(stderr);
  711. !       exit(1);
  712. !    }
  713. !    writestring(setup);
  714. !    if (!fcopy(pageptr[0]-endsetup)) {
  715.         fprintf(stderr, "%s: I/O error in prologue\n", prog);
  716.         fflush(stderr);
  717.         exit(1);
  718. diff -cr psutils-dist/psutil.h psutils/psutil.h
  719. *** psutils-dist/psutil.h    Wed Mar 31 15:57:37 1993
  720. --- psutils/psutil.h    Wed Mar 31 11:23:06 1993
  721. ***************
  722. *** 11,20 ****
  723.   #endif
  724.   
  725.   #define TMPDIR "/tmp"
  726. - #define MAXPAGES 5000 /* max pages in document */
  727.   
  728.   LOCAL char *prog;
  729. - LOCAL long pageptr[MAXPAGES];
  730.   LOCAL int pages;
  731.   LOCAL int verbose;
  732.   LOCAL FILE *infile;
  733. --- 11,18 ----
  734.  
  735. exit 0 # Just in case...
  736.