msvcrt: Added _mbstrlen_l implementation.

This commit is contained in:
Piotr Caban 2010-05-06 14:27:22 +02:00 committed by Alexandre Julliard
parent df6cd82ccf
commit d367314b46
2 changed files with 25 additions and 18 deletions

View File

@ -1688,26 +1688,33 @@ int CDECL MSVCRT_mblen(const char* str, MSVCRT_size_t size)
return 0;
}
/*********************************************************************
* _mbstrlen_l(MSVCRT.@)
*/
MSVCRT_size_t CDECL _mbstrlen_l(const char* str, MSVCRT__locale_t locale)
{
if(!locale)
locale = get_locale();
if(locale->locinfo->mb_cur_max > 1) {
MSVCRT_size_t len = 0;
while(*str) {
/* FIXME: According to the documentation we are supposed to test for
* multi-byte character validity. Whatever that means
*/
str += MSVCRT_isleadbyte(*str) ? 2 : 1;
len++;
}
return len;
}
return strlen(str);
}
/*********************************************************************
* _mbstrlen(MSVCRT.@)
* REMARKS
* Unlike most of the multibyte string functions this function uses
* the locale codepage, not the codepage set by _setmbcp
*/
MSVCRT_size_t CDECL _mbstrlen(const char* str)
{
if(get_locale()->locinfo->mb_cur_max > 1)
{
MSVCRT_size_t len = 0;
while(*str)
{
/* FIXME: According to the documentation we are supposed to test for
* multi-byte character validity. Whatever that means
*/
str += MSVCRT_isleadbyte(*str) ? 2 : 1;
len++;
}
return len;
}
return strlen(str); /* ASCII CP */
return _mbstrlen_l(str, NULL);
}

View File

@ -734,7 +734,7 @@
# stub _mbstowcs_l
# stub _mbstowcs_s_l
@ cdecl _mbstrlen(str)
# stub _mbstrlen_l
@ cdecl _mbstrlen_l(str ptr)
# stub _mbstrnlen
# stub _mbstrnlen_l
@ cdecl _mbsupr(str)