ck_errf.pl 993 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. foreach $file (@ARGV)
  10. {
  11. open(IN,"<$file") || die "unable to open $file\n";
  12. $func="";
  13. while (<IN>)
  14. {
  15. if (!/;$/ && /^\**([a-zA-Z].*[\s*])?([A-Za-z_0-9]+)\(.*([),]|$)/)
  16. {
  17. /^([^()]*(\([^()]*\)[^()]*)*)\(/;
  18. $1 =~ /([A-Za-z_0-9]*)$/;
  19. $func = $1;
  20. $func =~ tr/A-Z/a-z/;
  21. }
  22. if (/([A-Z0-9]+)err\(([^,]+)/)
  23. {
  24. $errlib=$1;
  25. $n=$2;
  26. if ($func eq "")
  27. { print "$file:$.:???:$n\n"; next; }
  28. if ($n !~ /([^_]+)_F_(.+)$/)
  29. {
  30. # print "check -$file:$.:$func:$n\n";
  31. next;
  32. }
  33. $lib=$1;
  34. $n=$2;
  35. if ($lib ne $errlib)
  36. { print "$file:$.:$func:$n [${errlib}err]\n"; next; }
  37. $n =~ tr/A-Z/a-z/;
  38. if (($n ne $func) && ($errlib ne "SYS"))
  39. { print "$file:$.:$func:$n\n"; next; }
  40. # print "$func:$1\n";
  41. }
  42. }
  43. close(IN);
  44. }