msvcrt: Implement _ismbblead/_ismbbtrail using _mbctype (with tests).

This commit is contained in:
Mikolaj Zalewski 2007-08-19 22:30:45 -07:00 committed by Alexandre Julliard
parent ea824f830f
commit ba43c67f8f
2 changed files with 8 additions and 6 deletions

View File

@ -1056,8 +1056,7 @@ int CDECL _ismbckata(unsigned int c)
*/ */
int CDECL _ismbblead(unsigned int c) int CDECL _ismbblead(unsigned int c)
{ {
/* FIXME: should reference MSVCRT_mbctype */ return (MSVCRT_mbctype[(c&0xff) + 1] & _M1) != 0;
return MSVCRT_isleadbyte(c);
} }
@ -1066,8 +1065,7 @@ int CDECL _ismbblead(unsigned int c)
*/ */
int CDECL _ismbbtrail(unsigned int c) int CDECL _ismbbtrail(unsigned int c)
{ {
/* FIXME: should reference MSVCRT_mbctype */ return (MSVCRT_mbctype[(c&0xff) + 1] & _M2) != 0;
return !_ismbblead(c);
} }
/********************************************************************* /*********************************************************************

View File

@ -161,7 +161,6 @@ void test_cp_table(int cp, int *result, int *todo)
static void test_mbcp(void) static void test_mbcp(void)
{ {
unsigned int s = '\354';
int mb_orig_max = __mb_cur_max; int mb_orig_max = __mb_cur_max;
int curr_mbcp = _getmbcp(); int curr_mbcp = _getmbcp();
@ -177,7 +176,12 @@ static void test_mbcp(void)
_setmbcp(936); _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); 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); _setmbcp(curr_mbcp);
} }