fix up perl script so it is a little cleaner and also works with perl 4
authorHerb Lewis <herb@samba.org>
Fri, 2 Jan 1998 04:26:39 +0000 (04:26 +0000)
committerHerb Lewis <herb@samba.org>
Fri, 2 Jan 1998 04:26:39 +0000 (04:26 +0000)
(This used to be commit 5b724c6551c963454fe4ce27cfc8756e0c76712d)

packaging/SGI/psfixes.pl

index 4ed9e16f7ec0ea9964c09ffbe496af465c61ee30..c5269b9142e4577dc4fca79f7e0b777ad29c5de2 100755 (executable)
@@ -1,26 +1,30 @@
 #!/usr/bin/perl
 
-$found_vm = 0;
-
 while (<>) {
-  if (not $found_vm) {
-    if (not /^\e%/) {
-       if (/^%%Title:/) {
-           s/.\r$/\r/;
+# strip any ctrl-d's
+    $_ =~ s/^\ 4//;
+# get rid of any non-postscript commands
+    if (/^\e%/) {
+       do {
+           $_ = <>;
+       } until ( /^%/ ) || eof() ;
+       if (! eof()) {
            print;
        }
-       elsif (/^\/VM?/) {
-           print "/VM? { pop } bind def\r\n";
-           $found_vm = 1;
-       }
-       else {
+    }
+# fix bug in long titles from MS Word
+    elsif (/^%%Title:/) {
+           s/.\r$/\r/;
            print;
-       }
     }
-  }
-  else {
-    if (/def\r/) {
-       $found_vm = 0;
+# remove VM test
+    elsif (/^\/VM?/) {
+       print "/VM? { pop } bind def\r\n";
+       do {
+           $_ = <>;
+       } until (/def\r/) || eof() ;
+    }
+    else {
+       print;
     }
-  }
 }