kernelbase: Reimplement EnumSystemLocalesA/W/Ex using the locale.nls data.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
1f70f72b29
commit
4c51d77951
|
@ -3506,20 +3506,19 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLanguageGroupsW( LANGUAGEGROUP_ENUMPROCW
|
||||||
BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLocalesA( LOCALE_ENUMPROCA proc, DWORD flags )
|
BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLocalesA( LOCALE_ENUMPROCA proc, DWORD flags )
|
||||||
{
|
{
|
||||||
char name[10];
|
char name[10];
|
||||||
DWORD name_len, type, index = 0;
|
DWORD i;
|
||||||
HKEY key;
|
|
||||||
|
|
||||||
if (RegOpenKeyExW( nls_key, L"Locale", 0, KEY_READ, &key )) return FALSE;
|
for (i = 0; i < locale_table->nb_lcnames; i++)
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
{
|
||||||
name_len = ARRAY_SIZE(name);
|
if (!lcnames_index[i].name) continue; /* skip invariant locale */
|
||||||
if (RegEnumValueA( key, index++, name, &name_len, NULL, &type, NULL, NULL )) break;
|
if (lcnames_index[i].id == LOCALE_CUSTOM_UNSPECIFIED) continue; /* skip locales with no lcid */
|
||||||
if (type != REG_SZ) continue;
|
if (lcnames_index[i].id & 0x80000000) continue; /* skip aliases */
|
||||||
if (!strtoul( name, NULL, 16 )) continue;
|
if (!get_locale_data( lcnames_index[i].idx )->inotneutral) continue; /* skip neutral locales */
|
||||||
|
if (!SORTIDFROMLCID( lcnames_index[i].id ) != !(flags & LCID_ALTERNATE_SORTS))
|
||||||
|
continue; /* skip alternate sorts */
|
||||||
|
sprintf( name, "%08x", lcnames_index[i].id );
|
||||||
if (!proc( name )) break;
|
if (!proc( name )) break;
|
||||||
}
|
}
|
||||||
RegCloseKey( key );
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3530,20 +3529,19 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLocalesA( LOCALE_ENUMPROCA proc, DWORD f
|
||||||
BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLocalesW( LOCALE_ENUMPROCW proc, DWORD flags )
|
BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLocalesW( LOCALE_ENUMPROCW proc, DWORD flags )
|
||||||
{
|
{
|
||||||
WCHAR name[10];
|
WCHAR name[10];
|
||||||
DWORD name_len, type, index = 0;
|
DWORD i;
|
||||||
HKEY key;
|
|
||||||
|
|
||||||
if (RegOpenKeyExW( nls_key, L"Locale", 0, KEY_READ, &key )) return FALSE;
|
for (i = 0; i < locale_table->nb_lcnames; i++)
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
{
|
||||||
name_len = ARRAY_SIZE(name);
|
if (!lcnames_index[i].name) continue; /* skip invariant locale */
|
||||||
if (RegEnumValueW( key, index++, name, &name_len, NULL, &type, NULL, NULL )) break;
|
if (lcnames_index[i].id == LOCALE_CUSTOM_UNSPECIFIED) continue; /* skip locales with no lcid */
|
||||||
if (type != REG_SZ) continue;
|
if (lcnames_index[i].id & 0x80000000) continue; /* skip aliases */
|
||||||
if (!wcstoul( name, NULL, 16 )) continue;
|
if (!get_locale_data( lcnames_index[i].idx )->inotneutral) continue; /* skip neutral locales */
|
||||||
|
if (!SORTIDFROMLCID( lcnames_index[i].id ) != !(flags & LCID_ALTERNATE_SORTS))
|
||||||
|
continue; /* skip alternate sorts */
|
||||||
|
swprintf( name, ARRAY_SIZE(name), L"%08lx", lcnames_index[i].id );
|
||||||
if (!proc( name )) break;
|
if (!proc( name )) break;
|
||||||
}
|
}
|
||||||
RegCloseKey( key );
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3554,10 +3552,8 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLocalesW( LOCALE_ENUMPROCW proc, DWORD f
|
||||||
BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLocalesEx( LOCALE_ENUMPROCEX proc, DWORD wanted_flags,
|
BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLocalesEx( LOCALE_ENUMPROCEX proc, DWORD wanted_flags,
|
||||||
LPARAM param, void *reserved )
|
LPARAM param, void *reserved )
|
||||||
{
|
{
|
||||||
WCHAR buffer[256], name[10];
|
WCHAR buffer[LOCALE_NAME_MAX_LENGTH];
|
||||||
DWORD name_len, type, neutral, flags, index = 0, alt = 0;
|
DWORD i, flags;
|
||||||
HKEY key, altkey;
|
|
||||||
LCID lcid;
|
|
||||||
|
|
||||||
if (reserved)
|
if (reserved)
|
||||||
{
|
{
|
||||||
|
@ -3565,36 +3561,20 @@ BOOL WINAPI DECLSPEC_HOTPATCH EnumSystemLocalesEx( LOCALE_ENUMPROCEX proc, DWORD
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RegOpenKeyExW( nls_key, L"Locale", 0, KEY_READ, &key )) return FALSE;
|
for (i = 0; i < locale_table->nb_lcnames; i++)
|
||||||
if (RegOpenKeyExW( key, L"Alternate Sorts", 0, KEY_READ, &altkey )) altkey = 0;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
{
|
||||||
name_len = ARRAY_SIZE(name);
|
const NLS_LOCALE_DATA *locale = get_locale_data( lcnames_index[i].idx );
|
||||||
if (RegEnumValueW( alt ? altkey : key, index++, name, &name_len, NULL, &type, NULL, NULL ))
|
const WCHAR *str = locale_strings + lcnames_index[i].name;
|
||||||
{
|
|
||||||
if (alt++) break;
|
|
||||||
index = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (type != REG_SZ) continue;
|
|
||||||
if (!(lcid = wcstoul( name, NULL, 16 ))) continue;
|
|
||||||
|
|
||||||
GetLocaleInfoW( lcid, LOCALE_SNAME | LOCALE_NOUSEROVERRIDE, buffer, ARRAY_SIZE( buffer ));
|
if (lcnames_index[i].id & 0x80000000) continue; /* skip aliases */
|
||||||
if (!GetLocaleInfoW( lcid, LOCALE_INEUTRAL | LOCALE_NOUSEROVERRIDE | LOCALE_RETURN_NUMBER,
|
memcpy( buffer, str + 1, (*str + 1) * sizeof(WCHAR) );
|
||||||
(LPWSTR)&neutral, sizeof(neutral) / sizeof(WCHAR) ))
|
if (SORTIDFROMLCID( lcnames_index[i].id ) || wcschr( str + 1, '_' ))
|
||||||
neutral = 0;
|
|
||||||
|
|
||||||
if (alt)
|
|
||||||
flags = LOCALE_ALTERNATE_SORTS;
|
flags = LOCALE_ALTERNATE_SORTS;
|
||||||
else
|
else
|
||||||
flags = LOCALE_WINDOWS | (neutral ? LOCALE_NEUTRALDATA : LOCALE_SPECIFICDATA);
|
flags = LOCALE_WINDOWS | (locale->inotneutral ? LOCALE_SPECIFICDATA : LOCALE_NEUTRALDATA);
|
||||||
|
|
||||||
if (wanted_flags && !(flags & wanted_flags)) continue;
|
if (wanted_flags && !(flags & wanted_flags)) continue;
|
||||||
if (!proc( buffer, flags, param )) break;
|
if (!proc( buffer, flags, param )) break;
|
||||||
}
|
}
|
||||||
RegCloseKey( altkey );
|
|
||||||
RegCloseKey( key );
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue