my $config = "crypto/err/openssl.ec";
my $debug = 0;
my $rebuild = 0;
-my $static = 0;
+my $static = 1;
my $recurse = 0;
my $reindex = 0;
+my $dowrite = 0;
while (@ARGV) {
} elsif($arg eq "-reindex") {
$reindex = 1;
shift @ARGV;
- } elsif($arg eq "-static") {
- $static = 1;
+ } elsif($arg eq "-nostatic") {
+ $static = 0;
+ shift @ARGV;
+ } elsif($arg eq "-write") {
+ $dowrite = 1;
shift @ARGV;
} else {
last;
} elsif (/^R\s+(\S+)\s+(\S+)/) {
$rextra{$1} = $2;
$rcodes{$1} = $2;
- # Add extra reason with $1, value $2
}
}
foreach (split /;/, $def) {
s/^[\n\s]*//g;
s/[\n\s]*$//g;
- next if (/\w+\W+(\w+)\W*\(\s*\)$/s); # K&R C
- next if (/\(\*(\w*)\([^\)]+/);
- if (/\w+\W+\w+\W*\(.*\)$/s) {
+ next if(/typedef\W/);
+ if (/\(\*(\w*)\([^\)]+/) {
+ my $name = $1;
+ $name =~ tr/[a-z]/[A-Z]/;
+ $ftrans{$name} = $1;
+ } elsif (/\w+\W+(\w+)\W*\(\s*\)$/s){
+ # K&R C
+ next ;
+ } elsif (/\w+\W+\w+\W*\(.*\)$/s) {
while (not /\(\)$/s) {
s/[^\(\)]*\)$/\)/s;
s/\([^\(\)]*\)\)$/\)/s;
}
s/\(void\)//;
/(\w+)\W*\(\)/s;
- next if(/typedef\W/);
my $name = $1;
$name =~ tr/[a-z]/[A-Z]/;
$ftrans{$name} = $1;
-
} elsif (/\(/ and not (/=/ or /DECLARE_STACK/)) {
print STDERR "Header $hdr: cannot parse: $_;\n";
}
} else {
print STDERR "$lib:\t\t$fnew{$lib} New Functions,";
print STDERR " $rnew{$lib} New Reasons.\n";
-
+ next unless $dowrite;
}
# If we get here then we have some new error codes so we
# Rewrite the C source file containing the error details.
- $hfile =~ /([^\/]+)$/;
- my $hincf = $1;
+ # 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 =~ /([^\/]+)$/;
+ $hincf = "<openssl/$1>";
+ } else {
+ $hincf = "\"$hfile\"";
+ }
+
open (OUT,">$cfile") || die "Can't open $cfile for writing";
*/
/* 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>
#include <openssl/err.h>
-#include <openssl/$hincf>
+#include $hincf
/* BEGIN ERROR CODES */
#ifndef NO_ERR
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";
#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
}
}
}
close OUT;
-
+ undef %err_reason_strings;
}
if($debug && defined(%notrans)) {