kernelbase: Fix the name of the default system locale.

This commit is contained in:
Alexandre Julliard 2024-05-24 11:13:11 +02:00
parent 77583eed19
commit b9638ebc1c
3 changed files with 24 additions and 8 deletions

View file

@ -2964,9 +2964,9 @@ static void test_LocaleNameToLCID(void)
buffer[0] = 0;
SetLastError(0xdeadbeef);
lcid = pLocaleNameToLCID(LOCALE_NAME_SYSTEM_DEFAULT, 0);
ok(!lcid && GetLastError() == ERROR_INVALID_PARAMETER,
"Expected lcid == 0, got %08lx, error %ld\n", lcid, GetLastError());
lcid = LocaleNameToLCID(LOCALE_NAME_SYSTEM_DEFAULT, 0);
ok(lcid == GetSystemDefaultLCID(),
"Expected lcid == %08lx, got %08lx, error %ld\n", GetSystemDefaultLCID(), lcid, GetLastError());
ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
ok(ret > 0, "Expected ret > 0, got %d, error %ld\n", ret, GetLastError());
trace("%08lx, %s\n", lcid, wine_dbgstr_w(buffer));
@ -5817,10 +5817,9 @@ static void test_ResolveLocaleName(void)
{ L"zz+XX", NULL },
{ L"zz.XX", NULL },
{ LOCALE_NAME_INVARIANT, L"" },
{ LOCALE_NAME_SYSTEM_DEFAULT, NULL },
};
INT i, ret;
WCHAR buffer[LOCALE_NAME_MAX_LENGTH];
WCHAR buffer[LOCALE_NAME_MAX_LENGTH], system[LOCALE_NAME_MAX_LENGTH];
if (!pResolveLocaleName)
{
@ -5831,7 +5830,7 @@ static void test_ResolveLocaleName(void)
{
SetLastError( 0xdeadbeef );
memset( buffer, 0xcc, sizeof(buffer) );
ret = pResolveLocaleName( tests[i].name, buffer, sizeof(buffer) );
ret = pResolveLocaleName( tests[i].name, buffer, ARRAY_SIZE(buffer) );
if (tests[i].exp)
{
ok( !wcscmp( buffer, tests[i].exp ) || broken( tests[i].broken ),
@ -5847,6 +5846,14 @@ static void test_ResolveLocaleName(void)
"%s: wrong error %lu\n", debugstr_w(tests[i].name), GetLastError() );
}
}
SetLastError( 0xdeadbeef );
memset( buffer, 0xcc, sizeof(buffer) );
ret = pResolveLocaleName( LOCALE_NAME_SYSTEM_DEFAULT, buffer, ARRAY_SIZE(buffer) );
ok( ret, "failed err %lu\n", GetLastError() );
GetSystemDefaultLocaleName( system, ARRAY_SIZE(system) );
ok( !wcscmp( buffer, system ), "got wrong syslocale %s / %s\n", debugstr_w(buffer), debugstr_w(system));
ok( ret == wcslen(system) + 1, "wrong len %u / %Iu\n", ret, wcslen(system) + 1 );
SetLastError( 0xdeadbeef );
ret = pResolveLocaleName( L"en-US", buffer, 4 );
ok( !ret, "got %u\n", ret );

View file

@ -648,6 +648,11 @@ static const NLS_LOCALE_DATA *get_locale_by_name( const WCHAR *name, LCID *lcid
*lcid = user_lcid;
return user_locale;
}
if (name[0] == '!' && !compare_locale_names( name, LOCALE_NAME_SYSTEM_DEFAULT ))
{
*lcid = system_lcid;
return system_locale;
}
if (!(entry = find_lcname_entry( name ))) return NULL;
*lcid = entry->id;
return get_locale_data( entry->idx );
@ -671,6 +676,10 @@ static const struct sortguid *get_language_sort( const WCHAR *name )
if (current_locale_sort) return current_locale_sort;
name = locale_strings + user_locale->sname + 1;
}
else if (name[0] == '!' && !compare_locale_names( name, LOCALE_NAME_SYSTEM_DEFAULT ))
{
name = locale_strings + system_locale->sname + 1;
}
if (!(entry = find_lcname_entry( name )))
{

View file

@ -336,9 +336,9 @@ static const WCHAR LOCALE_NAME_INVARIANT[] = { 0 };
#endif
#if defined(_MSC_VER) || defined(__MINGW32__)
# define LOCALE_NAME_SYSTEM_DEFAULT L"!sys-default-locale"
# define LOCALE_NAME_SYSTEM_DEFAULT L"!x-sys-default-locale"
#else
static const WCHAR LOCALE_NAME_SYSTEM_DEFAULT[] = {'!','s','y','s','-','d','e','f','a','u','l','t','-','l','o','c','a','l','e',0};
static const WCHAR LOCALE_NAME_SYSTEM_DEFAULT[] = {'!','x','-','s','y','s','-','d','e','f','a','u','l','t','-','l','o','c','a','l','e',0};
#endif
#define LOCALE_NAME_USER_DEFAULT NULL