Signed-off-by: Paul Gofman pgofman@codeweavers.com --- .../api-ms-win-crt-multibyte-l1-1-0.spec | 2 +- .../api-ms-win-crt-private-l1-1-0.spec | 2 +- dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr110/msvcr110.spec | 2 +- dlls/msvcr120/msvcr120.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/mbcs.c | 14 +++++++++++--- dlls/msvcrt/msvcrt.spec | 2 +- dlls/msvcrt/tests/string.c | 7 +++++++ dlls/ucrtbase/ucrtbase.spec | 4 ++-- include/msvcrt/mbstring.h | 3 ++- 12 files changed, 30 insertions(+), 14 deletions(-)
diff --git a/dlls/api-ms-win-crt-multibyte-l1-1-0/api-ms-win-crt-multibyte-l1-1-0.spec b/dlls/api-ms-win-crt-multibyte-l1-1-0/api-ms-win-crt-multibyte-l1-1-0.spec index 84ae0f449bf..f33d8c8f3d3 100644 --- a/dlls/api-ms-win-crt-multibyte-l1-1-0/api-ms-win-crt-multibyte-l1-1-0.spec +++ b/dlls/api-ms-win-crt-multibyte-l1-1-0/api-ms-win-crt-multibyte-l1-1-0.spec @@ -154,7 +154,7 @@ @ stub _mbsncpy_s @ stub _mbsncpy_s_l @ cdecl _mbsnextc(str) ucrtbase._mbsnextc -@ stub _mbsnextc_l +@ cdecl _mbsnextc_l(str ptr) ucrtbase._mbsnextc_l @ cdecl _mbsnicmp(str str long) ucrtbase._mbsnicmp @ stub _mbsnicmp_l @ cdecl _mbsnicoll(str str long) ucrtbase._mbsnicoll diff --git a/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec b/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec index f9cfe67c1b0..d260ff138e3 100644 --- a/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec +++ b/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec @@ -578,7 +578,7 @@ @ stub _o__mbsncpy_s @ stub _o__mbsncpy_s_l @ cdecl _o__mbsnextc(str) ucrtbase._o__mbsnextc -@ stub _o__mbsnextc_l +@ cdecl _o__mbsnextc_l(str ptr) ucrtbase._o__mbsnextc_l @ cdecl _o__mbsnicmp(str str long) ucrtbase._o__mbsnicmp @ stub _o__mbsnicmp_l @ stub _o__mbsnicoll diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 577fb69b5a2..02cba0e3e7e 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1160,7 +1160,7 @@ @ stub _mbsncpy_s @ stub _mbsncpy_s_l @ cdecl _mbsnextc(str) -@ stub _mbsnextc_l +@ cdecl _mbsnextc_l(str ptr) @ cdecl _mbsnicmp(str str long) @ stub _mbsnicmp_l @ stub _mbsnicoll(str str long) diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index 97edbec6a74..b545ffc25c8 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -1517,7 +1517,7 @@ @ stub _mbsncpy_s @ stub _mbsncpy_s_l @ cdecl _mbsnextc(str) -@ stub _mbsnextc_l +@ cdecl _mbsnextc_l(str ptr) @ cdecl _mbsnicmp(str str long) @ stub _mbsnicmp_l @ stub _mbsnicoll(str str long) diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index 1aa63de64a1..662c0973674 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -1527,7 +1527,7 @@ @ stub _mbsncpy_s @ stub _mbsncpy_s_l @ cdecl _mbsnextc(str) -@ stub _mbsnextc_l +@ cdecl _mbsnextc_l(str ptr) @ cdecl _mbsnicmp(str str long) @ stub _mbsnicmp_l @ stub _mbsnicoll(str str long) diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index a31943e4d7d..bc5c6f7bd99 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -832,7 +832,7 @@ @ stub _mbsncpy_s @ stub _mbsncpy_s_l @ cdecl _mbsnextc(str) -@ stub _mbsnextc_l +@ cdecl _mbsnextc_l(str ptr) @ cdecl _mbsnicmp(str str long) @ stub _mbsnicmp_l @ stub _mbsnicoll(str str long) diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index ff58757cb89..38b3912b4ab 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -810,7 +810,7 @@ @ stub _mbsncpy_s @ stub _mbsncpy_s_l @ cdecl _mbsnextc(str) -@ stub _mbsnextc_l +@ cdecl _mbsnextc_l(str ptr) @ cdecl _mbsnicmp(str str long) @ stub _mbsnicmp_l @ stub _mbsnicoll(str str long) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index dc52cf1b8cf..2a42c097b42 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -393,15 +393,23 @@ int CDECL _getmbcp(void) }
/********************************************************************* - * _mbsnextc(MSVCRT.@) + * _mbsnextc_l(MSVCRT.@) */ -unsigned int CDECL _mbsnextc(const unsigned char* str) +unsigned int CDECL _mbsnextc_l(const unsigned char* str, MSVCRT__locale_t locale) { - if(_ismbblead(*str)) + if(_ismbblead_l(*str, locale)) return *str << 8 | str[1]; return *str; }
+/********************************************************************* + * _mbsnextc(MSVCRT.@) + */ +unsigned int CDECL _mbsnextc(const unsigned char* str) +{ + return _mbsnextc_l(str, NULL); +} + /********************************************************************* * _mbctolower(MSVCRT.@) */ diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 6da32d025d8..9c049455af2 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -778,7 +778,7 @@ # stub _mbsncpy_s(ptr long str long) # stub _mbsncpy_s_l(ptr long str long ptr) @ cdecl _mbsnextc(str) -# stub _mbsnextc_l(str ptr) +@ cdecl _mbsnextc_l(str ptr) @ cdecl _mbsnicmp(str str long) # stub _mbsnicmp_l(str str long ptr) @ stub _mbsnicoll(str str long) diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index a08a76fc687..c6175189884 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -114,6 +114,7 @@ static int (__cdecl *p__mbccpy_s)(unsigned char*, size_t, int*, const unsigned c static int (__cdecl *p__memicmp)(const char*, const char*, size_t); static int (__cdecl *p__memicmp_l)(const char*, const char*, size_t, _locale_t); static size_t (__cdecl *p___strncnt)(const char*, size_t); +static unsigned int (__cdecl *p_mbsnextc_l)(const unsigned char*, _locale_t);
int CDECL __STRINGTOLD(_LDOUBLE*, char**, const char*, int);
@@ -351,6 +352,11 @@ static void test_mbcp(void) expect_eq(_mbsnextc(&mbstring[2]), 0xb220, int, "%x"); /* lead + invalid tail */ expect_eq(_mbsnextc(&mbstring[3]), 0x20, int, "%x"); /* single char */
+ if (!p_mbsnextc_l) + win_skip("_mbsnextc_l tests\n"); + else + expect_eq(p_mbsnextc_l(mbstring, NULL), 0xb0b1, int, "%x"); + /* _mbclen/_mbslen */ expect_eq(_mbclen(mbstring), 2, int, "%d"); expect_eq(_mbclen(&mbstring[2]), 2, int, "%d"); @@ -4451,6 +4457,7 @@ START_TEST(string) p__memicmp = (void*)GetProcAddress(hMsvcrt, "_memicmp"); p__memicmp_l = (void*)GetProcAddress(hMsvcrt, "_memicmp_l"); p___strncnt = (void*)GetProcAddress(hMsvcrt, "__strncnt"); + p_mbsnextc_l = (void*)GetProcAddress(hMsvcrt, "_mbsnextc_l");
/* MSVCRT memcpy behaves like memmove for overlapping moves, MFC42 CString::Insert seems to rely on that behaviour */ diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index 4981d7fbac7..ee06053a700 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -673,7 +673,7 @@ @ stub _mbsncpy_s @ stub _mbsncpy_s_l @ cdecl _mbsnextc(str) -@ stub _mbsnextc_l +@ cdecl _mbsnextc_l(str ptr) @ cdecl _mbsnicmp(str str long) @ stub _mbsnicmp_l @ stub _mbsnicoll(str str long) @@ -1242,7 +1242,7 @@ @ stub _o__mbsncpy_s @ stub _o__mbsncpy_s_l @ cdecl _o__mbsnextc(str) _mbsnextc -@ stub _o__mbsnextc_l +@ cdecl _o__mbsnextc_l(str ptr) _mbsnextc_l @ cdecl _o__mbsnicmp(str str long) _mbsnicmp @ stub _o__mbsnicmp_l @ stub _o__mbsnicoll diff --git a/include/msvcrt/mbstring.h b/include/msvcrt/mbstring.h index 80be664aaaa..82bc6f1aeee 100644 --- a/include/msvcrt/mbstring.h +++ b/include/msvcrt/mbstring.h @@ -90,7 +90,8 @@ size_t __cdecl _mbsnccnt(const unsigned char*,size_t); int __cdecl _mbsncmp(const unsigned char*,const unsigned char*,size_t); int __cdecl _mbsncoll(const unsigned char*,const unsigned char*,size_t); unsigned char* __cdecl _mbsncpy(unsigned char*,const unsigned char*,size_t); -unsigned int __cdecl _mbsnextc (const unsigned char*); +unsigned int __cdecl _mbsnextc(const unsigned char*); +unsigned int __cdecl _mbsnextc_l(const unsigned char*,_locale_t); int __cdecl _mbsnicmp(const unsigned char*,const unsigned char*,size_t); int __cdecl _mbsnicoll(const unsigned char*,const unsigned char*,size_t); unsigned char* __cdecl _mbsninc(const unsigned char*,size_t);
Signed-off-by: Paul Gofman pgofman@codeweavers.com --- .../api-ms-win-crt-multibyte-l1-1-0.spec | 2 +- .../api-ms-win-crt-private-l1-1-0.spec | 2 +- dlls/msvcr100/msvcr100.spec | 2 +- dlls/msvcr110/msvcr110.spec | 2 +- dlls/msvcr120/msvcr120.spec | 2 +- dlls/msvcr80/msvcr80.spec | 2 +- dlls/msvcr90/msvcr90.spec | 2 +- dlls/msvcrt/mbcs.c | 22 ++++++++++++++----- dlls/msvcrt/msvcrt.spec | 2 +- dlls/msvcrt/tests/string.c | 11 ++++++++++ dlls/ucrtbase/ucrtbase.spec | 4 ++-- include/msvcrt/mbstring.h | 1 + 12 files changed, 39 insertions(+), 15 deletions(-)
diff --git a/dlls/api-ms-win-crt-multibyte-l1-1-0/api-ms-win-crt-multibyte-l1-1-0.spec b/dlls/api-ms-win-crt-multibyte-l1-1-0/api-ms-win-crt-multibyte-l1-1-0.spec index f33d8c8f3d3..287c3c105b2 100644 --- a/dlls/api-ms-win-crt-multibyte-l1-1-0/api-ms-win-crt-multibyte-l1-1-0.spec +++ b/dlls/api-ms-win-crt-multibyte-l1-1-0/api-ms-win-crt-multibyte-l1-1-0.spec @@ -95,7 +95,7 @@ @ cdecl _mbschr(str long) ucrtbase._mbschr @ stub _mbschr_l @ cdecl _mbscmp(str str) ucrtbase._mbscmp -@ stub _mbscmp_l +@ cdecl _mbscmp_l(str str ptr) ucrtbase._mbscmp_l @ cdecl _mbscoll(str str) ucrtbase._mbscoll @ cdecl _mbscoll_l(str str ptr) ucrtbase._mbscoll_l @ cdecl _mbscpy_s(ptr long str) ucrtbase._mbscpy_s diff --git a/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec b/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec index d260ff138e3..3bbe14613da 100644 --- a/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec +++ b/dlls/api-ms-win-crt-private-l1-1-0/api-ms-win-crt-private-l1-1-0.spec @@ -520,7 +520,7 @@ @ cdecl _o__mbschr(str long) ucrtbase._o__mbschr @ stub _o__mbschr_l @ cdecl _o__mbscmp(str str) ucrtbase._o__mbscmp -@ stub _o__mbscmp_l +@ cdecl _o__mbscmp_l(str str ptr) ucrtbase._o__mbscmp_l @ cdecl _o__mbscoll(str str) ucrtbase._o__mbscoll @ cdecl _o__mbscoll_l(str str ptr) ucrtbase._o__mbscoll_l @ cdecl _o__mbscpy_s(ptr long str) ucrtbase._o__mbscpy_s diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec index 02cba0e3e7e..ec1eb0a7714 100644 --- a/dlls/msvcr100/msvcr100.spec +++ b/dlls/msvcr100/msvcr100.spec @@ -1102,7 +1102,7 @@ @ cdecl _mbschr(str long) @ stub _mbschr_l @ cdecl _mbscmp(str str) -@ stub _mbscmp_l +@ cdecl _mbscmp_l(str str ptr) @ cdecl _mbscoll(str str) @ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscpy_s(ptr long str) diff --git a/dlls/msvcr110/msvcr110.spec b/dlls/msvcr110/msvcr110.spec index b545ffc25c8..f32f8faba98 100644 --- a/dlls/msvcr110/msvcr110.spec +++ b/dlls/msvcr110/msvcr110.spec @@ -1459,7 +1459,7 @@ @ cdecl _mbschr(str long) @ stub _mbschr_l @ cdecl _mbscmp(str str) -@ stub _mbscmp_l +@ cdecl _mbscmp_l(str str ptr) @ cdecl _mbscoll(str str) @ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscpy_s(ptr long str) diff --git a/dlls/msvcr120/msvcr120.spec b/dlls/msvcr120/msvcr120.spec index 662c0973674..82598b74edd 100644 --- a/dlls/msvcr120/msvcr120.spec +++ b/dlls/msvcr120/msvcr120.spec @@ -1469,7 +1469,7 @@ @ cdecl _mbschr(str long) @ stub _mbschr_l @ cdecl _mbscmp(str str) -@ stub _mbscmp_l +@ cdecl _mbscmp_l(str str ptr) @ cdecl _mbscoll(str str) @ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscpy_s(ptr long str) diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index bc5c6f7bd99..95ffa62ab51 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -774,7 +774,7 @@ @ cdecl _mbschr(str long) @ stub _mbschr_l @ cdecl _mbscmp(str str) -@ stub _mbscmp_l +@ cdecl _mbscmp_l(str str ptr) @ cdecl _mbscoll(str str) @ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscpy_s(ptr long str) diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index 38b3912b4ab..f2d56166099 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -752,7 +752,7 @@ @ cdecl _mbschr(str long) @ stub _mbschr_l @ cdecl _mbscmp(str str) -@ stub _mbscmp_l +@ cdecl _mbscmp_l(str str ptr) @ cdecl _mbscoll(str str) @ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscpy_s(ptr long str) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 2a42c097b42..abd1f1df053 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -872,13 +872,17 @@ unsigned char* CDECL _mbsnbcpy(unsigned char* dst, const unsigned char* src, MSV }
/********************************************************************* - * _mbscmp(MSVCRT.@) + * _mbscmp_l(MSVCRT.@) */ -int CDECL _mbscmp(const unsigned char* str, const unsigned char* cmp) +int CDECL _mbscmp_l(const unsigned char* str, const unsigned char* cmp, MSVCRT__locale_t locale) { + MSVCRT_pthreadmbcinfo mbcinfo; + if (!str || !cmp) return INT_MAX;
- if(get_mbcinfo()->ismbcodepage) + mbcinfo = locale ? locale->mbcinfo : get_mbcinfo(); + + if(mbcinfo->ismbcodepage) { unsigned int strc, cmpc; do { @@ -886,8 +890,8 @@ int CDECL _mbscmp(const unsigned char* str, const unsigned char* cmp) return *cmp ? -1 : 0; if(!*cmp) return 1; - strc = _mbsnextc(str); - cmpc = _mbsnextc(cmp); + strc = _mbsnextc_l(str, locale); + cmpc = _mbsnextc_l(cmp, locale); if(strc != cmpc) return strc < cmpc ? -1 : 1; str +=(strc > 255) ? 2 : 1; @@ -897,6 +901,14 @@ int CDECL _mbscmp(const unsigned char* str, const unsigned char* cmp) return u_strcmp(str, cmp); /* ASCII CP */ }
+/********************************************************************* + * _mbscmp(MSVCRT.@) + */ +int CDECL _mbscmp(const unsigned char* str, const unsigned char* cmp, MSVCRT__locale_t locale) +{ + return _mbscmp_l(str, cmp, NULL); +} + /********************************************************************* * _mbsnbicoll_l(MSVCRT.@) */ diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 9c049455af2..6d6767b435c 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -717,7 +717,7 @@ @ cdecl _mbschr(str long) # stub _mbschr_l(str long ptr) @ cdecl _mbscmp(str str) -# stub _mbscmp_l(str str ptr) +@ cdecl _mbscmp_l(str str ptr) @ cdecl _mbscoll(str str) @ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscpy(ptr str) diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index c6175189884..6517995edde 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -115,6 +115,7 @@ static int (__cdecl *p__memicmp)(const char*, const char*, size_t); static int (__cdecl *p__memicmp_l)(const char*, const char*, size_t, _locale_t); static size_t (__cdecl *p___strncnt)(const char*, size_t); static unsigned int (__cdecl *p_mbsnextc_l)(const unsigned char*, _locale_t); +static int (__cdecl *p_mbscmp_l)(const unsigned char*, const unsigned char*, _locale_t);
int CDECL __STRINGTOLD(_LDOUBLE*, char**, const char*, int);
@@ -3725,6 +3726,15 @@ static void test__mbscmp(void)
ret = _mbscmp(b, a); ok(ret == 1, "got %d\n", ret); + + if (!p_mbscmp_l) + { + win_skip("_mbscmp_l tests\n"); + return; + } + + ret = p_mbscmp_l(a, b, NULL); + ok(ret == -1, "got %d\n", ret); }
static void test__ismbclx(void) @@ -4458,6 +4468,7 @@ START_TEST(string) p__memicmp_l = (void*)GetProcAddress(hMsvcrt, "_memicmp_l"); p___strncnt = (void*)GetProcAddress(hMsvcrt, "__strncnt"); p_mbsnextc_l = (void*)GetProcAddress(hMsvcrt, "_mbsnextc_l"); + p_mbscmp_l = (void*)GetProcAddress(hMsvcrt, "_mbscmp_l");
/* MSVCRT memcpy behaves like memmove for overlapping moves, MFC42 CString::Insert seems to rely on that behaviour */ diff --git a/dlls/ucrtbase/ucrtbase.spec b/dlls/ucrtbase/ucrtbase.spec index ee06053a700..a6c30f9a15b 100644 --- a/dlls/ucrtbase/ucrtbase.spec +++ b/dlls/ucrtbase/ucrtbase.spec @@ -614,7 +614,7 @@ @ cdecl _mbschr(str long) @ stub _mbschr_l @ cdecl _mbscmp(str str) -@ stub _mbscmp_l +@ cdecl _mbscmp_l(str str ptr) @ cdecl _mbscoll(str str) @ cdecl _mbscoll_l(str str ptr) @ cdecl _mbscpy_s(ptr long str) @@ -1184,7 +1184,7 @@ @ cdecl _o__mbschr(str long) _mbschr @ stub _o__mbschr_l @ cdecl _o__mbscmp(str str) _mbscmp -@ stub _o__mbscmp_l +@ cdecl _o__mbscmp_l(str str ptr) _mbscmp_l @ cdecl _o__mbscoll(str str) _mbscoll @ cdecl _o__mbscoll_l(str str ptr) _mbscoll_l @ cdecl _o__mbscpy_s(ptr long str) _mbscpy_s diff --git a/include/msvcrt/mbstring.h b/include/msvcrt/mbstring.h index 82bc6f1aeee..b3336a2fbae 100644 --- a/include/msvcrt/mbstring.h +++ b/include/msvcrt/mbstring.h @@ -65,6 +65,7 @@ int __cdecl _mbsbtype(const unsigned char*,size_t); unsigned char* __cdecl _mbscat(unsigned char*,const unsigned char*); unsigned char* __cdecl _mbschr(const unsigned char*,unsigned int); int __cdecl _mbscmp(const unsigned char*,const unsigned char*); +int __cdecl _mbscmp_l(const unsigned char*,const unsigned char*,_locale_t); int __cdecl _mbscoll(const unsigned char*,const unsigned char*); unsigned char* __cdecl _mbscpy(unsigned char*,const unsigned char*); size_t __cdecl _mbscspn(const unsigned char*,const unsigned char*);
Signed-off-by: Piotr Caban piotr@codeweavers.com