kernel32: Handle LOCALE_NAME_USER_DEFAULT with tests.
This commit is contained in:
parent
32612b7de8
commit
21b6d994d2
|
@ -976,6 +976,10 @@ LCID WINAPI LocaleNameToLCID( LPCWSTR name, DWORD flags )
|
|||
|
||||
if (flags) FIXME( "unsupported flags %x\n", flags );
|
||||
|
||||
if (name == LOCALE_NAME_USER_DEFAULT)
|
||||
return GetUserDefaultLCID();
|
||||
|
||||
/* string parsing */
|
||||
parse_locale_name( name, &locale_name );
|
||||
|
||||
TRACE( "found lcid %x for %s, matches %d\n",
|
||||
|
|
|
@ -71,6 +71,8 @@ static BOOL (WINAPI *pEnumSystemLanguageGroupsA)(LANGUAGEGROUP_ENUMPROC, DWORD,
|
|||
static BOOL (WINAPI *pEnumLanguageGroupLocalesA)(LANGGROUPLOCALE_ENUMPROC, LGRPID, DWORD, LONG_PTR);
|
||||
static BOOL (WINAPI *pEnumUILanguagesA)(UILANGUAGE_ENUMPROC, DWORD, LONG_PTR);
|
||||
static BOOL (WINAPI *pEnumSystemLocalesEx)(LOCALE_ENUMPROCEX, DWORD, LPARAM, LPVOID);
|
||||
static LCID (WINAPI *pLocaleNameToLCID)(LPCWSTR, DWORD);
|
||||
static INT (WINAPI *pLCIDToLocaleName)(LCID, LPWSTR, INT, DWORD);
|
||||
static INT (WINAPI *pFoldStringA)(DWORD, LPCSTR, INT, LPSTR, INT);
|
||||
static INT (WINAPI *pFoldStringW)(DWORD, LPCWSTR, INT, LPWSTR, INT);
|
||||
static BOOL (WINAPI *pIsValidLanguageGroup)(LGRPID, DWORD);
|
||||
|
@ -80,6 +82,8 @@ static void InitFunctionPointers(void)
|
|||
hKernel32 = GetModuleHandleA("kernel32");
|
||||
pEnumSystemLanguageGroupsA = (void*)GetProcAddress(hKernel32, "EnumSystemLanguageGroupsA");
|
||||
pEnumLanguageGroupLocalesA = (void*)GetProcAddress(hKernel32, "EnumLanguageGroupLocalesA");
|
||||
pLocaleNameToLCID = (void*)GetProcAddress(hKernel32, "LocaleNameToLCID");
|
||||
pLCIDToLocaleName = (void*)GetProcAddress(hKernel32, "LCIDToLocaleName");
|
||||
pFoldStringA = (void*)GetProcAddress(hKernel32, "FoldStringA");
|
||||
pFoldStringW = (void*)GetProcAddress(hKernel32, "FoldStringW");
|
||||
pIsValidLanguageGroup = (void*)GetProcAddress(hKernel32, "IsValidLanguageGroup");
|
||||
|
@ -1637,6 +1641,43 @@ static void test_LCMapStringW(void)
|
|||
"unexpected error code %d\n", GetLastError());
|
||||
}
|
||||
|
||||
static void test_LocaleNames(void)
|
||||
{
|
||||
LCID lcid;
|
||||
INT ret;
|
||||
WCHAR buffer[LOCALE_NAME_MAX_LENGTH];
|
||||
|
||||
if (!pLocaleNameToLCID)
|
||||
{
|
||||
win_skip( "LocaleNameToLCID not available\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
/* special cases */
|
||||
buffer[0] = 0;
|
||||
lcid = pLocaleNameToLCID(LOCALE_NAME_USER_DEFAULT, 0);
|
||||
ok(lcid == GetUserDefaultLCID() || broken(GetLastError() == ERROR_INVALID_PARAMETER /* Vista */),
|
||||
"Expected lcid == %08x, got %08x, error %d\n", lcid, GetUserDefaultLCID(), GetLastError());
|
||||
ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
|
||||
ok(ret > 0, "Expected ret > 0, got %d, error %d\n", ret, GetLastError());
|
||||
trace("%08x, %s\n", lcid, wine_dbgstr_w(buffer));
|
||||
|
||||
buffer[0] = 0;
|
||||
lcid = pLocaleNameToLCID(LOCALE_NAME_SYSTEM_DEFAULT, 0);
|
||||
todo_wine ok(!lcid && GetLastError() == ERROR_INVALID_PARAMETER,
|
||||
"Expected lcid != 0, got %08x, error %d\n", lcid, GetLastError());
|
||||
ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
|
||||
ok(ret > 0, "Expected ret > 0, got %d, error %d\n", ret, GetLastError());
|
||||
trace("%08x, %s\n", lcid, wine_dbgstr_w(buffer));
|
||||
|
||||
buffer[0] = 0;
|
||||
lcid = pLocaleNameToLCID(LOCALE_NAME_INVARIANT, 0);
|
||||
todo_wine ok(lcid == 0x7F, "Expected lcid = 0x7F, got %08x, error %d\n", lcid, GetLastError());
|
||||
ret = pLCIDToLocaleName(lcid, buffer, LOCALE_NAME_MAX_LENGTH, 0);
|
||||
ok(ret > 0, "Expected ret > 0, got %d, error %d\n", ret, GetLastError());
|
||||
trace("%08x, %s\n", lcid, wine_dbgstr_w(buffer));
|
||||
}
|
||||
|
||||
/* this requires collation table patch to make it MS compatible */
|
||||
static const char * const strings_sorted[] =
|
||||
{
|
||||
|
@ -2782,6 +2823,7 @@ START_TEST(locale)
|
|||
test_CompareStringA();
|
||||
test_LCMapStringA();
|
||||
test_LCMapStringW();
|
||||
test_LocaleNames();
|
||||
test_FoldStringA();
|
||||
test_FoldStringW();
|
||||
test_ConvertDefaultLocale();
|
||||
|
|
|
@ -321,6 +321,25 @@ extern "C" {
|
|||
#define LOCALE_SSORTNAME 0x1013
|
||||
#define LOCALE_IDIGITSUBSTITUTION 0x1014
|
||||
|
||||
/* Locale name special values */
|
||||
#if defined(__GNUC__)
|
||||
# define LOCALE_NAME_INVARIANT (const WCHAR []){ 0 }
|
||||
#elif defined(_MSC_VER)
|
||||
# define LOCALE_NAME_INVARIANT L""
|
||||
#else
|
||||
static const WCHAR LOCALE_NAME_INVARIANT[] = { 0 };
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__)
|
||||
# define LOCALE_NAME_SYSTEM_DEFAULT (const WCHAR []){'!','s','y','s','-','d','e','f','a','u','l','t','-','l','o','c','a','l','e',0}
|
||||
#elif defined(_MSC_VER)
|
||||
# define LOCALE_NAME_SYSTEM_DEFAULT L"!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};
|
||||
#endif
|
||||
|
||||
#define LOCALE_NAME_USER_DEFAULT NULL
|
||||
|
||||
#define LOCALE_IDEFAULTUNIXCODEPAGE 0x1030 /* Wine extension */
|
||||
|
||||
#define NORM_IGNORECASE 0x00001
|
||||
|
|
|
@ -1985,6 +1985,7 @@ NTSYSAPI void WINAPI RtlCaptureContext(CONTEXT*);
|
|||
#define LOCALE_CUSTOM_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_DEFAULT),SORT_DEFAULT))
|
||||
#define LOCALE_CUSTOM_UNSPECIFIED (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_CUSTOM_UNSPECIFIED),SORT_DEFAULT))
|
||||
#define LOCALE_CUSTOM_UI_DEFAULT (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_UI_CUSTOM_DEFAULT),SORT_DEFAULT))
|
||||
#define LOCALE_NAME_MAX_LENGTH 85
|
||||
|
||||
|
||||
#define UNREFERENCED_PARAMETER(u) (void)(u)
|
||||
|
|
Loading…
Reference in New Issue