summaryrefslogtreecommitdiff
path: root/utils/h2ph.PL
diff options
context:
space:
mode:
authorStepan Kasal <skasal@redhat.com>2009-07-09 15:49:57 +0200
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2009-07-12 16:41:50 +0200
commit3983eafb40341b21a64d20c0c4e7e618101ee6ce (patch)
tree966e246ee8e960b3f0f4bb6b9eef620b24099e32 /utils/h2ph.PL
parentd6521b5650c0b0e050e24c14c9f29510eb224d6d (diff)
downloadperl-3983eafb40341b21a64d20c0c4e7e618101ee6ce.tar.gz
h2ph: handle "#if defined SYMBOL" better
expr() contains a code to handle "defined(SYM)" in #if directives. Unfortunately, this code is not executed for "defined SYM", without parentheses. This patch fixes it.
Diffstat (limited to 'utils/h2ph.PL')
-rw-r--r--utils/h2ph.PL13
1 files changed, 10 insertions, 3 deletions
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
index cd4b5a0b2c..ada226cf75 100644
--- a/utils/h2ph.PL
+++ b/utils/h2ph.PL
@@ -509,7 +509,8 @@ sub expr {
s/^\s*\((\w),/("$1",/ if $id =~ /^_IO[WR]*$/i; # cheat
$new .= " &$id";
} elsif ($isatype{$id}) {
- if ($new =~ /{\s*$/) {
+ if ($new =~ /{\s*$/ # } for vi
+ ) {
$new .= "'$id'";
} elsif ($new =~ /\(\s*$/ && /^[\s*]*\)/) {
$new =~ s/\(\s*$//;
@@ -518,8 +519,14 @@ sub expr {
$new .= q(').$id.q(');
}
} else {
- if ($inif && $new !~ /defined\s*\($/) {
- $new .= '(defined(&' . $id . ') ? &' . $id . ' : undef)';
+ if ($inif) {
+ if ($new =~ /defined\s*$/) {
+ $new .= '(&' . $id . ')';
+ } elsif ($new =~ /defined\s*\($/) {
+ $new .= '&' . $id;
+ } else {
+ $new .= '(defined(&' . $id . ') ? &' . $id . ' : undef)';
+ }
} elsif (/^\[/) {
$new .= " \$$id";
} else {