util/*.pl update from HEAD.

This commit is contained in:
Andy Polyakov 2006-01-02 14:08:22 +00:00
parent 3152861e81
commit c4ac37361e
3 changed files with 38 additions and 26 deletions

View 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, $_;

View File

@ -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;

View 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;