From: Jarkko Hietaniemi Date: Sat, 8 Jun 2002 14:58:43 +0000 (+0000) Subject: h2ph: workarounds for too large hexadecimal constants. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=25146a1a5f206eb3696426eb0e4ae3d07b07ee6b;p=p5sagit%2Fp5-mst-13.2.git 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 --- diff --git a/utils/h2ph.PL b/utils/h2ph.PL index 206df49..094a275 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;};