X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=utils%2Fh2ph.PL;h=79039968768eb920be038e3497298af89ff9914d;hb=7589e17d81493a7065648e700081a252e10a5c33;hp=7cc3055ecd6b4fd2afeb3098c2e15fa77d91f2c0;hpb=e7cba2baf60b94f416f28ee32799a957707400d8;p=p5sagit%2Fp5-mst-13.2.git diff --git a/utils/h2ph.PL b/utils/h2ph.PL index 7cc3055..7903996 100644 --- a/utils/h2ph.PL +++ b/utils/h2ph.PL @@ -240,7 +240,7 @@ while (defined (my $file = next_file())) { } } elsif(/^\s*(typedef\s*)?enum\s*(\s+[a-zA-Z_]\w*\s*)?/) { until(/\{[^}]*\}.*;/ || /;/) { - last unless defined ($next = ); + last unless defined ($next = next_line()); chomp $next; # drop "#define FOO FOO" in enums $next =~ s/^\s*#\s*define\s+(\w+)\s+\1\s*$//; @@ -338,7 +338,7 @@ sub expr { # Eliminate typedefs /\(([\w\s]+)[\*\s]*\)\s*[\w\(]/ && do { foreach (split /\s+/, $1) { # Make sure all the words are types, - last unless ($isatype{$_} or $_ eq 'struct'); + last unless ($isatype{$_} or $_ eq 'struct' or $_ eq 'union'); } s/\([\w\s]+[\*\s]*\)// && next; # then eliminate them. }; @@ -361,7 +361,7 @@ sub expr { }; s/^([_a-zA-Z]\w*)// && do { my $id = $1; - if ($id eq 'struct') { + if ($id eq 'struct' || $id eq 'union') { s/^\s+(\w+)//; $id .= ' ' . $1; $isatype{$id} = 1; @@ -438,7 +438,7 @@ sub next_line } elsif ($in =~ s/^("(\\.|[^"\\])*")//) { # "... $out .= $1; } elsif ($in =~ s/^\/\/.*//) { # //... - last READ; + # fall through } elsif ($in =~ m/^\/\*/) { # /*... # C comment removal adapted from perlfaq6: if ($in =~ s/^\/\*[^*]*\*+([^\/*][^*]*\*+)*\///) { @@ -455,7 +455,7 @@ sub next_line } } - last READ; + last READ if $out =~ /\S/; } return $out; @@ -610,9 +610,9 @@ sub build_preamble_if_necessary print PREAMBLE "# $_=$define{$_}\n"; } - if ($define{$_} =~ /^\d+$/) { + if ($define{$_} =~ /^(\d+)U?L{0,2}$/i) { print PREAMBLE - "unless (defined &$_) { sub $_() { $define{$_} } }\n\n"; + "unless (defined &$_) { sub $_() { $1 } }\n\n"; } elsif ($define{$_} =~ /^\w+$/) { print PREAMBLE "unless (defined &$_) { sub $_() { &$define{$_} } }\n\n";