Re: locale, gui vs command line question?




On 2/2/2010, "David Ne&#269;as" <yeti physics muni cz> wrote:

On Mon, 1 Feb 2010, Freddie Unpenstein wrote:
On Sun, 31 Jan 2010, james morris wrote:
Why is store/change/restore of locale bad?

There's nothing at all wrong with it in the context you
specified -- i.e. you want to ensure that floating-point
values written to and read from file always use '.' as the
decimal separator. I do that in my app, gretl (also for
reasons of portability).

The problem would be the potential that the library may have
cached locale features under a different locale, wouldn't it?

A bigger problem is that setlocale() is non-local hence it breaks
anything asynchronous, namely threads.

It may not matter in a single-threaded program but it's something you
should never do in a library.

I was about ask something along similar lines.

Presumably, if the X environment changes locale it will be GTK which
deals with it and as GTK is not threaded, and, my code which
stores/restores locale only operates within the GTK thread (my code is
multi-threaded) then GTK will only deal with the locale change when it
is doing it's internal stuff and not going about my code?

James.

Yeti



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]