No fprintf in the txt_db component
[openssl.git] / util / ck_errf.pl
1 #!/usr/local/bin/perl
2 #
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
8 #
9
10 my $err_strict = 0;
11 my $bad = 0;
12
13 foreach $file (@ARGV)
14         {
15         if ($file eq "-strict")
16                 {
17                 $err_strict = 1;
18                 next;
19                 }
20         open(IN,"<$file") || die "unable to open $file\n";
21         $func="";
22         while (<IN>)
23                 {
24                 if (!/;$/ && /^\**([a-zA-Z_].*[\s*])?([A-Za-z_0-9]+)\(.*([),]|$)/)
25                         {
26                         /^([^()]*(\([^()]*\)[^()]*)*)\(/;
27                         $1 =~ /([A-Za-z_0-9]*)$/;
28                         $func = $1;
29                         $func =~ tr/A-Z/a-z/;
30                         }
31                 if (/([A-Z0-9]+)err\(([^,]+)/ && ! /ckerr_ignore/)
32                         {
33                         $errlib=$1;
34                         $n=$2;
35
36                         if ($func eq "")
37                                 { print "$file:$.:???:$n\n"; $bad = 1; next; }
38
39                         if ($n !~ /([^_]+)_F_(.+)$/)
40                                 {
41                 #               print "check -$file:$.:$func:$n\n";
42                                 next;
43                                 }
44                         $lib=$1;
45                         $n=$2;
46
47                         if ($lib ne $errlib)
48                                 { print "$file:$.:$func:$n [${errlib}err]\n"; $bad = 1; next; }
49
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";
54                         }
55                 }
56         close(IN);
57         }
58
59 if ($bad && $err_strict)
60         {
61         print STDERR "FATAL: error discrepancy\n";
62         exit 1;
63         }
64