[gtk/im-context-work: 5/5] composetable: Parse hex escapes too
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/im-context-work: 5/5] composetable: Parse hex escapes too
- Date: Tue, 2 Feb 2021 17:05:43 +0000 (UTC)
commit 949c7831871b396ef71db7b1360e3027ad79ccf7
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Feb 2 12:00:51 2021 -0500
composetable: Parse hex escapes too
This was a small omission from the Compose file
syntax that doesn't cost us much to support.
Add a test for this syntax too.
Fixes: #1004
gtk/gtkcomposetable.c | 16 ++++++++++++++++
testsuite/gtk/compose/hex | 1 +
testsuite/gtk/compose/hex.expected | 3 +++
testsuite/gtk/composetable.c | 1 +
4 files changed, 21 insertions(+)
---
diff --git a/gtk/gtkcomposetable.c b/gtk/gtkcomposetable.c
index a4c91abd90..a07f5da06f 100644
--- a/gtk/gtkcomposetable.c
+++ b/gtk/gtkcomposetable.c
@@ -113,6 +113,22 @@ parse_compose_value (GtkComposeData *compose_data,
else if (p[1] >= '0' && p[1] < '8')
{
ch = g_ascii_strtoll (p + 1, &endp, 8);
+ if (ch == 0)
+ {
+ g_warning ("Invalid escape sequence: %s: %s", val, line);
+ goto fail;
+ }
+ g_string_append_unichar (value, ch);
+ p = endp;
+ }
+ else if (p[1] == 'x' || p[1] == 'X')
+ {
+ ch = g_ascii_strtoll (p + 2, &endp, 16);
+ if (ch == 0)
+ {
+ g_warning ("Invalid escape sequence: %s: %s", val, line);
+ goto fail;
+ }
g_string_append_unichar (value, ch);
p = endp;
}
diff --git a/testsuite/gtk/compose/hex b/testsuite/gtk/compose/hex
new file mode 100644
index 0000000000..267972168f
--- /dev/null
+++ b/testsuite/gtk/compose/hex
@@ -0,0 +1 @@
+<Multi_key> <s> <e> <q> : "\x23fe\X23F3"
diff --git a/testsuite/gtk/compose/hex.expected b/testsuite/gtk/compose/hex.expected
new file mode 100644
index 0000000000..603344216c
--- /dev/null
+++ b/testsuite/gtk/compose/hex.expected
@@ -0,0 +1,3 @@
+# n_seqs: 1
+# max_seq_len: 4
+<Uff20> <U73> <U65> <U71> : "⏾⏳"
diff --git a/testsuite/gtk/composetable.c b/testsuite/gtk/composetable.c
index 2d88ad570d..b41faf08f2 100644
--- a/testsuite/gtk/composetable.c
+++ b/testsuite/gtk/composetable.c
@@ -308,6 +308,7 @@ main (int argc, char *argv[])
g_test_add_data_func ("/compose-table/basic", "basic", compose_table_compare);
g_test_add_data_func ("/compose-table/long", "long", compose_table_compare);
g_test_add_data_func ("/compose-table/octal", "octal", compose_table_compare);
+ g_test_add_data_func ("/compose-table/hex", "hex", compose_table_compare);
g_test_add_data_func ("/compose-table/codepoint", "codepoint", compose_table_compare);
g_test_add_data_func ("/compose-table/multi", "multi", compose_table_compare);
g_test_add_data_func ("/compose-table/strings", "strings", compose_table_compare);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]