summaryrefslogtreecommitdiff
path: root/utils/h2ph.PL
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2001-07-13 21:19:34 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2001-07-13 21:19:34 +0000
commite7cba2baf60b94f416f28ee32799a957707400d8 (patch)
tree9fdd67484f526125524f54ff7e0f1d75367e64b4 /utils/h2ph.PL
parent83f427f7167a4592d110171dc3016bab01e4e106 (diff)
downloadperl-e7cba2baf60b94f416f28ee32799a957707400d8.tar.gz
Handle glibc style of constant definitions using enum
with intervening #defines; from Brendan O'Dea. p4raw-id: //depot/perl@11363
Diffstat (limited to 'utils/h2ph.PL')
-rw-r--r--utils/h2ph.PL12
1 files changed, 8 insertions, 4 deletions
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
index f647831a53..7cc3055ecd 100644
--- a/utils/h2ph.PL
+++ b/utils/h2ph.PL
@@ -238,15 +238,19 @@ while (defined (my $file = next_file())) {
} elsif(/^ident\s+(.*)/) {
print OUT $t, "# $1\n";
}
- } elsif(/^\s*(typedef\s*)?enum\s*(\s+[a-zA-Z_]\w*\s*)?\{/) {
- until(/\}.*?;/) {
- chomp($next = <IN>);
+ } elsif(/^\s*(typedef\s*)?enum\s*(\s+[a-zA-Z_]\w*\s*)?/) {
+ until(/\{[^}]*\}.*;/ || /;/) {
+ last unless defined ($next = <IN>);
+ chomp $next;
+ # drop "#define FOO FOO" in enums
+ $next =~ s/^\s*#\s*define\s+(\w+)\s+\1\s*$//;
$_ .= $next;
print OUT "# $next\n" if $opt_D;
}
+ s/#\s*if.*?#\s*endif//g; # drop #ifdefs
s@/\*.*?\*/@@g;
s/\s+/ /g;
- /^\s?(typedef\s?)?enum\s?([a-zA-Z_]\w*)?\s?\{(.*)\}\s?([a-zA-Z_]\w*)?\s?;/;
+ next unless /^\s?(typedef\s?)?enum\s?([a-zA-Z_]\w*)?\s?\{(.*)\}\s?([a-zA-Z_]\w*)?\s?;/;
(my $enum_subs = $3) =~ s/\s//g;
my @enum_subs = split(/,/, $enum_subs);
my $enum_val = -1;