msvcrt: Added _mbstrlen_l implementation.
This commit is contained in:
parent
df6cd82ccf
commit
d367314b46
|
@ -1688,26 +1688,33 @@ int CDECL MSVCRT_mblen(const char* str, MSVCRT_size_t size)
|
||||||
return 0;
|
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.@)
|
* _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)
|
MSVCRT_size_t CDECL _mbstrlen(const char* str)
|
||||||
{
|
{
|
||||||
if(get_locale()->locinfo->mb_cur_max > 1)
|
return _mbstrlen_l(str, NULL);
|
||||||
{
|
|
||||||
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 */
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -734,7 +734,7 @@
|
||||||
# stub _mbstowcs_l
|
# stub _mbstowcs_l
|
||||||
# stub _mbstowcs_s_l
|
# stub _mbstowcs_s_l
|
||||||
@ cdecl _mbstrlen(str)
|
@ cdecl _mbstrlen(str)
|
||||||
# stub _mbstrlen_l
|
@ cdecl _mbstrlen_l(str ptr)
|
||||||
# stub _mbstrnlen
|
# stub _mbstrnlen
|
||||||
# stub _mbstrnlen_l
|
# stub _mbstrnlen_l
|
||||||
@ cdecl _mbsupr(str)
|
@ cdecl _mbsupr(str)
|
||||||
|
|
Loading…
Reference in New Issue