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

  1. Newsgroups: comp.sources.misc
  2. From: ajcd@dcs.ed.ac.uk (Angus Duggan)
  3. Subject: v36i033:  psutils - Postscript document manipulation tools, Patch02
  4. Message-ID: <1993Mar22.150304.26989@sparky.imd.sterling.com>
  5. X-Md4-Signature: 39f7e85c5d70b7dc8d57192b351022d8
  6. Date: Mon, 22 Mar 1993 15:03: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 33
  11. Archive-name: psutils/patch02
  12. Environment: UNIX, VMS
  13. Patch-To: psutils: Volume 35, Issue 8-11
  14.  
  15. Here's a second patch to the latest version of PSUtils, bringing it up
  16. to version 1.9. This patch allows pstops to work with arbitrary global
  17. coordinate systems, fixes a bug in psselect to do with selecting everything
  18. upto the end of a document, and adds some VMS support.
  19.  
  20. a.
  21. --
  22. Angus Duggan, Department of Computer Science,    | I'm pink, therefore I'm Spam.
  23. University of Edinburgh, The King's Buildings,  | PHONE: +44(0)31 650 5126
  24. Mayfield Road, Edinburgh EH9 3JZ, Scotland.    | INET: ajcd@dcs.ed.ac.uk
  25.  
  26. diff +new -cr psutils-dist/Makefile psutils/Makefile
  27. *** psutils-dist/Makefile    Fri Mar 19 14:48:34 1993
  28. --- psutils/Makefile    Fri Mar 19 17:14:08 1993
  29. ***************
  30. *** 22,34 ****
  31.       $(CC) $(CFLAGS) -o epsffit epsffit.c
  32.   
  33.   psbook: psbook.o psutil.o
  34. !     $(CC) -o psbook psutil.o psbook.o
  35.   
  36.   psselect: psselect.o psutil.o
  37. !     $(CC) -o psselect psutil.o psselect.o
  38.   
  39.   pstops: pstops.o psutil.o
  40. !     $(CC) -o pstops psutil.o pstops.o
  41.   
  42.   psbook.c: psutil.h patchlevel.h
  43.   
  44. --- 22,34 ----
  45.       $(CC) $(CFLAGS) -o epsffit epsffit.c
  46.   
  47.   psbook: psbook.o psutil.o
  48. !     $(CC) $(CFLAGS) -o psbook psutil.o psbook.o
  49.   
  50.   psselect: psselect.o psutil.o
  51. !     $(CC) $(CFLAGS) -o psselect psutil.o psselect.o
  52.   
  53.   pstops: pstops.o psutil.o
  54. !     $(CC) $(CFLAGS) -o pstops psutil.o pstops.o
  55.   
  56.   psbook.c: psutil.h patchlevel.h
  57.   
  58. diff +new -cr psutils-dist/Manifest psutils/Manifest
  59. *** psutils-dist/Manifest    Fri Mar 19 14:48:35 1993
  60. --- psutils/Manifest    Fri Mar 19 17:28:00 1993
  61. ***************
  62. *** 2,7 ****
  63. --- 2,8 ----
  64.   Makefile
  65.   Manifest
  66.   README
  67. + descrip.mms
  68.   epsffit.1
  69.   epsffit.c
  70.   fixfmps
  71. diff +new -cr psutils-dist/README psutils/README
  72. *** psutils-dist/README    Fri Mar 19 14:48:35 1993
  73. --- psutils/README    Fri Mar 19 17:18:38 1993
  74. ***************
  75. *** 98,103 ****
  76.           Kristian Jorg           etxkrjg@se.ericsson.solsta
  77.           Larry Weissman          larryw@nsr.bioeng.washington.edu 
  78.           Michael L. Brown        brown%uucp.vidiot@edu.wisc.cs
  79. !         
  80.   (Apologies to anyone who I have left out.)
  81.   
  82. --- 98,105 ----
  83.           Kristian Jorg           etxkrjg@se.ericsson.solsta
  84.           Larry Weissman          larryw@nsr.bioeng.washington.edu 
  85.           Michael L. Brown        brown%uucp.vidiot@edu.wisc.cs
  86. !         Hunter Goatley            goathunter@wkuvx1.bitnet
  87. !         John Interrante         interran@uluru.Stanford.edu
  88.   (Apologies to anyone who I have left out.)
  89.   
  90. diff +new -cr psutils-dist/descrip.mms psutils/descrip.mms
  91. *** psutils-dist/descrip.mms
  92. --- psutils/descrip.mms    Fri Mar 19 17:27:38 1993
  93. ***************
  94. *** 0 ****
  95. --- 1,52 ----
  96. + #
  97. + #  VMS MMS build file for PS utilities
  98. + #
  99. + #  Hunter Goatley, 16-MAR-1993 14:47
  100. + #
  101. + CFLAGS = /NOLIST/OBJECT=$(MMS$TARGET)
  102. + LFLAGS = /NOTRACE/EXEC=$(MMS$TARGET)
  103. + .IFDEF __ALPHA__               #If building with Alpha cross-compilers, OBJ
  104. + OPTIONS_FILE =                  #... is defined already
  105. + LINKOPT =
  106. + CFLAGS = /NOLIST/OBJECT=$(MMS$TARGET)/STANDARD=VAXC
  107. + .ELSE
  108. + OBJ = .OBJ
  109. + EXE = .EXE
  110. + OPTIONS_FILE = ,VAXC.OPT
  111. + LINKOPT = $(options_file)/OPTIONS
  112. + .ENDIF
  113. + # epsffit fits an epsf file to a given bounding box
  114. + # psbook rearranges pages into signatures
  115. + # psselect selects page ranges
  116. + # pstops performs general page rearrangement and merging
  117. + all : psbook$(exe), psselect$(exe), pstops$(exe), epsffit$(exe)
  118. +         @ write sys$output "PSUTILS build complete"
  119. + epsffit$(exe) : epsffit$(obj)$(options_file)
  120. +         $(LINK)$(LFLAGS) $(MMS$SOURCE)$(linkopt)
  121. + psbook$(exe) :  psbook$(obj), psutil$(obj)$(options_file)
  122. +         $(LINK)$(LFLAGS) psbook$(obj),psutil$(obj)$(linkopt)
  123. + psselect$(exe) :        psselect$(obj), psutil$(obj)
  124. +         $(LINK)$(LFLAGS) psselect$(obj),psutil$(obj)$(linkopt)
  125. + pstops$(exe) :  pstops$(obj), psutil$(obj)
  126. +         $(LINK)$(LFLAGS) pstops$(obj),psutil$(obj)$(linkopt)
  127. + psbook$(obj) : psbook.c psutil.h patchlevel.h
  128. + pstops$(obj) : pstops.c, psutil.h patchlevel.h
  129. + psutil$(obj) : psutil.c, psutil.h patchlevel.h
  130. + psselect$(obj) : psselect.c, psutil.h patchlevel.h
  131. + clean :
  132. +         delete/log *$(obj);*,psbook$(exe);*,psselect$(exe);*,pstops$(exe);*,epsf
  133. + fit$(e
  134. + xe);*
  135. diff +new -cr psutils-dist/patchlevel.h psutils/patchlevel.h
  136. *** psutils-dist/patchlevel.h    Fri Mar 19 14:48:41 1993
  137. --- psutils/patchlevel.h    Fri Mar 19 14:32:42 1993
  138. ***************
  139. *** 1,2 ****
  140.   #define RELEASE 1
  141. ! #define PATCHLEVEL 8
  142. --- 1,2 ----
  143.   #define RELEASE 1
  144. ! #define PATCHLEVEL 9
  145. diff +new -cr psutils-dist/psnup.1 psutils/psnup.1
  146. *** psutils-dist/psnup.1    Mon Feb  8 11:33:46 1993
  147. --- psutils/psnup.1    Fri Mar 19 17:16:58 1993
  148. ***************
  149. *** 4,12 ****
  150.   .SH SYNOPSIS
  151.   .B psnup
  152.   [
  153. - .B \-q
  154. - ]
  155. - [
  156.   .B \-w\fIwidth\fR
  157.   ]
  158.   [
  159. --- 4,9 ----
  160. ***************
  161. *** 15,28 ****
  162.   [
  163.   .B \-p\fIpaper\fR
  164.   ]
  165.   .B \-l
  166.   ]
  167.   [
  168. ! .B \-2 | \-4 | \-8 | \-h
  169.   ]
  170.   [
  171.   .I infile
  172. ! ] ]
  173.   .SH DESCRIPTION
  174.   .I Psnup
  175.   is a script making the use of 
  176. --- 12,33 ----
  177.   [
  178.   .B \-p\fIpaper\fR
  179.   ]
  180. + [
  181.   .B \-l
  182.   ]
  183.   [
  184. ! .B \-2 | \-4 |
  185. ! .B \-8 | \-9
  186. ! ]
  187. ! [
  188. ! .B \-b
  189. ! ]
  190. ! [
  191. ! .B \-q
  192.   ]
  193.   [
  194.   .I infile
  195. ! ]
  196.   .SH DESCRIPTION
  197.   .I Psnup
  198.   is a script making the use of 
  199. ***************
  200. *** 58,63 ****
  201. --- 63,83 ----
  202.   .B legal.
  203.   .PP
  204.   The
  205. + .B \-l
  206. + option prints in landscape mode.
  207. + .PP
  208. + The
  209. + .BR \-2 ,
  210. + .BR \-4 ,
  211. + .BR \-8 ,
  212. + and
  213. + .BR \-9
  214. + options print 2-,
  215. + 4-,
  216. + 8-,
  217. + and 9-up.
  218. + .PP
  219. + The
  220.   .I \-b
  221.   option prevents any
  222.   .B bind
  223. ***************
  224. *** 71,82 ****
  225.   The potential use of this utility is varied but one particular 
  226.   use is in conjunction with 
  227.   .I psbook(1).
  228. ! For example, using psroff to create a PostScript document and lpr as 
  229.   the 
  230.   .SM UNIX 
  231.   print spooler a typical command line might look like this: 
  232.   .sp
  233. ! psroff -ms \fIfile\fP | psbook | psnup -2 | lpr
  234.   .sp
  235.   Where file is a 4 page document this command will result in a 
  236.   two page document printing two pages of \fIfile\fP per page and
  237. --- 91,102 ----
  238.   The potential use of this utility is varied but one particular 
  239.   use is in conjunction with 
  240.   .I psbook(1).
  241. ! For example, using groff to create a PostScript document and lpr as 
  242.   the 
  243.   .SM UNIX 
  244.   print spooler a typical command line might look like this: 
  245.   .sp
  246. ! groff -Tps -ms \fIfile\fP | psbook | psnup -2 | lpr
  247.   .sp
  248.   Where file is a 4 page document this command will result in a 
  249.   two page document printing two pages of \fIfile\fP per page and
  250. ***************
  251. *** 87,97 ****
  252.   .SH AUTHOR
  253.   Angus Duggan
  254.   .br
  255. ! Brian Colfer, University of California, San Francisco
  256.   .br
  257.   brianc@labmed.ucsf.edu
  258.   .SH "SEE ALSO"
  259. ! psbook(1), pstops(1), psroff(1)
  260.   .SH TRADEMARKS
  261.   .B PostScript
  262.   is a trademark of Adobe Systems Incorporated.
  263. --- 107,117 ----
  264.   .SH AUTHOR
  265.   Angus Duggan
  266.   .br
  267. ! Manual page by Brian Colfer, University of California, San Francisco
  268.   .br
  269.   brianc@labmed.ucsf.edu
  270.   .SH "SEE ALSO"
  271. ! psbook(1), pstops(1)
  272.   .SH TRADEMARKS
  273.   .B PostScript
  274.   is a trademark of Adobe Systems Incorporated.
  275. diff +new -cr psutils-dist/psselect.c psutils/psselect.c
  276. *** psutils-dist/psselect.c    Mon Feb  8 11:33:47 1993
  277. --- psutils/psselect.c    Fri Mar 19 16:24:09 1993
  278. ***************
  279. *** 167,172 ****
  280. --- 167,174 ----
  281.         if (pagerange) {
  282.        range *r;
  283.        for (r = pagerange; r; r = r->next) {
  284. +         if (pagerange->last == MAXPAGES)
  285. +            pagerange->last = pages;
  286.           if (reverse) {
  287.              for (currentpg = r->last; currentpg >= r->first; currentpg--) {
  288.             if ((currentpg&1) ? (odd || all) : (even || all)) {
  289. diff +new -cr psutils-dist/pstops.c psutils/pstops.c
  290. *** psutils-dist/pstops.c    Mon Feb  8 11:33:48 1993
  291. --- psutils/pstops.c    Fri Mar 19 16:47:14 1993
  292. ***************
  293. *** 273,279 ****
  294.      /* rearrange pages: doesn't cope properly with:
  295.       * initmatrix, initgraphics, defaultmatrix, grestoreall, initclip */
  296.      writeheader((maxpage/modulo)*pagesperspec);
  297. !    writestring("%%BeginProcSet: pstops 1 0\n");
  298.      writestring("[/showpage/erasepage/copypage]{dup where{pop dup load\n");
  299.      writestring(" type/operatortype eq{1 array cvx dup 0 3 index cvx put\n");
  300.      writestring(" bind def}{pop}ifelse}{pop}ifelse}forall\n");
  301. --- 273,279 ----
  302.      /* rearrange pages: doesn't cope properly with:
  303.       * initmatrix, initgraphics, defaultmatrix, grestoreall, initclip */
  304.      writeheader((maxpage/modulo)*pagesperspec);
  305. !    writestring("%%BeginProcSet: pstops 1 1\n");
  306.      writestring("[/showpage/erasepage/copypage]{dup where{pop dup load\n");
  307.      writestring(" type/operatortype eq{1 array cvx dup 0 3 index cvx put\n");
  308.      writestring(" bind def}{pop}ifelse}{pop}ifelse}forall\n");
  309. ***************
  310. *** 285,290 ****
  311. --- 285,291 ----
  312.      writestring(" {/arraytype eq{dup xcheck{exch pop aload pop}\n");
  313.      writestring(" {pop cvx}ifelse}{pop cvx}ifelse}ifelse}bind def\n");
  314.      writestring("/pstopsmatrix matrix currentmatrix def\n");
  315. +    writestring("/pstopsxform matrix def\n");
  316.      writestring("/defaultmatrix{pstopsmatrix exch copy}bind def\n");
  317.      writestring("/initmatrix{matrix defaultmatrix setmatrix}bind def\n");
  318.      writestring("/pathtoproc{[{currentpoint}stopped{$error/newerror false\n");
  319. ***************
  320. *** 312,317 ****
  321. --- 313,321 ----
  322.         writestring("/bind{}def\n");
  323.      writestring("%%EndProcSet\n");
  324.      writeprolog();
  325. +    /* save transformation from original to current matrix */
  326. +    writestring("/pstopsxform pstopsmatrix matrix currentmatrix matrix\n");
  327. +    writestring("invertmatrix matrix concatmatrix matrix invertmatrix store\n");
  328.      for (thispg = 0; thispg < maxpage; thispg += modulo) {
  329.         int add_last = 0;
  330.         struct pagespec *ps;
  331. ***************
  332. *** 330,335 ****
  333. --- 334,340 ----
  334.        writestring("/pstopssaved save def\n");
  335.        if (ps->flags & GSAVE) {
  336.           char buffer[BUFSIZ];
  337. +         writestring("pstopsmatrix setmatrix\n");
  338.           if (ps->flags & OFFSET) {
  339.              sprintf(buffer, "%lf %lf translate\n", ps->xoff, ps->yoff);
  340.              writestring(buffer);
  341. ***************
  342. *** 342,351 ****
  343.              sprintf(buffer, "%lf dup scale\n", ps->scale);
  344.              writestring(buffer);
  345.           }
  346.           writestring("/pstopsmatrix matrix currentmatrix def\n");
  347. -      }
  348. -      if (width > 0.0 && height > 0.0) {
  349. -         writestring("initclip\n");
  350.        }
  351.        if (add_next) {
  352.           writestring("/showpage{}def/copypage{}def/erasepage{}def\n");
  353. --- 347,358 ----
  354.              sprintf(buffer, "%lf dup scale\n", ps->scale);
  355.              writestring(buffer);
  356.           }
  357. +         if (width > 0.0 && height > 0.0) {
  358. +            writestring("/pstopsmatrix matrix currentmatrix def\n");
  359. +            writestring("initclip\n");
  360. +         }
  361. +         writestring("pstopsxform concat\n");
  362.           writestring("/pstopsmatrix matrix currentmatrix def\n");
  363.        }
  364.        if (add_next) {
  365.           writestring("/showpage{}def/copypage{}def/erasepage{}def\n");
  366. diff +new -cr psutils-dist/psutil.c psutils/psutil.c
  367. *** psutils-dist/psutil.c    Mon Feb  8 11:33:36 1993
  368. --- psutils/psutil.c    Fri Mar 19 17:26:19 1993
  369. ***************
  370. *** 3,13 ****
  371. --- 3,21 ----
  372.    * utilities for PS programs
  373.    */
  374.   
  375. + /*
  376. +  *  Hunter Goatley     2-MAR-1993 14:41
  377. +  *    Added VMS support.
  378. +  */
  379.   #define LOCAL
  380.   #include "psutil.h"
  381.   #include "patchlevel.h"
  382.   
  383. + #ifdef VMS
  384. + #include <file.h>
  385. + #else
  386.   #include <fcntl.h>
  387. + #endif
  388.   #include <string.h>
  389.   
  390.   static char buffer[BUFSIZ];
  391. ***************
  392. *** 84,99 ****
  393. --- 92,122 ----
  394.   {
  395.      register char *comment = buffer+2;
  396.      register int nesting = 0;
  397. + #ifdef VMS
  398. +    register long int this_record;
  399. + #endif
  400.   
  401.      pages = 0;
  402.      fseek(infile, 0L, 0);
  403. + #ifdef VMS
  404. +    while (this_record = ftell(infile), fgets(buffer, BUFSIZ, infile) != NULL)
  405. + #else
  406.      while (fgets(buffer, BUFSIZ, infile) != NULL)
  407. + #endif
  408.         if (*buffer == '%') {
  409.        if (buffer[1] == '%') {
  410.           if (nesting == 0 && strncmp(comment, "Page:", 5) == 0)
  411. + #ifdef VMS
  412. +            pageptr[pages++] = this_record;
  413. + #else
  414.              pageptr[pages++] = ftell(infile)-strlen(buffer);
  415. + #endif
  416.           else if (headerlen == 0 && strncmp(comment, "Pages:", 6) == 0)
  417. + #ifdef VMS
  418. +            pagescmt = this_record;
  419. + #else
  420.              pagescmt = ftell(infile)-strlen(buffer);
  421. + #endif
  422.           else if (headerlen == 0 &&
  423.                strncmp(comment, "EndComments", 11) == 0)
  424.              headerlen = ftell(infile);
  425. ***************
  426. *** 106,118 ****
  427. --- 129,153 ----
  428.           else if (strncmp(comment, "EndBinary", 9) == 0)
  429.              nesting--;
  430.           else if (nesting == 0 && strncmp(comment, "Trailer", 7) == 0) {
  431. + #ifdef VMS
  432. +            fseek(infile, this_record, 0);
  433. + #else
  434.              fseek(infile, (long)(-strlen(buffer)), 1);
  435. + #endif
  436.              break;
  437.           }
  438.        } else if (headerlen == 0 && buffer[1] != '!')
  439. + #ifdef VMS
  440. +         headerlen = this_record;
  441. + #else
  442.           headerlen = ftell(infile)-strlen(buffer);
  443. + #endif
  444.         } else if (headerlen == 0)
  445. + #ifdef VMS
  446. +      headerlen = this_record;
  447. + #else
  448.        headerlen = ftell(infile)-strlen(buffer);
  449. + #endif
  450.      pageptr[pages] = ftell(infile);
  451.   }
  452.   
  453. diff +new -cr psutils-dist/psutil.h psutils/psutil.h
  454. *** psutils-dist/psutil.h    Mon Feb  8 11:33:48 1993
  455. --- psutils/psutil.h    Fri Mar 19 17:20:02 1993
  456. ***************
  457. *** 37,39 ****
  458. --- 37,42 ----
  459.   extern long lseek();
  460.   extern long ftell();
  461.   extern char *getenv();
  462. + #ifdef VMS
  463. + #define unlink delete
  464. + #endif
  465.  
  466. exit 0 # Just in case...
  467.