codeset problems in wprintf and wcsftime

Andy Koppe andy.koppe@gmail.com
Mon Apr 5 15:09:00 GMT 2010


Corinna Vinschen:
>> What I mean is, leave out the __get_current_ctype_locale() calls added
>> to __locale_charset() and __locale_mb_cur_max():
>>
>>   char *
>>   _DEFUN_VOID(__locale_charset)
>>   {
>> - #ifdef __HAVE_LOCALE_INFO__
>> -   return __get_current_ctype_locale ()->codeset;
>> - #else
>>     return lc_ctype_charset;
>> - #endif
>>   }
>>
>>   int
>>   _DEFUN_VOID(__locale_mb_cur_max)
>>   {
>> - #ifdef __HAVE_LOCALE_INFO__
>> -   return __get_current_ctype_locale ()->mb_cur_max[0];
>> - #else
>>     return __mb_cur_max;
>> - #endif
>>   }
>
> Why? For a *temporary* gain?

Hang on, it's you who has to justify why the indirection through
__get_current_ctype_locale() is necessary, and why it has to be added
now. All I'm saying is, keep it simple until the locale_t stuff
actually requires more complexity.

This is not a big change to your patch that I'm asking for here. The
lc_ctype_charset and __mb_cur_max variables are still there and still
being set, so unless I'm overlooking something, removing those lines
above is all there is to it.


> Temporarily you have a slight
> speedup, but this will have to change anyway.  The locale is not any
> longer a process-wide property.

That's why I keep on saying that __mb_cur_max and lc_ctype_charset
should move into locale_t when the time comes.


> Of course there must be a global locale_t.  But the reent structure
> must have a pointer to it because the locale is no longer a global
> property of the process.  The reent structure does not *contain* a
> locale_t.  It *points* to the current locale_t of the thread, and that
> locale_t *can* be the global locale_t, *or* a thread-specific locale.
> See SUSv4 newlocale(3), uselocale(3), or, for an extra kick, stuff like
> strcasecmp_l(3).

Sorry, I'd overlooked uselocale for setting a thread-specific locale.
So you're right, the reent structure has to have a pointer to the
current locale_t. I'd thought the _l functions were the whole point of
the locale_t stuff, but I guess those might be left to a second stage?

Andy



More information about the Newlib mailing list