Compare commits

...

3 Commits

Author SHA1 Message Date
Matthias Clasen
60e08e3191 composetable: Warn for things we can't handle
The compose table stores the keyvals to match against
in a guint16 array, so it can't handle directly encoded
Unicode codepoints (which have a high bit set). Warn
if we encounter those.
2023-08-29 12:18:49 -04:00
Mike FABIAN
208d3cf785 Add another test case for a single char compose sequence, using a code point (<UFEF7>) 2023-08-29 13:05:15 +02:00
Mike FABIAN
9e8bce3436 Add test case for single char compose sequence 2023-08-29 09:16:06 +02:00
3 changed files with 34 additions and 6 deletions

View File

@@ -231,7 +231,7 @@ parse_compose_sequence (const char *seq,
char *start = words[i];
char *end = strchr (words[i], '>');
char *match;
gunichar codepoint;
guint keyval;
if (words[i][0] == '\0')
continue;
@@ -248,18 +248,24 @@ parse_compose_sequence (const char *seq,
if (is_codepoint (match))
{
codepoint = (gunichar) g_ascii_strtoll (match + 1, NULL, 16);
sequence[n] = codepoint;
keyval = gdk_unicode_to_keyval ((gunichar) g_ascii_strtoll (match + 1, NULL, 16));
if (keyval > 0xffff)
g_warning ("Can't handle >16bit keyvals");
sequence[n] = (guint16) keyval;
sequence[n + 1] = 0;
}
else
{
codepoint = (gunichar) gdk_keyval_from_name (match);
sequence[n] = codepoint;
keyval = gdk_keyval_from_name (match);
if (keyval > 0xffff)
g_warning ("Can't handle >16bit keyvals");
sequence[n] = (guint16) keyval;
sequence[n + 1] = 0;
}
if (codepoint == GDK_KEY_VoidSymbol)
if (keyval == GDK_KEY_VoidSymbol)
g_warning ("Could not get code point of keysym %s", match);
g_free (match);
n++;

View File

@@ -2,3 +2,5 @@
<Multi_key> <s> <e> <q> <u> : "?"
<Multi_key> <z> <w> <i> <n> <e> <s> : "🥂"
<Multi_key> <l> <o> <n> <g> : "this is a long replacement string"
<q> : "qq"
<UFEF7> : "foobar"

View File

@@ -242,6 +242,26 @@ compose_table_match (void)
g_assert_true (match);
g_assert_cmpstr (output->str, ==, "this is a long replacement string");
g_string_set_size (output, 0);
buffer[0] = GDK_KEY_q;
buffer[1] = 0;
ret = gtk_compose_table_check (table, buffer, 1, &finish, &match, output);
g_assert_true (ret);
g_assert_false (finish);
g_assert_true (match);
g_assert_cmpstr (output->str, ==, "qq");
g_string_set_size (output, 0);
buffer[0] = 0x0100FEF7;
buffer[1] = 0;
ret = gtk_compose_table_check (table, buffer, 1, &finish, &match, output);
g_assert_true (ret);
g_assert_false (finish);
g_assert_true (match);
g_assert_cmpstr (output->str, ==, "foobar");
g_string_free (output, TRUE);
g_free (file);
}