Regression: broken locale in 0.9.25

Kirill K. Smirnov lich at math.spbu.ru
Fri Nov 10 16:18:07 CST 2006


As glibc manual 
http://www.cs.utah.edu/dept/old/texinfo/glibc-manual-0.02/library.html
says:
QUOTE
When you read the current locale for category LC_ALL, the value encodes the 
entire combination of selected locales for all categories. In this case, the 
value is not just a single locale name. In fact, we don't make any promises 
about what it looks like. But if you specify the same "locale name" with 
LC_ALL in a subsequent call to setlocale, it restores the same combination of 
locale selections.
END OF QUOTE

So, any calls setlocale(LC_ALL, *) with analyzing the return value should be 
eliminated.

Moreover, variable LC_ALL may be absent (my case).

Quick solution:
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 9a72a4c..1ac2b4c 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -512,7 +512,10 @@ static LCID get_env_lcid( UINT *unix_cp,
     char *buf, *lang,*country,*charset,*dialect,*next;
     LCID ret = 0;
 
-    if ((lang = setlocale( category, NULL )) && *lang)
+    if (category == LC_ALL) lang = getenv("LC_ALL");
+    else lang = setlocale(category, NULL);
+    if (!lang || !*lang) lang = getenv("LANG");
+    if (lang  && *lang)
     {
         if (!strcmp(lang,"POSIX") || !strcmp(lang,"C")) goto done;
 



More information about the wine-devel mailing list