msvcrt: Add _mbscspn_l implementation.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2019-10-28 13:29:09 +01:00 committed by Alexandre Julliard
parent de8e6b6a28
commit 225dad5d0d
10 changed files with 56 additions and 17 deletions

View File

@ -101,7 +101,7 @@
@ cdecl _mbscpy_s(ptr long str) ucrtbase._mbscpy_s
@ cdecl _mbscpy_s_l(ptr long str ptr) ucrtbase._mbscpy_s_l
@ cdecl _mbscspn(str str) ucrtbase._mbscspn
@ stub _mbscspn_l
@ cdecl _mbscspn_l(str str ptr) ucrtbase._mbscspn_l
@ cdecl _mbsdec(ptr ptr) ucrtbase._mbsdec
@ stub _mbsdec_l
@ cdecl _mbsdup(str) ucrtbase._mbsdup

View File

@ -1108,7 +1108,7 @@
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbscspn_l(str str ptr)
@ cdecl _mbsdec(ptr ptr)
@ stub _mbsdec_l
@ cdecl _mbsicmp(str str)

View File

@ -1465,7 +1465,7 @@
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbscspn_l(str str ptr)
@ cdecl _mbsdec(ptr ptr)
@ stub _mbsdec_l
@ cdecl _mbsicmp(str str)

View File

@ -1475,7 +1475,7 @@
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbscspn_l(str str ptr)
@ cdecl _mbsdec(ptr ptr)
@ stub _mbsdec_l
@ cdecl _mbsicmp(str str)

View File

@ -780,7 +780,7 @@
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbscspn_l(str str ptr)
@ cdecl _mbsdec(ptr ptr)
@ stub _mbsdec_l
@ cdecl _mbsicmp(str str)

View File

@ -758,7 +758,7 @@
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbscspn_l(str str ptr)
@ cdecl _mbsdec(ptr ptr)
@ stub _mbsdec_l
@ cdecl _mbsicmp(str str)

View File

@ -156,11 +156,6 @@ static inline unsigned char *u__strnset( unsigned char *s, unsigned char c, MSVC
return (unsigned char*) MSVCRT__strnset( (char*)s, c, len );
}
static inline MSVCRT_size_t u_strcspn( const unsigned char *s, const unsigned char *rej )
{
return strcspn( (const char *)s, (const char*)rej );
}
/*********************************************************************
* __p__mbctype (MSVCRT.@)
*/
@ -2073,13 +2068,39 @@ unsigned char* CDECL _mbsspnp(const unsigned char* string, const unsigned char*
}
/*********************************************************************
* _mbscspn(MSVCRT.@)
* _mbscspn_l (MSVCRT.@)
*/
MSVCRT_size_t CDECL _mbscspn_l(const unsigned char* str,
const unsigned char* cmp, MSVCRT__locale_t locale)
{
const unsigned char *p, *q;
for (p = str; *p; p++)
{
for (q = cmp; *q; q++)
{
if (_ismbblead_l(*q, locale))
{
/* duplicate a bug in native implementation */
if (!q[1]) return 0;
if (p[0] == q[0] && p[1] == q[1])
return p - str;
q++;
}
else if (p[0] == q[0])
return p - str;
}
}
return p - str;
}
/*********************************************************************
* _mbscspn (MSVCRT.@)
*/
MSVCRT_size_t CDECL _mbscspn(const unsigned char* str, const unsigned char* cmp)
{
if (get_mbcinfo()->ismbcodepage)
FIXME("don't handle double character case\n");
return u_strcspn(str, cmp);
return _mbscspn_l(str, cmp, NULL);
}
/*********************************************************************

View File

@ -724,7 +724,7 @@
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
# stub _mbscspn_l(str str ptr)
@ cdecl _mbscspn_l(str str ptr)
@ cdecl _mbsdec(ptr ptr)
# stub _mbsdec_l(ptr ptr ptr)
@ cdecl _mbsdup(str) MSVCRT__strdup

View File

@ -553,6 +553,13 @@ static void test_mbsspn( void)
ret=_mbsspn( str1, empty);
ok( ret==0, "_mbsspn returns %d should be 0\n", ret);
ret=_mbscspn( str1, set);
ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
ret=_mbscspn( str2, set);
ok( ret==4, "_mbscspn returns %d should be 4\n", ret);
ret=_mbscspn( str1, empty);
ok( ret==8, "_mbscspn returns %d should be 8\n", ret);
_setmbcp( 932);
ret=_mbsspn( mbstr, mbset1);
ok( ret==8, "_mbsspn returns %d should be 8\n", ret);
@ -565,6 +572,17 @@ static void test_mbsspn( void)
ret=_mbsspn( mbstr, mbset3);
ok( ret==14, "_mbsspn returns %d should be 14\n", ret);
ret=_mbscspn( mbstr, mbset1);
ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
ret=_mbscspn( mbstr, mbset2);
ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
ret=_mbscspn( mbstr+8, mbset1);
ok( ret==2, "_mbscspn returns %d should be 2\n", ret);
ret=_mbscspn( mbstr+8, mbset2);
ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
ret=_mbscspn( mbstr, mbset3);
ok( ret==0, "_mbscspn returns %d should be 0\n", ret);
_setmbcp( cp);
}

View File

@ -620,7 +620,7 @@
@ cdecl _mbscpy_s(ptr long str)
@ cdecl _mbscpy_s_l(ptr long str ptr)
@ cdecl _mbscspn(str str)
@ stub _mbscspn_l
@ cdecl _mbscspn_l(str str ptr)
@ cdecl _mbsdec(ptr ptr)
@ stub _mbsdec_l
@ stub _mbsdup(str)