1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-22 04:17:44 +00:00
freebsd-ports/graphics/pgplot/files/xf77
1999-09-22 19:30:45 +00:00

72 lines
1.1 KiB
Perl

#!/usr/bin/perl
$ftxt = "ipercent_val";
$ctxt = $ftxt . "__";
$myname = $0;
@names = ();
$count = 0;
while ($ARGV[0] =~ /^-/) {
$opt .= " $ARGV[0]";
if ($ARGV[0] eq "-o") {
shift;
$opt .= " $ARGV[0]";
}
shift;
}
if ("$opt" eq " -1") {&phase1;}
elsif ("$opt" eq " -2") {&phase2;}
else {
$src = $ARGV[0];
$tmp = $src;
$tmp =~ s:.*/::;
$tmp =~ s:f$:c:;
$tmp = "/tmp/$tmp";
system "$myname -1 < $src | f2c -f | $myname -2 > $tmp";
system "cc -c $opt $tmp";
unlink $tmp;
}
exit 0;
sub phase1 {
while (<>) {
s/%[Vv][Aa][Ll]/$ftxt/g;
print $_;
}
}
sub phase2 {
while (<>) {
if (/(\s*)(\w*)(\s*=\s*)($ctxt)/) {
$p = $2;
s/$ctxt\(&/\(/;
$names[$count] = $p;
$count++;
print $_;
} else {
if ($count && /(\s*)(\w*)_\(/) {
&repl ($_);
} else {
print $_;
}
}
}
}
sub repl {
$l = shift;
while ($l) {
foreach (@names) {
$l =~ s/&$_/$_/g;
}
print $l;
if ($l =~ /\);/) {
@names = ();
$count = 0;
return;
}
$l = <>;
}
}