Fix to allow multiple NONE libraries in mkerr.pl .
[openssl.git] / util / mkerr.pl
index 5f094a50826e869900741bcc0f34672f0f3df073..e812b9fc006d8b0194c0cf8955fc28743dccbd83 100644 (file)
@@ -38,7 +38,7 @@ while (@ARGV) {
 }
 
 if($recurse) {
 }
 
 if($recurse) {
-       @source = (<crypto/*.c>, <crypto/*/*.c>, <rsaref/*.c>, <ssl/*.c>);
+       @source = (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>);
 } else {
        @source = @ARGV;
 }
 } else {
        @source = @ARGV;
 }
@@ -53,6 +53,7 @@ while(<IN>)
 {
        if(/^L\s+(\S+)\s+(\S+)\s+(\S+)/) {
                $hinc{$1} = $2;
 {
        if(/^L\s+(\S+)\s+(\S+)\s+(\S+)/) {
                $hinc{$1} = $2;
+               $libinc{$2} = $1;
                $cskip{$3} = $1;
                if($3 ne "NONE") {
                        $csrc{$1} = $3;
                $cskip{$3} = $1;
                if($3 ne "NONE") {
                        $csrc{$1} = $3;
@@ -74,13 +75,16 @@ close IN;
 # Scan each header file in turn and make a list of error codes
 # and function names
 
 # Scan each header file in turn and make a list of error codes
 # and function names
 
-while (($lib, $hdr) = each %hinc)
+while (($hdr, $lib) = each %libinc)
 {
        next if($hdr eq "NONE");
        print STDERR "Scanning header file $hdr\n" if $debug; 
        open(IN, "<$hdr") || die "Can't open Header file $hdr\n";
 {
        next if($hdr eq "NONE");
        print STDERR "Scanning header file $hdr\n" if $debug; 
        open(IN, "<$hdr") || die "Can't open Header file $hdr\n";
-       my $line = "", $def= "";
+       my $line = "", $def= "", $linenr = 0;
        while(<IN>) {
        while(<IN>) {
+           $linenr++;
+           print STDERR "line: $linenr\r" if $debug;
+
            last if(/BEGIN\s+ERROR\s+CODES/);
            if ($line ne '') {
                $_ = $line . $_;
            last if(/BEGIN\s+ERROR\s+CODES/);
            if ($line ne '') {
                $_ = $line . $_;
@@ -110,7 +114,12 @@ while (($lib, $hdr) = each %hinc)
            }
        }
 
            }
        }
 
+       print STDERR "                                  \r" if $debug;
+        $defnr = 0;
        foreach (split /;/, $def) {
        foreach (split /;/, $def) {
+           $defnr++;
+           print STDERR "def: $defnr\r" if $debug;
+
            s/^[\n\s]*//g;
            s/[\n\s]*$//g;
            next if(/typedef\W/);
            s/^[\n\s]*//g;
            s/[\n\s]*$//g;
            next if(/typedef\W/);
@@ -136,6 +145,8 @@ while (($lib, $hdr) = each %hinc)
            }
        }
 
            }
        }
 
+       print STDERR "                                  \r" if $debug;
+
        next if $reindex;
 
        # Scan function and reason codes and store them: keep a note of the
        next if $reindex;
 
        # Scan function and reason codes and store them: keep a note of the
@@ -247,6 +258,7 @@ foreach $lib (keys %csrc)
 /* The following lines are auto generated by the script mkerr.pl. Any changes
  * made after this point may be overwritten when the script is next run.
  */
 /* The following lines are auto generated by the script mkerr.pl. Any changes
  * made after this point may be overwritten when the script is next run.
  */
+void ERR_load_${lib}_strings(void);
 
 /* Error codes for the $lib functions. */
 
 
 /* Error codes for the $lib functions. */
 
@@ -278,7 +290,6 @@ EOF
 }
 #endif
 #endif
 }
 #endif
 #endif
-
 EOF
        close OUT;
 
 EOF
        close OUT;
 
@@ -372,7 +383,7 @@ EOF
 #include $hincf
 
 /* BEGIN ERROR CODES */
 #include $hincf
 
 /* BEGIN ERROR CODES */
-#ifndef NO_ERR
+#ifndef OPENSSL_NO_ERR
 static ERR_STRING_DATA ${lib}_str_functs[]=
        {
 EOF
 static ERR_STRING_DATA ${lib}_str_functs[]=
        {
 EOF
@@ -422,7 +433,7 @@ void ERR_load_${lib}_strings(void)
        if (init)
                {
                init=0;
        if (init)
                {
                init=0;
-#ifndef NO_ERR
+#ifndef OPENSSL_NO_ERR
                ERR_load_strings(ERR_LIB_${lib},${lib}_str_functs);
                ERR_load_strings(ERR_LIB_${lib},${lib}_str_reasons);
 #endif
                ERR_load_strings(ERR_LIB_${lib},${lib}_str_functs);
                ERR_load_strings(ERR_LIB_${lib},${lib}_str_reasons);
 #endif
@@ -458,7 +469,7 @@ void ERR_load_${lib}_strings(void)
        if (init)
                {
                init=0;
        if (init)
                {
                init=0;
-#ifndef NO_ERR
+#ifndef OPENSSL_NO_ERR
                ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs);
                ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons);
 #endif
                ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs);
                ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons);
 #endif