home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / PSUTILS / FIXPSPPS.CMD < prev    next >
OS/2 REXX Batch file  |  1994-01-14  |  1KB  |  60 lines

  1. extproc perl -Sx 
  2. #!perl
  3. # mangle PostScript produced by PSPrint to make it almost conforming
  4.  
  5. # feed this into perl
  6. eval 'exec perl -S $0 "$@"'
  7.    if $running_under_some_shell;
  8.  
  9. $header = 1; $ignore = 0;
  10. $verbose = 0;
  11. @body = ();
  12. %fonts = (); $font = "";
  13. $inchar = 0; @char = ();
  14.  
  15. while (<>) {
  16.    if (/^@end$/) {
  17.       $ignore = 1;
  18.    } elsif (/^[0-9]+ @bop0$/) {
  19.       $ignore = 0;
  20.       $header = 1;
  21.    } elsif ($header) {
  22.       if (/^\/([a-z.0-9]+) @newfont$/) {
  23.      if (! defined($fonts{$1})) {
  24.         $fonts{$1} = 1;
  25.         print;
  26.      } elsif ($verbose) {
  27.         print STDERR "$font already defined\n";
  28.      }
  29.       } elsif (/^([a-z.0-9]+) sf$/) {
  30.      $font = $1;
  31.      print;
  32.       } elsif (/^\[</) {
  33.      $inchar = 1;
  34.      push (@char, $_);
  35.       } elsif ($inchar) {
  36.      push (@char, $_);
  37.      if (/.*\] ([0-9]+) dc$/) {
  38.         if (! defined($fonts{$font,$1})) {
  39.            $fonts{$font,$1} = 1;
  40.            print (@char);
  41.         } elsif ($verbose) {
  42.            print STDERR "$font character $1 already defined\n";
  43.         }
  44.         $inchar = 0;
  45.         @char = ();
  46.      }
  47.       } elsif (/^([0-9]+) @bop1$/) {
  48.      $header = 0;
  49.      push (@body, "%%Page: ? $1\n");
  50.      push (@body, $_);
  51.       } else {
  52.      print;
  53.       }
  54.    } elsif (! $ignore) {
  55.       push (@body, $_);
  56.    }
  57. }
  58. print (@body);
  59. print ("@end\n");
  60.