ntdll: Don't handle the full Unicode character range in wcsicmp/wcsnicmp.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
5a4cc97a3b
commit
1986328543
|
@ -57,6 +57,8 @@ static LPWSTR (__cdecl *p_wcslwr)(LPWSTR);
|
||||||
static LPWSTR (__cdecl *p_wcsupr)(LPWSTR);
|
static LPWSTR (__cdecl *p_wcsupr)(LPWSTR);
|
||||||
static WCHAR (__cdecl *ptowlower)(WCHAR);
|
static WCHAR (__cdecl *ptowlower)(WCHAR);
|
||||||
static WCHAR (__cdecl *ptowupper)(WCHAR);
|
static WCHAR (__cdecl *ptowupper)(WCHAR);
|
||||||
|
static int (__cdecl *p_wcsicmp)(LPCWSTR,LPCWSTR);
|
||||||
|
static int (__cdecl *p_wcsnicmp)(LPCWSTR,LPCWSTR,int);
|
||||||
|
|
||||||
static LPWSTR (__cdecl *pwcschr)(LPCWSTR, WCHAR);
|
static LPWSTR (__cdecl *pwcschr)(LPCWSTR, WCHAR);
|
||||||
static LPWSTR (__cdecl *pwcsrchr)(LPCWSTR, WCHAR);
|
static LPWSTR (__cdecl *pwcsrchr)(LPCWSTR, WCHAR);
|
||||||
|
@ -102,6 +104,8 @@ static void InitFunctionPtrs(void)
|
||||||
X(_wcsupr);
|
X(_wcsupr);
|
||||||
X(towlower);
|
X(towlower);
|
||||||
X(towupper);
|
X(towupper);
|
||||||
|
X(_wcsicmp);
|
||||||
|
X(_wcsnicmp);
|
||||||
X(wcschr);
|
X(wcschr);
|
||||||
X(wcsrchr);
|
X(wcsrchr);
|
||||||
X(qsort);
|
X(qsort);
|
||||||
|
@ -1196,6 +1200,28 @@ static void test_wcslwrupr(void)
|
||||||
ok( buffer[i - 1] == (i >= 'a' && i <= 'z' ? i - 32 : i), "%04x: got %04x\n", i, buffer[i-1] );
|
ok( buffer[i - 1] == (i >= 'a' && i <= 'z' ? i - 32 : i), "%04x: got %04x\n", i, buffer[i-1] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_wcsicmp(void)
|
||||||
|
{
|
||||||
|
WCHAR buf_a[2], buf_b[2];
|
||||||
|
int i, j, ret;
|
||||||
|
|
||||||
|
buf_a[1] = buf_b[1] = 0;
|
||||||
|
for (i = 0; i < 0x300; i++)
|
||||||
|
{
|
||||||
|
int lwr_a = (i >= 'A' && i <= 'Z') ? i + 32 : i;
|
||||||
|
buf_a[0] = i;
|
||||||
|
for (j = 0; j < 0x300; j++)
|
||||||
|
{
|
||||||
|
int lwr_b = (j >= 'A' && j <= 'Z') ? j + 32 : j;
|
||||||
|
buf_b[0] = j;
|
||||||
|
ret = p_wcsicmp( buf_a, buf_b );
|
||||||
|
ok( ret == lwr_a - lwr_b, "%04x:%04x: strings differ %d\n", i, j, ret );
|
||||||
|
ret = p_wcsnicmp( buf_a, buf_b, 2 );
|
||||||
|
ok( ret == lwr_a - lwr_b, "%04x:%04x: strings differ %d\n", i, j, ret );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int __cdecl intcomparefunc(const void *a, const void *b)
|
static int __cdecl intcomparefunc(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
const int *p = a, *q = b;
|
const int *p = a, *q = b;
|
||||||
|
@ -1567,5 +1593,6 @@ START_TEST(string)
|
||||||
test_tolower();
|
test_tolower();
|
||||||
test_toupper();
|
test_toupper();
|
||||||
test__strnicmp();
|
test__strnicmp();
|
||||||
|
test_wcsicmp();
|
||||||
test_sscanf();
|
test_sscanf();
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,14 @@
|
||||||
*/
|
*/
|
||||||
INT __cdecl NTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 )
|
INT __cdecl NTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 )
|
||||||
{
|
{
|
||||||
return strcmpiW( str1, str2 );
|
for (;;)
|
||||||
|
{
|
||||||
|
WCHAR ch1 = (*str1 >= 'A' && *str1 <= 'Z') ? *str1 + 32 : *str1;
|
||||||
|
WCHAR ch2 = (*str2 >= 'A' && *str2 <= 'Z') ? *str2 + 32 : *str2;
|
||||||
|
if (ch1 != ch2 || !*str1) return ch1 - ch2;
|
||||||
|
str1++;
|
||||||
|
str2++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +71,14 @@ LPWSTR __cdecl NTDLL__wcslwr( LPWSTR str )
|
||||||
*/
|
*/
|
||||||
INT __cdecl NTDLL__wcsnicmp( LPCWSTR str1, LPCWSTR str2, INT n )
|
INT __cdecl NTDLL__wcsnicmp( LPCWSTR str1, LPCWSTR str2, INT n )
|
||||||
{
|
{
|
||||||
return strncmpiW( str1, str2, n );
|
int ret = 0;
|
||||||
|
for ( ; n > 0; n--, str1++, str2++)
|
||||||
|
{
|
||||||
|
WCHAR ch1 = (*str1 >= 'A' && *str1 <= 'Z') ? *str1 + 32 : *str1;
|
||||||
|
WCHAR ch2 = (*str2 >= 'A' && *str2 <= 'Z') ? *str2 + 32 : *str2;
|
||||||
|
if ((ret = ch1 - ch2) || !*str1) break;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue