~ubuntu-branches/ubuntu/maverick/openssl/maverick

« back to all changes in this revision

Viewing changes to util/mkdef.pl

  • Committer: Bazaar Package Importer
  • Author(s): Kurt Roeckx
  • Date: 2006-05-15 16:00:58 UTC
  • mto: (11.1.1 lenny)
  • mto: This revision was merged to the branch mainline in revision 6.
  • Revision ID: james.westby@ubuntu.com-20060515160058-pg6lnbkkpkwpdj2e
Tags: upstream-0.9.8b
ImportĀ upstreamĀ versionĀ 0.9.8b

Show diffs side-by-side

added added

removed removed

Lines of Context:
145
145
                $do_crypto=1;
146
146
                $libname=$_;
147
147
        }
 
148
        $no_static_engine=1 if $_ eq "no-static-engine";
 
149
        $no_static_engine=0 if $_ eq "enable-static-engine";
148
150
        $do_update=1 if $_ eq "update";
149
151
        $do_rewrite=1 if $_ eq "rewrite";
150
152
        $do_ctest=1 if $_ eq "ctest";
450
452
                                next;
451
453
                        }
452
454
 
453
 
                        $cpp = 1 if /^\#.*ifdef.*cplusplus/;
 
455
                        if(/\/\*/) {
 
456
                                if (not /\*\//) {       # multiline comment...
 
457
                                        $line = $_;     # ... just accumulate
 
458
                                        next;
 
459
                                } else {
 
460
                                        s/\/\*.*?\*\///gs;# wipe it
 
461
                                }
 
462
                        }
 
463
 
454
464
                        if ($cpp) {
455
 
                                $cpp = 0 if /^\#.*endif/;
 
465
                                $cpp++ if /^#\s*if/;
 
466
                                $cpp-- if /^#\s*endif/;
456
467
                                next;
457
468
                        }
 
469
                        $cpp = 1 if /^#.*ifdef.*cplusplus/;
458
470
 
459
 
                        s/\/\*.*?\*\///gs;                   # ignore comments
460
 
                        if (/\/\*/) {                        # if we have part
461
 
                                $line = $_;                  # of a comment,
462
 
                                next;                        # continue reading
463
 
                        }
464
471
                        s/{[^{}]*}//gs;                      # ignore {} blocks
465
472
                        print STDERR "DEBUG: \$def=\"$def\"\n" if $debug && $def ne "";
466
473
                        print STDERR "DEBUG: \$_=\"$_\"\n" if $debug;
738
745
                                        $def .= "int i2d_$1_NDEF(void);";
739
746
                                } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
740
747
                                        next;
 
748
                                } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION\s*\(\s*(\w*)\s*\)/) {
 
749
                                        $def .= "int $1_print_ctx(void);";
 
750
                                        next;
 
751
                                } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
 
752
                                        $def .= "int $2_print_ctx(void);";
 
753
                                        next;
741
754
                                } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) {
742
755
                                        next;
743
756
                                } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
830
843
                        next if(/typedef\W/);
831
844
                        next if(/\#define/);
832
845
 
 
846
                        # Reduce argument lists to empty ()
 
847
                        # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {}
 
848
                        while(/\(.*\)/s) {
 
849
                                s/\([^\(\)]+\)/\{\}/gs;
 
850
                                s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs;    #(*f{}) -> f
 
851
                        }
 
852
                        # pretend as we didn't use curly braces: {} -> ()
 
853
                        s/\{\}/\(\)/gs;
 
854
 
 
855
                        s/STACK_OF\(\)/void/gs;
 
856
 
833
857
                        print STDERR "DEBUG: \$_ = \"$_\"\n" if $debug;
834
858
                        if (/^\#INFO:([^:]*):(.*)$/) {
835
859
                                $plats = $1;
840
864
                                $s = $1;
841
865
                                $k = "VARIABLE";
842
866
                                print STDERR "DEBUG: found external variable $s\n" if $debug;
843
 
                        } elsif (/\(\*(\w*(\{[0-9]+\})?)\([^\)]+/) {
844
 
                                $s = $1;
845
 
                                print STDERR "DEBUG: found ANSI C function $s\n" if $debug;
846
 
                        } elsif (/\w+\W+(\w+)\W*\(\s*\)(\s*__attribute__\(.*\)\s*)?$/s) {
847
 
                                # K&R C
848
 
                                print STDERR "DEBUG: found K&R C function $s\n" if $debug;
 
867
                        } elsif (/TYPEDEF_\w+_OF/s) {
849
868
                                next;
850
 
                        } elsif (/\w+\W+\w+(\{[0-9]+\})?\W*\(.*\)(\s*__attribute__\(.*\)\s*)?$/s) {
851
 
                                while (not /\(\)(\s*__attribute__\(.*\)\s*)?$/s) {
852
 
                                        s/[^\(\)]*\)(\s*__attribute__\(.*\)\s*)?$/\)/s;
853
 
                                        s/\([^\(\)]*\)\)(\s*__attribute__\(.*\)\s*)?$/\)/s;
854
 
                                }
855
 
                                s/\(void\)//;
856
 
                                /(\w+(\{[0-9]+\})?)\W*\(\)/s;
857
 
                                $s = $1;
 
869
                        } elsif (/(\w+)\s*\(\).*/s) {   # first token prior [first] () is
 
870
                                $s = $1;                # a function name!
858
871
                                print STDERR "DEBUG: found function $s\n" if $debug;
859
 
 
860
 
                        } elsif (/TYPEDEF_\w+_OF/) {
861
 
                                next;
862
872
                        } elsif (/\(/ and not (/=/)) {
863
873
                                print STDERR "File $file: cannot parse: $_;\n";
864
874
                                next;