Geoff Clare
2010-07-08 11:18:06 UTC
It's not clear to me whether the standard allows LC_GLOBAL_LOCALE
to passed to the *_l() functions (either directly or by using the
return value from uselocale(NULL)).
On the locale.h page it says:
The <locale.h> header shall define LC_GLOBAL_LOCALE, a special
locale object descriptor used by the uselocale() function.
This implies that LC_GLOBAL_LOCALE should not be passed directly
to the *_l() functions, only to uselocale(), but that still leaves
the possibility of passing the return value of uselocale(NULL) to
a *_l() function when the value happens to be LC_GLOBAL_LOCALE.
If applications are not supposed to do that, I would expect to
see statements on all the *_l() pages saying that if the locale
object has the value LC_GLOBAL_LOCALE the behaviour is undefined,
like there is on the newlocale() page.
Regardless of what the original intention was, I dislike forbidding
applications from doing this. Why should every application that
uses *_l() functions with a locale_t obtained from uselocale(NULL)
have to do things like:
if (locale == LC_GLOBAL_LOCALE)
... call isspace() ...
else
... call isspace_l() ...
everywhere, when the implementation could simply handle this inside
the *_l() functions?
to passed to the *_l() functions (either directly or by using the
return value from uselocale(NULL)).
On the locale.h page it says:
The <locale.h> header shall define LC_GLOBAL_LOCALE, a special
locale object descriptor used by the uselocale() function.
This implies that LC_GLOBAL_LOCALE should not be passed directly
to the *_l() functions, only to uselocale(), but that still leaves
the possibility of passing the return value of uselocale(NULL) to
a *_l() function when the value happens to be LC_GLOBAL_LOCALE.
If applications are not supposed to do that, I would expect to
see statements on all the *_l() pages saying that if the locale
object has the value LC_GLOBAL_LOCALE the behaviour is undefined,
like there is on the newlocale() page.
Regardless of what the original intention was, I dislike forbidding
applications from doing this. Why should every application that
uses *_l() functions with a locale_t obtained from uselocale(NULL)
have to do things like:
if (locale == LC_GLOBAL_LOCALE)
... call isspace() ...
else
... call isspace_l() ...
everywhere, when the implementation could simply handle this inside
the *_l() functions?
--
Geoff Clare <g.clare-7882/***@public.gmane.org>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
Geoff Clare <g.clare-7882/***@public.gmane.org>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England