]>
Commit | Line | Data |
---|---|---|
d02b48c6 RE |
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 | ||
3ed3603b DSH |
10 | my $err_strict = 0; |
11 | my $bad = 0; | |
12 | ||
d02b48c6 RE |
13 | foreach $file (@ARGV) |
14 | { | |
3ed3603b DSH |
15 | if ($file eq "-strict") |
16 | { | |
17 | $err_strict = 1; | |
18 | next; | |
19 | } | |
d02b48c6 RE |
20 | open(IN,"<$file") || die "unable to open $file\n"; |
21 | $func=""; | |
22 | while (<IN>) | |
23 | { | |
0223ca09 | 24 | if (!/;$/ && /^\**([a-zA-Z_].*[\s*])?([A-Za-z_0-9]+)\(.*([),]|$)/) |
d02b48c6 | 25 | { |
8afca8d9 BM |
26 | /^([^()]*(\([^()]*\)[^()]*)*)\(/; |
27 | $1 =~ /([A-Za-z_0-9]*)$/; | |
28 | $func = $1; | |
d02b48c6 RE |
29 | $func =~ tr/A-Z/a-z/; |
30 | } | |
5c95c2ac | 31 | if (/([A-Z0-9]+)err\(([^,]+)/ && ! /ckerr_ignore/) |
d02b48c6 | 32 | { |
d02b48c6 RE |
33 | $errlib=$1; |
34 | $n=$2; | |
8afca8d9 BM |
35 | |
36 | if ($func eq "") | |
3ed3603b | 37 | { print "$file:$.:???:$n\n"; $bad = 1; next; } |
8afca8d9 | 38 | |
d02b48c6 RE |
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) | |
3ed3603b | 48 | { print "$file:$.:$func:$n [${errlib}err]\n"; $bad = 1; next; } |
d02b48c6 RE |
49 | |
50 | $n =~ tr/A-Z/a-z/; | |
51 | if (($n ne $func) && ($errlib ne "SYS")) | |
3ed3603b | 52 | { print "$file:$.:$func:$n\n"; $bad = 1; next; } |
d02b48c6 RE |
53 | # print "$func:$1\n"; |
54 | } | |
55 | } | |
dfeab068 | 56 | close(IN); |
d02b48c6 RE |
57 | } |
58 | ||
3ed3603b DSH |
59 | if ($bad && $err_strict) |
60 | { | |
61 | print STDERR "FATAL: error discrepancy\n"; | |
62 | exit 1; | |
63 | } | |
64 |