ntdll: Don't handle the full Unicode character range in wcslwr/wcsupr.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2020-03-09 14:32:37 +01:00
parent 0d6802dcc5
commit 5a4cc97a3b
2 changed files with 31 additions and 2 deletions

View File

@ -1157,6 +1157,7 @@ static void test_wcslwrupr(void)
static WCHAR teststringW[] = {'a','b','r','a','c','a','d','a','b','r','a',0};
static WCHAR emptyW[] = {0};
static const WCHAR constemptyW[] = {0};
WCHAR buffer[65536];
int i;
if (0) /* crashes on native */
@ -1181,6 +1182,18 @@ static void test_wcslwrupr(void)
ok( ptowlower( i ) == lwr, "%04x: towlower got %04x expected %04x\n", i, ptowlower( i ), lwr );
ok( ptowupper( i ) == upr, "%04x: towupper got %04x expected %04x\n", i, ptowupper( i ), upr );
}
for (i = 1; i < 65536; i++) buffer[i - 1] = i;
buffer[65535] = 0;
p_wcslwr( buffer );
for (i = 1; i < 65536; i++)
ok( buffer[i - 1] == (i >= 'A' && i <= 'Z' ? i + 32 : i), "%04x: got %04x\n", i, buffer[i-1] );
for (i = 1; i < 65536; i++) buffer[i - 1] = i;
buffer[65535] = 0;
p_wcsupr( buffer );
for (i = 1; i < 65536; i++)
ok( buffer[i - 1] == (i >= 'a' && i <= 'z' ? i - 32 : i), "%04x: got %04x\n", i, buffer[i-1] );
}
static int __cdecl intcomparefunc(const void *a, const void *b)

View File

@ -47,7 +47,15 @@ INT __cdecl NTDLL__wcsicmp( LPCWSTR str1, LPCWSTR str2 )
*/
LPWSTR __cdecl NTDLL__wcslwr( LPWSTR str )
{
return strlwrW( str );
WCHAR *ret = str;
while (*str)
{
WCHAR ch = *str;
if (ch >= 'A' && ch <= 'Z') ch += 32;
*str++ = ch;
}
return ret;
}
@ -65,7 +73,15 @@ INT __cdecl NTDLL__wcsnicmp( LPCWSTR str1, LPCWSTR str2, INT n )
*/
LPWSTR __cdecl NTDLL__wcsupr( LPWSTR str )
{
return struprW( str );
WCHAR *ret = str;
while (*str)
{
WCHAR ch = *str;
if (ch >= 'a' && ch <= 'z') ch -= 32;
*str++ = ch;
}
return ret;
}