bss_log has dollars, so compile it with that warning flag disabled.
[openssl.git] / util / mkerr.pl
index 4b3bccb13e745b367a2b3db18f26c32f644fd7e1..8e18f3c2dff8d4c75fbf3a3a4c5b6d0279a8c028 100644 (file)
@@ -284,6 +284,17 @@ EOF
 
        # Rewrite the C source file containing the error details.
 
+       # First, read any existing reason string definitions:
+       my %err_reason_strings;
+       if (open(IN,"<$cfile")) {
+               while (<IN>) {
+                       if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) {
+                               $err_reason_strings{$1} = $2;
+                       }
+               }
+               close(IN);
+       }
+
        my $hincf;
        if($static) {
                $hfile =~ /([^\/]+)$/;
@@ -352,7 +363,8 @@ EOF
  */
 
 /* NOTE: this file was auto generated by the mkerr.pl script: any changes
- * made to it will be overwritten when the script next updates this file.
+ * made to it will be overwritten when the script next updates this file,
+ * only reason strings will be preserved.
  */
 
 #include <stdio.h>
@@ -385,9 +397,13 @@ EOF
        foreach $i (@reasons) {
                my $rn;
                my $nspc = 0;
-               $i =~ /^${lib}_R_(\S+)$/;
-               $rn = $1;
-               $rn =~ tr/_[A-Z]/ [a-z]/;
+               if (exists $err_reason_strings{$i}) {
+                       $rn = $err_reason_strings{$i};
+               } else {
+                       $i =~ /^${lib}_R_(\S+)$/;
+                       $rn = $1;
+                       $rn =~ tr/_[A-Z]/ [a-z]/;
+               }
                $nspc = 40 - length($i) unless length($i) > 40;
                $nspc = " " x $nspc;
                print OUT "{${i}${nspc},\"$rn\"},\n";
@@ -450,7 +466,7 @@ void ERR_load_${lib}_strings(void)
 #ifdef ${lib}_LIB_NAME
                ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0);
                ERR_load_strings(0,${lib}_lib_name);
-#endif;
+#endif
                }
        }
 
@@ -465,7 +481,7 @@ EOF
 }
 
        close OUT;
-
+       undef %err_reason_strings;
 }
 
 if($debug && defined(%notrans)) {