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 138424 - g_ascii_strtod confusion with trailing locale-separator
g_ascii_strtod confusion with trailing locale-separator
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: general
2.4.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2004-03-29 16:09 UTC by Nickolay V. Shmyrev
Modified: 2011-02-18 16:07 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Test case (571 bytes, text/plain)
2004-03-29 16:09 UTC, Nickolay V. Shmyrev
  Details
Proposed patch (549 bytes, patch)
2004-04-12 15:01 UTC, Nickolay V. Shmyrev
none Details | Review
Sorry, something strange with cvs. This is correct patch. (3.41 KB, patch)
2004-04-12 15:07 UTC, Nickolay V. Shmyrev
none Details | Review

Description Nickolay V. Shmyrev 2004-03-29 16:09:02 UTC
This fails
<g transform="matrix(0.05,0.0,0,-0.05,5,60)">

while this works well
<g transform="matrix(0.05,0.0,0.0,-0.05,5.0,60.0)">

See attachment for full svg example.
Comment 1 Nickolay V. Shmyrev 2004-03-29 16:09:47 UTC
Created attachment 26069 [details]
Test case
Comment 2 Nickolay V. Shmyrev 2004-03-29 16:51:18 UTC
It seems that i've found the reason. I am running in ru_RU locale, so "5,60"="5.60"

For example, this line works fine:
<g transform="matrix(0.05,0.0,0,-0.05,5,0,60)">

g_ascii_strtod seems to be locale-specific. It is strange, but appropriate place
in glib documentation is pretty unclear. I still can't understand should you use
g_ascii_dtostr or g_ascii_strtod.

Comment 3 Dominic Lachowicz 2004-03-29 17:18:47 UTC
gosh, this is likely a glib bug, and a big one to boot. we and other projects
use g_ascii_strtod() and g_ascii_dtostr() everywhere in our code.
g_ascii_strtod() should only work for numbers like "5.0", not "5,0".

reassigning
Comment 4 Dominic Lachowicz 2004-03-29 17:19:09 UTC
reassigning
Comment 5 Owen Taylor 2004-04-12 12:22:26 UTC
The way that g_ascii_strtod works is that it converts the . into
the locale especific separator, and then does the conversion.

It looks like the problem here is that for numbers without any 
decimal points, no copy is made, so that the trailing "junk" gets
fed right to strtod and confuses it.
Comment 6 Nickolay V. Shmyrev 2004-04-12 15:01:30 UTC
Created attachment 26578 [details] [review]
Proposed patch
Comment 7 Nickolay V. Shmyrev 2004-04-12 15:07:17 UTC
Created attachment 26579 [details] [review]
Sorry, something strange with cvs. This is correct patch.
Comment 8 Tor Lillqvist 2004-04-13 05:04:36 UTC
Isn't the documentation for g_ascii_strtod() backwards? Or is the 
implementation backwards? The doc comment says that it "behaves like the 
standard strtod() function does in the C locale". Doesn't that mean that it 
should accept only '.' as decimal separator?
Comment 9 Owen Taylor 2004-04-13 14:27:38 UTC
Tor - it's just a bug in the implementation. It does only accept .
as a decimal separator, but it gets confused when there is a trailing ,
in some cases.
Comment 10 Tor Lillqvist 2004-04-13 19:03:45 UTC
Ah yes, now I see. Couldn't think clearly that early in the morning ;-)