This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix for [perl #32491] h2xs incorrectly parses enums with implicit values
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 14 Dec 2004 16:22:42 +0000 (16:22 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 14 Dec 2004 16:22:42 +0000 (16:22 +0000)
p4raw-id: //depot/perl@23652

utils/h2xs.PL

index ceac64e..b973705 100644 (file)
@@ -901,8 +901,8 @@ if( @path_h ){
             next if $opt_e && $enum_name =~ /$opt_e/;
             my $val = 0;
             for my $item (split /,/, $enum_body) {
-                my ($key, $declared_val) = $item =~ /(\w+)\s*=\s*(.*)/;
-                $val = length($declared_val) ? $declared_val : 1 + $val;
+                my ($key, $declared_val) = $item =~ /(\w+)\s*(?:=\s*(.*))?/;
+                $val = defined($declared_val) && length($declared_val) ? $declared_val : 1 + $val;
                 $seen_define{$key} = $declared_val;
                 $const_names{$key}++;
             }