home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume29 / psutils / patch02 next >
Text File  |  1992-04-15  |  15KB  |  437 lines

  1. Newsgroups: comp.sources.misc
  2. From: ajcd@dcs.ed.ac.uk (Angus Duggan)
  3. Subject:  v29i077:  psutils - Postscript document manipulation tools, Patch02
  4. Message-ID: <1992Apr16.032058.26805@sparky.imd.sterling.com>
  5. X-Md4-Signature: 5d49c11419f668f19875a3488dec3934
  6. Date: Thu, 16 Apr 1992 03:20:58 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: ajcd@dcs.ed.ac.uk (Angus Duggan)
  10. Posting-number: Volume 29, Issue 77
  11. Archive-name: psutils/patch02
  12. Environment: UNIX
  13. Patch-To: psutils: Volume 22, Issue 87-88
  14.  
  15. Here's a minor bugfix patch to my PostScript utilities package (volumes 22 
  16. and 23). A new script is included, fixwpps, which fixes WordPerfect documents 
  17. so that they can be used with the package (I don't know if this script will 
  18. work in all cases - it was tested on one example document), and also fixes 
  19. pstops so that it accepts negative offsets.
  20.  
  21. A statement of the status of this software has also been included, to clarify
  22. the position for people wanting to include any of it in other packages.
  23.  
  24. a.
  25. --
  26. Angus Duggan, Department of Computer Science,    | I'm pink, therefore I'm Spam.
  27. University of Edinburgh, JCMB,            | JANET:  ajcd@uk.ac.ed.dcs
  28. The King's Buildings, Mayfield Road,        | VOICE:  (UK) 031 650 5126
  29. Edinburgh, EH9 3JZ, Scotland.         | OR: ajcd%dcs.ed.ac.uk@nsfnet-relay.ac.uk
  30.  
  31. diff -crN psutils.old/LICENSE psutils/LICENSE
  32. *** psutils.old/LICENSE
  33. --- psutils/LICENSE    Wed Mar 25 15:04:55 1992
  34. ***************
  35. *** 0 ****
  36. --- 1,36 ----
  37. +                         PS Utilities Package
  38. + The constituent files of this package listed below are copyright (C) 1991,1992
  39. + Angus J. C. Duggan.
  40. + Makefile        README          buffer.c        epsffit.c       fixfmps
  41. + fixmacps        fixpspps        getafm          magic.c         psbook.1
  42. + psbook.c        psnup           psnup.1         psselect.1      psselect.c
  43. + pstops.1        pstops.c        psutil.c        psutil.h        showchar
  44. + They may be copied and used for any purpose (including distribution as part of
  45. + a for-profit product), provided:
  46. + 1) The original attribution of the programs is clearly displayed in the product
  47. +    and/or documentation, even if the programs are modified and/or renamed as
  48. +    part of the product.
  49. + 2) The original source code of the programs is provided free of charge (except
  50. +    for reasonable distribution costs). For a definition of reasonable
  51. +    distribution costs, see the Gnu General Public License or Larry Wall's
  52. +    Artistic License (provided with the Perl 4 kit). The GPL and Artistic
  53. +    License in NO WAY affect this license; they are merely used as examples of
  54. +    the spirit in which it is intended.
  55. + 3) These programs are provided "as-is". No warranty or guarantee of their
  56. +    fitness for any particular task is provided. Use of these programs is
  57. +    completely at your own risk.
  58. + Basically, I don't mind how you use the programs so long as you acknowledge
  59. + the author, and give people the originals if they want them.
  60. + The included files appledict.ps, and appledict.ps.uue are (to the best of my
  61. + knowledge) copyright Apple Computer, Inc.
  62. +                                                                 AJCD 25/3/92
  63. diff -crN psutils.old/README psutils/README
  64. *** psutils.old/README    Wed Apr  8 10:32:25 1992
  65. --- psutils/README    Wed Apr  8 10:37:23 1992
  66. ***************
  67. *** 1,4 ****
  68. ! PostScript Utilities            Angus Duggan        3 September 1991
  69.   
  70.   This shar file contains some utilities for manipulating PostScript documents.
  71.   Page selection and rearrangement are supported, including arrangement into
  72. --- 1,4 ----
  73. ! PostScript Utilities            Angus Duggan                7 April 1992
  74.   
  75.   This shar file contains some utilities for manipulating PostScript documents.
  76.   Page selection and rearrangement are supported, including arrangement into
  77. ***************
  78. *** 12,38 ****
  79.   FILES
  80.   
  81.   The files contained are:
  82.   
  83. - -rw-r--r--  1 ajcd          643 Jul 12 10:34 Makefile
  84. - -rw-r--r--  1 ajcd         2819 Sep  3 10:35 README
  85. - -rw-r--r--  1 ajcd        42765 Sep  3 10:07 appledict.ps.uue
  86. - -rw-r--r--  1 ajcd         3673 Jul 12 10:34 epsffit.c
  87. - -rwxr-xr-x  1 ajcd          359 Jul 16 15:21 fixfmps
  88. - -rwxr-xr-x  1 ajcd         1042 Jul 16 15:21 fixmacps
  89. - -rwxr-xr-x  1 ajcd         1165 Jul 16 15:21 fixpspps
  90. - -rwxr-xr-x  1 ajcd         4706 Sep  3 10:22 getafm
  91. - -rw-r--r--  1 ajcd         1066 Jul 12 10:34 psbook.1
  92. - -rw-r--r--  1 ajcd         1990 Jul 12 10:34 psbook.c
  93. - -rwxr-xr-x  1 ajcd         2113 Jul 12 10:34 psnup
  94. - -rw-r--r--  1 ajcd         2146 Jul 12 10:34 psnup.1
  95. - -rw-r--r--  1 ajcd         1509 Jul 12 10:34 psselect.1
  96. - -rw-r--r--  1 ajcd         4621 Jul 12 10:34 psselect.c
  97. - -rw-r--r--  1 ajcd         3227 Jul 12 10:34 pstops.1
  98. - -rw-r--r--  1 ajcd         9273 Jul 12 10:34 pstops.c
  99. - -rw-r--r--  1 ajcd         5220 Jul 12 10:34 psutil.c
  100. - -rw-r--r--  1 ajcd          663 Jul 12 10:34 psutil.h
  101. - -rwxr-xr-x  1 ajcd         2472 Sep  3 10:38 showchar
  102.   PROGRAMS
  103.   
  104.   psbook          rearranges pages into signatures
  105. --- 12,39 ----
  106.   FILES
  107.   
  108.   The files contained are:
  109. + -rw-r--r--  1 ajcd         1665 Mar 25 15:04 LICENSE
  110. + -rw-r--r--  1 ajcd          643 Apr  7 19:13 Makefile
  111. + -rw-r--r--  1 ajcd         3044 Apr  8 10:36 README
  112. + -rw-r--r--  1 ajcd        31017 Jul 16  1991 appledict.ps
  113. + -rw-r--r--  1 ajcd         3673 Jul 12  1991 epsffit.c
  114. + -rwxr-xr-x  1 ajcd          362 Apr  7 19:51 fixfmps
  115. + -rwxr-xr-x  1 ajcd         1082 Apr  7 19:51 fixmacps
  116. + -rwxr-xr-x  1 ajcd         1165 Jul 16  1991 fixpspps
  117. + -rwxr-xr-x  1 ajcd          525 Apr  7 19:52 fixwpps
  118. + -rwxr-xr-x  1 ajcd         4706 Sep  3  1991 getafm
  119. + -rw-r--r--  1 ajcd         1066 Jul 12  1991 psbook.1
  120. + -rw-r--r--  1 ajcd         1990 Jul 12  1991 psbook.c
  121. + -rwxr-xr-x  1 ajcd         2113 Jul 12  1991 psnup
  122. + -rw-r--r--  1 ajcd         2152 Sep  5  1991 psnup.1
  123. + -rw-r--r--  1 ajcd         1509 Jul 12  1991 psselect.1
  124. + -rw-r--r--  1 ajcd         4621 Jul 12  1991 psselect.c
  125. + -rw-r--r--  1 ajcd         3209 Mar 23 09:48 pstops.1
  126. + -rw-r--r--  1 ajcd         9416 Apr  7 19:27 pstops.c
  127. + -rw-r--r--  1 ajcd         5270 Apr  7 19:01 psutil.c
  128. + -rw-r--r--  1 ajcd          682 Sep  5  1991 psutil.h
  129. + -rwxr-xr-x  1 ajcd         2552 Sep  5  1991 showchar
  130.   
  131.   PROGRAMS
  132.   
  133.   psbook          rearranges pages into signatures
  134. ***************
  135. *** 50,67 ****
  136.   getafm   (sh)   outputs PostScript to retrieve AFM file from printer
  137.   showchar (sh)   outputs PostScript to draw a character with metric info
  138.   fixfmps  (perl) filter to fix framemaker documents so that psselect etc. work
  139.   fixmacps (perl) filter to fix Macintosh documents with saner version of md
  140.   fixpspps (perl) filter to fix PSPrint PostScript so that psselect etc. work
  141.   
  142.   INSTALLATION
  143.   
  144. ! UUdecode appledict.ps.uue, edit Makefile to put in required CFLAGS (SYSV for
  145. ! System V machines), "make", and install files in appropriate places.
  146.   
  147.   BUGS
  148.   
  149.   The utilities don't check for PS-Adobe-?.? conformance; they assume documents
  150.   conform. Utilities need an extra save/restore around whole document on a
  151. ! SPARCPrinter, because of bugs in the xnews server.
  152.   
  153.   Bug fixes and suggestions to ajcd@dcs.ed.ac.uk
  154. --- 51,70 ----
  155.   getafm   (sh)   outputs PostScript to retrieve AFM file from printer
  156.   showchar (sh)   outputs PostScript to draw a character with metric info
  157.   fixfmps  (perl) filter to fix framemaker documents so that psselect etc. work
  158. + fixwpps  (perl) filter to fix WordPerfect documents so that psselect etc. work
  159.   fixmacps (perl) filter to fix Macintosh documents with saner version of md
  160.   fixpspps (perl) filter to fix PSPrint PostScript so that psselect etc. work
  161.   
  162.   INSTALLATION
  163.   
  164. ! UUdecode appledict.ps.uue (if supplied encoded), edit Makefile to put in
  165. ! required CFLAGS (SYSV for System V machines), "make", and install files in
  166. ! appropriate places.
  167.   
  168.   BUGS
  169.   
  170.   The utilities don't check for PS-Adobe-?.? conformance; they assume documents
  171.   conform. Utilities need an extra save/restore around whole document on a
  172. ! SPARCPrinter with NeWSPrint 1.0, because of bugs in the xnews server.
  173.   
  174.   Bug fixes and suggestions to ajcd@dcs.ed.ac.uk
  175. diff -crN psutils.old/fixfmps psutils/fixfmps
  176. *** psutils.old/fixfmps    Wed Apr  8 10:32:26 1992
  177. --- psutils/fixfmps    Tue Apr  7 19:51:26 1992
  178. ***************
  179. *** 1,5 ****
  180.   #!/usr/local/bin/perl
  181. ! # fmps: get conforming PostScript out of FrameMaker file
  182.   # move all FMDEFINEFONTs to start of pages
  183.   
  184.   %fonts=();
  185. --- 1,5 ----
  186.   #!/usr/local/bin/perl
  187. ! # fixfmps: get conforming PostScript out of FrameMaker file
  188.   # move all FMDEFINEFONTs to start of pages
  189.   
  190.   %fonts=();
  191. diff -crN psutils.old/fixmacps psutils/fixmacps
  192. *** psutils.old/fixmacps    Wed Apr  8 10:32:27 1992
  193. --- psutils/fixmacps    Tue Apr  7 19:51:59 1992
  194. ***************
  195. *** 1,4 ****
  196. --- 1,5 ----
  197.   #!/usr/local/bin/perl
  198. + # fixmacps: swap to sanitised appledict
  199.   
  200.   $line = 0;            # keep line count
  201.   $sane = "appledict.ps";
  202. diff -crN psutils.old/fixwpps psutils/fixwpps
  203. *** psutils.old/fixwpps
  204. --- psutils/fixwpps    Tue Apr  7 19:52:23 1992
  205. ***************
  206. *** 0 ****
  207. --- 1,22 ----
  208. + #!/usr/local/bin/perl
  209. + # fixwpps: get semi-conforming PostScript out of WordPerfect 5.0 file
  210. + $page = 1;
  211. + while (<>) {
  212. +    s/(_[a-zA-Z]+)([0-9]+)/\1 \2/g;
  213. +    if (/^_bp/) {
  214. +       print STDOUT "%%Page: $page $page\n";
  215. +       print STDOUT $_;
  216. +       $page++;
  217. +    } elsif (/^([^\/].*\S.*)(_bp.*)/) {
  218. +       print STDOUT "$1\n";
  219. +       print STDOUT "%%Page: $page $page\n";
  220. +       print STDOUT "$2\n";
  221. +       $page++;
  222. +    } elsif (/^_ed/) {
  223. +       print STDOUT "%%Trailer:\n";
  224. +       print STDOUT $_;
  225. +    } else {
  226. +       print STDOUT $_;
  227. +    }
  228. + }
  229. diff -crN psutils.old/pstops.1 psutils/pstops.1
  230. *** psutils.old/pstops.1    Wed Apr  8 10:32:28 1992
  231. --- psutils/pstops.1    Mon Mar 23 09:48:13 1992
  232. ***************
  233. *** 1,6 ****
  234.   .TH PSTOPS 1
  235.   .SH NAME
  236. ! pstops \- select pages from a PostScript file
  237.   .SH SYNOPSIS
  238.   .B pstops
  239.   [
  240. --- 1,6 ----
  241.   .TH PSTOPS 1
  242.   .SH NAME
  243. ! pstops \- shuffle pages in a PostScript file
  244.   .SH SYNOPSIS
  245.   .B pstops
  246.   [
  247. ***************
  248. *** 60,66 ****
  249.   .I xoff
  250.   and
  251.   .I yoff
  252. ! shift the page by the specified (positive) amount.
  253.   .I xoff
  254.   and
  255.   .I yoff
  256. --- 60,66 ----
  257.   .I xoff
  258.   and
  259.   .I yoff
  260. ! shift the page by the specified amount.
  261.   .I xoff
  262.   and
  263.   .I yoff
  264. ***************
  265. *** 116,122 ****
  266.   sheet (of A4 paper), the pagespec to use is:
  267.   .sp
  268.   .ce
  269. ! 2:0L@0.7(21cm,0)+1L@0.7(21cm,14.85cm)
  270.   .sp
  271.   To select all of the odd pages in reverse order, use:
  272.   .sp
  273. --- 116,122 ----
  274.   sheet (of A4 paper), the pagespec to use is:
  275.   .sp
  276.   .ce
  277. ! 2:0L@.7(21cm,0)+1L@.7(21cm,14.85cm)
  278.   .sp
  279.   To select all of the odd pages in reverse order, use:
  280.   .sp
  281. ***************
  282. *** 126,137 ****
  283.   To re-arrange pages for printing 2-up booklets, use
  284.   .sp
  285.   .ce
  286. ! 4:-3L@0.7(21cm,0)+0L@0.7(21cm,14.85cm)
  287.   .sp
  288.   for the front sides, and
  289.   .sp
  290.   .ce
  291. ! 4:1L@0.7(21cm,0)+-2L@0.7(21cm,14.85cm)
  292.   .sp
  293.   for the reverse sides (or join them with a comma for duplex printing).
  294.   .SH AUTHOR
  295. --- 126,137 ----
  296.   To re-arrange pages for printing 2-up booklets, use
  297.   .sp
  298.   .ce
  299. ! 4:-3L@.7(21cm,0)+0L@.7(21cm,14.85cm)
  300.   .sp
  301.   for the front sides, and
  302.   .sp
  303.   .ce
  304. ! 4:1L@.7(21cm,0)+-2L@.7(21cm,14.85cm)
  305.   .sp
  306.   for the reverse sides (or join them with a comma for duplex printing).
  307.   .SH AUTHOR
  308. diff -crN psutils.old/pstops.c psutils/pstops.c
  309. *** psutils.old/pstops.c    Wed Apr  8 10:32:29 1992
  310. --- psutils/pstops.c    Tue Apr  7 19:27:33 1992
  311. ***************
  312. *** 70,79 ****
  313.   double parsedouble(sp)
  314.        char **sp;
  315.   {
  316. !    int n = parseint(sp);
  317.      char *s = *sp;
  318.      int d = 0, frac = 1;
  319.   
  320.      if (*s == '.') {
  321.         *sp = ++s;
  322.         for (; isdigit(*s); s++) {
  323. --- 70,85 ----
  324.   double parsedouble(sp)
  325.        char **sp;
  326.   {
  327. !    int n = 0, neg = 1;
  328.      char *s = *sp;
  329.      int d = 0, frac = 1;
  330.   
  331. +    if (*s == '-') {
  332. +       neg = -1;
  333. +       *sp = ++s;
  334. +    }
  335. +    for (;isdigit(*s); s++)
  336. +       n = n*10 + (*s-'0');
  337.      if (*s == '.') {
  338.         *sp = ++s;
  339.         for (; isdigit(*s); s++) {
  340. ***************
  341. *** 80,89 ****
  342.        d = d*10 + (*s-'0');
  343.        frac *= 10;
  344.         }
  345. -       if (*sp == s) specusage();
  346.      }
  347.      *sp = s;
  348. !    return ((double)n+(double)d/frac);
  349.   }
  350.   
  351.   double parsedimen(sp)
  352. --- 86,95 ----
  353.        d = d*10 + (*s-'0');
  354.        frac *= 10;
  355.         }
  356.      }
  357. +    if (*sp == s) specusage();
  358.      *sp = s;
  359. !    return (neg*((double)n+(double)d/frac));
  360.   }
  361.   
  362.   double parsedimen(sp)
  363. ***************
  364. *** 269,275 ****
  365.      writestring(" bind def}{pop}ifelse}{pop}ifelse}forall\n");
  366.      writestring("[/letter/legal/executivepage/a4/a4small/b5/com10envelope\n");
  367.      writestring(" /monarchenvelope/c5envelope/dlenvelope/lettersmall/note\n");
  368. !    writestring(" /folio/quarto/a5]{dup where{exch{}put}{pop}ifelse}forall\n");
  369.      writestring("/lcvx{dup load dup type dup/operatortype eq{pop exch pop}\n");
  370.      writestring(" {/arraytype eq{dup xcheck{exch pop aload pop}\n");
  371.      writestring(" {pop cvx}ifelse}{pop cvx}ifelse}ifelse}bind def\n");
  372. --- 275,282 ----
  373.      writestring(" bind def}{pop}ifelse}{pop}ifelse}forall\n");
  374.      writestring("[/letter/legal/executivepage/a4/a4small/b5/com10envelope\n");
  375.      writestring(" /monarchenvelope/c5envelope/dlenvelope/lettersmall/note\n");
  376. !    writestring(" /folio/quarto/a5]{dup where{dup wcheck{exch{}put}\n");
  377. !    writestring(" {pop{}def}ifelse}{pop}ifelse}forall\n");
  378.      writestring("/lcvx{dup load dup type dup/operatortype eq{pop exch pop}\n");
  379.      writestring(" {/arraytype eq{dup xcheck{exch pop aload pop}\n");
  380.      writestring(" {pop cvx}ifelse}{pop cvx}ifelse}ifelse}bind def\n");
  381. ***************
  382. *** 302,310 ****
  383.      writestring("%%EndProcSet\n");
  384.      writeprolog();
  385.      for (thispg = 0; thispg < maxpage; thispg += modulo) {
  386. !       int ppp, add_last = 0;
  387.         struct pagespec *ps;
  388. !       for (ppp = 0, ps = specs; ps != NULL; ppp++, ps = ps->next) {
  389.        int actualpg;
  390.        int add_next = ((ps->flags & ADD_NEXT) != 0);
  391.        if (ps->reversed)
  392. --- 309,317 ----
  393.      writestring("%%EndProcSet\n");
  394.      writeprolog();
  395.      for (thispg = 0; thispg < maxpage; thispg += modulo) {
  396. !       int add_last = 0;
  397.         struct pagespec *ps;
  398. !       for (ps = specs; ps != NULL; ps = ps->next) {
  399.        int actualpg;
  400.        int add_next = ((ps->flags & ADD_NEXT) != 0);
  401.        if (ps->reversed)
  402. diff -crN psutils.old/psutil.c psutils/psutil.c
  403. *** psutils.old/psutil.c    Wed Apr  8 10:32:30 1992
  404. --- psutils/psutil.c    Tue Apr  7 19:01:46 1992
  405. ***************
  406. *** 110,116 ****
  407.           }
  408.        } else if (headerlen == 0 && buffer[1] != '!')
  409.           headerlen = ftell(infile)-strlen(buffer);
  410. !       }
  411.      pageptr[pages] = ftell(infile);
  412.   }
  413.   
  414. --- 110,117 ----
  415.           }
  416.        } else if (headerlen == 0 && buffer[1] != '!')
  417.           headerlen = ftell(infile)-strlen(buffer);
  418. !       } else if (headerlen == 0)
  419. !      headerlen = ftell(infile)-strlen(buffer);
  420.      pageptr[pages] = ftell(infile);
  421.   }
  422.   
  423.  
  424. exit 0 # Just in case...
  425.