Module: wine Branch: master Commit: ba43c67f8f54b256a7c509db68a7637ee432ad3a URL: http://source.winehq.org/git/wine.git/?a=commit;h=ba43c67f8f54b256a7c509db68...
Author: Mikolaj Zalewski mikolajz@google.com Date: Sun Aug 19 22:30:45 2007 -0700
msvcrt: Implement _ismbblead/_ismbbtrail using _mbctype (with tests).
---
dlls/msvcrt/mbcs.c | 6 ++---- dlls/msvcrt/tests/string.c | 8 ++++++-- 2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/dlls/msvcrt/mbcs.c b/dlls/msvcrt/mbcs.c index f2c4d0c..1bbb32d 100644 --- a/dlls/msvcrt/mbcs.c +++ b/dlls/msvcrt/mbcs.c @@ -1056,8 +1056,7 @@ int CDECL _ismbckata(unsigned int c) */ int CDECL _ismbblead(unsigned int c) { - /* FIXME: should reference MSVCRT_mbctype */ - return MSVCRT_isleadbyte(c); + return (MSVCRT_mbctype[(c&0xff) + 1] & _M1) != 0; }
@@ -1066,8 +1065,7 @@ int CDECL _ismbblead(unsigned int c) */ int CDECL _ismbbtrail(unsigned int c) { - /* FIXME: should reference MSVCRT_mbctype */ - return !_ismbblead(c); + return (MSVCRT_mbctype[(c&0xff) + 1] & _M2) != 0; }
/********************************************************************* diff --git a/dlls/msvcrt/tests/string.c b/dlls/msvcrt/tests/string.c index aa29703..6ac3fe2 100644 --- a/dlls/msvcrt/tests/string.c +++ b/dlls/msvcrt/tests/string.c @@ -161,7 +161,6 @@ void test_cp_table(int cp, int *result, int *todo)
static void test_mbcp(void) { - unsigned int s = '\354'; int mb_orig_max = __mb_cur_max; int curr_mbcp = _getmbcp();
@@ -177,7 +176,12 @@ static void test_mbcp(void)
_setmbcp(936); ok(__mb_cur_max == mb_orig_max, "__mb_cur_max shouldn't be updated (is %d != %d)\n", __mb_cur_max, mb_orig_max); - todo_wine ok(_ismbblead(s), "got result %d\n", _ismbblead(s)); + ok(_ismbblead('\354'), "\354 should be a lead byte\n"); + ok(_ismbblead(' ') == FALSE, "' ' should not be a lead byte\n"); + ok(_ismbblead(0x1234b0), "0x1234b0 should not be a lead byte\n"); + ok(_ismbblead(0x123420) == FALSE, "0x123420 should not be a lead byte\n"); + ok(_ismbbtrail('\xb0'), "\xa0 should be a trail byte\n"); + ok(_ismbbtrail(' ') == FALSE, "' ' should not be a trail byte\n"); _setmbcp(curr_mbcp); }