Move IsCharAlphaA and IsCharAlphaNumericA to user32

Dmitry Timoshkov dmitry at baikal.ru
Thu Jun 14 02:29:20 CDT 2001


Hello.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Move IsCharAlphaA and IsCharAlphaNumericA to user32.
    Better implement some of user32 *Char* functions regarding locale.
    Remove kernel32 dependency on user32.

Steps to proceed:
1. apply the patch
2. remove misc/lstr.c

Question:
In user32 IsCharAlphaW is implemented as
get_char_typeW(x) & (C1_ALPHA|C1_LOWER|C1_UPPER),
while in ntdll NTDLL_iswalpha is implemented as
get_char_typeW(wc) & C1_ALPHA.
Which of them is right?

diff -u cvs/hq/wine/dlls/user/lstr.c wine/dlls/user/lstr.c
--- cvs/hq/wine/dlls/user/lstr.c	Thu Jun 14 13:59:48 2001
+++ wine/dlls/user/lstr.c	Thu Jun 14 14:24:56 2001
@@ -405,7 +405,6 @@
 
 /***********************************************************************
  *           CharUpperW   (USER32.@)
- * FIXME: handle current locale
  */
 LPWSTR WINAPI CharUpperW(LPWSTR x)
 {
@@ -416,14 +415,24 @@
 
 /***********************************************************************
  *           CharLowerBuffA   (USER32.@)
- * FIXME: handle current locale
  */
 DWORD WINAPI CharLowerBuffA( LPSTR str, DWORD len )
 {
-    DWORD ret = len;
+    DWORD lenW;
+    WCHAR *strW;
     if (!str) return 0; /* YES */
-    for (; len; len--, str++) *str = tolower(*str);
-    return ret;
+
+    lenW = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0);
+    strW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
+    if(strW)
+    {
+	MultiByteToWideChar(CP_ACP, 0, str, len, strW, lenW);
+	CharLowerBuffW(strW, lenW);
+	len = WideCharToMultiByte(CP_ACP, 0, strW, lenW, str, len, NULL, NULL);
+	HeapFree(GetProcessHeap(), 0, strW);
+	return len;
+    }
+    return 0;
 }
 
 
@@ -441,14 +450,24 @@
 
 /***********************************************************************
  *           CharUpperBuffA   (USER32.@)
- * FIXME: handle current locale
  */
 DWORD WINAPI CharUpperBuffA( LPSTR str, DWORD len )
 {
-    DWORD ret = len;
+    DWORD lenW;
+    WCHAR *strW;
     if (!str) return 0; /* YES */
-    for (; len; len--, str++) *str = toupper(*str);
-    return ret;
+
+    lenW = MultiByteToWideChar(CP_ACP, 0, str, len, NULL, 0);
+    strW = HeapAlloc(GetProcessHeap(), 0, lenW * sizeof(WCHAR));
+    if(strW)
+    {
+	MultiByteToWideChar(CP_ACP, 0, str, len, strW, lenW);
+	CharUpperBuffW(strW, lenW);
+	len = WideCharToMultiByte(CP_ACP, 0, strW, lenW, str, len, NULL, NULL);
+	HeapFree(GetProcessHeap(), 0, strW);
+	return len;
+    }
+    return 0;
 }
 
 
@@ -467,11 +486,12 @@
 /***********************************************************************
  *           IsCharLowerA   (USER.436)
  *           IsCharLowerA   (USER32.@)
- * FIXME: handle current locale
  */
 BOOL WINAPI IsCharLowerA(CHAR x)
 {
-    return islower(x);
+    WCHAR wch;
+    MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
+    return IsCharLowerW(wch);
 }
 
 
@@ -487,11 +507,12 @@
 /***********************************************************************
  *           IsCharUpperA   (USER.435)
  *           IsCharUpperA   (USER32.@)
- * FIXME: handle current locale
  */
 BOOL WINAPI IsCharUpperA(CHAR x)
 {
-    return isupper(x);
+    WCHAR wch;
+    MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
+    return IsCharUpperW(wch);
 }
 
 
@@ -505,11 +526,33 @@
 
 
 /***********************************************************************
+ *           IsCharAlphaNumericA   (USER32.@)
+ */
+BOOL WINAPI IsCharAlphaNumericA(CHAR x)
+{
+    WCHAR wch;
+    MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
+    return IsCharAlphaNumericW(wch);
+}
+
+
+/***********************************************************************
  *           IsCharAlphaNumericW   (USER32.@)
  */
 BOOL WINAPI IsCharAlphaNumericW(WCHAR x)
 {
     return get_char_typeW(x) & (C1_ALPHA|C1_DIGIT|C1_LOWER|C1_UPPER);
+}
+
+
+/***********************************************************************
+ *           IsCharAlphaA   (USER32.@)
+ */
+BOOL WINAPI IsCharAlphaA(CHAR x)
+{
+    WCHAR wch;
+    MultiByteToWideChar(CP_ACP, 0, &x, 1, &wch, 1);
+    return IsCharAlphaW(wch);
 }
 
 
diff -u cvs/hq/wine/misc/Makefile.in wine/misc/Makefile.in
--- cvs/hq/wine/misc/Makefile.in	Tue Jan 16 04:12:56 2001
+++ wine/misc/Makefile.in	Thu Jun 14 14:18:40 2001
@@ -10,7 +10,6 @@
 	cdrom.c \
 	cpu.c \
 	error.c \
-	lstr.c \
 	main.c \
 	options.c \
 	registry.c \
diff -u cvs/hq/wine/ole/ole2nls.c wine/ole/ole2nls.c
--- cvs/hq/wine/ole/ole2nls.c	Thu Jun 14 13:59:51 2001
+++ wine/ole/ole2nls.c	Thu Jun 14 14:36:43 2001
@@ -1841,13 +1841,14 @@
 
 /******************************************************************************
  * OLE2NLS_isSymbol [INTERNAL]
+ * FIXME: handle current locale
  */
 static int OLE2NLS_isSymbol(unsigned char c) 
 {
   /* This function is used by LCMapStringA.  Characters 
      for which it returns true are ignored when mapping a
      string with NORM_IGNORESYMBOLS */
-  return ( (c!=0) && !IsCharAlphaNumericA(c) );
+  return ( (c!=0) && !(isalpha(c) || isdigit(c)) );
 }
 
 /******************************************************************************






More information about the wine-patches mailing list