1996-12-22 04:36:43 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
$ftxt = "ipercent_val";
|
|
|
|
$ctxt = $ftxt . "__";
|
|
|
|
$myname = $0;
|
|
|
|
|
|
|
|
@names = ();
|
|
|
|
$count = 0;
|
|
|
|
|
|
|
|
while ($ARGV[0] =~ /^-/) {
|
1998-10-05 03:06:04 +00:00
|
|
|
$opt .= " $ARGV[0]";
|
1996-12-22 04:36:43 +00:00
|
|
|
if ($ARGV[0] eq "-o") {
|
|
|
|
shift;
|
1998-10-05 03:06:04 +00:00
|
|
|
$opt .= " $ARGV[0]";
|
1996-12-22 04:36:43 +00:00
|
|
|
}
|
|
|
|
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)/) {
|
|
|
|
s/$ctxt\(&/\(/;
|
|
|
|
$names[$count] = $2;
|
|
|
|
$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 = <>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|