From f20f4dee00bee16b8dd860018a98a5d9080d976b Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Tue, 14 Jul 2020 20:23:02 +0200 Subject: [PATCH] msvcrt: Don't use strncmpW in wcsncmp. Signed-off-by: Piotr Caban Signed-off-by: Alexandre Julliard --- dlls/msvcrt/wcs.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 0db911fe819..961a680ab83 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -413,6 +413,21 @@ MSVCRT_wchar_t* CDECL MSVCRT__wcslwr( MSVCRT_wchar_t* str ) return str; } +/********************************************************************* + * wcsncmp (MSVCRT.@) + */ +int CDECL MSVCRT_wcsncmp(const MSVCRT_wchar_t *str1, const MSVCRT_wchar_t *str2, MSVCRT_size_t n) +{ + if (!n) + return 0; + while(--n && *str1 && (*str1 == *str2)) + { + str1++; + str2++; + } + return *str1 - *str2; +} + /********************************************************************* * _wcsncoll_l (MSVCRT.@) */ @@ -427,7 +442,7 @@ int CDECL MSVCRT__wcsncoll_l(const MSVCRT_wchar_t* str1, const MSVCRT_wchar_t* s locinfo = locale->locinfo; if(!locinfo->lc_handle[MSVCRT_LC_COLLATE]) - return strncmpW(str1, str2, count); + return MSVCRT_wcsncmp(str1, str2, count); return CompareStringW(locinfo->lc_handle[MSVCRT_LC_COLLATE], 0, str1, MSVCRT_wcsnlen(str1, count), str2, MSVCRT_wcsnlen(str2, count))-CSTR_EQUAL; @@ -2643,14 +2658,6 @@ __int64 CDECL MSVCRT__wtoi64(const MSVCRT_wchar_t *str) return MSVCRT__wtoi64_l(str, NULL); } -/********************************************************************* - * wcsncmp (MSVCRT.@) - */ -int CDECL MSVCRT_wcsncmp(const MSVCRT_wchar_t *str1, const MSVCRT_wchar_t *str2, int n) -{ - return strncmpW(str1, str2, n); -} - /********************************************************************* * _wcsxfrm_l (MSVCRT.@) */