Commit c59a856c authored by Bartosz Kosiorek's avatar Bartosz Kosiorek Committed by Alexandre Julliard

msvcrt: Add _mbsbtype_l implementation.

parent 4e2d8b13
......@@ -1096,7 +1096,7 @@
@ extern _mbctype MSVCRT_mbctype
@ stub _mblen_l
@ cdecl _mbsbtype(str long)
@ stub _mbsbtype_l
@ cdecl _mbsbtype_l(str long ptr)
@ cdecl _mbscat_s(ptr long str)
@ cdecl _mbscat_s_l(ptr long str ptr)
@ cdecl _mbschr(str long)
......
......@@ -1453,7 +1453,7 @@
@ extern _mbctype MSVCRT_mbctype
@ stub _mblen_l
@ cdecl _mbsbtype(str long)
@ stub _mbsbtype_l
@ cdecl _mbsbtype_l(str long ptr)
@ cdecl _mbscat_s(ptr long str)
@ cdecl _mbscat_s_l(ptr long str ptr)
@ cdecl _mbschr(str long)
......
......@@ -1464,7 +1464,7 @@
@ extern _mbctype MSVCRT_mbctype
@ stub _mblen_l
@ cdecl _mbsbtype(str long)
@ stub _mbsbtype_l
@ cdecl _mbsbtype_l(str long ptr)
@ cdecl _mbscat_s(ptr long str)
@ cdecl _mbscat_s_l(ptr long str ptr)
@ cdecl _mbschr(str long)
......
......@@ -768,7 +768,7 @@
@ extern _mbctype MSVCRT_mbctype
@ stub _mblen_l
@ cdecl _mbsbtype(str long)
@ stub _mbsbtype_l
@ cdecl _mbsbtype_l(str long ptr)
@ cdecl _mbscat_s(ptr long str)
@ cdecl _mbscat_s_l(ptr long str ptr)
@ cdecl _mbschr(str long)
......
......@@ -746,7 +746,7 @@
@ extern _mbctype MSVCRT_mbctype
@ stub _mblen_l
@ cdecl _mbsbtype(str long)
@ stub _mbsbtype_l
@ cdecl _mbsbtype_l(str long ptr)
@ cdecl _mbscat_s(ptr long str)
@ cdecl _mbscat_s_l(ptr long str ptr)
@ cdecl _mbschr(str long)
......
......@@ -2028,34 +2028,55 @@ int CDECL _mbbtype(unsigned char c, int type)
}
/*********************************************************************
* _mbsbtype (MSVCRT.@)
* _mbsbtype_l (MSVCRT.@)
*/
int CDECL _mbsbtype(const unsigned char *str, size_t count)
int CDECL _mbsbtype_l(const unsigned char *str, size_t count, _locale_t locale)
{
int lead = 0;
const unsigned char *end = str + count;
int lead = 0;
pthreadmbcinfo mbcinfo;
const unsigned char *end = str + count;
/* Lead bytes can also be trail bytes so we need to analyse the string.
* Also we must return _MBC_ILLEGAL for chars past the end of the string
*/
while (str < end) /* Note: we skip the last byte - will check after the loop */
{
if (!*str)
return _MBC_ILLEGAL;
lead = get_mbcinfo()->ismbcodepage && !lead && _ismbblead(*str);
str++;
}
if (!MSVCRT_CHECK_PMT(str))
return _MBC_ILLEGAL;
if (lead)
if (_ismbbtrail(*str))
return _MBC_TRAIL;
if (locale)
mbcinfo = locale->mbcinfo;
else
return _MBC_ILLEGAL;
else
if (_ismbblead(*str))
return _MBC_LEAD;
mbcinfo = get_mbcinfo();
/* Lead bytes can also be trail bytes so we need to analyse the string.
* Also we must return _MBC_ILLEGAL for chars past the end of the string
*/
while (str < end) /* Note: we skip the last byte - will check after the loop */
{
if (!*str)
return _MBC_ILLEGAL;
lead = mbcinfo->ismbcodepage && !lead && _ismbblead_l(*str, locale);
str++;
}
if (lead)
{
if (_ismbbtrail_l(*str, locale))
return _MBC_TRAIL;
else
return _MBC_ILLEGAL;
}
else
return _MBC_SINGLE;
{
if (_ismbblead_l(*str, locale))
return _MBC_LEAD;
else
return _MBC_SINGLE;
}
}
/*********************************************************************
* _mbsbtype (MSVCRT.@)
*/
int CDECL _mbsbtype(const unsigned char *str, size_t count)
{
return _mbsbtype_l(str, count, NULL);
}
/*********************************************************************
......
......@@ -713,7 +713,7 @@
@ extern _mbctype MSVCRT_mbctype
# stub _mblen_l(str long ptr)
@ cdecl _mbsbtype(str long)
# stub _mbsbtype_l(str long ptr)
@ cdecl _mbsbtype_l(str long ptr)
@ cdecl _mbscat(str str)
@ cdecl _mbscat_s(ptr long str)
@ cdecl _mbscat_s_l(ptr long str ptr)
......
......@@ -335,6 +335,7 @@ static void test_mbcp(void)
expect_eq(_ismbstrail(mbsonlylead, &mbsonlylead[5]), FALSE, int, "%d");
/* _mbsbtype */
expect_eq(_mbsbtype(NULL, 0), _MBC_ILLEGAL, int, "%d");
expect_eq(_mbsbtype(mbstring, 0), _MBC_LEAD, int, "%d");
expect_eq(_mbsbtype(mbstring, 1), _MBC_TRAIL, int, "%d");
expect_eq(_mbsbtype(mbstring, 2), _MBC_LEAD, int, "%d");
......
......@@ -611,7 +611,7 @@
@ cdecl _mbctoupper_l(long ptr)
@ stub _mblen_l
@ cdecl _mbsbtype(str long)
@ stub _mbsbtype_l
@ cdecl _mbsbtype_l(str long ptr)
@ cdecl _mbscat_s(ptr long str)
@ cdecl _mbscat_s_l(ptr long str ptr)
@ cdecl _mbschr(str long)
......@@ -1181,7 +1181,7 @@
@ cdecl _o__mbctoupper_l(long ptr) _mbctoupper_l
@ stub _o__mblen_l
@ cdecl _o__mbsbtype(str long) _mbsbtype
@ stub _o__mbsbtype_l
@ cdecl _o__mbsbtype_l(str long ptr) _mbsbtype_l
@ cdecl _o__mbscat_s(ptr long str) _mbscat_s
@ cdecl _o__mbscat_s_l(ptr long str ptr) _mbscat_s_l
@ cdecl _o__mbschr(str long) _mbschr
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment