Commit ebe3fe53 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

msvcrt: Implement _mbbtype_l().

Fixes Midnight Castle Succubus. Signed-off-by: 's avatarPaul Gofman <pgofman@codeweavers.com> Signed-off-by: 's avatarPiotr Caban <piotr@codeweavers.com> Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
parent 12106c21
......@@ -65,7 +65,7 @@
@ cdecl _mbbtombc(long) ucrtbase._mbbtombc
@ stub _mbbtombc_l
@ cdecl _mbbtype(long long) ucrtbase._mbbtype
@ stub _mbbtype_l
@ cdecl _mbbtype_l(long long ptr) ucrtbase._mbbtype_l
@ stub _mbcasemap
@ cdecl _mbccpy(ptr ptr) ucrtbase._mbccpy
@ cdecl _mbccpy_l(ptr ptr ptr) ucrtbase._mbccpy_l
......
......@@ -491,7 +491,7 @@
@ cdecl _o__mbbtombc(long) ucrtbase._o__mbbtombc
@ stub _o__mbbtombc_l
@ cdecl _o__mbbtype(long long) ucrtbase._o__mbbtype
@ stub _o__mbbtype_l
@ cdecl _o__mbbtype_l(long long ptr) ucrtbase._o__mbbtype_l
@ cdecl _o__mbccpy(ptr ptr) ucrtbase._o__mbccpy
@ cdecl _o__mbccpy_l(ptr ptr ptr) ucrtbase._o__mbccpy_l
@ cdecl _o__mbccpy_s(ptr long ptr ptr) ucrtbase._o__mbccpy_s
......
......@@ -1071,7 +1071,7 @@
@ cdecl _mbbtombc(long)
@ stub _mbbtombc_l
@ cdecl _mbbtype(long long)
@ stub _mbbtype_l
@ cdecl _mbbtype_l(long long ptr)
# extern _mbcasemap
@ cdecl _mbccpy(ptr ptr)
@ cdecl _mbccpy_l(ptr ptr ptr)
......
......@@ -1428,7 +1428,7 @@
@ cdecl _mbbtombc(long)
@ stub _mbbtombc_l
@ cdecl _mbbtype(long long)
@ stub _mbbtype_l
@ cdecl _mbbtype_l(long long ptr)
# extern _mbcasemap
@ cdecl _mbccpy(ptr ptr)
@ cdecl _mbccpy_l(ptr ptr ptr)
......
......@@ -1438,7 +1438,7 @@
@ cdecl _mbbtombc(long)
@ stub _mbbtombc_l
@ cdecl _mbbtype(long long)
@ stub _mbbtype_l
@ cdecl _mbbtype_l(long long ptr)
# extern _mbcasemap
@ cdecl _mbccpy(ptr ptr)
@ cdecl _mbccpy_l(ptr ptr ptr)
......
......@@ -743,7 +743,7 @@
@ cdecl _mbbtombc(long)
@ stub _mbbtombc_l
@ cdecl _mbbtype(long long)
@ stub _mbbtype_l
@ cdecl _mbbtype_l(long long ptr)
# extern _mbcasemap
@ cdecl _mbccpy(ptr ptr)
@ cdecl _mbccpy_l(ptr ptr ptr)
......
......@@ -721,7 +721,7 @@
@ cdecl _mbbtombc(long)
@ stub _mbbtombc_l
@ cdecl _mbbtype(long long)
@ stub _mbbtype_l
@ cdecl _mbbtype_l(long long ptr)
# extern _mbcasemap
@ cdecl _mbccpy(ptr ptr)
@ cdecl _mbccpy_l(ptr ptr ptr)
......
......@@ -1395,31 +1395,6 @@ unsigned int CDECL _mbbtombc(unsigned int c)
}
/*********************************************************************
* _mbbtype(MSVCRT.@)
*/
int CDECL _mbbtype(unsigned char c, int type)
{
if (type == 1)
{
if ((c >= 0x20 && c <= 0x7e) || (c >= 0xa1 && c <= 0xdf))
return _MBC_SINGLE;
else if ((c >= 0x40 && c <= 0x7e) || (c >= 0x80 && c <= 0xfc))
return _MBC_TRAIL;
else
return _MBC_ILLEGAL;
}
else
{
if ((c >= 0x20 && c <= 0x7e) || (c >= 0xa1 && c <= 0xdf))
return _MBC_SINGLE;
else if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc))
return _MBC_LEAD;
else
return _MBC_ILLEGAL;
}
}
/*********************************************************************
* _ismbbkana_l(MSVCRT.@)
*/
int CDECL _ismbbkana_l(unsigned int c, MSVCRT__locale_t locale)
......@@ -1731,6 +1706,26 @@ int CDECL _ismbstrail(const unsigned char* start, const unsigned char* str)
}
/*********************************************************************
* _mbbtype_l(MSVCRT.@)
*/
int CDECL _mbbtype_l(unsigned char c, int type, MSVCRT__locale_t locale)
{
if (type == 1)
return _ismbbtrail_l(c, locale) ? _MBC_TRAIL : _MBC_ILLEGAL;
else
return _ismbblead_l(c, locale) ? _MBC_LEAD
: MSVCRT__isprint_l(c, locale) ? _MBC_SINGLE : _MBC_ILLEGAL;
}
/*********************************************************************
* _mbbtype(MSVCRT.@)
*/
int CDECL _mbbtype(unsigned char c, int type)
{
return _mbbtype_l(c, type, NULL);
}
/*********************************************************************
* _mbsbtype (MSVCRT.@)
*/
int CDECL _mbsbtype(const unsigned char *str, MSVCRT_size_t count)
......
......@@ -1204,6 +1204,7 @@ int __cdecl MSVCRT_wcsncmp(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, MSVCRT_
int __cdecl MSVCRT__wcsnicmp(const MSVCRT_wchar_t*, const MSVCRT_wchar_t*, MSVCRT_size_t);
int __cdecl MSVCRT_towlower(MSVCRT_wint_t);
int __cdecl MSVCRT_towupper(MSVCRT_wint_t);
int __cdecl MSVCRT__isprint_l(int c, MSVCRT__locale_t locale);
int __cdecl MSVCRT__iswalnum_l(MSVCRT_wchar_t, MSVCRT__locale_t);
int __cdecl MSVCRT__iswdigit_l(MSVCRT_wchar_t, MSVCRT__locale_t);
int __cdecl MSVCRT__iswgraph_l(MSVCRT_wchar_t, MSVCRT__locale_t);
......
......@@ -35,6 +35,7 @@
#undef strncpy
#include "winbase.h"
#include "winnls.h"
#include "winuser.h"
static char *buf_to_string(const unsigned char *bin, int len, int nr)
{
......@@ -4396,6 +4397,59 @@ static void test_SpecialCasing(void)
}
}
static void test__mbbtype(void)
{
static const char *test_locales[] =
{
"Arabic_Algeria",
"Chinese_China",
"English_Australia",
"French_Belgium",
"German_Austria",
"Greek",
"Hindi",
"Japanese",
"Korean",
"Polish",
"Portuguese_Brazil",
"Russian",
"Spanish_Argentina",
"Swedish_Finland",
"Ukrainian",
"Vietnamese",
};
int expected, ret;
unsigned int c, i;
for (i = 0; i < ARRAY_SIZE(test_locales); ++i)
{
setlocale(LC_ALL, test_locales[i]);
_setmbcp(_MB_CP_LOCALE);
for (c = 0; c < 256; ++c)
{
if (_ismbblead(c))
expected = _MBC_LEAD;
else if (isprint(c))
expected = _MBC_SINGLE;
else
expected = _MBC_ILLEGAL;
ret = _mbbtype(c, 0);
ok(ret == expected, "test %u, c %#x, got ret %#x, expected %#x.\n", i, c, ret, expected);
if (_ismbbtrail(c))
expected = _MBC_TRAIL;
else
expected = _MBC_ILLEGAL;
ret = _mbbtype(c, 1);
ok(ret == expected, "test %u, c %#x, got ret %#x, expected %#x.\n", i, c, ret, expected);
}
}
}
START_TEST(string)
{
char mem[100];
......@@ -4550,4 +4604,5 @@ START_TEST(string)
test_wcscmp();
test___STRINGTOLD();
test_SpecialCasing();
test__mbbtype();
}
......@@ -516,6 +516,24 @@ static void test_SpecialCasing(void)
}
}
static void test__mbbtype_l(void)
{
int expected, ret;
unsigned int c;
_setmbcp(_MB_CP_LOCALE);
for (c = 0; c < 256; ++c)
{
expected = _mbbtype(c, 0);
ret = _mbbtype_l(c, 0, NULL);
ok(ret == expected, "c %#x, got ret %#x, expected %#x.\n", c, ret, expected);
expected = _mbbtype(c, 1);
ret = _mbbtype_l(c, 1, NULL);
ok(ret == expected, "c %#x, got ret %#x, expected %#x.\n", c, ret, expected);
}
}
START_TEST(string)
{
ok(_set_invalid_parameter_handler(test_invalid_parameter_handler) == NULL,
......@@ -530,4 +548,5 @@ START_TEST(string)
test_wcstok();
test__strnicmp();
test_SpecialCasing();
test__mbbtype_l();
}
......@@ -584,7 +584,7 @@
@ cdecl _mbbtombc(long)
@ stub _mbbtombc_l
@ cdecl _mbbtype(long long)
@ stub _mbbtype_l
@ cdecl _mbbtype_l(long long ptr)
@ stub _mbcasemap
@ cdecl _mbccpy(ptr ptr)
@ cdecl _mbccpy_l(ptr ptr ptr)
......@@ -1155,7 +1155,7 @@
@ cdecl _o__mbbtombc(long) _mbbtombc
@ stub _o__mbbtombc_l
@ cdecl _o__mbbtype(long long) _mbbtype
@ stub _o__mbbtype_l
@ cdecl _o__mbbtype_l(long long ptr) _mbbtype_l
@ cdecl _o__mbccpy(ptr ptr) _mbccpy
@ cdecl _o__mbccpy_l(ptr ptr ptr) _mbccpy_l
@ cdecl _o__mbccpy_s(ptr long ptr ptr) _mbccpy_s
......
......@@ -51,6 +51,7 @@ int __cdecl _ismbcsymbol(unsigned int);
int __cdecl _ismbcupper(unsigned int);
unsigned int __cdecl _mbbtombc(unsigned int);
int __cdecl _mbbtype(unsigned char,int);
int __cdecl _mbbtype_l(unsigned char,int,_locale_t);
#define _mbccmp(_cpc1,_cpc2) _mbsncmp((_cpc1),(_cpc2),1)
void __cdecl _mbccpy(unsigned char*,const unsigned char*);
unsigned int __cdecl _mbcjistojms(unsigned int);
......
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