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 @@ -18,7 +18,7 @@ if (!(-e $extracted_program)) {
22 # quickly compare two text files
24 @@ -41,8 +41,16 @@ $result = runperl( progfile => 'lib/h2ph.pht',
26 like( $result, qr/syntax OK$/, "output compiles");
28 +$result = runperl( progfile => '_h2ph_pre.ph',
31 +like( $result, qr/syntax OK$/, "preamble compiles");
33 $result = runperl( switches => ["-w"],
34 - prog => '$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht);');
37 +$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht);
39 is( $result, '', "output free of warnings" );
42 diff --git a/utils/h2ph.PL b/utils/h2ph.PL
43 index 8f56db4..1255807 100644
46 @@ -401,7 +401,10 @@ if ($opt_e && (scalar(keys %bad_file) > 0)) {
50 - $new = '"(assembly code)"' and return if /\b__asm__\b/; # freak out.
51 + if (/\b__asm__\b/) { # freak out
52 + $new = '"(assembly code)"';
57 $joined_args = join('|', keys(%curargs));
58 @@ -770,7 +773,7 @@ sub inc_dirs
59 sub build_preamble_if_necessary
61 # Increment $VERSION every time this function is modified:
64 my $preamble = "$Dest_dir/_h2ph_pre.ph";
66 # Can we skip building the preamble file?
67 @@ -798,7 +801,16 @@ sub build_preamble_if_necessary
68 # parenthesized value: d=(v)
71 - if ($define{$_} =~ /^([+-]?(\d+)?\.\d+([eE][+-]?\d+)?)[FL]?$/) {
72 + if (/^(\w+)\((\w)\)$/) {
73 + my($macro, $arg) = ($1, $2);
74 + my $def = $define{$_};
75 + $def =~ s/$arg/\$\{$arg\}/g;
76 + print PREAMBLE <<DEFINE;
77 +unless (defined &$macro) { sub $macro(\$) { my (\$$arg) = \@_; \"$def\" } }
81 + ($define{$_} =~ /^([+-]?(\d+)?\.\d+([eE][+-]?\d+)?)[FL]?$/) {
84 "unless (defined &$_) { sub $_() { $1 } }\n\n";
85 @@ -807,8 +819,14 @@ sub build_preamble_if_necessary
87 "unless (defined &$_) { sub $_() { $1 } }\n\n";
88 } elsif ($define{$_} =~ /^\w+$/) {
90 - "unless (defined &$_) { sub $_() { &$define{$_} } }\n\n";
91 + my $def = $define{$_};
92 + if ($isatype{$def}) {
94 + "unless (defined &$_) { sub $_() { \"$def\" } }\n\n";
97 + "unless (defined &$_) { sub $_() { &$def } }\n\n";
101 "unless (defined &$_) { sub $_() { \"",
103 1.6.5.2.74.g610f9.dirty