This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
No point in pack 'w' for inf/nan.
authorJarkko Hietaniemi <jhi@iki.fi>
Mon, 22 Sep 2014 01:53:24 +0000 (21:53 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Tue, 23 Sep 2014 01:01:43 +0000 (21:01 -0400)
(For inf, the existing code already did this, slowly.)

pp_pack.c

index d703a99..17f7182 100644 (file)
--- a/pp_pack.c
+++ b/pp_pack.c
@@ -2900,12 +2900,17 @@ S_pack_rec(pTHX_ SV *cat, tempsym_t* symptr, SV **beglist, SV **endlist )
                    char   buf[1 + (int)((308 + 1) / 2)]; /* valid C */
 #endif
                    char  *in = buf + sizeof(buf);
+                    static const char S_cannot_compress[] =
+                        "Cannot compress integer in pack";
+
+                    if (Perl_isinfnan(anv))
+                        Perl_croak(aTHX_ S_cannot_compress);
 
                    anv = Perl_floor(anv);
                    do {
                        const NV next = Perl_floor(anv / 128);
                        if (in <= buf)  /* this cannot happen ;-) */
-                           Perl_croak(aTHX_ "Cannot compress integer in pack");
+                           Perl_croak(aTHX_ S_cannot_compress);
                        *--in = (unsigned char)(anv - (next * 128)) | 0x80;
                        anv = next;
                    } while (anv > 0);