bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1


From: Paul Eggert
Subject: Re: "seq .1 .1" would mistakenly generate no output on FreeBSD 6.1
Date: Tue, 20 Nov 2007 16:37:41 -0800
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

Bruno Haible <address@hidden> writes:

> the diagnosis is
> clear: Bug in <float.h>. Same as on BeOS. We have a workaround in the
> 'float' module. Probably we need to add FreeBSD 6.1 here...

How about checking for this via a compile-time test?  That way we don't
need to maintain a list of which software systems have the bug.  Here
is a proposed patch (I don't have easy access to BeOS or FreeBSD, so
I can't easily test it).

2007-11-20  Paul Eggert  <address@hidden>

        Check for float.h double vs long double bug with a compile-time test.
        This works around a bug in FreeBSD 6.1 that affected 'seq' in coreutils.
        Problem reported by Jim Meyering in
        <http://lists.gnu.org/archive/html/bug-gnulib/2007-11/msg00120.html>.
        * lib/float.in.h: Do not depend on __i386__ and __BEOS__, since we
        now check for the bug at comfigure-time and include this file only
        if the bug is present.
        * m4/float_h.m4 (gl_FLOAT_H): Check for the bug at compile-time
        rather than relying on $host_os.

diff --git a/lib/float.in.h b/lib/float.in.h
index 986719b..773ba35 100644
--- a/lib/float.in.h
+++ b/lib/float.in.h
@@ -24,7 +24,6 @@
 #define _GL_FLOAT_H

 /* 'long double' properties.  */
-#if defined __i386__ && defined __BEOS__
 /* Number of mantissa units, in base FLT_RADIX.  */
 # undef LDBL_MANT_DIG
 # define LDBL_MANT_DIG   64
@@ -52,7 +51,6 @@
 /* Maximum e such that 10^e is in the range of representable finite numbers.  
*/
 # undef LDBL_MAX_10_EXP
 # define LDBL_MAX_10_EXP 4932
-#endif

 #endif /* _GL_FLOAT_H */
 #endif /* _GL_FLOAT_H */
diff --git a/m4/float_h.m4 b/m4/float_h.m4
index 1b1ad10..c7f6828 100644
--- a/m4/float_h.m4
+++ b/m4/float_h.m4
@@ -1,4 +1,4 @@
-# float_h.m4 serial 2
+# float_h.m4 serial 3
 dnl Copyright (C) 2007 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -7,13 +7,28 @@ dnl with or without modifications, as long as this notice is 
preserved.
 AC_DEFUN([gl_FLOAT_H],
 [
   AC_REQUIRE([AC_PROG_CC])
-  AC_REQUIRE([AC_CANONICAL_HOST])
   FLOAT_H=
-  case "$host_os" in
-    beos*)
-      FLOAT_H=float.h
-      gl_CHECK_NEXT_HEADERS([float.h])
-      ;;
-  esac
+  AC_CACHE_CHECK([for working float.h],
+    [gl_cv_header_working_float_h],
+    [AC_COMPILE_IFELSE(
+       [[/* Check for the bug that requires a float.h workaround, namely, that
+           float.h claims that long double and double are both IEEE double,
+           but actually, long double has a 64-bit fraction.  */
+        #include <float.h>
+        int check_LDBL_MANT_DIG[
+          (! (FLT_RADIX == 2
+              && DBL_MANT_DIG == 53
+              && (0.1L - 0.1
+                  == -5.5497598704101758215756490244530141353607177734375e-18L)
+              && LDBL_MANT_DIG != 64)
+           ? 1 : -1)
+        ];
+       ]],
+       [gl_cv_header_working_float_h=yes],
+       [gl_cv_header_working_float_h=no])])
+  if test $gl_cv_header_working_float_h != yes; then
+    FLOAT_H=float.h
+    gl_CHECK_NEXT_HEADERS([float.h])
+  fi
   AC_SUBST([FLOAT_H])
 ])




reply via email to

[Prev in Thread] Current Thread [Next in Thread]