K2.6 patches and update.
[tomato.git] / release / src / router / openssl / util / ck_errf.pl
blobf13af5c50b4ec80095dbdb82970cdea3cb41bf8f
1 #!/usr/local/bin/perl
3 # This is just a quick script to scan for cases where the 'error'
4 # function name in a XXXerr() macro is wrong.
5 #
6 # Run in the top level by going
7 # perl util/ck_errf.pl */*.c */*/*.c
10 my $err_strict = 0;
11 my $bad = 0;
13 foreach $file (@ARGV)
15 if ($file eq "-strict")
17 $err_strict = 1;
18 next;
20 open(IN,"<$file") || die "unable to open $file\n";
21 $func="";
22 while (<IN>)
24 if (!/;$/ && /^([a-zA-Z].*[\s*])?([A-Za-z_0-9]+)\(.*[),]/)
26 /^([^()]*(\([^()]*\)[^()]*)*)\(/;
27 $1 =~ /([A-Za-z_0-9]*)$/;
28 $func = $1;
29 $func =~ tr/A-Z/a-z/;
31 if (/([A-Z0-9]+)err\(([^,]+)/ && ! /ckerr_ignore/)
33 $errlib=$1;
34 $n=$2;
36 if ($func eq "")
37 { print "$file:$.:???:$n\n"; $bad = 1; next; }
39 if ($n !~ /([^_]+)_F_(.+)$/)
41 # print "check -$file:$.:$func:$n\n";
42 next;
44 $lib=$1;
45 $n=$2;
47 if ($lib ne $errlib)
48 { print "$file:$.:$func:$n [${errlib}err]\n"; $bad = 1; next; }
50 $n =~ tr/A-Z/a-z/;
51 if (($n ne $func) && ($errlib ne "SYS"))
52 { print "$file:$.:$func:$n\n"; $bad = 1; next; }
53 # print "$func:$1\n";
56 close(IN);
59 if ($bad && $err_strict)
61 print STDERR "FATAL: error discrepancy\n";
62 exit 1;