diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-09-03 11:49:38 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-09-03 11:49:38 -0700 |
commit | d20428973acbd9dd052ae5213098f5ff59df924a (patch) | |
tree | cbb1fce7b489a36822330c2e86736d89526bd693 | |
parent | 9b1f9cfd3a80d39c62b9bcf412b0c5ca79bbb71c (diff) | |
download | subsurface-d20428973acbd9dd052ae5213098f5ff59df924a.tar.gz |
Make xml (and CSV) parsing use 'g_ascii_strtod()' rather than 'strtod()'
GTK messes up the standard C library locales by default (instead of just
taking locale information into account internally). Which breaks
'strtod()' and 'printf()' etc. Since they screwed that up, they then
added helper functions for undoing that braindamage. Use it.
I'd like to blame the GTK people, but the standard C libary people bear
*some* responsibility for this. One of the reasons why people do not
use "setlocale()" in many normal programs is exactly because it messes
up core libc functionality - with number conversion being the main
thing.
Doing things like converting numbers in a locale-specific manner is
something people do want to do, but not *always*. So the C library
locale code should always had defaulted to C locale, with some *extra*
marker (like a printf/scanf modifier) to say "print/scan in the current
locale".
Because many things absoilutely need to be non-localized. You don't
want your internal file format to magically change just because you want
to show things to the user in France, for example.
Reported-by: Ivan Habunek <ivan.habunek@gmail.com>
Root-caused-by: Jef Driesen <jefdriesen@telenet.be>
Cc: Dirk Hohndel <dirk@hohndel.org>
Cc: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | file.c | 2 | ||||
-rw-r--r-- | parse-xml.c | 2 |
2 files changed, 2 insertions, 2 deletions
@@ -197,7 +197,7 @@ static int try_to_open_csv(const char *filename, struct memblock *mem, enum csv_ struct sample *sample; errno = 0; - val = strtod(p,&end); + val = g_ascii_strtod(p,&end); if (end == p) break; if (errno) diff --git a/parse-xml.c b/parse-xml.c index 5159a334f..59e9278ad 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -294,7 +294,7 @@ static enum number_type integer_or_float(char *buffer, union int_or_float *res) /* Looks like it might be floating point? */ if (*end == '.') { errno = 0; - fp = strtod(buffer, &end); + fp = g_ascii_strtod(buffer, &end); if (!errno) { res->fp = fp; return FLOAT; |