summaryrefslogtreecommitdiff
path: root/utils/h2ph.PL
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-06-08 14:58:43 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-06-08 14:58:43 +0000
commit25146a1a5f206eb3696426eb0e4ae3d07b07ee6b (patch)
tree7df7d6cfeb4db74c0c05d94a8f6ddbab60c0367e /utils/h2ph.PL
parent1be505aa59634a8036c429411fb42d2d38daabb8 (diff)
downloadperl-25146a1a5f206eb3696426eb0e4ae3d07b07ee6b.tar.gz
h2ph: workarounds for too large hexadecimal constants.
Now 'perlivp' passes without a whimper in Solaris 8 and Tru64 4.0F (Debian 2.2 Linux/x86 doesn't but my header installation is weird; e.g. float.h is not in /usr/include... (cd /usr/include; h2ph -l -r .) p4raw-id: //depot/perl@17094
Diffstat (limited to 'utils/h2ph.PL')
-rw-r--r--utils/h2ph.PL15
1 files changed, 14 insertions, 1 deletions
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
index 206df493fb..094a275015 100644
--- a/utils/h2ph.PL
+++ b/utils/h2ph.PL
@@ -300,7 +300,20 @@ sub expr {
s/^\&\&// && do { $new .= " &&"; next;}; # handle && operator
s/^\&([\(a-z\)]+)/$1/i; # hack for things that take the address of
s/^(\s+)// && do {$new .= ' '; next;};
- s/^(0X[0-9A-F]+)[UL]*//i && do {$new .= lc($1); next;};
+ s/^0X([0-9A-F]+)[UL]*//i
+ && do {my $hex = $1;
+ $hex =~ s/^0+//;
+ if (length $hex > 8 && !$Config{use64bitint}) {
+ # Croak if nv_preserves_uv_bits < 64 ?
+ $new .= hex(substr($hex, -8)) +
+ 2**32 * hex(substr($hex, 0, -8));
+ # The above will produce "errorneus" code
+ # if the hex constant was e.g. inside UINT64_C
+ # macro, but then again, h2ph is an approximation.
+ } else {
+ $new .= lc("0x$hex");
+ }
+ next;};
s/^(-?\d+\.\d+E[-+]?\d+)[FL]?//i && do {$new .= $1; next;};
s/^(\d+)\s*[LU]*//i && do {$new .= $1; next;};
s/^("(\\"|[^"])*")// && do {$new .= $1; next;};