Update linguistic casing patches to include tests.

This commit is contained in:
Erich E. Hoover 2014-02-12 13:29:06 -07:00
parent 43b0d84ae9
commit 35cab4ef93
6 changed files with 348 additions and 27 deletions

View File

@ -1,25 +0,0 @@
From d027a6891aa48f2614b606892bc54e25e147eee2 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Sun, 11 Aug 2013 17:45:19 -0600
Subject: kernel32: Allow string comparison with linguistic casing.
---
dlls/kernel32/locale.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 9ddf078..d635364 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -2934,7 +2934,7 @@ INT WINAPI CompareStringEx(LPCWSTR locale, DWORD flags, LPCWSTR str1, INT len1,
return 0;
}
- if( flags & ~(NORM_IGNORECASE|NORM_IGNORENONSPACE|NORM_IGNORESYMBOLS|
+ if( flags & ~(NORM_IGNORECASE|NORM_IGNORENONSPACE|NORM_IGNORESYMBOLS|NORM_LINGUISTIC_CASING|
SORT_STRINGSORT|NORM_IGNOREKANATYPE|NORM_IGNOREWIDTH|LOCALE_USE_CP_ACP|0x10000000) )
{
SetLastError(ERROR_INVALID_FLAGS);
--
1.7.9.5

View File

@ -0,0 +1,244 @@
From cfd4d6f8d11668e8dba511bc74c805fb53a52d9d Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 12 Feb 2014 13:26:57 -0700
Subject: kernel32/tests: Add a variety of tests for CompareStringEx.
---
dlls/kernel32/tests/locale.c | 200 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 200 insertions(+)
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index 62e9f01..9aab6b0 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -88,6 +88,8 @@ static INT (WINAPI *pIdnToUnicode)(DWORD, LPCWSTR, INT, LPWSTR, INT);
static INT (WINAPI *pGetLocaleInfoEx)(LPCWSTR, LCTYPE, LPWSTR, INT);
static BOOL (WINAPI *pIsValidLocaleName)(LPCWSTR);
static INT (WINAPI *pCompareStringOrdinal)(const WCHAR *, INT, const WCHAR *, INT, BOOL);
+static INT (WINAPI *pCompareStringEx)(LPCWSTR, DWORD, LPCWSTR, INT, LPCWSTR, INT,
+ LPNLSVERSIONINFO, LPVOID, LPARAM);
static void InitFunctionPointers(void)
{
@@ -108,6 +110,7 @@ static void InitFunctionPointers(void)
pGetLocaleInfoEx = (void*)GetProcAddress(hKernel32, "GetLocaleInfoEx");
pIsValidLocaleName = (void*)GetProcAddress(hKernel32, "IsValidLocaleName");
pCompareStringOrdinal = (void*)GetProcAddress(hKernel32, "CompareStringOrdinal");
+ pCompareStringEx = (void*)GetProcAddress(hKernel32, "CompareStringEx");
}
#define eq(received, expected, label, type) \
@@ -1472,6 +1475,202 @@ static void test_CompareStringA(void)
"ret %d, error %d, expected value %d\n", ret, GetLastError(), CSTR_EQUAL);
}
+struct comparestringex_test {
+ const char *locale;
+ DWORD flags;
+ const WCHAR first[2];
+ const WCHAR second[2];
+ INT ret;
+ INT broken;
+ BOOL todo;
+};
+
+static const struct comparestringex_test comparestringex_tests[] = {
+ /* default behavior */
+ { /* 0 */
+ "tr-TR", 0,
+ {'i',0}, {'I',0}, CSTR_LESS_THAN, -1, FALSE
+ },
+ { /* 1 */
+ "tr-TR", 0,
+ {'i',0}, {0x130,0}, CSTR_LESS_THAN, -1, FALSE
+ },
+ { /* 2 */
+ "tr-TR", 0,
+ {'i',0}, {0x131,0}, CSTR_LESS_THAN, -1, FALSE
+ },
+ { /* 3 */
+ "tr-TR", 0,
+ {'I',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 4 */
+ "tr-TR", 0,
+ {'I',0}, {0x131,0}, CSTR_LESS_THAN, -1, FALSE
+ },
+ { /* 5 */
+ "tr-TR", 0,
+ {0x130,0}, {0x131,0}, CSTR_GREATER_THAN, -1, TRUE
+ },
+ /* with NORM_IGNORECASE */
+ { /* 6 */
+ "tr-TR", NORM_IGNORECASE,
+ {'i',0}, {'I',0}, CSTR_EQUAL, -1, FALSE
+ },
+ { /* 7 */
+ "tr-TR", NORM_IGNORECASE,
+ {'i',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 8 */
+ "tr-TR", NORM_IGNORECASE,
+ {'i',0}, {0x131,0}, CSTR_LESS_THAN, -1, FALSE
+ },
+ { /* 9 */
+ "tr-TR", NORM_IGNORECASE,
+ {'I',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 10 */
+ "tr-TR", NORM_IGNORECASE,
+ {'I',0}, {0x131,0}, CSTR_LESS_THAN, -1, FALSE
+ },
+ { /* 11 */
+ "tr-TR", NORM_IGNORECASE,
+ {0x130,0}, {0x131,0}, CSTR_GREATER_THAN, -1, TRUE
+ },
+ /* with NORM_LINGUISTIC_CASING */
+ { /* 12 */
+ "tr-TR", NORM_LINGUISTIC_CASING,
+ {'i',0}, {'I',0}, CSTR_GREATER_THAN, CSTR_LESS_THAN, TRUE
+ },
+ { /* 13 */
+ "tr-TR", NORM_LINGUISTIC_CASING,
+ {'i',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 14 */
+ "tr-TR", NORM_LINGUISTIC_CASING,
+ {'i',0}, {0x131,0}, CSTR_GREATER_THAN, CSTR_LESS_THAN, TRUE
+ },
+ { /* 15 */
+ "tr-TR", NORM_LINGUISTIC_CASING,
+ {'I',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 16 */
+ "tr-TR", NORM_LINGUISTIC_CASING,
+ {'I',0}, {0x131,0}, CSTR_GREATER_THAN, CSTR_LESS_THAN, TRUE
+ },
+ { /* 17 */
+ "tr-TR", NORM_LINGUISTIC_CASING,
+ {0x130,0}, {0x131,0}, CSTR_GREATER_THAN, -1, TRUE
+ },
+ /* with LINGUISTIC_IGNORECASE */
+ { /* 18 */
+ "tr-TR", LINGUISTIC_IGNORECASE,
+ {'i',0}, {'I',0}, CSTR_EQUAL, -1, TRUE
+ },
+ { /* 19 */
+ "tr-TR", LINGUISTIC_IGNORECASE,
+ {'i',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 20 */
+ "tr-TR", LINGUISTIC_IGNORECASE,
+ {'i',0}, {0x131,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 21 */
+ "tr-TR", LINGUISTIC_IGNORECASE,
+ {'I',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 22 */
+ "tr-TR", LINGUISTIC_IGNORECASE,
+ {'I',0}, {0x131,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 23 */
+ "tr-TR", LINGUISTIC_IGNORECASE,
+ {0x130,0}, {0x131,0}, CSTR_GREATER_THAN, -1, TRUE
+ },
+ /* with NORM_LINGUISTIC_CASING | NORM_IGNORECASE */
+ { /* 24 */
+ "tr-TR", NORM_LINGUISTIC_CASING | NORM_IGNORECASE,
+ {'i',0}, {'I',0}, CSTR_GREATER_THAN, CSTR_EQUAL, TRUE
+ },
+ { /* 25 */
+ "tr-TR", NORM_LINGUISTIC_CASING | NORM_IGNORECASE,
+ {'i',0}, {0x130,0}, CSTR_EQUAL, CSTR_LESS_THAN, TRUE
+ },
+ { /* 26 */
+ "tr-TR", NORM_LINGUISTIC_CASING | NORM_IGNORECASE,
+ {'i',0}, {0x131,0}, CSTR_GREATER_THAN, CSTR_LESS_THAN, TRUE
+ },
+ { /* 27 */
+ "tr-TR", NORM_LINGUISTIC_CASING | NORM_IGNORECASE,
+ {'I',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 28 */
+ "tr-TR", NORM_LINGUISTIC_CASING | NORM_IGNORECASE,
+ {'I',0}, {0x131,0}, CSTR_EQUAL, CSTR_LESS_THAN, TRUE
+ },
+ { /* 29 */
+ "tr-TR", NORM_LINGUISTIC_CASING | NORM_IGNORECASE,
+ {0x130,0}, {0x131,0}, CSTR_GREATER_THAN, -1, TRUE
+ },
+ /* with NORM_LINGUISTIC_CASING | LINGUISTIC_IGNORECASE */
+ { /* 30 */
+ "tr-TR", NORM_LINGUISTIC_CASING | LINGUISTIC_IGNORECASE,
+ {'i',0}, {'I',0}, CSTR_GREATER_THAN, CSTR_EQUAL, TRUE
+ },
+ { /* 31 */
+ "tr-TR", NORM_LINGUISTIC_CASING | LINGUISTIC_IGNORECASE,
+ {'i',0}, {0x130,0}, CSTR_EQUAL, CSTR_LESS_THAN, TRUE
+ },
+ { /* 32 */
+ "tr-TR", NORM_LINGUISTIC_CASING | LINGUISTIC_IGNORECASE,
+ {'i',0}, {0x131,0}, CSTR_GREATER_THAN, CSTR_LESS_THAN, TRUE
+ },
+ { /* 33 */
+ "tr-TR", NORM_LINGUISTIC_CASING | LINGUISTIC_IGNORECASE,
+ {'I',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ },
+ { /* 34 */
+ "tr-TR", NORM_LINGUISTIC_CASING | LINGUISTIC_IGNORECASE,
+ {'I',0}, {0x131,0}, CSTR_EQUAL, CSTR_LESS_THAN, TRUE
+ },
+ { /* 35 */
+ "tr-TR", NORM_LINGUISTIC_CASING | LINGUISTIC_IGNORECASE,
+ {0x130,0}, {0x131,0}, CSTR_GREATER_THAN, CSTR_LESS_THAN, TRUE
+ }
+};
+
+static void test_CompareStringEx(void)
+{
+ const char *op[] = {"ERROR", "CSTR_LESS_THAN", "CSTR_EQUAL", "CSTR_GREATER_THAN"};
+ WCHAR locale[6];
+ INT ret, i;
+
+ /* CompareStringEx is only available on Vista+ */
+ if (!pCompareStringEx)
+ {
+ win_skip("CompareStringEx not supported\n");
+ return;
+ }
+
+ for (i = 0; i < sizeof(comparestringex_tests)/sizeof(comparestringex_tests[0]); i++)
+ {
+ const struct comparestringex_test *e = &comparestringex_tests[i];
+
+ MultiByteToWideChar(CP_ACP, 0, e->locale, -1, locale, sizeof(locale)/sizeof(WCHAR));
+ ret = pCompareStringEx(locale, e->flags, e->first, -1, e->second, -1, NULL, NULL, 0);
+ if (e->todo)
+ {
+ todo_wine ok(ret == e->ret || broken(ret == e->broken),
+ "%d: got %s, expected %s\n", i, op[ret], op[e->ret]);
+ }
+ else
+ {
+ ok(ret == e->ret || broken(ret == e->broken),
+ "%d: got %s, expected %s\n", i, op[ret], op[e->ret]);
+ }
+ }
+
+}
+
static void test_LCMapStringA(void)
{
int ret, ret2;
@@ -3608,6 +3807,7 @@ START_TEST(locale)
test_GetCurrencyFormatA(); /* Also tests the W version */
test_GetNumberFormatA(); /* Also tests the W version */
test_CompareStringA();
+ test_CompareStringEx();
test_LCMapStringA();
test_LCMapStringW();
test_LCMapStringEx();
--
1.7.9.5

View File

@ -0,0 +1,48 @@
From 216cec49d8aa2698a30351c56e9eb97bde71f587 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 12 Feb 2014 13:27:10 -0700
Subject: kernel32: Allow CompareStringEx NORM_LINGUISTIC_CASING flag.
---
dlls/kernel32/locale.c | 2 +-
dlls/kernel32/tests/locale.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 22903d5..24ca804 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -2935,7 +2935,7 @@ INT WINAPI CompareStringEx(LPCWSTR locale, DWORD flags, LPCWSTR str1, INT len1,
return 0;
}
- if( flags & ~(NORM_IGNORECASE|NORM_IGNORENONSPACE|NORM_IGNORESYMBOLS|
+ if( flags & ~(NORM_IGNORECASE|NORM_IGNORENONSPACE|NORM_IGNORESYMBOLS|NORM_LINGUISTIC_CASING|
SORT_STRINGSORT|NORM_IGNOREKANATYPE|NORM_IGNOREWIDTH|LOCALE_USE_CP_ACP|0x10000000) )
{
SetLastError(ERROR_INVALID_FLAGS);
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index 9aab6b0..bb6fbdc 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -1543,7 +1543,7 @@ static const struct comparestringex_test comparestringex_tests[] = {
},
{ /* 13 */
"tr-TR", NORM_LINGUISTIC_CASING,
- {'i',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ {'i',0}, {0x130,0}, CSTR_LESS_THAN, -1, FALSE
},
{ /* 14 */
"tr-TR", NORM_LINGUISTIC_CASING,
@@ -1593,7 +1593,7 @@ static const struct comparestringex_test comparestringex_tests[] = {
},
{ /* 25 */
"tr-TR", NORM_LINGUISTIC_CASING | NORM_IGNORECASE,
- {'i',0}, {0x130,0}, CSTR_EQUAL, CSTR_LESS_THAN, TRUE
+ {'i',0}, {0x130,0}, CSTR_EQUAL, CSTR_LESS_THAN, FALSE
},
{ /* 26 */
"tr-TR", NORM_LINGUISTIC_CASING | NORM_IGNORECASE,
--
1.7.9.5

View File

@ -0,0 +1,54 @@
From aa81fa5f638112147fc7fd0ace9b7454f7ebf960 Mon Sep 17 00:00:00 2001
From: "Erich E. Hoover" <erich.e.hoover@gmail.com>
Date: Wed, 12 Feb 2014 13:27:24 -0700
Subject: kernel32: Allow CompareStringEx LINGUISTIC_IGNORECASE flag.
---
dlls/kernel32/locale.c | 3 ++-
dlls/kernel32/tests/locale.c | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index 24ca804..3009df5 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -2936,7 +2936,8 @@ INT WINAPI CompareStringEx(LPCWSTR locale, DWORD flags, LPCWSTR str1, INT len1,
}
if( flags & ~(NORM_IGNORECASE|NORM_IGNORENONSPACE|NORM_IGNORESYMBOLS|NORM_LINGUISTIC_CASING|
- SORT_STRINGSORT|NORM_IGNOREKANATYPE|NORM_IGNOREWIDTH|LOCALE_USE_CP_ACP|0x10000000) )
+ SORT_STRINGSORT|NORM_IGNOREKANATYPE|NORM_IGNOREWIDTH|LOCALE_USE_CP_ACP|
+ LINGUISTIC_IGNORECASE|0x10000000) )
{
SetLastError(ERROR_INVALID_FLAGS);
return 0;
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index bb6fbdc..5eda11b 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -1568,11 +1568,11 @@ static const struct comparestringex_test comparestringex_tests[] = {
},
{ /* 19 */
"tr-TR", LINGUISTIC_IGNORECASE,
- {'i',0}, {0x130,0}, CSTR_LESS_THAN, -1, TRUE
+ {'i',0}, {0x130,0}, CSTR_LESS_THAN, -1, FALSE
},
{ /* 20 */
"tr-TR", LINGUISTIC_IGNORECASE,
- {'i',0}, {0x131,0}, CSTR_LESS_THAN, -1, TRUE
+ {'i',0}, {0x131,0}, CSTR_LESS_THAN, -1, FALSE
},
{ /* 21 */
"tr-TR", LINGUISTIC_IGNORECASE,
@@ -1580,7 +1580,7 @@ static const struct comparestringex_test comparestringex_tests[] = {
},
{ /* 22 */
"tr-TR", LINGUISTIC_IGNORECASE,
- {'I',0}, {0x131,0}, CSTR_LESS_THAN, -1, TRUE
+ {'I',0}, {0x131,0}, CSTR_LESS_THAN, -1, FALSE
},
{ /* 23 */
"tr-TR", LINGUISTIC_IGNORECASE,
--
1.7.9.5

View File

@ -1,3 +1,3 @@
Revision: 1
Revision: 2
Author: Erich E. Hoover
Title: Allow string comparison with linguistic casing.

View File

@ -48,7 +48,7 @@ index a273502..5fa0cd5 100644
+} wine_patch_data[] = {
+ { "8a366b6d-8ad6-4581-8aa9-66a03590a57b:1", "Erich E. Hoover", "Implement SIO_ADDRESS_LIST_CHANGE." },
+ { "92938b89-506b-430a-ba50-32de8b286e56:2", "Erich E. Hoover", "Store and return security attributes with extended file attributes." },
+ { "9cb0f665-bf7c-485f-89cc-554adcdf8880:1", "Erich E. Hoover", "Allow string comparison with linguistic casing." },
+ { "9cb0f665-bf7c-485f-89cc-554adcdf8880:2", "Erich E. Hoover", "Allow string comparison with linguistic casing." },
+ { "5d6bb7b5-ec88-4ed3-907d-9ad2173a2f88:1", "Sebastian Lackner", "Enable/disable windows when they are (un)mapped by foreign applications." },
+ { "94186fff-6dbf-44d0-8eb1-2463d1608a0f:1", "Sebastian Lackner", "Update gl_drawable for embedded windows." },
+ { "cbe240e8-2c58-430a-b61c-7fbb9d0e1e11:1", "Sebastian Lackner", "Change return value of stub SetNamedPipeHandleState to TRUE." },