Daily bump.
[gcc.git] / contrib / filter_knr2ansi.pl
blob6b43e407711c56583b18bacc5067ce3042d84e43
1 #!/usr/bin/perl
3 # Goes through the input line by line to find K&R style function
4 # declarations, and replaces them with ANSI style declarations.
6 @blah = <>;
8 for ($i = 0; $i < @blah; $i++)
10 if ($blah[$i] =~ /^([a-zA-Z_0-9]+)\s*\([^)]+\)\s*$/)
12 $name = $1;
13 $funci = $i;
14 $blah[$funci]="$name (";
15 $i++;
16 $lastline = $i;
17 while ($lastline < @blah && $blah[$lastline] !~ /^{/)
19 $lastline++;
21 $lastline--;
22 while ($i < @blah && $blah[$i] !~ /^{/)
24 $arg = $blah[$i];
25 if ($i != $lastline)
27 $arg =~ s/;/,/g;
29 else
31 $arg =~ s/;//g;
33 $blah[$i] = "";
34 $blah[$funci] = "$blah[$funci]" . "$arg";
35 $i++;
37 $blah[$funci] = "$blah[$funci]" . ")\n";
41 for ($i = 0; $i < @blah; $i++)
43 print $blah[$i];