msvcrt: Add mbsnlen_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 2017-10-05 19:39:25 +02:00 committed by Alexandre Julliard
parent bce8330f99
commit f097c2be11
9 changed files with 72 additions and 37 deletions

View File

@ -112,7 +112,7 @@
@ cdecl _mbsinc(str) ucrtbase._mbsinc @ cdecl _mbsinc(str) ucrtbase._mbsinc
@ stub _mbsinc_l @ stub _mbsinc_l
@ cdecl _mbslen(str) ucrtbase._mbslen @ cdecl _mbslen(str) ucrtbase._mbslen
@ stub _mbslen_l @ cdecl _mbslen_l(str ptr) ucrtbase._mbslen_l
@ cdecl _mbslwr(str) ucrtbase._mbslwr @ cdecl _mbslwr(str) ucrtbase._mbslwr
@ stub _mbslwr_l @ stub _mbslwr_l
@ cdecl _mbslwr_s(str long) ucrtbase._mbslwr_s @ cdecl _mbslwr_s(str long) ucrtbase._mbslwr_s
@ -161,8 +161,8 @@
@ stub _mbsnicoll_l @ stub _mbsnicoll_l
@ cdecl _mbsninc(str long) ucrtbase._mbsninc @ cdecl _mbsninc(str long) ucrtbase._mbsninc
@ stub _mbsninc_l @ stub _mbsninc_l
@ stub _mbsnlen @ cdecl _mbsnlen(str long) ucrtbase._mbsnlen
@ stub _mbsnlen_l @ cdecl _mbsnlen_l(str long ptr) ucrtbase._mbsnlen_l
@ cdecl _mbsnset(ptr long long) ucrtbase._mbsnset @ cdecl _mbsnset(ptr long long) ucrtbase._mbsnset
@ stub _mbsnset_l @ stub _mbsnset_l
@ stub _mbsnset_s @ stub _mbsnset_s

View File

@ -1118,7 +1118,7 @@
@ cdecl _mbsinc(str) @ cdecl _mbsinc(str)
@ stub _mbsinc_l @ stub _mbsinc_l
@ cdecl _mbslen(str) @ cdecl _mbslen(str)
@ stub _mbslen_l @ cdecl _mbslen_l(str ptr)
@ cdecl _mbslwr(str) @ cdecl _mbslwr(str)
@ stub _mbslwr_l @ stub _mbslwr_l
@ cdecl _mbslwr_s(str long) @ cdecl _mbslwr_s(str long)
@ -1167,8 +1167,8 @@
@ stub _mbsnicoll_l @ stub _mbsnicoll_l
@ cdecl _mbsninc(str long) @ cdecl _mbsninc(str long)
@ stub _mbsninc_l @ stub _mbsninc_l
@ stub _mbsnlen @ cdecl _mbsnlen(str long)
@ stub _mbsnlen_l @ cdecl _mbsnlen_l(str long ptr)
@ cdecl _mbsnset(ptr long long) @ cdecl _mbsnset(ptr long long)
@ stub _mbsnset_l @ stub _mbsnset_l
@ stub _mbsnset_s @ stub _mbsnset_s

View File

@ -1475,7 +1475,7 @@
@ cdecl _mbsinc(str) @ cdecl _mbsinc(str)
@ stub _mbsinc_l @ stub _mbsinc_l
@ cdecl _mbslen(str) @ cdecl _mbslen(str)
@ stub _mbslen_l @ cdecl _mbslen_l(str ptr)
@ cdecl _mbslwr(str) @ cdecl _mbslwr(str)
@ stub _mbslwr_l @ stub _mbslwr_l
@ cdecl _mbslwr_s(str long) @ cdecl _mbslwr_s(str long)
@ -1524,8 +1524,8 @@
@ stub _mbsnicoll_l @ stub _mbsnicoll_l
@ cdecl _mbsninc(str long) @ cdecl _mbsninc(str long)
@ stub _mbsninc_l @ stub _mbsninc_l
@ stub _mbsnlen @ cdecl _mbsnlen(str long)
@ stub _mbsnlen_l @ cdecl _mbsnlen_l(str long ptr)
@ cdecl _mbsnset(ptr long long) @ cdecl _mbsnset(ptr long long)
@ stub _mbsnset_l @ stub _mbsnset_l
@ stub _mbsnset_s @ stub _mbsnset_s

View File

@ -1485,7 +1485,7 @@
@ cdecl _mbsinc(str) @ cdecl _mbsinc(str)
@ stub _mbsinc_l @ stub _mbsinc_l
@ cdecl _mbslen(str) @ cdecl _mbslen(str)
@ stub _mbslen_l @ cdecl _mbslen_l(str ptr)
@ cdecl _mbslwr(str) @ cdecl _mbslwr(str)
@ stub _mbslwr_l @ stub _mbslwr_l
@ cdecl _mbslwr_s(str long) @ cdecl _mbslwr_s(str long)
@ -1534,8 +1534,8 @@
@ stub _mbsnicoll_l @ stub _mbsnicoll_l
@ cdecl _mbsninc(str long) @ cdecl _mbsninc(str long)
@ stub _mbsninc_l @ stub _mbsninc_l
@ stub _mbsnlen @ cdecl _mbsnlen(str long)
@ stub _mbsnlen_l @ cdecl _mbsnlen_l(str long ptr)
@ cdecl _mbsnset(ptr long long) @ cdecl _mbsnset(ptr long long)
@ stub _mbsnset_l @ stub _mbsnset_l
@ stub _mbsnset_s @ stub _mbsnset_s

View File

@ -790,7 +790,7 @@
@ cdecl _mbsinc(str) @ cdecl _mbsinc(str)
@ stub _mbsinc_l @ stub _mbsinc_l
@ cdecl _mbslen(str) @ cdecl _mbslen(str)
@ stub _mbslen_l @ cdecl _mbslen_l(str ptr)
@ cdecl _mbslwr(str) @ cdecl _mbslwr(str)
@ stub _mbslwr_l @ stub _mbslwr_l
@ cdecl _mbslwr_s(str long) @ cdecl _mbslwr_s(str long)
@ -839,8 +839,8 @@
@ stub _mbsnicoll_l @ stub _mbsnicoll_l
@ cdecl _mbsninc(str long) @ cdecl _mbsninc(str long)
@ stub _mbsninc_l @ stub _mbsninc_l
@ stub _mbsnlen @ cdecl _mbsnlen(str long)
@ stub _mbsnlen_l @ cdecl _mbsnlen_l(str long ptr)
@ cdecl _mbsnset(ptr long long) @ cdecl _mbsnset(ptr long long)
@ stub _mbsnset_l @ stub _mbsnset_l
@ stub _mbsnset_s @ stub _mbsnset_s

View File

@ -768,7 +768,7 @@
@ cdecl _mbsinc(str) @ cdecl _mbsinc(str)
@ stub _mbsinc_l @ stub _mbsinc_l
@ cdecl _mbslen(str) @ cdecl _mbslen(str)
@ stub _mbslen_l @ cdecl _mbslen_l(str ptr)
@ cdecl _mbslwr(str) @ cdecl _mbslwr(str)
@ stub _mbslwr_l @ stub _mbslwr_l
@ cdecl _mbslwr_s(str long) @ cdecl _mbslwr_s(str long)
@ -817,8 +817,8 @@
@ stub _mbsnicoll_l @ stub _mbsnicoll_l
@ cdecl _mbsninc(str long) @ cdecl _mbsninc(str long)
@ stub _mbsninc_l @ stub _mbsninc_l
@ stub _mbsnlen @ cdecl _mbsnlen(str long)
@ stub _mbsnlen_l @ cdecl _mbsnlen_l(str long ptr)
@ cdecl _mbsnset(ptr long long) @ cdecl _mbsnset(ptr long long)
@ stub _mbsnset_l @ stub _mbsnset_l
@ stub _mbsnset_s @ stub _mbsnset_s

View File

@ -568,24 +568,59 @@ unsigned char* CDECL _mbsninc(const unsigned char* str, MSVCRT_size_t num)
return (unsigned char*)str; return (unsigned char*)str;
} }
/*********************************************************************
* _mbsnlen_l(MSVCRT.@)
*/
MSVCRT_size_t CDECL _mbsnlen_l(const unsigned char *str,
MSVCRT_size_t maxsize, MSVCRT__locale_t locale)
{
MSVCRT_pthreadmbcinfo mbcinfo;
MSVCRT_size_t i = 0, len = 0;
if(!locale)
mbcinfo = get_mbcinfo();
else
mbcinfo = locale->mbcinfo;
if(!mbcinfo->ismbcodepage)
return MSVCRT_strnlen((const char*)str, maxsize);
while(i<maxsize && str[i])
{
if (_ismbblead_l(str[i], locale))
{
i++;
if (!str[i]) /* count only full chars */
break;
}
i++;
len++;
}
return i < maxsize ? len : maxsize;
}
/********************************************************************* /*********************************************************************
* _mbslen(MSVCRT.@) * _mbslen(MSVCRT.@)
*/ */
MSVCRT_size_t CDECL _mbslen(const unsigned char* str) MSVCRT_size_t CDECL _mbslen(const unsigned char* str)
{ {
MSVCRT_size_t len = 0; return _mbsnlen_l(str, -1, NULL);
while(*str) }
{
if (_ismbblead(*str)) /*********************************************************************
{ * _mbslen_l(MSVCRT.@)
str++; */
if (!*str) /* count only full chars */ MSVCRT_size_t CDECL _mbslen_l(const unsigned char* str, MSVCRT__locale_t locale)
break; {
} return _mbsnlen_l(str, -1, locale);
str++; }
len++;
} /*********************************************************************
return len; * _mbsnlen(MSVCRT.@)
*/
MSVCRT_size_t CDECL _mbsnlen(const unsigned char* str, MSVCRT_size_t maxsize)
{
return _mbsnlen_l(str, maxsize, NULL);
} }
/********************************************************************* /*********************************************************************

View File

@ -737,7 +737,7 @@
@ cdecl _mbsinc(str) @ cdecl _mbsinc(str)
# stub _mbsinc_l(str ptr) # stub _mbsinc_l(str ptr)
@ cdecl _mbslen(str) @ cdecl _mbslen(str)
# stub _mbslen_l(str ptr) @ cdecl _mbslen_l(str ptr)
@ cdecl _mbslwr(str) @ cdecl _mbslwr(str)
# stub _mbslwr_l(str ptr) # stub _mbslwr_l(str ptr)
@ cdecl _mbslwr_s(str long) @ cdecl _mbslwr_s(str long)
@ -786,8 +786,8 @@
# stub _mbsnicoll_l(str str long ptr) # stub _mbsnicoll_l(str str long ptr)
@ cdecl _mbsninc(str long) @ cdecl _mbsninc(str long)
# stub _mbsninc_l(str long ptr) # stub _mbsninc_l(str long ptr)
# stub _mbsnlen(str long) @ cdecl _mbsnlen(str long)
# stub _mbsnlen_l(str long ptr) @ cdecl _mbsnlen_l(str long ptr)
@ cdecl _mbsnset(ptr long long) @ cdecl _mbsnset(ptr long long)
# stub _mbsnset_l(ptr long long ptr) # stub _mbsnset_l(ptr long long ptr)
# stub _mbsnset_s(ptr long long long) # stub _mbsnset_s(ptr long long long)

View File

@ -631,7 +631,7 @@
@ cdecl _mbsinc(str) @ cdecl _mbsinc(str)
@ stub _mbsinc_l @ stub _mbsinc_l
@ cdecl _mbslen(str) @ cdecl _mbslen(str)
@ stub _mbslen_l @ cdecl _mbslen_l(str ptr)
@ cdecl _mbslwr(str) @ cdecl _mbslwr(str)
@ stub _mbslwr_l @ stub _mbslwr_l
@ cdecl _mbslwr_s(str long) @ cdecl _mbslwr_s(str long)
@ -680,8 +680,8 @@
@ stub _mbsnicoll_l @ stub _mbsnicoll_l
@ cdecl _mbsninc(str long) @ cdecl _mbsninc(str long)
@ stub _mbsninc_l @ stub _mbsninc_l
@ stub _mbsnlen @ cdecl _mbsnlen(str long)
@ stub _mbsnlen_l @ cdecl _mbsnlen_l(str long ptr)
@ cdecl _mbsnset(ptr long long) @ cdecl _mbsnset(ptr long long)
@ stub _mbsnset_l @ stub _mbsnset_l
@ stub _mbsnset_s @ stub _mbsnset_s