From aa496615dfac6305881c5d9f493808c93e233bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Mon, 4 Oct 2004 19:22:16 +0000 Subject: [PATCH] Use GetStringTypeW() for implementation of IsCharAlphaNumericW(), IsCharAlphaW(), IsCharLowerW() and IsCharUpperW() svn path=/trunk/; revision=11187 --- reactos/lib/user32/windows/text.c | 134 ++++++++++++------------------ 1 file changed, 51 insertions(+), 83 deletions(-) diff --git a/reactos/lib/user32/windows/text.c b/reactos/lib/user32/windows/text.c index 40cc81f2fc6..caa047ac27c 100644 --- a/reactos/lib/user32/windows/text.c +++ b/reactos/lib/user32/windows/text.c @@ -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 #include -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) -{ - extern const unsigned short wctype_table[]; - return wctype_table[wctype_table[ch >> 8] + (ch & 0xff)]; -} - /* FUNCTIONS *****************************************************************/ -//LPSTR STDCALL CharLowerA(LPSTR lpsz) +static WORD +GetC1Type(WCHAR Ch) +{ + WORD CharType; + + if (! GetStringTypeW(CT_CTYPE1, &Ch, 1, &CharType)) + { + return 0; + } + + return CharType; +} + /* * @implemented */ @@ -76,7 +76,6 @@ CharLowerA(LPSTR x) return x; } -//DWORD STDCALL CharLowerBuffA(LPSTR lpsz, DWORD cchLength) /* * @implemented */ @@ -100,7 +99,6 @@ CharLowerBuffA(LPSTR str, DWORD len) return 0; } -//DWORD STDCALL CharLowerBuffW(LPWSTR lpsz, DWORD cchLength) /* * @implemented */ @@ -114,7 +112,6 @@ CharLowerBuffW(LPWSTR str, DWORD len) return ret; } -//LPWSTR STDCALL CharLowerW(LPWSTR lpsz) /* * @implemented */ @@ -129,7 +126,6 @@ CharLowerW(LPWSTR x) } } -//LPWSTR STDCALL CharPrevW(LPCWSTR lpszStart, LPCWSTR lpszCurrent) /* * @implemented */ @@ -141,7 +137,6 @@ CharPrevW(LPCWSTR start, LPCWSTR x) else return (LPWSTR)x; } -//LPSTR STDCALL CharNextA(LPCSTR lpsz) /* * @implemented */ @@ -154,7 +149,6 @@ CharNextA(LPCSTR ptr) return (LPSTR)(ptr + 1); } -//LPSTR STDCALL CharNextExA(WORD CodePage, LPCSTR lpCurrentChar, DWORD dwFlags) /* * @implemented */ @@ -167,7 +161,6 @@ CharNextExA(WORD codepage, LPCSTR ptr, DWORD flags) return (LPSTR)(ptr + 1); } -//LPWSTR STDCALL CharNextW(LPCWSTR lpsz) /* * @implemented */ @@ -179,7 +172,6 @@ CharNextW(LPCWSTR x) return (LPWSTR)x; } -//LPSTR STDCALL CharPrevA(LPCSTR lpszStart, LPCSTR lpszCurrent) /* * @implemented */ @@ -195,7 +187,6 @@ CharPrevA(LPCSTR start, LPCSTR ptr) return (LPSTR)start; } -//LPSTR STDCALL CharPrevExA(WORD CodePage, LPCSTR lpStart, LPCSTR lpCurrentChar, DWORD dwFlags) /* * @implemented */ @@ -210,7 +201,6 @@ LPSTR WINAPI CharPrevExA( WORD codepage, LPCSTR start, LPCSTR ptr, DWORD flags ) return (LPSTR)start; } -//BOOL STDCALL CharToOemA(LPCSTR lpszSrc, LPSTR lpszDst) /* * @implemented */ @@ -222,7 +212,6 @@ CharToOemA(LPCSTR s, LPSTR d) return CharToOemBuffA(s, d, strlen(s) + 1); } -//BOOL STDCALL CharToOemBuffA(LPCSTR lpszSrc, LPSTR lpszDst, DWORD cchDstLength) /* * @implemented */ @@ -241,7 +230,6 @@ CharToOemBuffA(LPCSTR s, LPSTR d, DWORD len) return TRUE; } -//BOOL STDCALL CharToOemBuffW(LPCWSTR lpszSrc, LPSTR lpszDst, DWORD cchDstLength) /* * @implemented */ @@ -255,7 +243,6 @@ CharToOemBuffW(LPCWSTR s, LPSTR d, DWORD len) return TRUE; } -//BOOL STDCALL CharToOemW(LPCWSTR lpszSrc, LPSTR lpszDst) /* * @implemented */ @@ -266,7 +253,6 @@ CharToOemW(LPCWSTR s, LPSTR d) return CharToOemBuffW(s, d, wcslen(s) + 1); } -//LPSTR STDCALL CharUpperA(LPSTR lpsz) /* * @implemented */ @@ -277,7 +263,6 @@ LPSTR WINAPI CharUpperA(LPSTR x) return x; } -//DWORD STDCALL CharUpperBuffA(LPSTR lpsz, DWORD cchLength) /* * @implemented */ @@ -301,7 +286,6 @@ CharUpperBuffA(LPSTR str, DWORD len) return 0; } -//DWORD STDCALL CharUpperBuffW(LPWSTR lpsz, DWORD cchLength) /* * @implemented */ @@ -315,7 +299,6 @@ CharUpperBuffW(LPWSTR str, DWORD len) return ret; } -//LPWSTR STDCALL CharUpperW(LPWSTR lpsz) /* * @implemented */ @@ -327,39 +310,17 @@ CharUpperW(LPWSTR x) 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 -}; - -/* - * @implemented - */ -BOOL -STDCALL -IsCharAlphaNumericA(CHAR ch) -{ -// return (IsCharAlphaNumericA_lookup_table[ch / 8] & (1 << (ch % 8))) ? 1 : 0; - - WCHAR wch; - MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wch, 1); - return IsCharAlphaNumericW(wch); - //return FALSE; + MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1); + return IsCharAlphaW(WCh); } /* @@ -367,72 +328,80 @@ IsCharAlphaNumericA(CHAR ch) */ BOOL STDCALL -IsCharAlphaNumericW(WCHAR ch) +IsCharAlphaNumericA(CHAR Ch) { - return (get_char_typeW(ch) & (C1_ALPHA|C1_DIGIT)) != 0; -// return FALSE; + WCHAR WCh; + + MultiByteToWideChar(CP_ACP, 0, &Ch, 1, &WCh, 1); + return IsCharAlphaNumericW(WCh); +} + +/* + * @implemented + */ +BOOL +STDCALL +IsCharAlphaNumericW(WCHAR Ch) +{ + 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 @@ OemToCharA(LPCSTR s, LPSTR d) return OemToCharBuffA(s, d, strlen(s) + 1); } -//BOOL STDCALL OemToCharBuffA(LPCSTR lpszSrc, LPSTR lpszDst, DWORD cchDstLength) /* * @implemented */ @@ -460,7 +428,6 @@ BOOL WINAPI OemToCharBuffA(LPCSTR s, LPSTR d, DWORD len) return TRUE; } -//BOOL STDCALL OemToCharBuffW(LPCSTR lpszSrc, LPWSTR lpszDst, DWORD cchDstLength) /* * @implemented */ @@ -472,7 +439,6 @@ OemToCharBuffW(LPCSTR s, LPWSTR d, DWORD len) return TRUE; } -//BOOL STDCALL OemToCharW(LPCSTR lpszSrc, LPWSTR lpszDst) /* * @implemented */ @@ -480,3 +446,5 @@ BOOL WINAPI OemToCharW(LPCSTR s, LPWSTR d) { return OemToCharBuffW(s, d, strlen(s) + 1); } + +/* EOF */