Ken Thomases : kernel32: Strip modifiers from the Mac locale so setlocale can parse it.

Alexandre Julliard julliard at winehq.org
Mon Aug 18 10:46:07 CDT 2008


Module: wine
Branch: master
Commit: 59bf036c80470a55ea742ff7fcc376abc02adfb6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=59bf036c80470a55ea742ff7fcc376abc02adfb6

Author: Ken Thomases <ken at codeweavers.com>
Date:   Thu Aug  7 19:00:00 2008 -0500

kernel32: Strip modifiers from the Mac locale so setlocale can parse it.

The CFLocale API can produce locale identifiers with modifiers, such as
"pl_PL at currency=EUR".  However, the Mac setlocale() can't understand such
locale strings.

---

 dlls/kernel32/locale.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 5fdb307..0366894 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -2867,12 +2867,15 @@ void LOCALE_Init(void)
     CFArrayRef preferred_locales, all_locales;
     CFStringRef user_language_string_ref = NULL;
     char user_locale[50];
+    char* p;
 
     CFLocaleRef user_locale_ref = CFLocaleCopyCurrent();
     CFStringRef user_locale_string_ref = CFLocaleGetIdentifier( user_locale_ref );
 
     CFStringGetCString( user_locale_string_ref, user_locale, sizeof(user_locale), kCFStringEncodingUTF8 );
     CFRelease( user_locale_ref );
+    /* Strip modifiers because setlocale() can't parse them. */
+    if (p = strchr( user_locale, '@' )) *p = 0;
     if (!strchr( user_locale, '.' )) strcat( user_locale, ".UTF-8" );
     unix_cp = CP_UTF8;  /* default to utf-8 even if we don't get a valid locale */
     setenv( "LANG", user_locale, 0 );




More information about the wine-cvs mailing list