summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-02-14 17:25:58 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-02-14 17:25:58 +0000
commit2623932886dcf4c3ae426c56580e8d971bfa6f1a (patch)
treed91ea2bcc55d28f1fc1329c549143f4aed815b5b
parentb0a82b1dfe2bba205fb5584e89fd4714bfad91ee (diff)
parentf15aa2f3e535336ba177510a87b3f28070c76fc2 (diff)
downloadgtk+-2623932886dcf4c3ae426c56580e8d971bfa6f1a.tar.gz
Merge branch 'fix-compose-comments' into 'master'
Fix compose comments Closes #3664 See merge request GNOME/gtk!3199
-rw-r--r--gtk/gtkcomposetable.c30
-rw-r--r--testsuite/gtk/compose/comments4
-rw-r--r--testsuite/gtk/compose/comments.expected5
-rw-r--r--testsuite/gtk/compose/match.expected5
4 files changed, 34 insertions, 10 deletions
diff --git a/gtk/gtkcomposetable.c b/gtk/gtkcomposetable.c
index c5261f8a63..20afc2dc44 100644
--- a/gtk/gtkcomposetable.c
+++ b/gtk/gtkcomposetable.c
@@ -77,28 +77,40 @@ parse_compose_value (GtkComposeData *compose_data,
const char *val,
const char *line)
{
- char *word;
const char *p;
- gsize len;
GString *value;
gunichar ch;
char *endp;
- len = strlen (val);
- if (val[0] != '"' || val[len - 1] != '"')
+ if (val[0] != '"')
{
g_warning ("Need to double-quote the value: %s: %s", val, line);
goto fail;
}
- word = g_strndup (val + 1, len - 2);
-
value = g_string_new ("");
- p = word;
+ p = val + 1;
while (*p)
{
- if (*p == '\\')
+ if (*p == '\0')
+ {
+ g_warning ("Missing closing '\"': %s: %s", val, line);
+ goto fail;
+ }
+ else if (*p == '\"')
+ {
+ p++;
+ while (*p && g_ascii_isspace (*p))
+ p++;
+ if (*p != '\0' && *p != '#')
+ {
+ g_warning ("Garbage after closing '\"': %s: %s", val, line);
+ goto fail;
+ }
+ break;
+ }
+ else if (*p == '\\')
{
if (p[1] == '"')
{
@@ -148,8 +160,6 @@ parse_compose_value (GtkComposeData *compose_data,
compose_data->value = g_string_free (value, FALSE);
- g_free (word);
-
return TRUE;
fail:
diff --git a/testsuite/gtk/compose/comments b/testsuite/gtk/compose/comments
new file mode 100644
index 0000000000..062c9aac08
--- /dev/null
+++ b/testsuite/gtk/compose/comments
@@ -0,0 +1,4 @@
+<Multi_key> <a> : "a" # just an a
+<Multi_key> <b> : "#" # not an a
+# this line is ignored
+<Multi_key> <c> : "a" # wild and wilder: "@!$#
diff --git a/testsuite/gtk/compose/comments.expected b/testsuite/gtk/compose/comments.expected
new file mode 100644
index 0000000000..728817b5db
--- /dev/null
+++ b/testsuite/gtk/compose/comments.expected
@@ -0,0 +1,5 @@
+# n_seqs: 3
+# max_seq_len: 2
+<Uff20> <U61> : "a" # U61
+<Uff20> <U62> : "#" # U23
+<Uff20> <U63> : "a" # U61
diff --git a/testsuite/gtk/compose/match.expected b/testsuite/gtk/compose/match.expected
new file mode 100644
index 0000000000..c9013cac3c
--- /dev/null
+++ b/testsuite/gtk/compose/match.expected
@@ -0,0 +1,5 @@
+# n_seqs: 3
+# max_seq_len: 7
+<Uff20> <U73> <U65> <U71> <U0> <U0> <U0> : "!" # U21
+<Uff20> <U73> <U65> <U71> <U75> <U0> <U0> : "?" # U3f
+<Uff20> <U7a> <U77> <U69> <U6e> <U65> <U73> : "🥂" # U1f942