After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 156421 - g_ascii_strtod broken by previous fix
g_ascii_strtod broken by previous fix
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.5.x
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
: 160197 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2004-10-25 20:33 UTC by Morten Welinder
Modified: 2011-02-18 16:09 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Morten Welinder 2004-10-25 20:33:01 UTC
The fix for bug 138424 ended up breaking g_ascii_strtod for strings
like "1e1".  The "e1" never makes it to strtod.

(Probably 2.4 branch too.)
Comment 1 Morten Welinder 2004-10-25 20:41:55 UTC
Also broken for "NAN" and infinities.  See section 7.19.6.1 in
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n869/n869.txt.gz



A  double  argument  representing  an  infinity   is
               converted in one of the styles [-]inf or [-]infinity
                --   which  style  is  implementation-defined.    A
               double  argument  representing a NaN is converted in
               one of the styles [-]nan or [-]nan(n-char-sequence)
                --  which style, and the  meaning  of  any  n-char-
               sequence,    is   implementation-defined.    The   F
               conversion specifier produces INF, INFINITY, or  NAN
               instead of inf, infinity, or nan, respectively.220)
Comment 2 Matthias Clasen 2004-11-05 03:24:52 UTC
Should be fixed now.

Comment 3 Morten Welinder 2004-11-05 14:17:48 UTC
From visual inspection, it looks good.  There is one thing it does not handle
and that it probably never will:

[#6] In  other  than  the  "C"  locale,  additional  locale-
       specific subject sequence forms may be accepted.

so g_ascii_strtod may accept things it should not.  In practice I doubt that
will happen and with a vague clause like the above there isn't anything we can
do about it anyway.
Comment 4 Hans Breuer 2004-11-24 22:17:42 UTC
now it fails on "-.75,0" in locale 'de'. The following patch appears to fix it:

--- from-cvs/glib/glib/gstrfuncs.c	Sun Nov 21 17:48:04 2004
+++ my-gtk/glib/glib/gstrfuncs.c	Wed Nov 24 10:34:35 2004
@@ -386,7 +386,7 @@
 
 	  end = p;
 	}
-      else if (g_ascii_isdigit (*p))
+      else if (g_ascii_isdigit (*p) || *p == '.')
 	{
 	  while (g_ascii_isdigit (*p))
 	    p++;
Comment 5 Matthias Clasen 2004-11-26 04:40:57 UTC
2004-11-25  Matthias Clasen  <mclasen@redhat.com>

	* tests/strtod-test.c (main): Add a testcase for the previous fix.

	* glib/gstrfuncs.c (g_ascii_strtod): Make it work again for floats
	starting with a decimal point, like .75  (#156421, Hans Breuer)

Comment 6 Sebastien Bacher 2004-12-02 21:37:17 UTC
*** Bug 160197 has been marked as a duplicate of this bug. ***