r20189 - gnucash/trunk/src/backend/dbi - Handle localization-ignorance bug in libdbi by setting LC_NUMERIC locale

Christian Stimming stimming at tuhh.de
Sat Jan 29 04:43:38 EST 2011


Am Freitag, 28. Januar 2011 schrieb John Ralls:
> Author: jralls
> Date: 2011-01-28 16:35:50 -0500 (Fri, 28 Jan 2011)
> New Revision: 20189
> Trac: http://svn.gnucash.org/trac/changeset/20189
> 
> Modified:
>    gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
> Log:
> Handle localization-ignorance bug in libdbi by setting LC_NUMERIC locale
> to "C" before calling dbi_result_get_double() and back afterwards. This
> is not thread-safe, but we're not multithreaded yet.

I believe unfortunately it doesn't work this easy way: The returned value of 
setlocale( ) might point to static storage, which will subsequently be 
overwritten by setlocale("C"), so you won't be setting it to the original 
value by the third setlocale. Instead, unfortunately you will have to g_strdup 
the returned value of setlocale() immediately, then change the locale, then do 
the broken libdbi stuff, then setlocale() back to the original value, then 
g_free the original value.

Seems like this is asking for some refactoring into separate functions...

Thanks for working on this in any case!

Regards,

Christian


More information about the gnucash-devel mailing list