GNOME Bugzilla – Bug 720594
gda_numeric_get_double()'s use of atof() is locale-dependent
Last modified: 2014-04-27 14:18:45 UTC
Created attachment 264397 [details] test_libgda_numeric.cc This test case shows that gda_numeric_get_double() returns the incorrect value if we first call std::locale::global() (in C++).
Created attachment 264398 [details] test_libgda_numeric.c It's interesting that, as in this test case, just calling setlocale() does not cause this problem.
Created attachment 264399 [details] [review] 0001-GdaNumeric-Use-g_ascii_strtod-instead-of-atof.patch This patch fixes the problem.
Created attachment 264400 [details] [review] 0001-GdaNumeric-Use-g_ascii_dtostr-instead-of-g_strdup_pr.patch And this patch avoids some more use of setlocale(), though they are not causing any known bugs, but g_ascii_dtostr() seems cleaner.
(In reply to comment #0) > Created an attachment (id=264397) [details] > test_libgda_numeric.cc > > This test case shows that gda_numeric_get_double() returns the incorrect value > if we first call std::locale::global() (in C++). Of course, this only fails if you are using a non-English locale, such as my German locale that uses , instead of . for decimal points.
Created attachment 264468 [details] [review] 0001-Replace-more-uses-of-atof-with-g_ascii_strtod.patch While I'm at it, here is another patch to avoid some more uses of atof() elsewhere in libgda. But you should check that each of these is really not meant to be locale-dependent.
I though this was corrected with the gda_locale_changed() function... I'll have a look ASAP at your patches.
I've corrected, for now without your patches the problem, see commit https://git.gnome.org/browse/libgda/commit/?id=b85faf3eacd4bf8ce182938fbfd0b89dab5ac6a8 I'll use you patches to avoid having to change the locale which is not thread safe.
Thanks. When you are ready, it would be great to have a release to depend on for this fix.
I think we forgot to mark this bug as fixed.