New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
h2xs generates incorrect code for Makefile.PL for enums #7602
Comments
From akolb@sun.comCreated by akolb@sun.comThe h2xs generates the following part of Makefile.PL for both #define and enum my $generate_code = This produce an entry in the Makefile.PL: my @names = (qw(bar_enum def_bar def_foo foo_enum)); ExtUtils::Constant::WriteConstants( The ExtUtils::Constant module treats all simple names as #defines and for #ifdef bar_enum for enums which do not have the name defined. Instead, for enum constants it my @names = (qw(def_bar def_foo), ExtUtils::Constant::WriteConstants( which will generate correct code for #defines and enums. Perl Info
|
From sitz@onastick.netI got hit with this problem as well; the attached patch takes care of it |
From sitz@onastick.neth2xs.patch--- h2xs-cvs 2005-01-17 00:29:53.826930528 -0500
+++ h2xs 2005-01-17 00:40:06.392806360 -0500
@@ -859,7 +859,6 @@
# Remove C and C++ comments
$src =~ s#/\*[^*]*\*+([^/*][^*]*\*+)*/|("(\\.|[^"\\])*"|'(\\.|[^'\\])*'|.[^/"'\\]*)#$2#gs;
-
while ($src =~ /(\benum\s*([\w_]*)\s*\{\s([\s\w=,]+)\})/gsc) {
my ($enum_name, $enum_body) =
$1 =~ /enum\s*([\w_]*)\s*\{\s([\s\w=,]+)\}/gs;
@@ -869,8 +868,9 @@
for my $item (split /,/, $enum_body) {
my ($key, $declared_val) = $item =~ /(\w+)\s*(?:=\s*(.*))?/;
$val = defined($declared_val) && length($declared_val) ? $declared_val : 1 + $val;
+ print "Matched $key ($val)\n" if $opt_d;
$seen_define{$key} = $declared_val;
- $const_names{$key}++;
+ $const_names{$key} = {name => $key, macro => 1};
}
} # while (...)
} # if (!defined $opt_e or $opt_e)
@@ -1035,6 +1035,11 @@
}
}
my @const_names = sort keys %const_names;
+my @const_keys = map {
+ ref($const_names{$_}) eq 'HASH'
+ ? $const_names{$_}
+ : $_
+ } sort keys(%const_names);
-d $modpmdir || mkpath([$modpmdir], 0, 0775);
open(PM, ">$modpmname") || die "Can't create $ext$modpname/$modpmname: $!\n";
@@ -1422,7 +1427,7 @@
XS_FILE => $xsfallback,
DEFAULT_TYPE => $opt_t,
NAME => $module,
- NAMES => \@const_names,
+ NAMES => \@const_keys,
);
print XS "#include \"$constscfname\"\n";
}
@@ -1906,7 +1911,7 @@
XS_FILE => $constsxsfname,
DEFAULT_TYPE => $opt_t,
NAME => $module,
- NAMES => \@const_names,
+ NAMES => \@const_keys,
);
print PL <<"END";
if (eval {require ExtUtils::Constant; 1}) {
|
The RT System itself - Status changed from 'new' to 'open' |
From @rgsakolb@sun.com (via RT) wrote:
I suppose this is a duplicate of bug #32491, which has been fixed by |
From sitz@onastick.netOn Wed, Jan 19, 2005 at 12:30:51PM +0100, Rafael Garcia-Suarez wrote:
Am I missing the glaringly obvious, or should this: $seen_define{$key} = $declared_val; read like this: $seen_define{$key} = $val; ? --noah |
From @rgsNoah wrote:
You're not ; it should. Thanks, applied as change #23822 to bleadperl. |
From xw5s-73y5@disposable.spamcon.org
No it isn't. If you look at sitz's patch, you'll see that the version There were previously (at least) two distinct problems: 1) for some Please read Alexander's original description of the problem. sitz's |
From xw5s-73y5@disposable.spamcon.org
Never mind that part of my comment, I had misapplied the patch. |
@smpeters - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#32498 (status was 'resolved')
Searchable as RT32498$
The text was updated successfully, but these errors were encountered: