diff --git "a/sdk/lib/crt/mbstring/ismbc.c" "b/sdk/lib/crt/mbstring/ismbc.c" index 087700e3592..e228b736ad8 100644 --- "a/sdk/lib/crt/mbstring/ismbc.c" +++ "b/sdk/lib/crt/mbstring/ismbc.c" @@ -14,6 +14,82 @@ #include #include +#if _MSVCR_VER <= 110 +# define B110 _BLANK +#else +# define B110 0 +#endif +#if _MSVCR_VER == 120 +# define D120 0 +#else +# define D120 4 +#endif + +#if _MSVCR_VER >= 140 +# define S140 _SPACE +# define L140 _LOWER | 0x100 +# define C140 _CONTROL +#else +# define S140 0 +# define L140 0 +# define C140 0 +#endif + +WORD MSVCRT__wctype[257] = +{ + 0, + /* 00 */ + 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, + 0x0020, 0x0028 | B110, 0x0028, 0x0028, 0x0028, 0x0028, 0x0020, 0x0020, + /* 10 */ + 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, + 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, + /* 20 */ + 0x0048, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, + 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, + /* 30 */ + 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, 0x0084, + 0x0084, 0x0084, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, + /* 40 */ + 0x0010, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0181, 0x0101, + 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, + /* 50 */ + 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, + 0x0101, 0x0101, 0x0101, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, + /* 60 */ + 0x0010, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0182, 0x0102, + 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, + /* 70 */ + 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, + 0x0102, 0x0102, 0x0102, 0x0010, 0x0010, 0x0010, 0x0010, 0x0020, + /* 80 */ + 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020 | S140, 0x0020, 0x0020, + 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, + /* 90 */ + 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, + 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, + /* a0 */ + 0x0008 | B110, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, + 0x0010, 0x0010, 0x0010 | L140, 0x0010, 0x0010, 0x0010 | C140, 0x0010, 0x0010, + /* b0 */ + 0x0010, 0x0010, 0x0010 | D120, 0x0010 | D120, 0x0010, 0x0010 | L140, 0x0010, 0x0010, + 0x0010, 0x0010 | D120, 0x0010 | L140, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, + /* c0 */ + 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, + 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, + /* d0 */ + 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0010, + 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0101, 0x0102, + /* e0 */ + 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, + 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, + /* f0 */ + 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0010, + 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102, 0x0102 +}; + +WORD *MSVCRT__pwctype = MSVCRT__wctype + 1; + /* * @implemented */ @@ -61,12 +137,70 @@ int _ismbcsymbol( unsigned int c ) return (c >= 0x8141 && c <= 0x817e) || (c >= 0x8180 && c <= 0x81ac); } +static wchar_t MSVCRT_mbc_to_wc_l(unsigned int ch, _locale_t locale) +{ + MSVCRT_pthreadmbcinfo mbcinfo = get_mbcinfo(); // ReactOS modified + + wchar_t chW; + char mbch[2]; + int n_chars; + + if (ch <= 0xff) { + mbch[0] = ch; + n_chars = 1; + } else { + mbch[0] = (ch >> 8) & 0xff; + mbch[1] = ch & 0xff; + n_chars = 2; + } + if (!MultiByteToWideChar(mbcinfo->mbcodepage, 0, mbch, n_chars, &chW, 1)) + { + WARN("MultiByteToWideChar failed on %x\n", ch); + return 0; + } + return chW; +} + +/********************************************************************* + * _iswctype_l (MSVCRT.@) + */ +INT CDECL MSVCRT_iswctype_l( wchar_t wc, wctype_t type, _locale_t locale ) +{ + WORD ct; + + if (wc == WEOF) return 0; + if (wc < 256) return MSVCRT__pwctype[wc] & type; + + if (!GetStringTypeW(CT_CTYPE1, &wc, 1, &ct)) + { + ERR("GetStringTypeW failed for %x\n", wc); + return 0; + } + return ct & type; +} + +/********************************************************************* + * _iswspace_l (MSVCRT.@) + */ +INT CDECL MSVCRT_iswspace_l( wchar_t wc, _locale_t locale ) +{ + return MSVCRT_iswctype_l( wc, _SPACE, locale ); +} + +/********************************************************************* + * _ismbcspace_l (MSVCRT.@) + */ +int CDECL MSVCRT_ismbcspace_l(unsigned int ch, _locale_t locale) +{ + return MSVCRT_iswspace_l( MSVCRT_mbc_to_wc_l(ch, locale), locale ); +} + /* * @implemented */ int _ismbcspace( unsigned int c ) { - return ((c) == 0x8140); + return MSVCRT_ismbcspace_l( c, NULL ); } /* * @implemented