Commit in reactos/lib/user32/windows on MAIN
text.c+41-731.11 -> 1.12
Use GetStringTypeW() for implementation of IsCharAlphaNumericW(),
IsCharAlphaW(), IsCharLowerW() and IsCharUpperW()

reactos/lib/user32/windows
text.c 1.11 -> 1.12
diff -u -r1.11 -r1.12
--- text.c	22 Aug 2004 20:51:57 -0000	1.11
+++ text.c	4 Oct 2004 19:22:16 -0000	1.12
@@ -16,7 +16,7 @@
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
-/* $Id: text.c,v 1.11 2004/08/22 20:51:57 navaraf Exp $
+/* $Id: text.c,v 1.12 2004/10/04 19:22:16 gvg Exp $
  *
  * PROJECT:         ReactOS user32.dll
  * FILE:            lib/user32/windows/input.c
@@ -32,22 +32,22 @@
 #include <ctype.h>
 #include <debug.h>
 
-const unsigned short wctype_table[] =
-{
-};
 
-/* the character type contains the C1_* flags in the low 12 bits */
-/* and the C2_* type in the high 4 bits */
-static inline unsigned short get_char_typeW(WCHAR ch)
+/* FUNCTIONS *****************************************************************/
+
+static WORD
+GetC1Type(WCHAR Ch)
 {
-    extern const unsigned short wctype_table[];
-    return wctype_table[wctype_table[ch >> 8] + (ch & 0xff)];
-}
+    WORD CharType;
 
+    if (! GetStringTypeW(CT_CTYPE1, &Ch, 1, &CharType))
+    {
+        return 0;
+    }
 
-/* FUNCTIONS *****************************************************************/
+    return CharType;
+}
 
-//LPSTR STDCALL CharLowerA(LPSTR lpsz)
 /*
  * @implemented
  */
@@ -76,7 +76,6 @@
     return x;
 }
 
-//DWORD STDCALL CharLowerBuffA(LPSTR lpsz, DWORD cchLength)
 /*
  * @implemented
  */
@@ -100,7 +99,6 @@
     return 0;
 }
 
-//DWORD STDCALL CharLowerBuffW(LPWSTR lpsz, DWORD cchLength)
 /*
  * @implemented
  */
@@ -114,7 +112,6 @@
     return ret;
 }
 
-//LPWSTR STDCALL CharLowerW(LPWSTR lpsz)
 /*
  * @implemented
  */
@@ -129,7 +126,6 @@
     }
 }
 
-//LPWSTR STDCALL CharPrevW(LPCWSTR lpszStart, LPCWSTR lpszCurrent)
 /*
  * @implemented
  */
@@ -141,7 +137,6 @@
     else return (LPWSTR)x;
 }
 
-//LPSTR STDCALL CharNextA(LPCSTR lpsz)
 /*
  * @implemented
  */
@@ -154,7 +149,6 @@
     return (LPSTR)(ptr + 1);
 }
 
-//LPSTR STDCALL CharNextExA(WORD CodePage, LPCSTR lpCurrentChar, DWORD dwFlags)
 /*
  * @implemented
  */
@@ -167,7 +161,6 @@
     return (LPSTR)(ptr + 1);
 }
 
-//LPWSTR STDCALL CharNextW(LPCWSTR lpsz)
 /*
  * @implemented
  */
@@ -179,7 +172,6 @@
     return (LPWSTR)x;
 }
 
-//LPSTR STDCALL CharPrevA(LPCSTR lpszStart, LPCSTR lpszCurrent)
 /*
  * @implemented
  */
@@ -195,7 +187,6 @@
     return (LPSTR)start;
 }
 
-//LPSTR STDCALL CharPrevExA(WORD CodePage, LPCSTR lpStart, LPCSTR lpCurrentChar, DWORD dwFlags)
 /*
  * @implemented
  */
@@ -210,7 +201,6 @@
     return (LPSTR)start;
 }
 
-//BOOL STDCALL CharToOemA(LPCSTR lpszSrc, LPSTR lpszDst)
 /*
  * @implemented
  */
@@ -222,7 +212,6 @@
     return CharToOemBuffA(s, d, strlen(s) + 1);
 }
 
-//BOOL STDCALL CharToOemBuffA(LPCSTR lpszSrc, LPSTR lpszDst, DWORD cchDstLength)
 /*
  * @implemented
  */
@@ -241,7 +230,6 @@
     return TRUE;
 }
 
-//BOOL STDCALL CharToOemBuffW(LPCWSTR lpszSrc, LPSTR lpszDst, DWORD cchDstLength)
 /*
  * @implemented
  */
@@ -255,7 +243,6 @@
     return TRUE;
 }
 
-//BOOL STDCALL CharToOemW(LPCWSTR lpszSrc, LPSTR lpszDst)
 /*
  * @implemented
  */
@@ -266,7 +253,6 @@
     return CharToOemBuffW(s, d, wcslen(s) + 1);
 }
 
-//LPSTR STDCALL CharUpperA(LPSTR lpsz)
 /*
  * @implemented
  */
@@ -277,7 +263,6 @@
     return x;
 }
 
-//DWORD STDCALL CharUpperBuffA(LPSTR lpsz, DWORD cchLength)
 /*
  * @implemented
  */
@@ -301,7 +286,6 @@
     return 0;
 }
 
-//DWORD STDCALL CharUpperBuffW(LPWSTR lpsz, DWORD cchLength)
 /*
  * @implemented
  */
@@ -315,7 +299,6 @@
     return ret;
 }
 
-//LPWSTR STDCALL CharUpperW(LPWSTR lpsz)
 /*
  * @implemented
  */
@@ -327,39 +310,30 @@
     else return (LPWSTR)(UINT)towlower((WORD)(((DWORD)(x)) & 0xFFFF));
 }
 
-//BOOL STDCALL IsCharAlphaA(CHAR ch)
 /*
  * @implemented
  */
 BOOL
 WINAPI
-IsCharAlphaA(CHAR x)
+IsCharAlphaA(CHAR Ch)
 {
-    WCHAR wch;
-    MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
-    return IsCharAlphaW(wch);
-}
+    WCHAR WCh;
 
-const char IsCharAlphaNumericA_lookup_table[] = { 
-    0x00,  0x00,  0x00,  0x00,  0x00,  0x00,  0xff,  0x03,
-    0xfe,  0xff,  0xff,  0x07,  0xfe,  0xff,  0xff,  0x07,
-    0x08,  0x54,  0x00,  0xd4,  0x00,  0x00,  0x0c,  0x02,
-    0xff,  0xff,  0x7f,  0xff,  0xff,  0xff,  0x7f,  0xff
-};
+    MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
+    return IsCharAlphaW(WCh);
+}
 
 /*
  * @implemented
  */
 BOOL
 STDCALL
-IsCharAlphaNumericA(CHAR ch)
+IsCharAlphaNumericA(CHAR Ch)
 {
-//    return (IsCharAlphaNumericA_lookup_table[ch / 8] & (1 << (ch % 8))) ? 1 : 0;
+    WCHAR WCh;
 
-    WCHAR wch;
-    MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wch, 1);
-    return IsCharAlphaNumericW(wch);
-  //return FALSE;
+    MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
+    return IsCharAlphaNumericW(WCh);
 }
 
 /*
@@ -367,72 +341,67 @@
  */
 BOOL
 STDCALL
-IsCharAlphaNumericW(WCHAR ch)
+IsCharAlphaNumericW(WCHAR Ch)
 {
-    return (get_char_typeW(ch) & (C1_ALPHA|C1_DIGIT)) != 0;
-//  return FALSE;
+    return (GetC1Type(Ch) & (C1_ALPHA|C1_DIGIT)) != 0;
 }
 
-//BOOL STDCALL IsCharAlphaW(WCHAR ch)
 /*
  * @implemented
  */
 BOOL
 WINAPI
-IsCharAlphaW(WCHAR x)
+IsCharAlphaW(WCHAR Ch)
 {
-    return (get_char_typeW(x) & C1_ALPHA) != 0;
+    return (GetC1Type(Ch) & C1_ALPHA) != 0;
 }
 
-//BOOL STDCALL IsCharLowerA(CHAR ch)
 /*
  * @implemented
  */
 BOOL
 WINAPI
-IsCharLowerA(CHAR x)
+IsCharLowerA(CHAR Ch)
 {
-    WCHAR wch;
-    MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
-    return IsCharLowerW(wch);
+    WCHAR WCh;
+
+    MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
+    return IsCharLowerW(WCh);
 }
 
-//BOOL STDCALL IsCharLowerW(WCHAR ch)
 /*
  * @implemented
  */
 BOOL
 WINAPI
-IsCharLowerW(WCHAR x)
+IsCharLowerW(WCHAR Ch)
 {
-    return (get_char_typeW(x) & C1_LOWER) != 0;
+    return (GetC1Type(Ch) & C1_LOWER) != 0;
 }
 
-//BOOL STDCALL IsCharUpperA(CHAR ch)
 /*
  * @implemented
  */
 BOOL
 WINAPI
-IsCharUpperA(CHAR x)
+IsCharUpperA(CHAR Ch)
 {
-    WCHAR wch;
-    MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
-    return IsCharUpperW(wch);
+    WCHAR WCh;
+
+    MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1);
+    return IsCharUpperW(WCh);
 }
 
-//BOOL STDCALL IsCharUpperW(WCHAR ch)
 /*
  * @implemented
  */
 BOOL
 WINAPI
-IsCharUpperW(WCHAR x)
+IsCharUpperW(WCHAR Ch)
 {
-    return (get_char_typeW(x) & C1_UPPER) != 0;
+    return (GetC1Type(Ch) & C1_UPPER) != 0;
 }
 
-//BOOL STDCALL OemToCharA(LPCSTR lpszSrc, LPSTR lpszDst)
 /*
  * @implemented
  */
@@ -443,7 +412,6 @@
     return OemToCharBuffA(s, d, strlen(s) + 1);
 }
 
-//BOOL STDCALL OemToCharBuffA(LPCSTR lpszSrc, LPSTR lpszDst, DWORD cchDstLength)
 /*
  * @implemented
  */
@@ -460,7 +428,6 @@
     return TRUE;
 }
 
-//BOOL STDCALL OemToCharBuffW(LPCSTR lpszSrc, LPWSTR lpszDst, DWORD cchDstLength)
 /*
  * @implemented
  */
@@ -472,7 +439,6 @@
     return TRUE;
 }
 
-//BOOL STDCALL OemToCharW(LPCSTR lpszSrc, LPWSTR lpszDst)
 /*
  * @implemented
  */
@@ -480,3 +446,5 @@
 {
     return OemToCharBuffW(s, d, strlen(s) + 1);
 }
+
+/* EOF */
CVSspam 0.2.8