diff --git a/reactos/dll/win32/msvcrt/msvcrt.spec b/reactos/dll/win32/msvcrt/msvcrt.spec index b8451fadb4f..4c3131bac9b 100644 --- a/reactos/dll/win32/msvcrt/msvcrt.spec +++ b/reactos/dll/win32/msvcrt/msvcrt.spec @@ -1266,7 +1266,7 @@ @ cdecl -i386 longjmp(ptr long) @ cdecl malloc(long) @ cdecl mblen(ptr long) -# stub mbrlen +@ cdecl mbrlen(ptr long ptr) # stub mbrtowc # stub mbsdup_dbg # stub mbsrtowcs diff --git a/reactos/lib/sdk/crt/locale/locale.c b/reactos/lib/sdk/crt/locale/locale.c index 0aebb4b2dd4..1c7f76fb889 100644 --- a/reactos/lib/sdk/crt/locale/locale.c +++ b/reactos/lib/sdk/crt/locale/locale.c @@ -1483,6 +1483,9 @@ void __init_global_locale() unsigned i; LOCK_LOCALE; + /* Someone created it before us */ + if(global_locale) + return; global_locale = MSVCRT__create_locale(0, "C"); MSVCRT___lc_codepage = MSVCRT_locale->locinfo->lc_codepage; diff --git a/reactos/lib/sdk/crt/mbstring/islead.c b/reactos/lib/sdk/crt/mbstring/islead.c index c471e7cf06c..44c1f22e7b9 100644 --- a/reactos/lib/sdk/crt/mbstring/islead.c +++ b/reactos/lib/sdk/crt/mbstring/islead.c @@ -6,6 +6,6 @@ */ int isleadbyte(int c) { - return _isctype( c, _MLEAD ); + return _isctype( c, _LEADBYTE ); } diff --git a/reactos/lib/sdk/crt/mbstring/mbclen.c b/reactos/lib/sdk/crt/mbstring/mbclen.c index e186674242d..364c6e9b87e 100644 --- a/reactos/lib/sdk/crt/mbstring/mbclen.c +++ b/reactos/lib/sdk/crt/mbstring/mbclen.c @@ -9,10 +9,8 @@ * */ +#include #include -#include - -int isleadbyte(int byte); /* * @implemented @@ -40,3 +38,33 @@ int mblen( const char *str, size_t size ) } return 0; } + +size_t __cdecl mbrlen(const char *str, size_t len, mbstate_t *state) +{ + mbstate_t s = (state ? *state : 0); + size_t ret; + + if(!len || !str || !*str) + return 0; + + if(get_locinfo()->mb_cur_max == 1) { + return 1; + }else if(!s && 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; +} +