Read function names from C source files.
authorDr. Stephen Henson <steve@openssl.org>
Tue, 3 Nov 2015 13:52:45 +0000 (13:52 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Thu, 5 Nov 2015 15:48:37 +0000 (15:48 +0000)
In mkerr.pl read parse functions names in C source files and use
them for translation and sanity checks.

Reviewed-by: Richard Levitte <levitte@openssl.org>
util/mkerr.pl

index 8a51588c881495f3317e1c3ec79da86db12291da..95f288304ec9e63ac6da084bbcf000c26ea77b6a 100644 (file)
@@ -328,9 +328,18 @@ foreach $file (@source) {
        next if exists $cskip{$file};
        print STDERR "File loaded: ".$file."\r" if $debug;
        open(IN, "<$file") || die "Can't open source file $file\n";
+       my $func;
+       my $linenr = 0;
        while(<IN>) {
                # skip obsoleted source files entirely!
                last if(/^#error\s+obsolete/);
+               $linenr++;
+               if (!/;$/ && /^\**([a-zA-Z_].*[\s*])?([A-Za-z_0-9]+)\(.*([),]|$)/)
+                       {
+                       /^([^()]*(\([^()]*\)[^()]*)*)\(/;
+                       $1 =~ /([A-Za-z_0-9]*)$/;
+                       $func = $1;
+                       }
 
                if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) {
                        next unless exists $csrc{$2};
@@ -340,7 +349,11 @@ foreach $file (@source) {
                                $fcodes{$1} = "X";
                                $fnew{$2}++;
                        }
-                       $notrans{$1} = 1 unless exists $ftrans{$3};
+                       $ftrans{$3} = $func unless exists $ftrans{$3};
+            if (uc $func ne $3) {
+                print STDERR "ERROR: mismatch $file:$linenr $func:$3\n";
+                $errcount++;
+            }
                        print STDERR "Function: $1\t= $fcodes{$1} (lib: $2, name: $3)\n" if $debug; 
                }
                if(/(([A-Z0-9]+)_R_[A-Z0-9_]+)/) {