#!/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;
}
- }
}