The call to setenv() has 0 (false) as its third parameter, so that LANG is not overwritten.
-Ken
On Nov 23, 2009, at 9:12 AM, Charles Davis wrote:
dlls/kernel32/locale.c | 53 +++++++++++++++++++++++++---------------------- 1 files changed, 28 insertions(+), 25 deletions(-)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c index fb9b517..d9ea8eb 100644 --- a/dlls/kernel32/locale.c +++ b/dlls/kernel32/locale.c @@ -2925,32 +2925,35 @@ void LOCALE_Init(void) UINT ansi_cp = 1252, oem_cp = 437, mac_cp = 10000, unix_cp;
#ifdef __APPLE__
- /* MacOS doesn't set the locale environment variables so we have to do it ourselves */
- 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 );
- TRACE( "setting locale to '%s'\n", user_locale );
- /* We still want to set the retrieve the preferred language as chosen in
System Preferences.app, because it can differ from CFLocaleCopyCurrent().
- */
- all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
- preferred_locales = CFBundleCopyLocalizationsForPreferences( all_locales, NULL );
- if (preferred_locales && CFArrayGetCount( preferred_locales ))
user_language_string_ref = CFArrayGetValueAtIndex( preferred_locales, 0 );
- CFRelease( all_locales );
- if (!getenv( "LANG" ))
- {
/* MacOS doesn't set the locale environment variables so we have to do it ourselves */
CFArrayRef preferred_locales, all_locales;
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 );
TRACE( "setting locale to '%s'\n", user_locale );
/* We still want to set the retrieve the preferred language as chosen in
System Preferences.app, because it can differ from CFLocaleCopyCurrent().
*/
all_locales = CFLocaleCopyAvailableLocaleIdentifiers();
preferred_locales = CFBundleCopyLocalizationsForPreferences( all_locales, NULL );
if (preferred_locales && CFArrayGetCount( preferred_locales ))
user_language_string_ref = CFArrayGetValueAtIndex( preferred_locales, 0 );
CFRelease( all_locales );
- }
#endif /* __APPLE__ */
setlocale( LC_ALL, "" );