1 From 8d66b3f930dc6d88b524d103e304308ae73a46e7 Mon Sep 17 00:00:00 2001
2 From: Robin Barker <rmbarker@cpan.org>
3 Date: Thu, 22 Apr 2010 11:51:20 +0100
4 Subject: [PATCH] Fix h2ph and test
7 lib/h2ph.t | 12 ++++++++++--
8 utils/h2ph.PL | 28 +++++++++++++++++++++++-----
9 2 files changed, 33 insertions(+), 7 deletions(-)
11 diff --git a/lib/h2ph.t b/lib/h2ph.t
12 index 27dd7b9..8d62d46 100644
15 @@ -41,8 +41,16 @@ $result = runperl( progfile => 'lib/h2ph.pht',
17 like( $result, qr/syntax OK$/, "output compiles");
19 +$result = runperl( progfile => '_h2ph_pre.ph',
22 +like( $result, qr/syntax OK$/, "preamble compiles");
24 $result = runperl( switches => ["-w"],
25 - prog => '$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht);');
28 +$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht);
30 is( $result, '', "output free of warnings" );
33 diff --git a/utils/h2ph.PL b/utils/h2ph.PL
34 index 8f56db4..1255807 100644
37 @@ -401,7 +401,10 @@ if ($opt_e && (scalar(keys %bad_file) > 0)) {
41 - $new = '"(assembly code)"' and return if /\b__asm__\b/; # freak out.
42 + if (/\b__asm__\b/) { # freak out
43 + $new = '"(assembly code)"';
48 $joined_args = join('|', keys(%curargs));
49 @@ -770,7 +773,7 @@ sub inc_dirs
50 sub build_preamble_if_necessary
52 # Increment $VERSION every time this function is modified:
55 my $preamble = "$Dest_dir/_h2ph_pre.ph";
57 # Can we skip building the preamble file?
58 @@ -798,7 +801,16 @@ sub build_preamble_if_necessary
59 # parenthesized value: d=(v)
62 - if ($define{$_} =~ /^([+-]?(\d+)?\.\d+([eE][+-]?\d+)?)[FL]?$/) {
63 + if (/^(\w+)\((\w)\)$/) {
64 + my($macro, $arg) = ($1, $2);
65 + my $def = $define{$_};
66 + $def =~ s/$arg/\$\{$arg\}/g;
67 + print PREAMBLE <<DEFINE;
68 +unless (defined &$macro) { sub $macro(\$) { my (\$$arg) = \@_; \"$def\" } }
72 + ($define{$_} =~ /^([+-]?(\d+)?\.\d+([eE][+-]?\d+)?)[FL]?$/) {
75 "unless (defined &$_) { sub $_() { $1 } }\n\n";
76 @@ -807,8 +819,14 @@ sub build_preamble_if_necessary
78 "unless (defined &$_) { sub $_() { $1 } }\n\n";
79 } elsif ($define{$_} =~ /^\w+$/) {
81 - "unless (defined &$_) { sub $_() { &$define{$_} } }\n\n";
82 + my $def = $define{$_};
83 + if ($isatype{$def}) {
85 + "unless (defined &$_) { sub $_() { \"$def\" } }\n\n";
88 + "unless (defined &$_) { sub $_() { &$def } }\n\n";
92 "unless (defined &$_) { sub $_() { \"",
94 1.6.5.2.74.g610f9.dirty