[illumos-Developer] Problems in setlocale and codereview
Joerg Schilling
Joerg.Schilling at fokus.fraunhofer.de
Thu Sep 2 04:35:37 PDT 2010
Hi all,
you may remember that I mentioned before already that the way "webrev" handles
code imported from *BSD or other sources, it does not allow to do a decent
review.
This is a result from the fact that webrev does not include the important diffs
relatively to the original BSD code.
The reason why the i18n code does not work correctly is that the order of the
locale names did change.
Currently only setting LANG has the desired effect, but LANG should have the
lowes priority after LC_* while LC_ALL should have the highest priority.
The original order in locale.c:
/*
* Category names for getenv()
*/
static char *categories[_LC_LAST] = {
"LC_ALL",
"LC_COLLATE",
"LC_CTYPE",
"LC_MONETARY",
"LC_NUMERIC",
"LC_TIME",
"LC_MESSAGES",
};
works as expected.
If you change this order, you of course also need to change any code that
depends on the order of this array. This is e.g.
static const char *
__get_locale_env(category)
int category;
{
const char *env;
/* 1. check LC_ALL. */
env = getenv(categories[0]);
/* 2. check LC_* */
if (env == NULL || !*env)
env = getenv(categories[category]);
/* 3. check LANG */
if (env == NULL || !*env)
env = getenv("LANG");
/* 4. if none is set, fall to "C" */
if (env == NULL || !*env)
env = "C";
return (env);
}
It is obvious that we need a new review tool that creates diffs from e.g. BSD
to the current code to be able to check for bugs that have been added while
adopting code for Solaris.
Jörg
--
EMail:joerg at schily.isdn.cs.tu-berlin.de (home) Jörg Schilling D-13353 Berlin
js at cs.tu-berlin.de (uni)
joerg.schilling at fokus.fraunhofer.de (work) Blog: http://schily.blogspot.com/
URL: http://cdrecord.berlios.de/private/ ftp://ftp.berlios.de/pub/schily
More information about the Developer
mailing list