mirror of
git://source.winehq.org/git/wine.git
synced 2024-09-30 04:48:36 +00:00
msvcrt: Fix _strnicmp and _strnicmp_l implementation.
This commit is contained in:
parent
49d3236da9
commit
2af3f3204d
|
@ -3313,11 +3313,15 @@ int __cdecl _strnicmp_l(const char *s1, const char *s2,
|
|||
pthreadlocinfo locinfo;
|
||||
int c1, c2;
|
||||
|
||||
if(s1==NULL || s2==NULL)
|
||||
return _NLSCMPERROR;
|
||||
|
||||
if(!count)
|
||||
return 0;
|
||||
#if _MSVCR_VER>=80
|
||||
if(!MSVCRT_CHECK_PMT(s1 && s2 && count <= INT_MAX))
|
||||
#else
|
||||
/* Old versions of msvcrt.dll didn't have count <= INT_MAX check */
|
||||
if(!MSVCRT_CHECK_PMT(s1 && s2))
|
||||
#endif /* _MSVCR_VER>=140 */
|
||||
return _NLSCMPERROR;
|
||||
|
||||
if(!locale)
|
||||
locinfo = get_locinfo();
|
||||
|
@ -3349,7 +3353,7 @@ int __cdecl _strnicmp_l(const char *s1, const char *s2,
|
|||
*/
|
||||
int __cdecl _stricmp_l(const char *s1, const char *s2, _locale_t locale)
|
||||
{
|
||||
return _strnicmp_l(s1, s2, -1, locale);
|
||||
return _strnicmp_l(s1, s2, INT_MAX, locale);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
@ -3365,7 +3369,7 @@ int __cdecl _strnicmp(const char *s1, const char *s2, size_t count)
|
|||
*/
|
||||
int __cdecl _stricmp(const char *s1, const char *s2)
|
||||
{
|
||||
return _strnicmp_l(s1, s2, -1, NULL);
|
||||
return _strnicmp_l(s1, s2, INT_MAX, NULL);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
|
@ -480,15 +480,33 @@ static void test__strnicmp(void)
|
|||
static const char str2[] = "test";
|
||||
int ret;
|
||||
|
||||
SET_EXPECT(invalid_parameter_handler);
|
||||
errno = 0xdeadbeef;
|
||||
ret = _strnicmp(str1, NULL, 2);
|
||||
CHECK_CALLED(invalid_parameter_handler);
|
||||
ok(ret == _NLSCMPERROR, "got %d.\n", ret);
|
||||
ok(errno == EINVAL, "Unexpected errno %d.\n", errno);
|
||||
|
||||
SET_EXPECT(invalid_parameter_handler);
|
||||
errno = 0xdeadbeef;
|
||||
ret = _strnicmp(str1, str2, -1);
|
||||
todo_wine CHECK_CALLED(invalid_parameter_handler);
|
||||
todo_wine ok(ret == _NLSCMPERROR, "got %d.\n", ret);
|
||||
todo_wine ok(errno == EINVAL, "Unexpected errno %d.\n", errno);
|
||||
CHECK_CALLED(invalid_parameter_handler);
|
||||
ok(ret == _NLSCMPERROR, "got %d.\n", ret);
|
||||
ok(errno == EINVAL, "Unexpected errno %d.\n", errno);
|
||||
|
||||
ret = _strnicmp(str1, str2, 0);
|
||||
ok(!ret, "got %d.\n", ret);
|
||||
|
||||
ret = _strnicmp(str1, str2, 0x7fffffff);
|
||||
ok(!ret, "got %d.\n", ret);
|
||||
|
||||
/* If numbers of characters to compare is too big return error */
|
||||
SET_EXPECT(invalid_parameter_handler);
|
||||
errno = 0xdeadbeef;
|
||||
ret = _strnicmp(str1, str2, 0x80000000);
|
||||
CHECK_CALLED(invalid_parameter_handler);
|
||||
ok(ret == _NLSCMPERROR, "got %d.\n", ret);
|
||||
ok(errno == EINVAL, "Unexpected errno %d.\n", errno);
|
||||
}
|
||||
|
||||
static void test_wcsnicmp(void)
|
||||
|
|
Loading…
Reference in a new issue