OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [contrib/] [filter_knr2ansi.pl] - Diff between revs 154 and 816

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 154 Rev 816
#!/usr/bin/perl
#!/usr/bin/perl
#
#
# Goes through the input line by line to find K&R style function
# Goes through the input line by line to find K&R style function
# declarations, and replaces them with ANSI style declarations.
# declarations, and replaces them with ANSI style declarations.
#
#
@blah = <>;
@blah = <>;
 
 
for ($i = 0; $i < @blah; $i++)
for ($i = 0; $i < @blah; $i++)
{
{
        if ($blah[$i] =~ /^([a-zA-Z_0-9]+)\s*\([^)]+\)\s*$/)
        if ($blah[$i] =~ /^([a-zA-Z_0-9]+)\s*\([^)]+\)\s*$/)
        {
        {
                $name = $1;
                $name = $1;
                $funci = $i;
                $funci = $i;
                $blah[$funci]="$name (";
                $blah[$funci]="$name (";
                $i++;
                $i++;
                $lastline = $i;
                $lastline = $i;
                while ($lastline < @blah && $blah[$lastline] !~ /^{/)
                while ($lastline < @blah && $blah[$lastline] !~ /^{/)
                {
                {
                        $lastline++;
                        $lastline++;
                }
                }
                $lastline--;
                $lastline--;
                while ($i < @blah && $blah[$i] !~ /^{/)
                while ($i < @blah && $blah[$i] !~ /^{/)
                {
                {
                        $arg = $blah[$i];
                        $arg = $blah[$i];
                        if ($i != $lastline)
                        if ($i != $lastline)
                        {
                        {
                                $arg =~ s/;/,/g;
                                $arg =~ s/;/,/g;
                        }
                        }
                        else
                        else
                        {
                        {
                                $arg =~ s/;//g;
                                $arg =~ s/;//g;
                        }
                        }
                        $blah[$i] = "";
                        $blah[$i] = "";
                        $blah[$funci] = "$blah[$funci]" . "$arg";
                        $blah[$funci] = "$blah[$funci]" . "$arg";
                        $i++;
                        $i++;
                }
                }
                $blah[$funci] = "$blah[$funci]" . ")\n";
                $blah[$funci] = "$blah[$funci]" . ")\n";
        }
        }
}
}
 
 
for ($i = 0; $i < @blah; $i++)
for ($i = 0; $i < @blah; $i++)
{
{
        print $blah[$i];
        print $blah[$i];
}
}
 
 
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.