|
From: Ethan A M. <merritt@u.washington.edu> - 2007-11-24 19:32:55
|
On Friday 23 November 2007 19:37, Allin Cottrell wrote:
> On Fri, 23 Nov 2007, Ethan A Merritt wrote:
> >
> > > lascaux [1235] ./gnuplot...
> >
> > > gnuplot> show locale
> > >
> > > LC_CTYPE is en_US.UTF-8
> > > LC_TIME is C
>
> This is puzzling.
>
> 1) If LC_CTYPE is en_US.UTF-8 then g_get_charset should certainly
> return UTF-8, which it is not doing in the cairo driver.
>
> 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(). The body of this routine is listed below:
/* get a line from stdin, and display a prompt if interactive */
static char*
gp_get_string(char * buffer, size_t len, const char * prompt)
{
# if defined(READLINE) || defined(HAVE_LIBREADLINE)
if (interactive)
return rlgets(buffer, len, prompt);
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^
else
return fgets_ipc(buffer, len);
# else /* !(READLINE || HAVE_LIBREADLINE) */
if (interactive)
PUT_STRING(prompt);
return GET_STRING(buffer, len);
# endif /* !(READLINE || HAVE_LIBREADLINE) */
}
So we see that the use of this input path depends on the setting of "interactive"
and the presence/absence of READLINE support.
> 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.
I am thinking that regardless of any possible bugs in the cairo processing,
we should be consistent and always call setlocale(LC_CTYPE,"").
Can anyone see a problem if we load the locale from the environment immediately
on program entry?
--
Ethan A Merritt
|