From d367314b463e47aa24dea801f0789f459b3dcf4d Mon Sep 17 00:00:00 2001 From: Piotr Caban Date: Thu, 6 May 2010 14:27:22 +0200 Subject: [PATCH] msvcrt: Added _mbstrlen_l implementation. --- dlls/msvcrt/mbcs.c | 41 ++++++++++++++++++++++++----------------- dlls/msvcrt/msvcrt.spec | 2 +- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index e5588085ec5..c562234dc00 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -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); } diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 4334b850d35..34374429a05 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -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)