This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: codeset problems in wprintf and wcsftime


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]