bug-m4
[Top][All Lists]
Advanced

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

Re: m4-1.4.11 strtod test failure


From: Eric Blake
Subject: Re: m4-1.4.11 strtod test failure
Date: Thu, 03 Apr 2008 22:39:53 -0600
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080213 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

According to Bob Friesenhahn on 4/3/2008 8:14 PM:
| If I sound a bit harsh on Linux's "enhanced" strtod() it is because it
| cost me several days worth of time to work-around it.  GraphicsMagick
| uses many arguments of the form NxN (in thousands of places) and Linux's
| non-standard behavior caused the argument parsing not to work if the
| first number happened to be 0. There are plenty of other glibc
| "enhancements" which cause problems for standard code.

The standard changed.  C89 requires strtod("0xa",ptr) to return 0 and set
ptr to 'x' (one byte consumed), C99 requires strtod("0xa",ptr) to return
10 and set ptr to '\0' (three bytes consumed).  Linux's strtod() isn't
enhanced, so much as compliant to a newer standard.  The decision was made
9 years ago, and vendors are just slow to comply.

http://www.opengroup.org/onlinepubs/009695399/functions/strtod.html

POSIX even says this:

"The changes to strtod() introduced by the ISO/IEC 9899:1999 standard can
alter the behavior of well-formed applications complying with the ISO/IEC
9899:1990 standard and thus earlier versions of the base documents."

| configure:22286: checking whether strtod obeys C99
| configure:22335: gcc-4.2.1 -std=gnu99 -o conftest -O2  -L/usr/local/lib
| -R/usr/local/lib conftest.c  >&5
| configure:22338: $? = 0
| configure:22344: ./conftest
| configure:22347: $? = 0
| configure:22363: result: yes

Bingo; just as I had guessed.  I'm fixing it like this:

- --
Don't work too hard, make some time for fun as well!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkf1sRYACgkQ84KuGfSFAYBLMgCfSVpIKpPJUy8v6EZINcGdDrMM
9VEAn3oo66OUfbg6IerI6RRn8FOlm53t
=4FfK
-----END PGP SIGNATURE-----
>From 5b771b68d79f919a40670d909294dfc17a7793fd Mon Sep 17 00:00:00 2001
From: Eric Blake <address@hidden>
Date: Thu, 3 Apr 2008 22:37:49 -0600
Subject: [PATCH] Improve strtod bug detection check.

* m4/strtod.m4 (gl_FUNC_STRTOD): Also check for hex-float parsing,
required for Solaris 10.
Reported by Bob Friesenhahn and Nelson H. F. Beebe.

Signed-off-by: Eric Blake <address@hidden>
---
 ChangeLog    |    7 +++++++
 m4/strtod.m4 |   10 +++++++++-
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 950a574..79c8815 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2008-04-03  Eric Blake  <address@hidden>
+
+       Improve strtod bug detection check.
+       * m4/strtod.m4 (gl_FUNC_STRTOD): Also check for hex-float parsing,
+       required for Solaris 10.
+       Reported by Bob Friesenhahn and Nelson H. F. Beebe.
+
 2008-04-04  Bruno Haible  <address@hidden>
 
        * modules/relocatable-prog-wrapper (Files): Add m4/environ.m4. Needed
diff --git a/m4/strtod.m4 b/m4/strtod.m4
index 7a10a21..646798d 100644
--- a/m4/strtod.m4
+++ b/m4/strtod.m4
@@ -1,4 +1,4 @@
-# strtod.m4 serial 7
+# strtod.m4 serial 8
 dnl Copyright (C) 2002, 2003, 2006, 2007, 2008 Free Software
 dnl Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
@@ -29,6 +29,14 @@ AC_DEFUN([gl_FUNC_STRTOD],
       return 1;
   }
   {
+    /* Many platforms do not parse hex floats.  */
+    char *string = "0XaP+1";
+    char *term;
+    double value = strtod (string, &term);
+    if (1 != 20 || term != (string + 6))
+      return 1;
+  }
+  {
     /* Many platforms do not parse infinities.  */
     char *string = "inf";
     char *term;
-- 
1.5.4


reply via email to

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