]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
numfmt: increase precision on 32 bit FreeBSD
authorPádraig Brady <P@draigBrady.com>
Tue, 30 Jun 2015 23:10:23 +0000 (00:10 +0100)
committerPádraig Brady <P@draigBrady.com>
Wed, 1 Jul 2015 11:29:59 +0000 (12:29 +0100)
* m4/jm-macros.m4 (HAVE_FPSETPREC): Define if needed.
* src/numfmt.c (main): Call fpsetprec() if needed.
Fixes large-15 and large-16 test failures on 32 bit FreeBSD.

m4/jm-macros.m4
src/numfmt.c

index 79f124b019f964d76a40895525f3e418075f54df..51c533a42ab442f90cc010f8a509b65bcf522af6 100644 (file)
@@ -165,6 +165,21 @@ AC_DEFUN([coreutils_MACROS],
      LIBS="$ac_seq_save_LIBS"
     ])
 
+
+  # See is fpsetprec() required to use extended double precision
+  # This is needed on 32 bit FreeBSD to give accurate conversion of:
+  # `numfmt 9223372036854775808`
+  AC_TRY_LINK([#include <ieeefp.h>],
+    [#ifdef __i386__
+      fpsetprec(FP_PE);
+     #else
+     # error not required on 64 bit
+     #endif
+    ], [ac_have_fpsetprec=yes], [ac_have_fpsetprec=no])
+  if test "$ac_have_fpsetprec" = "yes" ; then
+    AC_DEFINE([HAVE_FPSETPREC], 1, [whether fpsetprec is present and required])
+  fi
+
   AC_REQUIRE([AM_LANGINFO_CODESET])
 
   # Accept configure options: --with-tty-group[=GROUP], --without-tty-group
index e58972bce62565c94c6195790fc27d972f52e352..35c5c5b97d34b7eadc3ce6320804c88ec9da5d12 100644 (file)
 #include "gl_linked_list.h"
 #include "gl_xlist.h"
 
+#if HAVE_FPSETPREC
+# include <ieeefp.h>
+#endif
+
 /* The official name of this program (e.g., no 'g' prefix).  */
 #define PROGRAM_NAME "numfmt"
 
@@ -1574,6 +1578,11 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+#if HAVE_FPSETPREC
+  /* Enabled extended precision if needed.  */
+  fpsetprec (FP_PE);
+#endif
+
   decimal_point = nl_langinfo (RADIXCHAR);
   if (decimal_point == NULL || strlen (decimal_point) == 0)
     decimal_point = ".";