|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- require 'getopts.pl';
-
-
-
- $program = "fixmswrd";
-
- sub usage {
- die "Usage: $program [-v] [file [output-file]]\n";
- }
-
-
-
- &Getopts("v") || &usage;
-
- $verbose = $opt_v;
-
-
- $infile = shift(@ARGV);
- if ($infile)
- {
- open(INFILE, $infile) || die "$program: Cannot read from $infile\n";
- $handle = "INFILE";
- }
- else
- {
- $handle = "STDIN";
- }
-
-
- $outfile = shift(@ARGV);
- if ($outfile)
- {
- open(OUTFILE, ">$outfile") || die "$program: Cannot write to $outfile\n";
- select(OUTFILE);
- }
-
-
- $have_marker = 0;
-
- undef $dict_name;
- undef $dict_line;
-
- &read_comments;
- &put_comments;
-
- if ($have_marker)
- {
- $verbose && print STDERR "$program: Warning - already converted\n";
-
- while(<$handle>)
- {
- print;
- }
- }
- else
- {
- $seen_trailer = 0;
-
- while(<$handle>)
- {
- if ($dict_line)
- {
- next if (/$dict_line/o);
- $seen_trailer = 1 if (/^%%Trailer/);
- next if ($seen_trailer and /^end/);
- }
-
- print;
-
- if (/^%%Page:/)
- {
- print "$dict_name begin\n";
- }
- elsif (/^showpage/)
- {
- print "end\n";
- }
- elsif (/^%%BeginResource: procset (\S+)/)
- {
- $dict_name = $1;
- $dict_line = "^$dict_name begin";
- }
- elsif (/^%%BeginProcSet: (\S+)/)
- {
- $dict_name = $1;
- $dict_line = "^$dict_name begin";
- }
- elsif (/^%%EndProlog:/)
- {
- unless ($dict_line)
- {
- $verbose &&
- print STDERR "$program: Warning - unrecognised document structure\n";
- }
- }
- }
- }
-
- exit 0;
-
-
-
-
-
-
-
- sub read_comments
- {
- @headers = ();
-
- while (<$handle>)
- {
- push(@headers, $_);
- if (/^%LOCALGhostviewPatched/)
- {
- $have_marker = 1;
- }
- last if /^%%EndComments/;
- }
- }
-
-
-
- sub put_comments
- {
- foreach $h (@headers)
- {
- if (!$have_marker and ($h =~ /^%%EndComments/))
- {
- print "%LOCALGhostviewPatched\n";
- }
- print $h;
- }
- }
|