home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / TEKST / PSUTILS / FIXPSPPS.PL < prev    next >
Perl Script  |  1993-10-27  |  1KB  |  59 lines

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