[RFC PATCH 3/9] ntdll: Fix functions that depend on wctype table.

Jeff Smith whydoubt at gmail.com
Thu Jan 9 00:53:43 CST 2020


Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
 dlls/ntdll/tests/string.c | 22 +++++++++----------
 dlls/ntdll/wcstring.c     | 45 +++++++++++++++++++++++++++++++++------
 2 files changed, 49 insertions(+), 18 deletions(-)

diff --git a/dlls/ntdll/tests/string.c b/dlls/ntdll/tests/string.c
index 3b62bde1a7..19b49dca88 100644
--- a/dlls/ntdll/tests/string.c
+++ b/dlls/ntdll/tests/string.c
@@ -1544,31 +1544,29 @@ static void test_iswctype(void)
         base_wctype[c] = p_iswctype(c, 0xffff);
         types |= base_wctype[c];
     }
-    todo_wine ok(types == 0x1ff, "Unexpected wctype bits present\n");
+    ok(types == 0x1ff, "Unexpected wctype bits present\n");
 
     for (c = 0x100; c <= 0xffff; c++)
     {
         types = p_iswctype(c, 0xffff);
-        todo_wine_if(types != 0) ok(types == 0, "Unexpected iswctype for %#x\n", c);
+        ok(types == 0, "Unexpected iswctype for %#x\n", c);
         types = p_iswalpha(c);
-        todo_wine_if(types != 0) ok(types == 0, "Unexpected iswalpha for %#x\n", c);
+        ok(types == 0, "Unexpected iswalpha for %#x\n", c);
         types = p_iswdigit(c);
-        todo_wine_if(types != 0) ok(types == 0, "Unexpected iswdigit for %#x\n", c);
+        ok(types == 0, "Unexpected iswdigit for %#x\n", c);
         types = p_iswlower(c);
-        todo_wine_if(types != 0) ok(types == 0, "Unexpected iswlower for %#x\n", c);
+        ok(types == 0, "Unexpected iswlower for %#x\n", c);
         types = p_iswspace(c);
-        todo_wine_if(types != 0) ok(types == 0, "Unexpected iswspace for %#x\n", c);
+        ok(types == 0, "Unexpected iswspace for %#x\n", c);
         types = p_iswxdigit(c);
-        todo_wine_if(types != 0) ok(types == 0, "Unexpected iswxdigit for %#x\n", c);
+        ok(types == 0, "Unexpected iswxdigit for %#x\n", c);
     }
 
     for (i = 0; i < ARRAY_SIZE(iswctype_tests); i++)
     {
-        todo_wine {
-            ok(base_wctype[iswctype_tests[i].c] == iswctype_tests[i].wctype,
-                "Unexpected wctype %#x for char %#x\n",
-                base_wctype[iswctype_tests[i].c], iswctype_tests[i].c);
-        }
+        ok(base_wctype[iswctype_tests[i].c] == iswctype_tests[i].wctype,
+            "Unexpected wctype %#x for char %#x\n",
+            base_wctype[iswctype_tests[i].c], iswctype_tests[i].c);
     }
 }
 
diff --git a/dlls/ntdll/wcstring.c b/dlls/ntdll/wcstring.c
index acdb33ac24..98372ae8d2 100644
--- a/dlls/ntdll/wcstring.c
+++ b/dlls/ntdll/wcstring.c
@@ -33,6 +33,39 @@
 #include "winternl.h"
 #include "wine/unicode.h"
 
+/* Some abbreviations to make the following table readable */
+#define _C_ C1_CNTRL
+#define _S_ C1_SPACE
+#define _P_ C1_PUNCT
+#define _D_ C1_DIGIT
+#define _H_ C1_XDIGIT
+#define _U_ C1_UPPER|C1_ALPHA
+#define _L_ C1_LOWER|C1_ALPHA
+#define _B_ C1_BLANK
+
+static const WORD NTDLL_wctype [256] = {
+    _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _S_|_C_|_B_, _S_|_C_, _S_|_C_,
+      _S_|_C_, _S_|_C_, _C_, _C_,
+    _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
+    _S_|_B_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_,
+    _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_, _D_|_H_,
+      _P_, _P_, _P_, _P_, _P_, _P_,
+    _P_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_|_H_, _U_, _U_, _U_, _U_, _U_,
+      _U_, _U_, _U_, _U_,
+    _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _P_, _P_, _P_, _P_, _P_,
+    _P_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_, _L_|_H_, _L_, _L_, _L_, _L_, _L_,
+      _L_, _L_, _L_, _L_,
+    _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _P_, _P_, _P_, _P_, _C_,
+    _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
+    _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_, _C_,
+    _S_|_B_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_, _P_,
+    _P_, _P_, _P_|_D_, _P_|_D_, _P_, _P_, _P_, _P_, _P_, _P_|_D_, _P_, _P_, _P_, _P_, _P_, _P_,
+    _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _U_,
+    _U_, _U_, _U_, _U_, _U_, _U_, _U_, _P_, _U_, _U_, _U_, _U_, _U_, _U_, _U_, _L_,
+    _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_,
+    _L_, _L_, _L_, _L_, _L_, _L_, _L_, _P_, _L_, _L_, _L_, _L_, _L_, _L_, _L_, _L_
+};
+
 /*********************************************************************
  *           _wcsicmp    (NTDLL.@)
  */
@@ -298,7 +331,7 @@ ULONG __cdecl NTDLL_wcstoul(LPCWSTR s, LPWSTR *end, INT base)
  */
 INT __cdecl NTDLL_iswctype( WCHAR wc, WCHAR wct )
 {
-    return (get_char_typeW(wc) & 0xfff) & wct;
+    return (wc > 0xff) ? 0 : NTDLL_wctype[wc] & wct;
 }
 
 
@@ -313,7 +346,7 @@ INT __cdecl NTDLL_iswctype( WCHAR wc, WCHAR wct )
  */
 INT __cdecl NTDLL_iswalpha( WCHAR wc )
 {
-    return isalphaW(wc);
+    return NTDLL_iswctype( wc, C1_ALPHA|C1_LOWER|C1_UPPER );
 }
 
 
@@ -328,7 +361,7 @@ INT __cdecl NTDLL_iswalpha( WCHAR wc )
  */
 INT __cdecl NTDLL_iswdigit( WCHAR wc )
 {
-    return isdigitW(wc);
+    return NTDLL_iswctype( wc, C1_DIGIT );
 }
 
 
@@ -343,7 +376,7 @@ INT __cdecl NTDLL_iswdigit( WCHAR wc )
  */
 INT __cdecl NTDLL_iswlower( WCHAR wc )
 {
-    return islowerW(wc);
+    return NTDLL_iswctype( wc, C1_LOWER );
 }
 
 
@@ -358,7 +391,7 @@ INT __cdecl NTDLL_iswlower( WCHAR wc )
  */
 INT __cdecl NTDLL_iswspace( WCHAR wc )
 {
-    return isspaceW(wc);
+    return NTDLL_iswctype( wc, C1_SPACE );
 }
 
 
@@ -373,7 +406,7 @@ INT __cdecl NTDLL_iswspace( WCHAR wc )
  */
 INT __cdecl NTDLL_iswxdigit( WCHAR wc )
 {
-    return isxdigitW(wc);
+    return NTDLL_iswctype( wc, C1_XDIGIT );
 }
 
 
-- 
2.23.0




More information about the wine-devel mailing list