Piotr Caban : libwine: Ignore 0 weights as described in Unicode collation algorithm.

Alexandre Julliard julliard at winehq.org
Wed May 22 15:52:06 CDT 2019


Module: wine
Branch: master
Commit: 4a6e69ad3aff6fff2817b05ee2cdcc7e94f960a5
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=4a6e69ad3aff6fff2817b05ee2cdcc7e94f960a5

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Tue May 21 17:19:52 2019 +0200

libwine: Ignore 0 weights as described in Unicode collation algorithm.

Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/kernel32/tests/locale.c |  8 ++++----
 libs/port/sortkey.c          | 28 ++++++++++++++++++++++------
 2 files changed, 26 insertions(+), 10 deletions(-)

diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index 1c632cc..81e7453 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -2043,9 +2043,9 @@ static void test_CompareStringW(void)
     ok(ret == CSTR_GREATER_THAN, "expected CSTR_GREATER_THAN, got %d\n", ret);
 
     ret = CompareStringW(CP_ACP, 0, ABC_EE, 4, A_ACUTE_BC, 4);
-    todo_wine ok(ret == CSTR_LESS_THAN, "expected CSTR_LESS_THAN, got %d\n", ret);
+    ok(ret == CSTR_LESS_THAN, "expected CSTR_LESS_THAN, got %d\n", ret);
     ret = CompareStringW(CP_ACP, 0, ABC_EE, 4, A_ACUTE_BC_DECOMP, 5);
-    todo_wine ok(ret == CSTR_LESS_THAN, "expected CSTR_LESS_THAN, got %d\n", ret);
+    ok(ret == CSTR_LESS_THAN, "expected CSTR_LESS_THAN, got %d\n", ret);
     ret = CompareStringW(CP_ACP, 0, A_ACUTE_BC, 4, A_ACUTE_BC_DECOMP, 5);
     ok(ret == CSTR_EQUAL, "expected CSTR_EQUAL, got %d\n", ret);
 
@@ -2057,9 +2057,9 @@ static void test_CompareStringW(void)
     ok(ret == CSTR_EQUAL, "expected CSTR_EQUAL, got %d\n", ret);
 
     ret = CompareStringW(CP_ACP, 0, ABC_EE, 4, A_NULL_BC, 4);
-    todo_wine ok(ret == CSTR_EQUAL, "expected CSTR_LESS_THAN, got %d\n", ret);
+    ok(ret == CSTR_EQUAL, "expected CSTR_LESS_THAN, got %d\n", ret);
     ret = CompareStringW(CP_ACP, NORM_IGNORENONSPACE, ABC_EE, 4, A_NULL_BC, 4);
-    todo_wine ok(ret == CSTR_EQUAL, "expected CSTR_EQUAL, got %d\n", ret);
+    ok(ret == CSTR_EQUAL, "expected CSTR_EQUAL, got %d\n", ret);
 
     ret = CompareStringW(CP_ACP, 0, A_NULL_BC, 4, A_ACUTE_BC, 4);
     ok(ret == CSTR_LESS_THAN, "expected CSTR_LESS_THAN, got %d\n", ret);
diff --git a/libs/port/sortkey.c b/libs/port/sortkey.c
index 5d83fcd..f62289b 100644
--- a/libs/port/sortkey.c
+++ b/libs/port/sortkey.c
@@ -245,22 +245,38 @@ static inline int compare_weights(int flags, const WCHAR *str1, int len1,
         }
 
         ce1 = get_weight(dstr1[dpos1], type);
+        if (!ce1)
+        {
+            inc_str_pos(&str1, &len1, &dpos1, &dlen1);
+            continue;
+        }
         ce2 = get_weight(dstr2[dpos2], type);
+        if (!ce2)
+        {
+            inc_str_pos(&str2, &len2, &dpos2, &dlen2);
+            continue;
+        }
 
         if (ce1 - ce2) return ce1 - ce2;
 
         inc_str_pos(&str1, &len1, &dpos1, &dlen1);
         inc_str_pos(&str2, &len2, &dpos2, &dlen2);
     }
-    while (len1 && !*str1)
+    while (len1)
     {
-        str1++;
-        len1--;
+        if (!dlen1) dlen1 = wine_decompose(0, *str1, dstr1, 4);
+
+        ce1 = get_weight(dstr1[dpos1], type);
+        if (ce1) break;
+        inc_str_pos(&str1, &len1, &dpos1, &dlen1);
     }
-    while (len2 && !*str2)
+    while (len2)
     {
-        str2++;
-        len2--;
+        if (!dlen2) dlen2 = wine_decompose(0, *str2, dstr2, 4);
+
+        ce2 = get_weight(dstr2[dpos2], type);
+        if (ce2) break;
+        inc_str_pos(&str2, &len2, &dpos2, &dlen2);
     }
     return len1 - len2;
 }




More information about the wine-cvs mailing list