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
[PATCH] h2ph produces incorrect code in preamble #10341
Comments
From r.m.barker@btinternet.comThe h2ph utility produces non-compiling code in its preamble, unless (defined &__INT64_C(c)) { sub __INT64_C(c)() { &cLL } } (note double prototype). The preamble also contains "&int" The patch fixes h2ph.PL to produce compiling code and fixes (Perhaps severity should be "low" because I guess no one is Perl Info
|
From rmbarker@cpan.org0009-Fix-h2ph-and-test.patchFrom 7010c9a4ee0dd0a6ff494670c45e04c98a1f8556 Mon Sep 17 00:00:00 2001
From: Robin Barker <rmbarker@cpan.org>
Date: Thu, 22 Apr 2010 11:51:20 +0100
Subject: [PATCH 9/9] Fix h2ph and test
---
lib/h2ph.t | 12 ++++++++++--
utils/h2ph.PL | 28 +++++++++++++++++++++++-----
2 files changed, 33 insertions(+), 7 deletions(-)
diff --git a/lib/h2ph.t b/lib/h2ph.t
index 27dd7b9..58885d3 100644
--- a/lib/h2ph.t
+++ b/lib/h2ph.t
@@ -18,7 +18,7 @@ if (!(-e $extracted_program)) {
exit 0;
}
-plan(4);
+plan(5);
# quickly compare two text files
sub txt_compare {
@@ -41,8 +41,16 @@ $result = runperl( progfile => 'lib/h2ph.pht',
stderr => 1 );
like( $result, qr/syntax OK$/, "output compiles");
+$result = runperl( progfile => '_h2ph_pre.ph',
+ switches => ['-c'],
+ stderr => 1 );
+like( $result, qr/syntax OK$/, "preample compiles");
+
$result = runperl( switches => ["-w"],
- prog => '$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht);');
+ stderr => 1,
+ prog => <<'PROG' );
+$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht);
+PROG
is( $result, '', "output free of warnings" );
# cleanup
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
index 8f56db4..474076e 100644
--- a/utils/h2ph.PL
+++ b/utils/h2ph.PL
@@ -401,7 +401,10 @@ if ($opt_e && (scalar(keys %bad_file) > 0)) {
exit $Exit;
sub expr {
- $new = '"(assembly code)"' and return if /\b__asm__\b/; # freak out.
+ if (/\b__asm__\b/) { # freak out
+ $new = '"(assembly code)"';
+ return
+ }
my $joined_args;
if(keys(%curargs)) {
$joined_args = join('|', keys(%curargs));
@@ -770,7 +773,7 @@ sub inc_dirs
sub build_preamble_if_necessary
{
# Increment $VERSION every time this function is modified:
- my $VERSION = 2;
+ my $VERSION = 3;
my $preamble = "$Dest_dir/_h2ph_pre.ph";
# Can we skip building the preamble file?
@@ -798,7 +801,16 @@ sub build_preamble_if_necessary
# parenthesized value: d=(v)
$define{$_} = $1;
}
- if ($define{$_} =~ /^([+-]?(\d+)?\.\d+([eE][+-]?\d+)?)[FL]?$/) {
+ if (/^(\w+)\((\w)\)$/) {
+ my($macro, $arg) = ($1, $2);
+ my $def = $define{$_};
+ $def =~ s/$arg/\$\{$arg\}/g;
+ print PREAMBLE <<DEFINE;
+unless (defined &$macro) { sub $macro(\$) { my (\$$arg) = \@_; \"$def\" } }
+
+DEFINE
+ } elsif
+ ($define{$_} =~ /^([+-]?(\d+)?\.\d+([eE][+-]?\d+)?)[FL]?$/) {
# float:
print PREAMBLE
"unless (defined &$_) { sub $_() { $1 } }\n\n";
@@ -807,8 +819,14 @@ sub build_preamble_if_necessary
print PREAMBLE
"unless (defined &$_) { sub $_() { $1 } }\n\n";
} elsif ($define{$_} =~ /^\w+$/) {
- print PREAMBLE
- "unless (defined &$_) { sub $_() { &$define{$_} } }\n\n";
+ my $def = $define{$_};
+ if ($isatype{$def}) {
+ print PREAMBLE
+ "unless (defined &$_) { sub $_() { \"$def\" } }\n\n";
+ } else {
+ print PREAMBLE
+ "unless (defined &$_) { sub $_() { &$def } }\n\n";
+ }
} else {
print PREAMBLE
"unless (defined &$_) { sub $_() { \"",
--
1.6.3.3
|
From @rgsThanks, applied to bleadperl. |
The RT System itself - Status changed from 'new' to 'open' |
@rgs - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#74614 (status was 'resolved')
Searchable as RT74614$
The text was updated successfully, but these errors were encountered: