From acfa6d7f1565357086b441dbcd47aa4b3e7b9bd0 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Mon, 20 Aug 2012 17:20:48 +0000 Subject: [PATCH] [CRT] - Use wine's wctype table in CRT for iswctype() function. Previous implementation was returning incorrect information for non-Latin characters. Problem found and fixed by Sergey Shamanaev (seven_ro). - Move wctype.c from libwine to lib/sdk/crt instead of making yet another copy of it (currently there is one more in tools/unicode). Suggested by Amine Khaldi. See issue #5090 for more details. svn path=/trunk/; revision=57119 --- reactos/lib/3rdparty/libwine/CMakeLists.txt | 2 +- reactos/lib/sdk/crt/crt.cmake | 1 + reactos/lib/sdk/crt/string/ctype.c | 6 ++++-- reactos/lib/{3rdparty/libwine => sdk/crt/string}/wctype.c | 0 4 files changed, 6 insertions(+), 3 deletions(-) rename reactos/lib/{3rdparty/libwine => sdk/crt/string}/wctype.c (100%) diff --git a/reactos/lib/3rdparty/libwine/CMakeLists.txt b/reactos/lib/3rdparty/libwine/CMakeLists.txt index 8f4c440fcd6..d8059eb51b1 100644 --- a/reactos/lib/3rdparty/libwine/CMakeLists.txt +++ b/reactos/lib/3rdparty/libwine/CMakeLists.txt @@ -8,7 +8,7 @@ list(APPEND SOURCE isinf.c isnan.c loader.c - wctype.c + ../../sdk/crt/string/wctype.c register.c # string.c implements _stricmp, already shipped with crt ) diff --git a/reactos/lib/sdk/crt/crt.cmake b/reactos/lib/sdk/crt/crt.cmake index 6abd6fe87d2..f5f4b8e2e2c 100644 --- a/reactos/lib/sdk/crt/crt.cmake +++ b/reactos/lib/sdk/crt/crt.cmake @@ -281,6 +281,7 @@ list(APPEND CRT_SOURCE string/wcs.c string/wcstol.c string/wcstoul.c + string/wctype.c string/wsplitp.c string/wtoi.c string/wtoi64.c diff --git a/reactos/lib/sdk/crt/string/ctype.c b/reactos/lib/sdk/crt/string/ctype.c index 28dcda5ab66..7c5188570f9 100644 --- a/reactos/lib/sdk/crt/string/ctype.c +++ b/reactos/lib/sdk/crt/string/ctype.c @@ -551,6 +551,8 @@ const unsigned short _wctype[] = { const unsigned short *_pctype = _ctype + 1; const unsigned short *_pwctype = _wctype + 1; +extern const unsigned short wine_wctype_table[]; + /* * @implemented */ @@ -587,7 +589,7 @@ int _isctype (int c, int ctypeFlags) */ int iswctype(wint_t wc, wctype_t wctypeFlags) { - return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags); + return (wine_wctype_table[wine_wctype_table[wc >> 8] + (wc & 0xff)] & wctypeFlags); } /* @@ -597,7 +599,7 @@ int iswctype(wint_t wc, wctype_t wctypeFlags) */ int is_wctype(wint_t wc, wctype_t wctypeFlags) { - return (_pwctype[(unsigned char)(wc & 0xFF)] & wctypeFlags); + return (wine_wctype_table[wine_wctype_table[wc >> 8] + (wc & 0xff)] & wctypeFlags); } /* diff --git a/reactos/lib/3rdparty/libwine/wctype.c b/reactos/lib/sdk/crt/string/wctype.c similarity index 100% rename from reactos/lib/3rdparty/libwine/wctype.c rename to reactos/lib/sdk/crt/string/wctype.c