|
From: <tim...@lp...> - 2007-11-24 20:12:32
|
Allin Cottrell a écrit : > On Sat, 24 Nov 2007, Ethan A Merritt wrote: > > >>> 2) How did LC_CTYPE _get_ to be equal to en_US.UTF-8 at this point >>> in execution, when the only command that has been issued is "show >>> locale"? >>> >> Puzzling indeed. With the help of many trace statements, I find that >> the locale is loaded during the first call to readline_ipc() in rlgets(), >> which is itself called from gp_get_string()... >> > > Nice detective work! > > Please note that gtk+ (used by wxGTK, used by wxt) is another offender here which calls setlocale(LC_ALL,"") or something like that. For example, on my system where wxt is built: > tipote@tipote-laptop:~$ echo "show locale; plot x; show locale" | gnuplot > > LC_CTYPE is C > LC_TIME is C > > > LC_CTYPE is fr_FR.UTF-8 > LC_TIME is fr_FR.UTF-8 When wxt is initialized, gtk+ loads the locale settings. I have already had to work around it for LC_NUMERIC in wxt, as you can see from the following lines of code taken from lines 1445-1449 in src/wxterminal/wxt_gui.cpp: > #ifdef HAVE_LOCALE_H > /* when wxGTK is initialised, GTK+ also sets the locale of the > program itself; > * we must revert it */ > setlocale(LC_NUMERIC, "C"); > #endif /*have_locale_h*/ At least, we know understand what happens on Mojca's box too: > > Here I have: > > >> > locale >> > LANG= > LC_COLLATE="sl_SI.UTF-8" > LC_CTYPE="sl_SI.UTF-8" > LC_MESSAGES="sl_SI.UTF-8" > LC_MONETARY="sl_SI.UTF-8" > LC_NUMERIC="sl_SI.UTF-8" > LC_TIME="sl_SI.UTF-8" > LC_ALL="sl_SI.UTF-8" > Terminal type set to 'aqua' > gnuplot> show locale > > LC_CTYPE is C > LC_TIME is C > LC_NUMERIC is C > > gnuplot> > > Mojca Mojca runs MacOS, so she surely doesn't have wxt, aqua is indeed the terminal initialized on startup, and she most likely doesn't have readline. That's why her LC_* are not set from her locale settings. >>> 3) Anyway, by the time you plot a graph using cairo the LC_CTYPE >>> setting has reverted to "C". I've verified that by sticking a >>> print before the g_get_charset() invocation: >>> >> I can't reproduce that. Once the locale gets set, it sticks. >> As you would expect. >> > > Yup, I was wrong. The active factor was interactive vs > non-interactive, not anything that happened in between "show > locale" and gp_cairo calling g_get_charset. > Ah, I was puzzled too by that one. > >> I am thinking that regardless of any possible bugs in the cairo >> processing, we should be consistent and always call >> setlocale(LC_CTYPE,""). >> > > That makes sense to me: maybe in init_locale? > I agree with that. Why not LC_ALL by the way ? Timothée |