bug-m4
[Top][All Lists]
Advanced

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

Re: HP-UX 10.20 format failure (was: snapshot 3 in preparation for 1.4.1


From: Bruno Haible
Subject: Re: HP-UX 10.20 format failure (was: snapshot 3 in preparation for 1.4.13)
Date: Thu, 26 Feb 2009 13:39:25 +0100
User-agent: KMail/1.9.9

Hi Gary,

> > $ grep NEED config.h
> 
> % grep NEED lib/config.h
> #define NEED_PRINTF_DIRECTIVE_A 1
> #define NEED_PRINTF_DIRECTIVE_F 1
> /* #undef NEED_PRINTF_DOUBLE */
> /* #undef NEED_PRINTF_ENOMEM */
> /* #undef NEED_PRINTF_FLAG_GROUPING */
> #define NEED_PRINTF_FLAG_LEFTADJUST 1
> #define NEED_PRINTF_FLAG_ZERO 1
> /* #undef NEED_PRINTF_INFINITE_DOUBLE */
> /* #undef NEED_PRINTF_INFINITE_LONG_DOUBLE */
> /* #undef NEED_PRINTF_LONG_DOUBLE */
> /* #undef NEED_PRINTF_UNBOUNDED_PRECISION */
> 
> % cc -Ae +DAportable -o printf-minus-zero printf-minus-zero.c
> % ./printf-minus-zero
> 4
> 0 33

Thanks for these precisions. I'm applying this workaround.


2009-02-26  Bruno Haible  <address@hidden>

        Work around *printf bug with %g directive and 0.0 on HP-UX 10.20.
        * m4/printf.m4 (gl_PRINTF_INFINITE): Also test for %g output of -0.0.
        Reported by Gary V. Vaughan <address@hidden>.

--- m4/printf.m4.orig   2009-02-26 13:36:00.000000000 +0100
+++ m4/printf.m4        2009-02-26 13:28:39.000000000 +0100
@@ -1,4 +1,4 @@
-# printf.m4 serial 29
+# printf.m4 serial 30
 dnl Copyright (C) 2003, 2007-2009 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -125,7 +125,8 @@
 ])
 
 dnl Test whether the *printf family of functions supports infinite and NaN
-dnl 'double' arguments in the %f, %e, %g directives. (ISO C99, POSIX:2001)
+dnl 'double' arguments and negative zero arguments in the %f, %e, %g
+dnl directives. (ISO C99, POSIX:2001)
 dnl Result is gl_cv_func_printf_infinite.
 
 AC_DEFUN([gl_PRINTF_INFINITE],
@@ -156,6 +157,13 @@
     }
   return 0;
 }
+static int
+have_minus_zero ()
+{
+  static double plus_zero = 0.0;
+  double minus_zero = - plus_zero;
+  return memcmp (&plus_zero, &minus_zero, sizeof (double)) != 0;
+}
 static char buf[10000];
 static double zero = 0.0;
 int main ()
@@ -187,6 +195,11 @@
   if (sprintf (buf, "%g", zero / zero) < 0
       || !strisnan (buf, 0, strlen (buf)))
     return 1;
+  /* This test fails on HP-UX 10.20.  */
+  if (have_minus_zero ())
+    if (sprintf (buf, "%g", - zero) < 0
+        || strcmp (buf, "-0") != 0)
+    return 1;
   return 0;
 }], [gl_cv_func_printf_infinite=yes], [gl_cv_func_printf_infinite=no],
       [
@@ -1357,7 +1370,7 @@
 dnl   AIX 4.3.2, 5.1                 #  .  #  #  #  #  .  .  .  .  .  #  .  .  
.  .  .  .  .  .
 dnl   HP-UX 11.31                    .  .  .  .  #  .  .  .  .  .  .  #  .  .  
.  .  #  #  .  .
 dnl   HP-UX 11.{00,11,23}            #  .  .  .  #  #  .  .  .  .  .  #  .  .  
.  .  #  #  .  #
-dnl   HP-UX 10.20                    #  .  .  .  #  #  .  ?  .  .  #  #  .  .  
.  .  #  #  ?  #
+dnl   HP-UX 10.20                    #  .  #  .  #  #  .  ?  .  .  #  #  .  .  
.  .  #  #  ?  #
 dnl   IRIX 6.5                       #  .  #  #  #  #  .  #  .  .  .  #  .  .  
.  .  #  .  .  .
 dnl   OSF/1 5.1                      #  .  #  #  #  #  .  .  .  .  .  #  .  .  
.  .  #  .  .  #
 dnl   OSF/1 4.0d                     #  .  #  #  #  #  .  .  .  .  .  #  .  .  
#  #  #  #  #  #




reply via email to

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