From: Jarkko Hietaniemi Date: Fri, 13 Jul 2001 21:19:34 +0000 (+0000) Subject: Handle glibc style of constant definitions using enum X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e7cba2baf60b94f416f28ee32799a957707400d8;p=p5sagit%2Fp5-mst-13.2.git Handle glibc style of constant definitions using enum with intervening #defines; from Brendan O'Dea. p4raw-id: //depot/perl@11363 --- diff --git a/utils/h2ph.PL b/utils/h2ph.PL index f647831..7cc3055 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 = ); + } elsif(/^\s*(typedef\s*)?enum\s*(\s+[a-zA-Z_]\w*\s*)?/) { + until(/\{[^}]*\}.*;/ || /;/) { + last unless defined ($next = ); + 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;