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