OSDN Git Service

* config/sol2.c (solaris_assemble_visibility): Declare decl, vis
[pf3gnuchains/gcc-fork.git] / contrib / filter_knr2ansi.pl
1 #!/usr/bin/perl
2 #
3 # Goes through the input line by line to find K&R style function
4 # declarations, and replaces them with ANSI style declarations.
5 #
6 @blah = <>;
7
8 for ($i = 0; $i < @blah; $i++)
9 {
10         if ($blah[$i] =~ /^([a-zA-Z_0-9]+)\s*\([^)]+\)\s*$/)
11         {
12                 $name = $1;
13                 $funci = $i;
14                 $blah[$funci]="$name (";
15                 $i++;
16                 $lastline = $i;
17                 while ($lastline < @blah && $blah[$lastline] !~ /^{/)
18                 {
19                         $lastline++;
20                 }
21                 $lastline--;
22                 while ($i < @blah && $blah[$i] !~ /^{/)
23                 {
24                         $arg = $blah[$i];
25                         if ($i != $lastline)
26                         {
27                                 $arg =~ s/;/,/g;
28                         }
29                         else
30                         {
31                                 $arg =~ s/;//g;
32                         }
33                         $blah[$i] = "";
34                         $blah[$funci] = "$blah[$funci]" . "$arg";
35                         $i++;
36                 }
37                 $blah[$funci] = "$blah[$funci]" . ")\n";
38         }
39 }
40
41 for ($i = 0; $i < @blah; $i++)
42 {
43         print $blah[$i];
44 }
45