This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: {PATCH] Re: Lexical scoping bug with EXPR for EXPR?
[perl5.git] / utils / h2ph.PL
index 4dab916..7903996 100644 (file)
@@ -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/^\/\/.*//) {                  # //...
-                next 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;