root/branches/vendor/third/perl/Porting/fixvars @ 20074

Revision 20074, 1.4 KB (checked in by zacheiss, 6 years ago)

Import perl 5.8.3.

  • Property svn:executable set to *
Line 
1#!/usr/bin/perl -w
2use Data::Dumper;
3
4my $targ = (@ARGV) ? join(' ',@ARGV) : 'miniperl' ;
5
6my $work = 1;
7while ($work)
8 {
9  open(PIPE,"make $targ 2>&1 |") || die "Cannot open pipe to make:$!";
10  my %fix;
11  while (<PIPE>)
12   {
13    if (/^(.*):(\d+):\s+\`(\w+)'\s+undeclared/ && -f $1 )
14     {
15      my ($file,$line,$var) = ($1,$2,$3);
16      $fix{$file} = [] unless exists $fix{$file}; 
17      push(@{$fix{$file}},[$line => $var]) unless ($var =~ /^PL_/ || $file =~ /\.h$/);
18     }
19    print;
20   }
21  close(PIPE);
22  warn "Make retured $?\n";
23  last unless $?;
24  my $changed = 0;
25  foreach my $file (keys %fix)
26   {         
27    my @ar = sort( { $a->[0] <=> $b->[0] } @{delete $fix{$file}});
28    my @miss;
29    my $fixed = 0;
30    unless (-w $file)
31     {
32      system("d4","edit",$file);
33     }             
34    @ARGV = ($file);
35    $. = 0;
36    local $^I = '.sav';
37    while (<>)
38     {
39      while (@ar && $. == $ar[0][0])
40       {
41        my ($line,$var) = @{shift(@ar)};
42        if (s/\b$var\b/PL_$var/)
43         {
44          warn "$file:$line: FIX $var\n"; 
45          $fixed++;
46          $changed++;
47         }
48        else
49         {
50          push(@miss,[$line,$var,$_]);
51         }
52       }
53      print;
54     }
55    unless ($fixed)
56     {
57      rename("$file$^I",$file);
58      if (@miss)
59       {
60        while (@miss)
61         {
62          my ($line,$var,$txt) = @{shift(@miss)};
63          warn "$file:$line:$var | $txt";
64         }
65       }
66     }   
67   }
68  last unless $changed;
69 }
Note: See TracBrowser for help on using the browser.