]>
Commit | Line | Data |
---|---|---|
6de9cd9a DN |
1 | #!/usr/bin/perl |
2 | # | |
d0e71b9c | 3 | # Goes through the input line by line to find K&R style function |
6de9cd9a DN |
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 |