summaryrefslogtreecommitdiff
path: root/Porting/fixvars
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1998-07-21 10:26:01 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-07-21 10:26:01 +0000
commit2bd2b9e04a68ec86766c4219cf4da7f0d3168395 (patch)
treefeb11c93f6fed81991107bc208769dbb695ece5a /Porting/fixvars
parentdb15561cb83ed8e36f76d63e4283fc51c30fd71f (diff)
downloadperl-2bd2b9e04a68ec86766c4219cf4da7f0d3168395.tar.gz
final tweaks before beta2
p4raw-id: //depot/perl@1613
Diffstat (limited to 'Porting/fixvars')
-rwxr-xr-xPorting/fixvars69
1 files changed, 69 insertions, 0 deletions
diff --git a/Porting/fixvars b/Porting/fixvars
new file mode 100755
index 0000000000..a211e5816f
--- /dev/null
+++ b/Porting/fixvars
@@ -0,0 +1,69 @@
+#!/usr/local/bin/perl -w
+use Data::Dumper;
+
+my $targ = (@ARGV) ? join(' ',@ARGV) : 'miniperl' ;
+
+my $work = 1;
+while ($work)
+ {
+ open(PIPE,"make $targ 2>&1 |") || die "Cannot open pipe to make:$!";
+ my %fix;
+ while (<PIPE>)
+ {
+ if (/^(.*):(\d+):\s+\`(\w+)'\s+undeclared/ && -f $1 )
+ {
+ my ($file,$line,$var) = ($1,$2,$3);
+ $fix{$file} = [] unless exists $fix{$file};
+ push(@{$fix{$file}},[$line => $var]) unless ($var =~ /^PL_/ || $file =~ /\.h$/);
+ }
+ print;
+ }
+ close(PIPE);
+ warn "Make retured $?\n";
+ last unless $?;
+ my $changed = 0;
+ foreach my $file (keys %fix)
+ {
+ my @ar = sort( { $a->[0] <=> $b->[0] } @{delete $fix{$file}});
+ my @miss;
+ my $fixed = 0;
+ unless (-w $file)
+ {
+ system("d4","edit",$file);
+ }
+ @ARGV = ($file);
+ $. = 0;
+ local $^I = '.sav';
+ while (<>)
+ {
+ while (@ar && $. == $ar[0][0])
+ {
+ my ($line,$var) = @{shift(@ar)};
+ if (s/\b$var\b/PL_$var/)
+ {
+ warn "$file:$line: FIX $var\n";
+ $fixed++;
+ $changed++;
+ }
+ else
+ {
+ push(@miss,[$line,$var,$_]);
+ }
+ }
+ print;
+ }
+ unless ($fixed)
+ {
+ rename("$file$^I",$file);
+ if (@miss)
+ {
+ while (@miss)
+ {
+ my ($line,$var,$txt) = @{shift(@miss)};
+ warn "$file:$line:$var | $txt";
+ }
+ }
+ }
+ }
+ last unless $changed;
+ }