]> git.ipfire.org Git - thirdparty/gcc.git/blame - contrib/filter_knr2ansi.pl
PR c++/87554 - ICE with extern template and reference member.
[thirdparty/gcc.git] / contrib / filter_knr2ansi.pl
CommitLineData
4ee9c684 1#!/usr/bin/perl
2#
69cb9f90 3# Goes through the input line by line to find K&R style function
4ee9c684 4# declarations, and replaces them with ANSI style declarations.
5#
6@blah = <>;
7
8for ($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
41for ($i = 0; $i < @blah; $i++)
42{
43 print $blah[$i];
44}
45