]>
Commit | Line | Data |
---|---|---|
e0517fb6 | 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 | |
5 | ||
6 | --- | |
7 | lib/h2ph.t | 12 ++++++++++-- | |
8 | utils/h2ph.PL | 28 +++++++++++++++++++++++----- | |
9 | 2 files changed, 33 insertions(+), 7 deletions(-) | |
10 | ||
11 | diff --git a/lib/h2ph.t b/lib/h2ph.t | |
12 | index 27dd7b9..8d62d46 100644 | |
13 | --- a/lib/h2ph.t | |
14 | +++ b/lib/h2ph.t | |
e0517fb6 | 15 | @@ -41,8 +41,16 @@ $result = runperl( progfile => 'lib/h2ph.pht', |
16 | stderr => 1 ); | |
17 | like( $result, qr/syntax OK$/, "output compiles"); | |
18 | ||
19 | +$result = runperl( progfile => '_h2ph_pre.ph', | |
20 | + switches => ['-c'], | |
21 | + stderr => 1 ); | |
22 | +like( $result, qr/syntax OK$/, "preamble compiles"); | |
23 | + | |
24 | $result = runperl( switches => ["-w"], | |
25 | - prog => '$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht);'); | |
26 | + stderr => 1, | |
27 | + prog => <<'PROG' ); | |
28 | +$SIG{__WARN__} = sub { die $_[0] }; require q(lib/h2ph.pht); | |
29 | +PROG | |
30 | is( $result, '', "output free of warnings" ); | |
31 | ||
32 | # cleanup | |
33 | diff --git a/utils/h2ph.PL b/utils/h2ph.PL | |
34 | index 8f56db4..1255807 100644 | |
35 | --- a/utils/h2ph.PL | |
36 | +++ b/utils/h2ph.PL | |
37 | @@ -401,7 +401,10 @@ if ($opt_e && (scalar(keys %bad_file) > 0)) { | |
38 | exit $Exit; | |
39 | ||
40 | sub expr { | |
41 | - $new = '"(assembly code)"' and return if /\b__asm__\b/; # freak out. | |
42 | + if (/\b__asm__\b/) { # freak out | |
43 | + $new = '"(assembly code)"'; | |
44 | + return | |
45 | + } | |
46 | my $joined_args; | |
47 | if(keys(%curargs)) { | |
48 | $joined_args = join('|', keys(%curargs)); | |
49 | @@ -770,7 +773,7 @@ sub inc_dirs | |
50 | sub build_preamble_if_necessary | |
51 | { | |
52 | # Increment $VERSION every time this function is modified: | |
53 | - my $VERSION = 2; | |
54 | + my $VERSION = 3; | |
55 | my $preamble = "$Dest_dir/_h2ph_pre.ph"; | |
56 | ||
57 | # Can we skip building the preamble file? | |
58 | @@ -798,7 +801,16 @@ sub build_preamble_if_necessary | |
59 | # parenthesized value: d=(v) | |
60 | $define{$_} = $1; | |
61 | } | |
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\" } } | |
69 | + | |
70 | +DEFINE | |
71 | + } elsif | |
72 | + ($define{$_} =~ /^([+-]?(\d+)?\.\d+([eE][+-]?\d+)?)[FL]?$/) { | |
73 | # float: | |
74 | print PREAMBLE | |
75 | "unless (defined &$_) { sub $_() { $1 } }\n\n"; | |
76 | @@ -807,8 +819,14 @@ sub build_preamble_if_necessary | |
77 | print PREAMBLE | |
78 | "unless (defined &$_) { sub $_() { $1 } }\n\n"; | |
79 | } elsif ($define{$_} =~ /^\w+$/) { | |
80 | - print PREAMBLE | |
81 | - "unless (defined &$_) { sub $_() { &$define{$_} } }\n\n"; | |
82 | + my $def = $define{$_}; | |
83 | + if ($isatype{$def}) { | |
84 | + print PREAMBLE | |
85 | + "unless (defined &$_) { sub $_() { \"$def\" } }\n\n"; | |
86 | + } else { | |
87 | + print PREAMBLE | |
88 | + "unless (defined &$_) { sub $_() { &$def } }\n\n"; | |
89 | + } | |
90 | } else { | |
91 | print PREAMBLE | |
92 | "unless (defined &$_) { sub $_() { \"", | |
93 | -- | |
94 | 1.6.5.2.74.g610f9.dirty | |
95 |