X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=util%2Fmkstack.pl;h=6a43757c95bd96cb1c38d70006968699ef10831f;hp=30f1722312fc92b29abbb9c8b5133f5bbc471b6d;hb=cc0661374f032b788016300be8705feeca10a93a;hpb=e41c8d6ad4d1ffab51865d8cf90baff108bbe4a1 diff --git a/util/mkstack.pl b/util/mkstack.pl index 30f1722312..6a43757c95 100755 --- a/util/mkstack.pl +++ b/util/mkstack.pl @@ -1,112 +1,192 @@ #!/usr/local/bin/perl -w -# + # This is a utility that searches out "DECLARE_STACK_OF()" -# declarations in header files, and updates/creates/replaces -# the corresponding macro declarations that follow it. The -# reason is that with "DEBUG_SAFESTACK" defined, each type -# will generate 19 functions, all type-safe variants of the -# base "sk_***" functions for the general STACK type. Without -# DEBUG_SAFESTACK defined, we need to macro define all the -# "type'd sk_##type##_***" functions as mapping directly to -# the standard sk_*** equivalents. As it's not generally -# possible to have macros that generate macros, we need to -# control this from the "outside", here in this script. +# declarations in .h and .c files, and updates/creates/replaces +# the corresponding macro declarations in crypto/stack/safestack.h. +# As it's not generally possible to have macros that generate macros, +# we need to control this from the "outside", here in this script. # # Geoff Thorpe, June, 2000 (with massive Perl-hacking # help from Steve Robb) -my $type_thing; -my $recurse = 0; -my @files = @ARGV; +my $safestack = "crypto/stack/safestack"; +my $do_write; while (@ARGV) { my $arg = $ARGV[0]; - if($arg eq "-recurse") { - $recurse = 1; - shift @ARGV; - } else { - last; + if($arg eq "-write") { + $do_write = 1; } + shift @ARGV; } -if($recurse) { - @source = (, , , ); -} else { - @source = @ARGV; -} +@source = (, , , ); foreach $file (@source) { - # After "Configure" has been run, we need to make sure we don't - # overwrite symbollic links with new header files! next if -l $file; # Open the .c/.h file for reading open(IN, "< $file") || die "Can't open $file for reading: $!"; - open(OUT, "> $file.tmp") || die "Can't open $file.tmp for writing: $!"; - - select(OUT); - process_the_file(); - - close(OUT); - close(IN); - - unlink($file); - rename("$file.tmp", $file); -} - -sub process_the_file { - - my $inside_block = 0; - my $output_defines = 0; while() { if (/^DECLARE_STACK_OF\(([^)]+)\)/) { - $type_thing = $1; - $output_defines = 1; + push @stacklst, $1; } - if (m|^/\* This block of defines is updated by a perl script, please do not touch! \*/|) { - $inside_block = 1; + if (/^DECLARE_SPECIAL_STACK_OF\(([^,\s]+)\s*,\s*([^>\s]+)\)/) { + push @sstacklst, [$1, $2]; } - if (m|^/\* End of perl script block, you may now edit :-\) \*/|) { - $inside_block = 0; - } elsif ($inside_block == 0) { - print; + if (/^DECLARE_ASN1_SET_OF\(([^)]+)\)/) { + push @asn1setlst, $1; } - if($output_defines == 1) { - print <) { + $old_stackfile .= $_; + + if (m|^/\* This block of defines is updated by util/mkstack.pl, please do not touch! \*/|) { + $inside_block = 1; + } + if (m|^/\* End of util/mkstack.pl block, you may now edit :-\) \*/|) { + $inside_block = 0; + } elsif ($inside_block == 0) { + $new_stackfile .= $_; + } + next if($inside_block != 1); + $new_stackfile .= "/* This block of defines is updated by util/mkstack.pl, please do not touch! */"; + + foreach $type_thing (sort @stacklst) { + $new_stackfile .= <[0]; + my $t2 = $type_thing->[1]; + $new_stackfile .= <$safestack.h" || die "Can't open output file"; + print OUT $new_stackfile; + close OUT; }