From ffa7ac73317f3e89c05d2a07d8e63cdf037bd17e Mon Sep 17 00:00:00 2001 From: Daniel Lehman Date: Wed, 31 Oct 2012 16:20:16 -0700 Subject: [PATCH] msvcrt: Return value from MSVCRT____mb_cur_max_func instead of pointer. --- dlls/msvcrt/mbcs.c | 12 +++++++++-- dlls/msvcrt/msvcrt.spec | 2 +- dlls/msvcrt/tests/locale.c | 44 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index 96236530c50..3c575e9b07f 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -174,13 +174,21 @@ unsigned char* CDECL __p__mbctype(void) } /********************************************************************* - * ___mb_cur_max_func(MSVCRT.@) + * __p___mb_cur_max(MSVCRT.@) */ -int* CDECL MSVCRT____mb_cur_max_func(void) +int* CDECL __p___mb_cur_max(void) { return &get_locinfo()->mb_cur_max; } +/********************************************************************* + * ___mb_cur_max_func(MSVCRT.@) + */ +int CDECL MSVCRT____mb_cur_max_func(void) +{ + return get_locinfo()->mb_cur_max; +} + /* ___mb_cur_max_l_func - not exported in native msvcrt */ int* CDECL ___mb_cur_max_l_func(MSVCRT__locale_t locale) { diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index 03181c03c90..f5cad2267b5 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -221,7 +221,7 @@ @ cdecl __p___argc() @ cdecl __p___argv() @ cdecl __p___initenv() -@ cdecl __p___mb_cur_max() MSVCRT____mb_cur_max_func +@ cdecl __p___mb_cur_max() @ cdecl __p___wargv() @ cdecl __p___winitenv() @ cdecl __p__acmdln() diff --git a/dlls/msvcrt/tests/locale.c b/dlls/msvcrt/tests/locale.c index 225cbb9f1b8..73eeb91cb08 100644 --- a/dlls/msvcrt/tests/locale.c +++ b/dlls/msvcrt/tests/locale.c @@ -25,6 +25,8 @@ static BOOL (__cdecl *p__crtGetStringTypeW)(DWORD, DWORD, const wchar_t*, int, WORD*); static int (__cdecl *pmemcpy_s)(void *, size_t, void*, size_t); +static int (__cdecl *p___mb_cur_max_func)(void); +static int *(__cdecl *p__p___mb_cur_max)(void); void* __cdecl _Gettnames(void); static void init(void) @@ -33,6 +35,8 @@ static void init(void) p__crtGetStringTypeW = (void*)GetProcAddress(hmod, "__crtGetStringTypeW"); pmemcpy_s = (void*)GetProcAddress(hmod, "memcpy_s"); + p___mb_cur_max_func = (void*)GetProcAddress(hmod, "___mb_cur_max_func"); + p__p___mb_cur_max = (void*)GetProcAddress(hmod, "__p___mb_cur_max"); } static void test_setlocale(void) @@ -738,6 +742,45 @@ static void test__Gettnames(void) setlocale(LC_ALL, "C"); } +static void test___mb_cur_max_func(void) +{ + int mb_cur_max; + + /* for newer Windows */ + if(!p___mb_cur_max_func) + win_skip("Skipping ___mb_cur_max_func tests\n"); + else { + mb_cur_max = p___mb_cur_max_func(); + ok(mb_cur_max == 1, "mb_cur_max = %d, expected 1\n", mb_cur_max); + + /* some old Windows don't set chinese */ + if (!setlocale(LC_ALL, "chinese")) + win_skip("Skipping test with chinese locale\n"); + else { + mb_cur_max = p___mb_cur_max_func(); + ok(mb_cur_max == 2, "mb_cur_max = %d, expected 2\n", mb_cur_max); + setlocale(LC_ALL, "C"); + } + } + + /* for older Windows */ + if (!p__p___mb_cur_max) + win_skip("Skipping __p___mb_cur_max tests\n"); + else { + mb_cur_max = *p__p___mb_cur_max(); + ok(mb_cur_max == 1, "mb_cur_max = %d, expected 1\n", mb_cur_max); + + /* some old Windows don't set chinese */ + if (!setlocale(LC_ALL, "chinese")) + win_skip("Skipping test with chinese locale\n"); + else { + mb_cur_max = *p__p___mb_cur_max(); + ok(mb_cur_max == 2, "mb_cur_max = %d, expected 2\n", mb_cur_max); + setlocale(LC_ALL, "C"); + } + } +} + START_TEST(locale) { init(); @@ -745,4 +788,5 @@ START_TEST(locale) test_crtGetStringTypeW(); test_setlocale(); test__Gettnames(); + test___mb_cur_max_func(); }