This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
remove HAS_LDBL_SPRINTF_BUG code
authorDavid Mitchell <davem@iabyn.com>
Wed, 17 May 2017 12:36:27 +0000 (13:36 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 7 Jun 2017 08:11:01 +0000 (09:11 +0100)
This code was added in 2002 to work round an Irix 6 rounding bug in
long double sprintfs.

I strongly suspect that any such OS bug has long been fixed and/or such
machines have been retired or are unlikely to have new perls installed on
them.

Part of the motivation for removing this code is that following the
previous commit, that block of code's use of the float_need variable
is likely to be wrong (since it now includes exponent etc), but I have no
way of testing it.

I've left the probe code in hints/irix_6.sh, so if anyone ever reports
sprintf.t failures on an old Irix platform, perl -V should show if their
system still has the bug. At that point someone brave could resurrect this
block of code.

sv.c

diff --git a/sv.c b/sv.c
index 071cdcb..d5e6f4a 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -12548,76 +12548,6 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
            if (float_need < width)
                float_need = width;
 
-#ifdef HAS_LDBL_SPRINTF_BUG
-           /* This is to try to fix a bug with irix/nonstop-ux/powerux and
-              with sfio - Allen <allens@cpan.org> */
-
-#  ifdef DBL_MAX
-#    define MY_DBL_MAX DBL_MAX
-#  else /* XXX guessing! HUGE_VAL may be defined as infinity, so not using */
-#    if DOUBLESIZE >= 8
-#      define MY_DBL_MAX 1.7976931348623157E+308L
-#    else
-#      define MY_DBL_MAX 3.40282347E+38L
-#    endif
-#  endif
-
-#  ifdef HAS_LDBL_SPRINTF_BUG_LESS1 /* only between -1L & 1L - Allen */
-#    define MY_DBL_MAX_BUG 1L
-#  else
-#    define MY_DBL_MAX_BUG MY_DBL_MAX
-#  endif
-
-#  ifdef DBL_MIN
-#    define MY_DBL_MIN DBL_MIN
-#  else  /* XXX guessing! -Allen */
-#    if DOUBLESIZE >= 8
-#      define MY_DBL_MIN 2.2250738585072014E-308L
-#    else
-#      define MY_DBL_MIN 1.17549435E-38L
-#    endif
-#  endif
-
-           if ((intsize == 'q') && (c == 'f') &&
-               ((fv < MY_DBL_MAX_BUG) && (fv > -MY_DBL_MAX_BUG)) &&
-               (float_need < DBL_DIG))
-            {
-                bool fix_ldbl_sprintf_bug = FALSE;
-
-               /* it's going to be short enough that
-                * long double precision is not needed */
-
-               if ((fv <= 0L) && (fv >= -0L))
-                   fix_ldbl_sprintf_bug = TRUE; /* 0 is 0 - easiest */
-               else {
-                   /* would use Perl_fp_class as a double-check but not
-                    * functional on IRIX - see perl.h comments */
-
-                   if ((fv >= MY_DBL_MIN) || (fv <= -MY_DBL_MIN)) {
-                       /* It's within the range that a double can represent */
-#if defined(DBL_MAX) && !defined(DBL_MIN)
-                       if ((fv >= ((long double)1/DBL_MAX)) ||
-                           (fv <= (-(long double)1/DBL_MAX)))
-#endif
-                       fix_ldbl_sprintf_bug = TRUE;
-                   }
-               }
-
-               if (fix_ldbl_sprintf_bug == TRUE) {
-                   double temp;
-
-                   intsize = 0;
-                   temp = (double)fv;
-                   fv = (NV)temp;
-               }
-           }
-
-#  undef MY_DBL_MAX
-#  undef MY_DBL_MAX_BUG
-#  undef MY_DBL_MIN
-
-#endif /* HAS_LDBL_SPRINTF_BUG */
-
 /* We should have correctly calculated (or indeed over-estimated) the
  * buffer size, but you never know what strange floating-point systems
  * there are out there. So for production use, add a little extra overhead.