util/*.pl update from HEAD.
authorAndy Polyakov <appro@openssl.org>
Mon, 2 Jan 2006 14:08:22 +0000 (14:08 +0000)
committerAndy Polyakov <appro@openssl.org>
Mon, 2 Jan 2006 14:08:22 +0000 (14:08 +0000)
util/copy.pl
util/mkdef.pl
util/mkerr.pl

index 73ac928ed277a6ae3f8ada78a27cf4fa23793d3a..e20b45530a8f5f645ec2717cff6cf8c1e4d0187f 100644 (file)
@@ -11,6 +11,7 @@ use Fcntl;
 my $arg;
 
 foreach $arg (@ARGV) {
+       $arg =~ s|\\|/|g;       # compensate for bug/feature in cygwin glob...
        foreach (glob $arg)
                {
                push @filelist, $_;
index 8be2e39f541403dc4dfacfac56138cfef7bcd7dc..24386009bfbb217bdebe53f053f5bf61e23edf68 100755 (executable)
@@ -452,17 +452,22 @@ sub do_defs
                                next;
                        }
 
-                       $cpp = 1 if /^\#.*ifdef.*cplusplus/;
+                       if(/\/\*/) {
+                               if (not /\*\//) {       # multiline comment...
+                                       $line = $_;     # ... just accumulate
+                                       next;
+                               } else {
+                                       s/\/\*.*?\*\///gs;# wipe it
+                               }
+                       }
+
                        if ($cpp) {
-                               $cpp = 0 if /^\#.*endif/;
+                               $cpp++ if /^#\s*if/;
+                               $cpp-- if /^#\s*endif/;
                                next;
                        }
+                       $cpp = 1 if /^#.*ifdef.*cplusplus/;
 
-                       s/\/\*.*?\*\///gs;                   # ignore comments
-                       if (/\/\*/) {                        # if we have part
-                               $line = $_;                  # of a comment,
-                               next;                        # continue reading
-                       }
                        s/{[^{}]*}//gs;                      # ignore {} blocks
                        print STDERR "DEBUG: \$def=\"$def\"\n" if $debug && $def ne "";
                        print STDERR "DEBUG: \$_=\"$_\"\n" if $debug;
@@ -740,6 +745,12 @@ sub do_defs
                                        $def .= "int i2d_$1_NDEF(void);";
                                } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
                                        next;
+                               } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION\s*\(\s*(\w*)\s*\)/) {
+                                       $def .= "int $1_print_ctx(void);";
+                                       next;
+                               } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
+                                       $def .= "int $2_print_ctx(void);";
+                                       next;
                                } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) {
                                        next;
                                } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
@@ -832,6 +843,17 @@ sub do_defs
                        next if(/typedef\W/);
                        next if(/\#define/);
 
+                       # Reduce argument lists to empty ()
+                       # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {}
+                       while(/\(.*\)/s) {
+                               s/\([^\(\)]+\)/\{\}/gs;
+                               s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs;    #(*f{}) -> f
+                       }
+                       # pretend as we didn't use curly braces: {} -> ()
+                       s/\{\}/\(\)/gs;
+
+                       s/STACK_OF\(\)/void/gs;
+
                        print STDERR "DEBUG: \$_ = \"$_\"\n" if $debug;
                        if (/^\#INFO:([^:]*):(.*)$/) {
                                $plats = $1;
@@ -842,25 +864,11 @@ sub do_defs
                                $s = $1;
                                $k = "VARIABLE";
                                print STDERR "DEBUG: found external variable $s\n" if $debug;
-                       } elsif (/\(\*(\w*(\{[0-9]+\})?)\([^\)]+/) {
-                               $s = $1;
-                               print STDERR "DEBUG: found ANSI C function $s\n" if $debug;
-                       } elsif (/\w+\W+(\w+)\W*\(\s*\)(\s*__attribute__\(.*\)\s*)?$/s) {
-                               # K&R C
-                               print STDERR "DEBUG: found K&R C function $s\n" if $debug;
+                       } elsif (/TYPEDEF_\w+_OF/s) {
                                next;
-                       } elsif (/\w+\W+\w+(\{[0-9]+\})?\W*\(.*\)(\s*__attribute__\(.*\)\s*)?$/s) {
-                               while (not /\(\)(\s*__attribute__\(.*\)\s*)?$/s) {
-                                       s/[^\(\)]*\)(\s*__attribute__\(.*\)\s*)?$/\)/s;
-                                       s/\([^\(\)]*\)\)(\s*__attribute__\(.*\)\s*)?$/\)/s;
-                               }
-                               s/\(void\)//;
-                               /(\w+(\{[0-9]+\})?)\W*\(\)/s;
-                               $s = $1;
+                       } elsif (/(\w+)\s*\(\).*/s) {   # first token prior [first] () is
+                               $s = $1;                # a function name!
                                print STDERR "DEBUG: found function $s\n" if $debug;
-
-                       } elsif (/TYPEDEF_\w+_OF/) {
-                               next;
                        } elsif (/\(/ and not (/=/)) {
                                print STDERR "File $file: cannot parse: $_;\n";
                                next;
index 7e0bdff8cc3fa4fbded4782357157a3554fe2ed5..030899b7ab449f6cbfac737ef758477c4d1046d1 100644 (file)
@@ -143,11 +143,14 @@ while (($hdr, $lib) = each %libinc)
            s/[\n\s]*$//g;
 
            # Skip over recognized non-function declarations
-           next if(/typedef\W/ or /struct\W/ or /DECLARE_STACK_OF/ or /TYPEDEF_.*_OF/);
+           next if(/typedef\W/ or /DECLARE_STACK_OF/ or /TYPEDEF_.*_OF/);
 
            # Reduce argument lists to empty ()
            # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {}
-           while(/\(.*\)/s) { s/\([^\(\)]+\)/\{\}/gs; }
+           while(/\(.*\)/s) {
+               s/\([^\(\)]+\)/\{\}/gs;
+               s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs;    #(*f{}) -> f
+           }
            # pretend as we didn't use curly braces: {} -> ()
            s/\{\}/\(\)/gs;