Commit b8ee0dd7 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added mbrlen implementation.

parent d55eabbb
......@@ -1902,12 +1902,44 @@ 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.@)
*/
MSVCRT_size_t CDECL _mbstrlen_l(const char* str, MSVCRT__locale_t locale)
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment