Fix logs for last delta. Sorry for the screw-up.
[official-gcc.git] / contrib / filter_knr2ansi.pl
blobc05e8d2ed205a32ef4bcd08cdfb4ceac1ed194f6
1 #!/usr/bin/perl
3 # Goes thourgh 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];