Listtree.mcc: rename variables in Listtree_GetEntry to match the template of other...
[AROS.git] / tools / cxref / contrib / knr2ansi.pl
blobfbf17c18d65c06596a8ad8ebc515a39ed2035cf9
1 #!/bin/sh
3 exec perl -x $0 $*
5 #!perl
7 die "Usage: $0 <filename>\n" if($#ARGV==-1);
9 foreach $argv (@ARGV)
11 push(@files,$argv) if(-f $argv);
12 push(@args,$argv) if(! -f $argv);
15 $args=join(" ",@args);
17 foreach $file (@files)
19 open(CXREF,"cxref $args $file -raw |") || die "Cannot run cxref on $file\n";
21 $function=0;
22 $comment=0;
23 $functype="";
24 $funcname="";
25 @funcargs=();
27 @local=();
28 @global=();
30 while(<CXREF>)
32 if(m/^FUNCTION : ([a-z0-9A-Z_\$]+) \[([a-zA-Z]+)\]$/)
34 $function=1;
35 $functype="static " if($2 eq "Local");
36 $funcname=$1;
38 $comment=1 if($function && m/^<<<$/);
39 $comment=0 if($function && m/^>>>$/);
41 $functype.=substr($1,0,length($1)-length($funcname)-1) if($function && m/^Type: ([^<]+)( <|\n)/);
42 push(@funcargs,$1) if($function && m/^Arguments: ([^<]+)( <|\n)/);
44 if(!$comment && $function && (m/^$/ || m/^-+$/))
46 push(@funcargs,"void") if($#funcargs==-1);
48 $f="$functype $funcname(".join(",",@funcargs).");";
50 push(@local,$f) if($functype =~ m/static/);
51 push(@global,$f) if($functype !~ m/static/);
53 $functype="";
54 $funcname="";
55 @funcargs=();
56 $function=0;
60 close(CXREF);
62 # Output the results
64 print "\n /* local functions in $file */\n\n";
66 foreach $f (@local)
68 print "$f\n";
71 print "\n /* global functions in $file */\n\n";
73 foreach $f (@global)
75 print "$f\n";