From c9f1489cab159c882b7110fa8475d86a5b849124 Mon Sep 17 00:00:00 2001 From: Akihiro Sagawa Date: Thu, 15 Mar 2012 23:41:33 +0900 Subject: [PATCH] msvcrt: Implement _mbcjmstojis. --- dlls/msvcrt/mbcs.c | 18 +++++++++++++++++- dlls/msvcrt/msvcrt.h | 1 + dlls/msvcrt/tests/string.c | 8 ++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index cde1e06295f..6d3e3fbc8db 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -474,7 +474,23 @@ unsigned int CDECL _mbcjmstojis(unsigned int c) In all other cases, c is returned unchanged */ if(get_mbcinfo()->mbcodepage == 932) { - FIXME("(%x): stub\n", c); + if(_ismbclegal(c) && HIBYTE(c) < 0xf0) + { + if(HIBYTE(c) >= 0xe0) + c -= 0x4000; + + c = (((HIBYTE(c) - 0x81)*2 + 0x21) << 8) | LOBYTE(c); + + if(LOBYTE(c) > 0x7f) + c -= 0x1; + + if(LOBYTE(c) > 0x9d) + c += 0x83; + else + c -= 0x1f; + } + else + return 0; /* Codepage is 932, but c can't be converted */ } return c; diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h index 76f558ce41c..6103c1e7bb2 100644 --- a/dlls/msvcrt/msvcrt.h +++ b/dlls/msvcrt/msvcrt.h @@ -913,6 +913,7 @@ int _setmbcp_l(int, LCID, MSVCRT_pthreadmbcinfo) DECLSPEC_HIDDEN; int __cdecl MSVCRT__write(int,const void*,unsigned int); int __cdecl _getch(void); int __cdecl _ismbblead(unsigned int); +int __cdecl _ismbclegal(unsigned int c); int __cdecl _ismbstrail(const unsigned char* start, const unsigned char* str); MSVCRT_size_t __cdecl MSVCRT_mbstowcs(MSVCRT_wchar_t*,const char*,MSVCRT_size_t); MSVCRT_intptr_t __cdecl MSVCRT__spawnve(int,const char*,const char* const *,const char* const *); diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index 659afc2e5f0..c40451c9b6c 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -901,12 +901,8 @@ static void test_mbcjmsjis(void) unsigned int ret, exp; ret = _mbcjmstojis(jmsjis[j][0]); exp = (cp[i] == 932) ? jmsjis[j][1] : jmsjis[j][0]; - if (cp[i] == 932) - todo_wine ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n", - exp, ret, jmsjis[j][0], cp[i]); - else - ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n", - exp, ret, jmsjis[j][0], cp[i]); + ok(ret == exp, "Expected 0x%x, got 0x%x (0x%x, codepage=%d)\n", + exp, ret, jmsjis[j][0], cp[i]); } } _setmbcp(prev_cp);