msvcrt: Added mbrlen implementation.

This commit is contained in:
Piotr Caban 2012-11-29 09:22:27 +00:00 committed by Alexandre Julliard
parent d55eabbb31
commit b8ee0dd7ab
2 changed files with 34 additions and 2 deletions

View File

@ -1902,11 +1902,43 @@ int CDECL MSVCRT_mblen(const char* str, MSVCRT_size_t size)
if(get_locinfo()->mb_cur_max == 1)
return 1; /* ASCII CP */
return !MSVCRT_isleadbyte(*str) ? 1 : (size>1 ? 2 : -1);
return !MSVCRT_isleadbyte((unsigned char)*str) ? 1 : (size>1 ? 2 : -1);
}
return 0;
}
/*********************************************************************
* mbrlen(MSVCRT.@)
*/
MSVCRT_size_t CDECL MSVCRT_mbrlen(const char *str, MSVCRT_size_t len, MSVCRT_mbstate_t *state)
{
MSVCRT_mbstate_t s = (state ? *state : 0);
MSVCRT_size_t ret;
if(!len || !str || !*str)
return 0;
if(get_locinfo()->mb_cur_max == 1) {
return 1;
}else if(!s && MSVCRT_isleadbyte((unsigned char)*str)) {
if(len == 1) {
s = (unsigned char)*str;
ret = -2;
}else {
ret = 2;
}
}else if(!s) {
ret = 1;
}else {
s = 0;
ret = 2;
}
if(state)
*state = s;
return ret;
}
/*********************************************************************
* _mbstrlen_l(MSVCRT.@)
*/

View File

@ -1328,7 +1328,7 @@
@ cdecl -arch=i386,x86_64 longjmp(ptr long) MSVCRT_longjmp
@ cdecl malloc(long) MSVCRT_malloc
@ cdecl mblen(ptr long) MSVCRT_mblen
# stub mbrlen(ptr long ptr)
@ cdecl mbrlen(ptr long ptr) MSVCRT_mbrlen
# stub mbrtowc(ptr str long ptr)
# stub mbsdup_dbg(wstr long ptr long)
# stub mbsrtowcs(ptr ptr long ptr)