Commit 5dfc2a34 authored by Austin English's avatar Austin English Committed by Alexandre Julliard

kernel32: Implement IsValidLocaleName (with tests).

parent e9c368c9
......@@ -779,6 +779,7 @@
@ stdcall IsValidCodePage(long)
@ stdcall IsValidLanguageGroup(long long)
@ stdcall IsValidLocale(long long)
@ stdcall IsValidLocaleName(wstr)
# @ stub IsValidUILanguage
@ stdcall IsWow64Process(ptr ptr)
@ stdcall K32EmptyWorkingSet(long)
......
......@@ -2210,6 +2210,21 @@ BOOL WINAPI IsValidLocale( LCID lcid, DWORD flags )
(LPCWSTR)LOCALE_ILANGUAGE, LANGIDFROMLCID(lcid)) != 0;
}
/******************************************************************************
* IsValidLocaleName (KERNEL32.@)
*/
BOOL WINAPI IsValidLocaleName( LPCWSTR locale )
{
struct locale_name locale_name;
/* string parsing */
parse_locale_name( locale, &locale_name );
TRACE( "found lcid %x for %s, matches %d\n",
locale_name.lcid, debugstr_w(locale), locale_name.matches );
return locale_name.matches > 0;
}
static BOOL CALLBACK enum_lang_proc_a( HMODULE hModule, LPCSTR type,
LPCSTR name, WORD LangID, LONG_PTR lParam )
......
......@@ -86,6 +86,7 @@ static INT (WINAPI *pIdnToNameprepUnicode)(DWORD, LPCWSTR, INT, LPWSTR, INT);
static INT (WINAPI *pIdnToAscii)(DWORD, LPCWSTR, INT, LPWSTR, INT);
static INT (WINAPI *pIdnToUnicode)(DWORD, LPCWSTR, INT, LPWSTR, INT);
static INT (WINAPI *pGetLocaleInfoEx)(LPCWSTR, LCTYPE, LPWSTR, INT);
static BOOL (WINAPI *pIsValidLocaleName)(LPCWSTR);
static void InitFunctionPointers(void)
{
......@@ -104,6 +105,7 @@ static void InitFunctionPointers(void)
pIdnToAscii = (void*)GetProcAddress(hKernel32, "IdnToAscii");
pIdnToUnicode = (void*)GetProcAddress(hKernel32, "IdnToUnicode");
pGetLocaleInfoEx = (void*)GetProcAddress(hKernel32, "GetLocaleInfoEx");
pIsValidLocaleName = (void*)GetProcAddress(hKernel32, "IsValidLocaleName");
}
#define eq(received, expected, label, type) \
......@@ -3435,6 +3437,30 @@ todo_wine
}
}
static void test_IsValidLocaleName(void)
{
static const WCHAR enW[] = {'e','n',0};
static const WCHAR enusW[] = {'e','n','-','U','S',0};
static const WCHAR zzW[] = {'z','z',0};
static const WCHAR zzzzW[] = {'z','z','-','Z','Z',0};
BOOL ret;
if (!pIsValidLocaleName)
{
win_skip("IsValidLocaleName not supported\n");
return;
}
ret = pIsValidLocaleName(enW);
ok(ret, "IsValidLocaleName failed\n");
ret = pIsValidLocaleName(enusW);
ok(ret, "IsValidLocaleName failed\n");
ret = pIsValidLocaleName(zzW);
ok(!ret, "IsValidLocaleName should have failed\n");
ret = pIsValidLocaleName(zzzzW);
ok(!ret, "IsValidLocaleName should have failed\n");
}
START_TEST(locale)
{
InitFunctionPointers();
......@@ -3468,6 +3494,7 @@ START_TEST(locale)
test_IdnToNameprepUnicode();
test_IdnToAscii();
test_IdnToUnicode();
test_IsValidLocaleName();
/* this requires collation table patch to make it MS compatible */
if (0) test_sorting();
}
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