home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume35
/
psutils
/
part04
/
fixmacps
< prev
next >
Wrap
Text File
|
1993-02-04
|
1KB
|
63 lines
#!/usr/local/bin/perl
# fixmacps: swap to sanitised appledict
$line = 0; # keep line count
$dir = "/usr/local/share/tex/dvips";
$prefix = "md";
$default = "appledict.ps";
while ($_ = shift(@ARGV)) {
if (/^-d(ir)?$/) { $dir = shift(@ARGV); }
if (/^-n(ame)?$/) { $prefix = shift(@ARGV); }
else {
unshift(@ARGV, $_);
last;
}
}
while (<>) {
if (/^%!/) {
if (! $line) {
print;
}
} elsif (/^%%BeginProcSet: "\(AppleDict md\)" ([0-9]+) ([0-9]+)$/) {
local($mdv, $mdr) = ($1, $2);
if (open(SANE, "<$dir/$prefix$mdv.$mdr.ps") ||
open(SANE, "<$dir/$default")) {
$sane = <SANE>;
local($snv, $snr) =
$sane =~ /^%%BeginProcSet: "\(AppleDict md\)" ([0-9]+) ([0-9]+)$/;
if ($mdv == $snv && $mdr == $snr) {
$ignore = 1;
} else {
print STDERR "Unrecognised AppleDict version $mdv $mdr\n";
print "%!\n" if !$line;
print;
}
} else {
print STDERR "Can't find sanitised AppleDict\n";
print "%!\n" if !$line;
print;
}
} elsif (/^%%EndProcSet/) {
if ($ignore) {
$ignore = 0;
print "%!\n" if !$line;
print $sane;
while(<SANE>) {
print;
}
close(SANE);
} else {
print "%!\n" if !$line;
print;
}
} else {
if (! $ignore) {
print "%!\n" if !$line;
print;
}
}
$line++;
}