diff options
Diffstat (limited to 'helpers')
-rwxr-xr-x | helpers/make_export.pl | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/helpers/make_export.pl b/helpers/make_export.pl new file mode 100755 index 000000000..d9ef5500d --- /dev/null +++ b/helpers/make_export.pl @@ -0,0 +1,73 @@ +#!/usr/bin/perl + +require "getopts.pl"; + +&Getopts( 'o:' ); + +if ($#ARGV < 0) { + die "Usage: -o <output_file> <input_files>"; +} + +if (!defined $opt_o) { + $opt_o = "apr.exports"; +} + +open (OUTFILE, ">$opt_o") || die "Can't open $opt_o $!\n"; + +while ($srcfile = shift(@ARGV)) { + my $line; + my $count; + my $found; + + open (FILE, $srcfile) || die "Can't open $srcfile\n"; + print STDERR "Reading \"$srcfile\"\n"; + + $count = 0; + $found = 0; + $line = ""; +# print OUTFILE "____$srcfile\n"; + while (<FILE>) { + chomp; + + s/^\s*//; + + if (/\#if (APR_HAS.*)/) { + $count++; + $found++; + $macro = $1; + $line = "$macro\n"; + next; + } + elsif (/^(APR_DECLARE[^\(]*\()?[a-z_]+\)?\s+([A-Za-z0-9_]+)\(/) { + # We only want to increase this if we are in the middle of a + # #if ... #endif block. + if ($found) { + $found++; + } + for (my $i=0; $i < $count; $i++) { + $line .= "\t"; + } + $line .= "$2\n"; + next; + } + elsif (/\#endif/) { + if ($count > 0) { + $count--; + $line .= "\\$macro\n"; + } + if ($found == 1) { + $found = 0; + $line = ""; + next; + } + elsif ($found > 1) { + $found = 0; + } + } + if ($line && !$found) { + print OUTFILE "$line"; + $line = ""; + } + } +} + |