Commit 1e52895e authored by Alexandre Julliard's avatar Alexandre Julliard

kernelbase: Implement IsNLSDefinedString().

parent 94f7f52d
......@@ -989,7 +989,7 @@
@ stdcall -import IsDBCSLeadByteEx(long long)
@ stdcall -import IsDebuggerPresent()
@ stub -i386 IsLSCallback
# @ stub IsNLSDefinedString
@ stdcall -import IsNLSDefinedString(long long ptr wstr long)
@ stdcall -import IsNormalizedString(long wstr long)
@ stdcall -import IsProcessInJob(long long ptr)
@ stdcall -import IsProcessorFeaturePresent(long)
......
......@@ -95,6 +95,7 @@ static INT (WINAPI *pFindStringOrdinal)(DWORD, LPCWSTR lpStringSource, INT, LPCW
static BOOL (WINAPI *pGetNLSVersion)(NLS_FUNCTION,LCID,NLSVERSIONINFO*);
static BOOL (WINAPI *pGetNLSVersionEx)(NLS_FUNCTION,LPCWSTR,NLSVERSIONINFOEX*);
static DWORD (WINAPI *pIsValidNLSVersion)(NLS_FUNCTION,LPCWSTR,NLSVERSIONINFOEX*);
static BOOL (WINAPI *pIsNLSDefinedString)(NLS_FUNCTION,DWORD,NLSVERSIONINFO*,const WCHAR *,int);
static NTSTATUS (WINAPI *pRtlNormalizeString)(ULONG, LPCWSTR, INT, LPWSTR, INT*);
static NTSTATUS (WINAPI *pRtlIsNormalizedString)(ULONG, LPCWSTR, INT, BOOLEAN*);
static NTSTATUS (WINAPI *pNtGetNlsSectionPtr)(ULONG,ULONG,void*,void**,SIZE_T*);
......@@ -146,6 +147,7 @@ static void InitFunctionPointers(void)
X(GetNLSVersion);
X(GetNLSVersionEx);
X(IsValidNLSVersion);
X(IsNLSDefinedString);
mod = GetModuleHandleA("kernelbase");
X(NlsValidateLocale);
......@@ -7750,6 +7752,56 @@ static void test_NLSVersion(void)
ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
}
else win_skip( "IsValidNLSVersion not available\n" );
if (pIsNLSDefinedString)
{
SetLastError( 0xdeadbeef );
info.dwNLSVersionInfoSize = sizeof(info);
ret = pIsNLSDefinedString( COMPARE_STRING, 0, (NLSVERSIONINFO *)&info, L"A", 1 );
if (ret)
ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
else
ok( broken( GetLastError() == ERROR_INSUFFICIENT_BUFFER ), /* win7 */
"wrong error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
info.dwNLSVersionInfoSize = sizeof(info) + 1;
ret = pIsNLSDefinedString( COMPARE_STRING, 0, (NLSVERSIONINFO *)&info, L"A", 1 );
ok( !ret, "IsNLSDefinedString succeeded\n" );
ok( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "wrong error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
info.dwNLSVersionInfoSize = offsetof( NLSVERSIONINFO, dwEffectiveId );
ret = pIsNLSDefinedString( COMPARE_STRING, 0, (NLSVERSIONINFO *)&info, L"A", 1 );
ok( ret, "IsNLSDefinedString failed err %lu\n", GetLastError() );
ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pIsNLSDefinedString( 2, 0, (NLSVERSIONINFO *)&info, L"A", 1 );
ok( !ret, "IsNLSDefinedString succeeded\n" );
ok( GetLastError() == ERROR_INVALID_FLAGS, "wrong error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pIsNLSDefinedString( COMPARE_STRING, 0, (NLSVERSIONINFO *)&info, L"ABC", -10 );
ok( ret, "IsNLSDefinedString failed err %lu\n", GetLastError() );
ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pIsNLSDefinedString( COMPARE_STRING, 0, (NLSVERSIONINFO *)&info, L"ABC", -1 );
ok( ret, "IsNLSDefinedString failed err %lu\n", GetLastError() );
ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pIsNLSDefinedString( COMPARE_STRING, 0, (NLSVERSIONINFO *)&info, L"\xd800", 1 );
ok( !ret, "IsNLSDefinedString failed err %lu\n", GetLastError() );
ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
SetLastError( 0xdeadbeef );
ret = pIsNLSDefinedString( COMPARE_STRING, 0, (NLSVERSIONINFO *)&info, L"\xd800", -20 );
ok( !ret, "IsNLSDefinedString failed err %lu\n", GetLastError() );
ok( GetLastError() == 0xdeadbeef, "wrong error %lu\n", GetLastError() );
}
else win_skip( "IsNLSDefinedString not available\n" );
}
static void test_locale_nls(void)
......
......@@ -892,7 +892,7 @@
# @ stub IsEnclaveTypeSupported
# @ stub IsGlobalizationUserSettingsKeyRedirected
@ stdcall IsInternetESCEnabled()
@ stub IsNLSDefinedString
@ stdcall IsNLSDefinedString(long long ptr wstr long)
@ stdcall IsNormalizedString(long wstr long)
# @ stub IsProcessCritical
@ stdcall IsProcessInJob(long long ptr)
......
......@@ -6431,6 +6431,47 @@ BOOL WINAPI DECLSPEC_HOTPATCH IsValidLocaleName( const WCHAR *locale )
/******************************************************************************
* IsNLSDefinedString (kernelbase.@)
*/
BOOL WINAPI DECLSPEC_HOTPATCH IsNLSDefinedString( NLS_FUNCTION func, DWORD flags, NLSVERSIONINFO *info,
const WCHAR *str, int len )
{
int i;
if (func != COMPARE_STRING)
{
SetLastError( ERROR_INVALID_FLAGS );
return FALSE;
}
if (info)
{
if (info->dwNLSVersionInfoSize != sizeof(*info) &&
(info->dwNLSVersionInfoSize != offsetof( NLSVERSIONINFO, dwEffectiveId )))
{
SetLastError( ERROR_INSUFFICIENT_BUFFER );
return FALSE;
}
}
if (len < 0) len = lstrlenW( str ) + 1;
for (i = 0; i < len; i++)
{
if (is_private_use_area_char( str[i] )) return FALSE;
if (IS_LOW_SURROGATE( str[i] )) return FALSE;
if (IS_HIGH_SURROGATE( str[i] ))
{
if (++i == len) return FALSE;
if (!IS_LOW_SURROGATE( str[i] )) return FALSE;
continue;
}
if (!(get_char_type( CT_CTYPE1, str[i] ) & C1_DEFINED)) return FALSE;
}
return TRUE;
}
/******************************************************************************
* IsValidNLSVersion (kernelbase.@)
*/
DWORD WINAPI DECLSPEC_HOTPATCH IsValidNLSVersion( NLS_FUNCTION func, const WCHAR *locale,
......
......@@ -964,6 +964,7 @@ WINNORMALIZEAPI INT WINAPI IdnToNameprepUnicode(DWORD,LPCWSTR,INT,LPWSTR,INT)
WINNORMALIZEAPI INT WINAPI IdnToUnicode(DWORD,LPCWSTR,INT,LPWSTR,INT);
WINBASEAPI BOOL WINAPI IsDBCSLeadByte(BYTE);
WINBASEAPI BOOL WINAPI IsDBCSLeadByteEx(UINT,BYTE);
WINBASEAPI BOOL WINAPI IsNLSDefinedString(NLS_FUNCTION,DWORD,NLSVERSIONINFO*,LPCWSTR,INT);
WINNORMALIZEAPI BOOL WINAPI IsNormalizedString(NORM_FORM,LPCWSTR,INT);
WINBASEAPI BOOL WINAPI IsValidCodePage(UINT);
WINBASEAPI BOOL WINAPI IsValidLanguageGroup(LGRPID,DWORD);
......
......@@ -110,7 +110,7 @@ struct ctype
static const char *get_ctype( const struct ctype *ctype )
{
static char buffer[100];
static const char *c1[] = { "up ", "lo ", "dg ", "sp ", "pt ", "cl ", "bl ", "xd ", "al " };
static const char *c1[] = { "up ", "lo ", "dg ", "sp ", "pt ", "cl ", "bl ", "xd ", "al " , "df "};
static const char *c2[] = { " ", "L ", "R ", "EN", "ES", "ET",
"AN", "CS", "B ", "S ", "WS", "ON" };
static const char *c3[] = { "ns ", "di ", "vo ", "sy ", "ka ", "hi ", "hw ", "fw ",
......
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