[illumos-Developer] Problems in setlocale and codereview

Garrett D'Amore garrett at nexenta.com
Thu Sep 2 08:26:36 PDT 2010


Thanks.  Can you post a bug on this (if not already done)?

I had used the order of the array from Solaris, but didn't realize that
the implementation was sensitive to the ordering.  So my bad.

I'll work on this soon.

	- Garrett

On Thu, 2010-09-02 at 13:35 +0200, Joerg Schilling wrote:
> 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
> 




More information about the Developer mailing list