msvcrt: Don't use strcmpW in wcscmp.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2020-07-14 20:22:45 +02:00 committed by Alexandre Julliard
parent 2a12ccd8e8
commit 841fbd5b14
2 changed files with 34 additions and 9 deletions

View File

@ -4210,6 +4210,20 @@ static void test_iswdigit(void)
} }
} }
static void test_wcscmp(void)
{
int r;
r = wcscmp(L"a", L"z");
ok(r == -1, "wcscmp returned %d\n", r);
r = wcscmp(L"z", L"a");
ok(r == 1, "wcscmp returned %d\n", r);
r = wcscmp(L"f", L"f");
ok(!r, "wcscmp returned %d\n", r);
}
START_TEST(string) START_TEST(string)
{ {
char mem[100]; char mem[100];
@ -4359,4 +4373,5 @@ START_TEST(string)
test_C_locale(); test_C_locale();
test_strstr(); test_strstr();
test_iswdigit(); test_iswdigit();
test_wcscmp();
} }

View File

@ -1583,6 +1583,24 @@ int WINAPIV MSVCRT_swprintf_p_l(MSVCRT_wchar_t *buffer, MSVCRT_size_t length,
return r; return r;
} }
/*********************************************************************
* wcscmp (MSVCRT.@)
*/
int CDECL MSVCRT_wcscmp(const MSVCRT_wchar_t *str1, const MSVCRT_wchar_t *str2)
{
while (*str1 && (*str1 == *str2))
{
str1++;
str2++;
}
if (*str1 < *str2)
return -1;
if (*str1 > *str2)
return 1;
return 0;
}
/********************************************************************* /*********************************************************************
* _wcscoll_l (MSVCRT.@) * _wcscoll_l (MSVCRT.@)
*/ */
@ -1596,7 +1614,7 @@ int CDECL MSVCRT__wcscoll_l(const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* st
locinfo = locale->locinfo; locinfo = locale->locinfo;
if(!locinfo->lc_handle[MSVCRT_LC_COLLATE]) if(!locinfo->lc_handle[MSVCRT_LC_COLLATE])
return strcmpW(str1, str2); return MSVCRT_wcscmp(str1, str2);
return CompareStringW(locinfo->lc_handle[MSVCRT_LC_COLLATE], 0, str1, -1, str2, -1)-CSTR_EQUAL; return CompareStringW(locinfo->lc_handle[MSVCRT_LC_COLLATE], 0, str1, -1, str2, -1)-CSTR_EQUAL;
} }
@ -2668,11 +2686,3 @@ MSVCRT_size_t CDECL MSVCRT_wcsxfrm(MSVCRT_wchar_t *dest,
{ {
return MSVCRT__wcsxfrm_l(dest, src, len, NULL); return MSVCRT__wcsxfrm_l(dest, src, len, NULL);
} }
/*********************************************************************
* wcscmp (MSVCRT.@)
*/
int CDECL MSVCRT_wcscmp(const MSVCRT_wchar_t *str1, const MSVCRT_wchar_t *str2)
{
return strcmpW(str1, str2);
}