[PATCH 3/6] kernel32: Implement canonical reordering.

Huw Davies huw at codeweavers.com
Fri Feb 8 04:41:24 CST 2019


Signed-off-by: Huw Davies <huw at codeweavers.com>
---
 dlls/kernel32/locale.c       |   1 +
 dlls/kernel32/tests/locale.c |   6 +-
 libs/port/Makefile.in        |   1 +
 libs/port/combclass.c        | 288 +++++++++++++++++++++++++++++++++++
 libs/port/normalize.c        |  68 +++++++++
 tools/make_unicode           |  24 +++
 6 files changed, 385 insertions(+), 3 deletions(-)
 create mode 100644 libs/port/combclass.c

diff --git a/dlls/kernel32/locale.c b/dlls/kernel32/locale.c
index a4e5ef5a38..f2455bd72e 100644
--- a/dlls/kernel32/locale.c
+++ b/dlls/kernel32/locale.c
@@ -5374,6 +5374,7 @@ INT WINAPI NormalizeString(NORM_FORM form, const WCHAR *src, INT src_len, WCHAR
 
     if (form == NormalizationKC || form == NormalizationKD) flags |= WINE_DECOMPOSE_COMPAT;
     if (form == NormalizationC || form == NormalizationKC) compose = 1;
+    if (compose || dst_len) flags |= WINE_DECOMPOSE_REORDER;
 
     if (!compose && dst_len)
     {
diff --git a/dlls/kernel32/tests/locale.c b/dlls/kernel32/tests/locale.c
index 0fa6aeb7b4..851da7febf 100644
--- a/dlls/kernel32/tests/locale.c
+++ b/dlls/kernel32/tests/locale.c
@@ -5696,10 +5696,10 @@ static void test_NormalizeString(void)
         { part0_str2, { part0_nfc2, part0_str2, part0_nfc2, part0_str2 }, { 1, 0, 1, 0 } },
         { part0_str3, { part0_nfc3, part0_str3, part0_nfc3, part0_str3 }, { 1, 0, 1, 0 } },
         { part0_str4, { part0_nfc4, part0_str4, part0_nfc4, part0_str4 }, { 1, 0, 1, 0 } },
-        { part0_str5, { part0_nfc5, part0_nfc5, part0_nfc5, part0_nfc5 }, { 1, 1, 1, 1 } },
-        { part0_str6, { part0_nfc6, part0_nfc6, part0_nfc6, part0_nfc6 }, { 1, 1, 1, 1 } },
+        { part0_str5, { part0_nfc5, part0_nfc5, part0_nfc5, part0_nfc5 }, { 1, 0, 1, 0 } },
+        { part0_str6, { part0_nfc6, part0_nfc6, part0_nfc6, part0_nfc6 }, { 1, 0, 1, 0 } },
         { part0_str8, { part0_str8, part0_nfd8, part0_str8, part0_nfd8 }, { 1, 0, 1, 0 } },
-        { part0_str9, { part0_nfc9, part0_nfd9, part0_nfc9, part0_nfd9 }, { 1, 1, 1, 1 } },
+        { part0_str9, { part0_nfc9, part0_nfd9, part0_nfc9, part0_nfd9 }, { 1, 0, 1, 0 } },
         { part0_str10, { part0_str10, part0_nfd10, part0_str10, part0_nfd10 }, { 1, 0, 1, 0 } },
         { part0_str11, { part0_str11, part0_nfd11, part0_str11, part0_nfd11 }, { 1, 0, 1, 0 } },
         { part0_str12, { part0_nfc12, part0_nfd12, part0_nfc12, part0_nfd12 }, { 1, 0, 1, 0 } },
diff --git a/libs/port/Makefile.in b/libs/port/Makefile.in
index 1c753fd893..8d16741534 100644
--- a/libs/port/Makefile.in
+++ b/libs/port/Makefile.in
@@ -73,6 +73,7 @@ C_SRCS = \
 	c_936.c \
 	c_949.c \
 	c_950.c \
+	combclass.c \
 	compose.c \
 	cpsymbol.c \
 	cptable.c \
diff --git a/libs/port/combclass.c b/libs/port/combclass.c
new file mode 100644
index 0000000000..1567812c33
--- /dev/null
+++ b/libs/port/combclass.c
@@ -0,0 +1,288 @@
+/* Unicode Combining Classes */
+/* generated from http://www.unicode.org/Public/11.0.0/ucd/UnicodeData.txt */
+/* DO NOT EDIT!! */
+
+#include "wine/unicode.h"
+
+const unsigned short DECLSPEC_HIDDEN combining_class_table[2208] =
+{
+    /* level 1 offsets */
+    0x0100, 0x0100, 0x0100, 0x0110, 0x0120, 0x0130, 0x0140, 0x0150,
+    0x0160, 0x0170, 0x0180, 0x0190, 0x01a0, 0x01b0, 0x01c0, 0x01d0,
+    0x01e0, 0x0100, 0x0100, 0x01f0, 0x0100, 0x0100, 0x0100, 0x0200,
+    0x0210, 0x0220, 0x0230, 0x0240, 0x0250, 0x0260, 0x0100, 0x0100,
+    0x0270, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0280, 0x0290, 0x0100, 0x0100,
+    0x02a0, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x02b0, 0x0100,
+    0x02c0, 0x02d0, 0x02e0, 0x02f0, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100, 0x0100,
+    0x0100, 0x0100, 0x0100, 0x0300, 0x0100, 0x0100, 0x0310, 0x0100,
+    /* level 2 offsets */
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0330, 0x0340, 0x0350, 0x0360, 0x0370, 0x0380, 0x0390, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x03a0, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x03b0, 0x03c0, 0x03d0, 0x03e0, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x03f0, 0x0320, 0x0320, 0x0400, 0x0410, 0x0320, 0x0420,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0430, 0x0440, 0x0320,
+    0x0320, 0x0450, 0x0320, 0x0460, 0x0470, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0480, 0x0490,
+    0x0320, 0x04a0, 0x04b0, 0x0320, 0x0320, 0x04c0, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x04d0, 0x04e0, 0x04f0,
+    0x0320, 0x0320, 0x0320, 0x0500, 0x0510, 0x0520, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0500, 0x0510, 0x0320, 0x0320, 0x0530,
+    0x0320, 0x0320, 0x0320, 0x0500, 0x0510, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0500, 0x0510, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0500, 0x0510, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0510, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0510, 0x0540, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0500, 0x0510, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0550, 0x0510, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0560, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0570, 0x0580, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0590, 0x05a0, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x05b0, 0x0320, 0x05c0, 0x0320, 0x0320, 0x0320, 0x05d0,
+    0x05e0, 0x0320, 0x0320, 0x0320, 0x05f0, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0600, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0610, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0620, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0630, 0x0320, 0x0630, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0640, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0650, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0660, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0670, 0x0320, 0x0320, 0x0320, 0x0320, 0x0680, 0x0690,
+    0x0320, 0x0320, 0x0320, 0x06a0, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x06b0, 0x0630, 0x0320, 0x06c0, 0x06d0,
+    0x0320, 0x0320, 0x06e0, 0x0320, 0x0320, 0x0320, 0x06f0, 0x0700,
+    0x0320, 0x0320, 0x0320, 0x0710, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0720, 0x0730, 0x0740,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0750, 0x0760, 0x0330, 0x0770,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0780, 0x0790, 0x07a0,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x07b0, 0x07c0,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x07d0,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0330, 0x0330,
+    0x0320, 0x0320, 0x07e0, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x07f0, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x07b0, 0x0800,
+    0x0320, 0x0810, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x07c0,
+    0x0820, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0630, 0x0320, 0x0330, 0x07c0,
+    0x0320, 0x0320, 0x0830, 0x0320, 0x0320, 0x0840, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0850, 0x0680, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0860, 0x0870, 0x0320, 0x0320, 0x0820,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0510, 0x0320,
+    0x0320, 0x0880, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0890, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320, 0x0320,
+    /* values */
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e8, 0x00dc, 0x00dc,
+    0x00dc, 0x00dc, 0x00e8, 0x00d8, 0x00dc, 0x00dc, 0x00dc, 0x00dc,
+    0x00dc, 0x00ca, 0x00ca, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00ca,
+    0x00ca, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00dc,
+    0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x0001, 0x0001, 0x0001, 0x0001,
+    0x0001, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00f0, 0x00e6, 0x00dc,
+    0x00dc, 0x00dc, 0x00e6, 0x00e6, 0x00e6, 0x00dc, 0x00dc, 0x0000,
+    0x00e6, 0x00e6, 0x00e6, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00e6,
+    0x00e8, 0x00dc, 0x00dc, 0x00e6, 0x00e9, 0x00ea, 0x00ea, 0x00e9,
+    0x00ea, 0x00ea, 0x00e9, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x0000, 0x0000, 0x0000, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x00dc, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00dc, 0x00e6,
+    0x00e6, 0x00e6, 0x00de, 0x00dc, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00dc,
+    0x00e6, 0x00e6, 0x00dc, 0x00e6, 0x00e6, 0x00de, 0x00e4, 0x00e6,
+    0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f, 0x0010, 0x0011,
+    0x0012, 0x0013, 0x0013, 0x0014, 0x0015, 0x0016, 0x0000, 0x0017,
+    0x0000, 0x0018, 0x0019, 0x0000, 0x00e6, 0x00dc, 0x0000, 0x0012,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x001e, 0x001f, 0x0020, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
+    0x0020, 0x0021, 0x0022, 0x00e6, 0x00e6, 0x00dc, 0x00dc, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00dc, 0x00e6, 0x00e6, 0x00dc,
+    0x0023, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x0000, 0x0000, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00dc, 0x00e6, 0x0000, 0x0000, 0x00e6,
+    0x00e6, 0x0000, 0x00dc, 0x00e6, 0x00e6, 0x00dc, 0x0000, 0x0000,
+    0x0000, 0x0024, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x00e6, 0x00dc, 0x00e6, 0x00e6, 0x00dc, 0x00e6, 0x00e6, 0x00dc,
+    0x00dc, 0x00dc, 0x00e6, 0x00dc, 0x00dc, 0x00e6, 0x00dc, 0x00e6,
+    0x00e6, 0x00e6, 0x00dc, 0x00e6, 0x00dc, 0x00e6, 0x00dc, 0x00e6,
+    0x00dc, 0x00e6, 0x00e6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00dc, 0x00e6, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00dc, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x0000, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x0000, 0x00e6, 0x00e6, 0x00e6,
+    0x0000, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x00dc, 0x00dc, 0x00dc, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x00dc, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x0000, 0x00dc, 0x00e6, 0x00e6, 0x00dc, 0x00e6,
+    0x00e6, 0x00dc, 0x00e6, 0x00e6, 0x00e6, 0x00dc, 0x00dc, 0x00dc,
+    0x001b, 0x001c, 0x001d, 0x00e6, 0x00e6, 0x00e6, 0x00dc, 0x00e6,
+    0x00e6, 0x00dc, 0x00dc, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0007, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0009, 0x0000, 0x0000,
+    0x0000, 0x00e6, 0x00dc, 0x00e6, 0x00e6, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0054, 0x005b, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0009, 0x0009, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0009, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0067, 0x0067, 0x0009, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x006b, 0x006b, 0x006b, 0x006b, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0076, 0x0076, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x007a, 0x007a, 0x007a, 0x007a, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x00dc, 0x00dc, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00dc, 0x0000, 0x00dc,
+    0x0000, 0x00d8, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0081, 0x0082, 0x0000, 0x0084, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0082, 0x0082, 0x0082, 0x0082, 0x0000, 0x0000,
+    0x0082, 0x0000, 0x00e6, 0x00e6, 0x0009, 0x0000, 0x00e6, 0x00e6,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00dc, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0007,
+    0x0000, 0x0009, 0x0009, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00dc, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x00e6, 0x00e6,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0009, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0009, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x00e4, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x00de, 0x00e6, 0x00dc, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6,
+    0x00dc, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0009, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x0000, 0x0000, 0x00dc,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00dc, 0x00dc, 0x00dc,
+    0x00dc, 0x00dc, 0x00dc, 0x00e6, 0x00e6, 0x00dc, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0007, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x00e6, 0x00dc, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0009, 0x0009, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0007, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0009, 0x0009, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0007,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x00e6, 0x00e6, 0x00e6, 0x0000, 0x0001, 0x00dc, 0x00dc, 0x00dc,
+    0x00dc, 0x00dc, 0x00e6, 0x00e6, 0x00dc, 0x00dc, 0x00dc, 0x00dc,
+    0x00e6, 0x0000, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001,
+    0x0001, 0x0000, 0x0000, 0x0000, 0x0000, 0x00dc, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x0000, 0x0000, 0x0000,
+    0x00e6, 0x00e6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x00e6, 0x00e6, 0x00dc, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00dc, 0x00e6, 0x00e6, 0x00ea, 0x00d6, 0x00dc,
+    0x00ca, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e8, 0x00e4,
+    0x00e4, 0x00dc, 0x0000, 0x00e6, 0x00e9, 0x00dc, 0x00e6, 0x00dc,
+    0x00e6, 0x00e6, 0x0001, 0x0001, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x0001, 0x0001, 0x0001, 0x00e6, 0x00e6, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x00e6, 0x0000, 0x0000, 0x0000, 0x0001, 0x0001, 0x00e6,
+    0x00dc, 0x00e6, 0x0001, 0x0001, 0x00dc, 0x00dc, 0x00dc, 0x00dc,
+    0x00e6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6,
+    0x00e6, 0x00e6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0009,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x00da, 0x00e4, 0x00e8, 0x00de, 0x00e0, 0x00e0,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0008, 0x0008, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x00e6, 0x00e6, 0x00e6,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x00e6,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0009, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x00dc, 0x00dc, 0x00dc, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0009, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0007, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x00e6, 0x0000, 0x00e6, 0x00e6, 0x00dc, 0x0000, 0x0000, 0x00e6,
+    0x00e6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x00e6, 0x00e6,
+    0x0000, 0x00e6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
+    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x001a, 0x0000,
+    0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00e6, 0x00dc,
+    0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00dc, 0x00e6, 0x00e6
+};
diff --git a/libs/port/normalize.c b/libs/port/normalize.c
index ba6e39fe0e..8363eee98e 100644
--- a/libs/port/normalize.c
+++ b/libs/port/normalize.c
@@ -21,6 +21,72 @@
 #include "wine/unicode.h"
 
 extern unsigned int wine_decompose( int flags, WCHAR ch, WCHAR *dst, unsigned int dstlen ) DECLSPEC_HIDDEN;
+extern const unsigned short combining_class_table[] DECLSPEC_HIDDEN;
+
+static BYTE get_combining_class( WCHAR c )
+{
+    return combining_class_table[combining_class_table[combining_class_table[c >> 8] + ((c >> 4) & 0xf)] + (c & 0xf)];
+}
+
+static BOOL is_starter( WCHAR c )
+{
+    return !get_combining_class( c );
+}
+
+static BOOL reorderable_pair( WCHAR c1, WCHAR c2 )
+{
+    BYTE ccc1, ccc2;
+
+    /* reorderable if ccc1 > ccc2 > 0 */
+    ccc1 = get_combining_class( c1 );
+    if (ccc1 < 2) return FALSE;
+    ccc2 = get_combining_class( c2 );
+    return ccc2 && (ccc1 > ccc2);
+}
+
+static void canonical_order_substring( WCHAR *str, unsigned int len )
+{
+    unsigned int i;
+    BOOL swapped;
+
+    do
+    {
+        swapped = FALSE;
+        for (i = 0; i < len - 1; i++)
+        {
+            if (reorderable_pair( str[i], str[i + 1] ))
+            {
+                WCHAR tmp = str[i];
+                str[i] = str[i + 1];
+                str[i + 1] = tmp;
+                swapped = TRUE;
+            }
+        }
+    } while (swapped);
+}
+
+/****************************************************************************
+ *             canonical_order_string
+ *
+ * Reorder the string into canonical order - D108/D109.
+ *
+ * Starters (chars with combining class == 0) don't move, so look for continuous
+ * substrings of non-starters and only reorder those.
+ */
+static void canonical_order_string( WCHAR *str, unsigned int len )
+{
+    unsigned int i, next = 0;
+
+    for (i = 1; i <= len; i++)
+    {
+        if (i == len || is_starter( str[i] ))
+        {
+            if (i > next + 1) /* at least two successive non-starters */
+                canonical_order_substring( str + next, i - next );
+            next = i + 1;
+        }
+    }
+}
 
 unsigned int wine_decompose_string( int flags, const WCHAR *src, unsigned int src_len,
                                     WCHAR *dst, unsigned int dst_len )
@@ -34,5 +100,7 @@ unsigned int wine_decompose_string( int flags, const WCHAR *src, unsigned int sr
         if (decomp_len == 0) return 0;
         dst_pos += decomp_len;
     }
+
+    if (flags & WINE_DECOMPOSE_REORDER) canonical_order_string( dst, dst_pos );
     return dst_pos;
 }
diff --git a/tools/make_unicode b/tools/make_unicode
index 1533c46cea..f0056d09f3 100755
--- a/tools/make_unicode
+++ b/tools/make_unicode
@@ -360,6 +360,7 @@ my @joining_table = ();
 my @direction_table = ();
 my @decomp_table = ();
 my @compose_table = ();
+my @combining_class_table = ();
 my $default_char;
 my $default_wchar;
 
@@ -457,6 +458,10 @@ sub READ_DEFAULTS($)
         {
             $digitmap_table[$src] = ord $dig;
         }
+        if ($comb ne "")
+        {
+            $combining_class_table[$src] = $comb;
+        }
 
         # copy the category and direction for everything between First/Last pairs
         if ($name =~ /, First>/) { $start = $src; }
@@ -2370,6 +2375,24 @@ EOF
     save_file($filename);
 }
 
+################################################################
+# dump the combining class table
+sub dump_combining_class($)
+{
+    my $filename = shift;
+
+    open OUTPUT,">$filename.new" or die "Cannot create $filename";
+    print "Building $filename\n";
+    print OUTPUT "/* Unicode Combining Classes */\n";
+    print OUTPUT "/* generated from $UNIDATA/UnicodeData.txt */\n";
+    print OUTPUT "/* DO NOT EDIT!! */\n\n";
+    print OUTPUT "#include \"wine/unicode.h\"\n\n";
+
+    dump_two_level_mapping( "combining_class_table", 0, @combining_class_table );
+    close OUTPUT;
+    save_file($filename);
+}
+
 ################################################################
 # output a codepage definition file from the global tables
 sub output_codepage_file($$$$)
@@ -2604,6 +2627,7 @@ dump_compose_table( "libs/port/compose.c" );
 dump_decompose_table( "libs/port/decompose.c" );
 DUMP_CTYPE_TABLES( "libs/wine/wctype.c" );
 dump_digit_folding( "libs/port/digitmap.c" );
+dump_combining_class( "libs/port/combclass.c" );
 dump_mirroring( "dlls/usp10/mirror.c" );
 dump_mirroring( "dlls/dwrite/mirror.c" );
 dump_bracket( "dlls/usp10/bracket.c" );
-- 
2.18.0




More information about the wine-devel mailing list