Commit 8ccb24b1 authored by Alexandre Julliard's avatar Alexandre Julliard

ntdll: Move user/system locale initialization to ntdll.

parent d66d642d
...@@ -699,27 +699,6 @@ done: ...@@ -699,27 +699,6 @@ done:
} }
static LCID locale_to_lcid( WCHAR *win_name )
{
WCHAR *p;
LCID lcid;
if (!RtlLocaleNameToLcid( win_name, &lcid, 0 )) return lcid;
/* try neutral name */
if ((p = wcsrchr( win_name, '-' )))
{
*p = 0;
if (!RtlLocaleNameToLcid( win_name, &lcid, 2 ))
{
if (SUBLANGID(lcid) == SUBLANG_NEUTRAL)
lcid = MAKELANGID( PRIMARYLANGID(lcid), SUBLANG_DEFAULT );
return lcid;
}
}
return 0;
}
/*********************************************************************** /***********************************************************************
* init_locale * init_locale
*/ */
...@@ -728,7 +707,7 @@ void init_locale(void) ...@@ -728,7 +707,7 @@ void init_locale(void)
UINT ansi_cp = 0, oem_cp = 0; UINT ansi_cp = 0, oem_cp = 0;
USHORT *ansi_ptr, *oem_ptr; USHORT *ansi_ptr, *oem_ptr;
void *sort_ptr; void *sort_ptr;
LCID user_lcid = 0, system_lcid = 0; LCID user_lcid;
WCHAR bufferW[LOCALE_NAME_MAX_LENGTH]; WCHAR bufferW[LOCALE_NAME_MAX_LENGTH];
DYNAMIC_TIME_ZONE_INFORMATION timezone; DYNAMIC_TIME_ZONE_INFORMATION timezone;
GEOID geoid = GEOID_NOT_AVAILABLE; GEOID geoid = GEOID_NOT_AVAILABLE;
...@@ -738,16 +717,6 @@ void init_locale(void) ...@@ -738,16 +717,6 @@ void init_locale(void)
if (GetEnvironmentVariableW( L"WINEUNIXCP", bufferW, ARRAY_SIZE(bufferW) )) if (GetEnvironmentVariableW( L"WINEUNIXCP", bufferW, ARRAY_SIZE(bufferW) ))
unix_cp = wcstoul( bufferW, NULL, 10 ); unix_cp = wcstoul( bufferW, NULL, 10 );
if (GetEnvironmentVariableW( L"WINELOCALE", bufferW, ARRAY_SIZE(bufferW) ))
system_lcid = locale_to_lcid( bufferW );
if (GetEnvironmentVariableW( L"WINEUSERLOCALE", bufferW, ARRAY_SIZE(bufferW) ))
user_lcid = locale_to_lcid( bufferW );
if (!system_lcid) system_lcid = MAKELCID( MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT), SORT_DEFAULT );
if (!user_lcid) user_lcid = system_lcid;
NtSetDefaultUILanguage( LANGIDFROMLCID(user_lcid) );
NtSetDefaultLocale( TRUE, user_lcid );
NtSetDefaultLocale( FALSE, system_lcid );
kernel32_handle = GetModuleHandleW( L"kernel32.dll" ); kernel32_handle = GetModuleHandleW( L"kernel32.dll" );
...@@ -806,6 +775,7 @@ void init_locale(void) ...@@ -806,6 +775,7 @@ void init_locale(void)
/* Update registry contents if the user locale has changed. /* Update registry contents if the user locale has changed.
* This simulates the action of the Windows control panel. */ * This simulates the action of the Windows control panel. */
user_lcid = GetUserDefaultLCID();
count = sizeof(bufferW); count = sizeof(bufferW);
if (!RegQueryValueExW( intl_key, L"Locale", NULL, NULL, (BYTE *)bufferW, &count )) if (!RegQueryValueExW( intl_key, L"Locale", NULL, NULL, (BYTE *)bufferW, &count ))
{ {
......
...@@ -273,8 +273,10 @@ static const NLS_LOCALE_DATA *get_locale_data( UINT idx ) ...@@ -273,8 +273,10 @@ static const NLS_LOCALE_DATA *get_locale_data( UINT idx )
void locale_init(void) void locale_init(void)
{ {
WCHAR locale[LOCALE_NAME_MAX_LENGTH];
UNICODE_STRING name, value;
LARGE_INTEGER unused; LARGE_INTEGER unused;
LCID system_lcid; LCID system_lcid, user_lcid = 0;
NTSTATUS status; NTSTATUS status;
struct struct
{ {
...@@ -298,6 +300,26 @@ void locale_init(void) ...@@ -298,6 +300,26 @@ void locale_init(void)
lcids_index = (const NLS_LOCALE_LCID_INDEX *)((char *)locale_table + locale_table->lcids_offset); lcids_index = (const NLS_LOCALE_LCID_INDEX *)((char *)locale_table + locale_table->lcids_offset);
lcnames_index = (const NLS_LOCALE_LCNAME_INDEX *)((char *)locale_table + locale_table->lcnames_offset); lcnames_index = (const NLS_LOCALE_LCNAME_INDEX *)((char *)locale_table + locale_table->lcnames_offset);
locale_strings = (const WCHAR *)((char *)locale_table + locale_table->strings_offset); locale_strings = (const WCHAR *)((char *)locale_table + locale_table->strings_offset);
value.Buffer = locale;
value.MaximumLength = sizeof(locale);
RtlInitUnicodeString( &name, L"WINELOCALE" );
if (!RtlQueryEnvironmentVariable_U( NULL, &name, &value ))
{
const NLS_LOCALE_LCNAME_INDEX *entry = find_lcname_entry( locale );
if (entry) system_lcid = get_locale_data( entry->idx )->idefaultlanguage;
}
RtlInitUnicodeString( &name, L"WINEUSERLOCALE" );
if (!RtlQueryEnvironmentVariable_U( NULL, &name, &value ))
{
const NLS_LOCALE_LCNAME_INDEX *entry = find_lcname_entry( locale );
if (entry) user_lcid = get_locale_data( entry->idx )->idefaultlanguage;
}
if (!system_lcid) system_lcid = MAKELANGID( LANG_ENGLISH, SUBLANG_DEFAULT );
if (!user_lcid) user_lcid = system_lcid;
NtSetDefaultUILanguage( user_lcid );
NtSetDefaultLocale( TRUE, user_lcid );
NtSetDefaultLocale( FALSE, system_lcid );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment