summaryrefslogtreecommitdiff
path: root/pp_pack.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2002-03-16 21:52:15 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-03-18 13:40:28 +0000
commit196b62db48c48e65dfbfa734e2c0981779160ea3 (patch)
tree841f1a95a572f7adba292306d6908fa3393e7816 /pp_pack.c
parent34073cabb53a557532d5a01f749b64f7e241d789 (diff)
downloadperl-196b62db48c48e65dfbfa734e2c0981779160ea3.tar.gz
another pack "w" thing
Message-ID: <20020316215215.GF330@Bagpuss.unfortu.net> p4raw-id: //depot/perl@15287
Diffstat (limited to 'pp_pack.c')
-rw-r--r--pp_pack.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/pp_pack.c b/pp_pack.c
index 51b8772bc9..b653362039 100644
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -2163,26 +2163,21 @@ Perl_pack_cat(pTHX_ SV *cat, char *pat, register char *patend, register SV **beg
case 'w':
while (len-- > 0) {
fromstr = NEXTFROM;
- adouble = Perl_floor(SvNV(fromstr));
+ adouble = SvNV(fromstr);
if (adouble < 0)
Perl_croak(aTHX_ "Cannot compress negative numbers");
- if (
-#if UVSIZE > 4 && UVSIZE >= NVSIZE
- adouble <= 0xffffffff
-#else
-# ifdef CXUX_BROKEN_CONSTANT_CONVERT
- adouble <= UV_MAX_cxux
-# else
- adouble <= UV_MAX
-# endif
-#endif
- )
+ /* 0xFFFFFFFFFFFFFFFF may cast to 18446744073709551616.0,
+ which is == UV_MAX_P1. IOK is fine (instead of UV_only), as
+ any negative IVs will have already been got by the croak()
+ above. IOK is untrue for fractions, so we test them
+ against UV_MAX_P1. */
+ if (SvIOK(fromstr) || adouble < UV_MAX_P1)
{
char buf[1 + sizeof(UV)];
char *in = buf + sizeof(buf);
- UV auv = U_V(adouble);
+ UV auv = SvUV(fromstr);
do {
*--in = (auv & 0x7f) | 0x80;
@@ -2216,6 +2211,7 @@ Perl_pack_cat(pTHX_ SV *cat, char *pat, register char *patend, register SV **beg
char buf[sizeof(double) * 2]; /* 8/7 <= 2 */
char *in = buf + sizeof(buf);
+ adouble = Perl_floor(adouble);
do {
double next = floor(adouble / 128);
*--in = (unsigned char)(adouble - (next * 128)) | 0x80;