Piotr Caban : ntdll: Use ANSI code page in toupper.
Alexandre Julliard
julliard at winehq.org
Tue Mar 26 16:43:13 CDT 2019
Module: wine
Branch: master
Commit: 748628e23e774bb4f3ade085d931ed09973037e3
URL: https://source.winehq.org/git/wine.git/?a=commit;h=748628e23e774bb4f3ade085d931ed09973037e3
Author: Piotr Caban <piotr at codeweavers.com>
Date: Tue Mar 26 10:26:16 2019 +0100
ntdll: Use ANSI code page in toupper.
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/ntdll/string.c | 12 +++++++++++-
dlls/ntdll/tests/string.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/dlls/ntdll/string.c b/dlls/ntdll/string.c
index d881e85..3e71740 100644
--- a/dlls/ntdll/string.c
+++ b/dlls/ntdll/string.c
@@ -321,7 +321,17 @@ LPSTR __cdecl _strlwr( LPSTR str )
*/
int __cdecl NTDLL_toupper( int c )
{
- return toupper( c );
+ char str[2], *p = str;
+ WCHAR wc;
+ DWORD len;
+
+ str[0] = c;
+ str[1] = c >> 8;
+ wc = RtlAnsiCharToUnicodeChar( &p );
+ wc = RtlUpcaseUnicodeChar( wc );
+ RtlUnicodeToMultiByteN( str, sizeof(str), &len, &wc, sizeof(wc) );
+ if (len == 2) return ((unsigned char)str[0] << 8) + (unsigned char)str[1];
+ return (unsigned char)str[0];
}
diff --git a/dlls/ntdll/tests/string.c b/dlls/ntdll/tests/string.c
index 84755fd..22f2359 100644
--- a/dlls/ntdll/tests/string.c
+++ b/dlls/ntdll/tests/string.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include "ntdll_test.h"
+#include "winnls.h"
/* Function ptrs for ntdll calls */
@@ -62,6 +63,7 @@ static void* (__cdecl *p_bsearch)(void *,void*,size_t,size_t, int(__cdecl *co
static int (WINAPIV *p__snprintf)(char *, size_t, const char *, ...);
static int (__cdecl *p_tolower)(int);
+static int (__cdecl *p_toupper)(int);
static void InitFunctionPtrs(void)
{
@@ -102,6 +104,7 @@ static void InitFunctionPtrs(void)
p__snprintf = (void *)GetProcAddress(hntdll, "_snprintf");
p_tolower = (void *)GetProcAddress(hntdll, "tolower");
+ p_toupper = (void *)GetProcAddress(hntdll, "toupper");
} /* if */
}
@@ -1350,6 +1353,34 @@ static void test_tolower(void)
}
}
+static void test_toupper(void)
+{
+
+ int i, ret, exp_ret;
+ char str[2], *p;
+ WCHAR wc;
+
+ ok(p_toupper != NULL, "toupper is not available\n");
+
+ for (i = -512; i < 0xffff; i++)
+ {
+ str[0] = i;
+ str[1] = i >> 8;
+ p = str;
+ wc = RtlAnsiCharToUnicodeChar( &p );
+ wc = RtlUpcaseUnicodeChar( wc );
+ ret = WideCharToMultiByte( CP_ACP, 0, &wc, 1, str, 2, NULL, NULL );
+ ok(ret == 1 || ret == 2, "WideCharToMultiByte returned %d\n", ret);
+ if (ret == 2)
+ exp_ret = (unsigned char)str[1] + ((unsigned char)str[0] << 8);
+ else
+ exp_ret = (unsigned char)str[0];
+
+ ret = p_toupper(i);
+ ok(ret == exp_ret, "toupper(%x) = %x, expected %x\n", i, ret, exp_ret);
+ }
+}
+
START_TEST(string)
{
InitFunctionPtrs();
@@ -1387,4 +1418,5 @@ START_TEST(string)
if (p__snprintf)
test__snprintf();
test_tolower();
+ test_toupper();
}
More information about the wine-cvs
mailing list