summaryrefslogtreecommitdiff
path: root/utils/h2ph.PL
diff options
context:
space:
mode:
authorJason Vas Dias <unknown>2006-01-31 01:50:32 -0800
committerH.Merijn Brand <h.m.brand@xs4all.nl>2006-03-02 20:07:51 +0000
commitddfca5da10590b8934c0a4e6b1f77a03901648cf (patch)
treed721dcb84267415c1e8d4efd4fa39033a0ed5fac /utils/h2ph.PL
parent2664ba31e585823b9cf5eeb21aacafe2a554582a (diff)
downloadperl-ddfca5da10590b8934c0a4e6b1f77a03901648cf.tar.gz
[perl #38385] _h2ph_pre.ph / $Config{cppsymbols} omits gcc-3.4+ cpp "predefined macros"
From: Jason Vas Dias (via RT) <perlbug-followup@perl.org> p4raw-id: //depot/perl@27363
Diffstat (limited to 'utils/h2ph.PL')
-rw-r--r--utils/h2ph.PL63
1 files changed, 35 insertions, 28 deletions
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
index 78e10a4637..5fe2e9f458 100644
--- a/utils/h2ph.PL
+++ b/utils/h2ph.PL
@@ -772,25 +772,33 @@ sub build_preamble_if_necessary
my (%define) = _extract_cc_defines();
open PREAMBLE, ">$preamble" or die "Cannot open $preamble: $!";
- print PREAMBLE "# This file was created by h2ph version $VERSION\n";
+ print PREAMBLE "# This file was created by h2ph version $VERSION\n";
- foreach (sort keys %define) {
- if ($opt_D) {
- print PREAMBLE "# $_=$define{$_}\n";
- }
-
- if ($define{$_} =~ /^(\d+)U?L{0,2}$/i) {
- print PREAMBLE
- "unless (defined &$_) { sub $_() { $1 } }\n\n";
- } elsif ($define{$_} =~ /^\w+$/) {
- print PREAMBLE
- "unless (defined &$_) { sub $_() { &$define{$_} } }\n\n";
- } else {
- print PREAMBLE
- "unless (defined &$_) { sub $_() { \"",
- quotemeta($define{$_}), "\" } }\n\n";
- }
- }
+ foreach (sort keys %define) {
+ if ($opt_D) {
+ print PREAMBLE "# $_=$define{$_}\n";
+ }
+ if ($define{$_} =~ /^\((.*)\)$/) {
+ # parenthesized value: d=(v)
+ $define{$_} = $1;
+ }
+ if ($define{$_} =~ /^([+-]?(\d+)?\.\d+([eE][+-]?\d+)?)[FL]?$/) {
+ # float:
+ print PREAMBLE
+ "unless (defined &$_) { sub $_() { $1 } }\n\n";
+ } elsif ($define{$_} =~ /^([+-]?\d+)U?L{0,2}$/i) {
+ # integer:
+ print PREAMBLE
+ "unless (defined &$_) { sub $_() { $1 } }\n\n";
+ } elsif ($define{$_} =~ /^\w+$/) {
+ print PREAMBLE
+ "unless (defined &$_) { sub $_() { &$define{$_} } }\n\n";
+ } else {
+ print PREAMBLE
+ "unless (defined &$_) { sub $_() { \"",
+ quotemeta($define{$_}), "\" } }\n\n";
+ }
+ }
close PREAMBLE or die "Cannot close $preamble: $!";
}
@@ -802,15 +810,14 @@ sub _extract_cc_defines
{
my %define;
my $allsymbols = join " ",
- @Config{'ccsymbols', 'cppsymbols', 'cppccsymbols'};
+ @Config{'ccsymbols', 'cppsymbols', 'cppccsymbols'};
# Split compiler pre-definitions into `key=value' pairs:
- foreach (split /\s+/, $allsymbols) {
- /(.+?)=(.+)/ and $define{$1} = $2;
-
- if ($opt_D) {
- print STDERR "$_: $1 -> $2\n";
- }
+ while ($allsymbols =~ /([^\s]+)=((\\\s|[^\s])+)/g) {
+ $define{$1} = $2;
+ if ($opt_D) {
+ print STDERR "$_: $1 -> $2\n";
+ }
}
return %define;
@@ -945,10 +952,10 @@ installation.
Doesn't handle complicated expressions built piecemeal, a la:
enum {
- FIRST_VALUE,
- SECOND_VALUE,
+ FIRST_VALUE,
+ SECOND_VALUE,
#ifdef ABC
- THIRD_VALUE
+ THIRD_VALUE
#endif
};