[gtk/gtk-4-4] gtkcomposetable: Accept long replacement strings



commit 0476b5a34ce4b83dfac20b2f8f3ab8a844365091
Author: Martin KΓΌhl <martin kuehl posteo net>
Date:   Tue Sep 21 16:56:47 2021 +0200

    gtkcomposetable: Accept long replacement strings
    
    This change removes the assertions limiting replacement strings in the compose table to be less than 20 
characters.
    The limit seems arbitrary, is not required, will break some users' setups, and problems with it result in 
applications not launching.
    
    Fixes #4273

 gtk/gtkcomposetable.c                |  3 ---
 testsuite/gtk/compose/long           |  1 +
 testsuite/gtk/compose/long.expected  |  7 ++++---
 testsuite/gtk/compose/match          |  1 +
 testsuite/gtk/compose/match.expected |  7 ++++---
 testsuite/gtk/composetable.c         | 13 +++++++++++++
 6 files changed, 23 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkcomposetable.c b/gtk/gtkcomposetable.c
index 6495163d88..e7ed9d7474 100644
--- a/gtk/gtkcomposetable.c
+++ b/gtk/gtkcomposetable.c
@@ -936,8 +936,6 @@ parser_get_compose_table (GtkComposeParser *parser)
         }
       else
         {
-          g_assert (strlen (value) < 20);
-
           if (char_data->len > 0)
             g_string_append_c (char_data, 0);
 
@@ -1437,7 +1435,6 @@ gtk_compose_table_foreach (const GtkComposeTable      *table,
                   int char_offset = encoded_value & ~(1 << 15);
                   g_assert (char_offset < table->n_chars);
                   value = &table->char_data[char_offset];
-                  g_assert (strlen (value) < 20);
                 }
               else
                 {
diff --git a/testsuite/gtk/compose/long b/testsuite/gtk/compose/long
index 84ef7acee8..1e57ea7b76 100644
--- a/testsuite/gtk/compose/long
+++ b/testsuite/gtk/compose/long
@@ -1 +1,2 @@
 <Multi_key> <e> <m> <m> <e> <n> <t> <a> <l> <e> <r> : "πŸ§€"
+<Multi_key> <t> <m> <y> <k> : "the mooore you knooow πŸ’«"
diff --git a/testsuite/gtk/compose/long.expected b/testsuite/gtk/compose/long.expected
index 0846c7f6e9..ec7035d1db 100644
--- a/testsuite/gtk/compose/long.expected
+++ b/testsuite/gtk/compose/long.expected
@@ -1,6 +1,7 @@
-# n_sequences: 1
+# n_sequences: 2
 # max_seq_len: 11
 # n_index_size: 1
-# data_size: 23
-# n_chars: 5
+# data_size: 28
+# n_chars: 32
+<Uff20> <U74> <U6d> <U79> <U6b> : "the mooore you knooow πŸ’«"
 <Uff20> <U65> <U6d> <U6d> <U65> <U6e> <U74> <U61> <U6c> <U65> <U72> : "πŸ§€" # U1f9c0
diff --git a/testsuite/gtk/compose/match b/testsuite/gtk/compose/match
index 0554ac02c2..1cb4e74cf5 100644
--- a/testsuite/gtk/compose/match
+++ b/testsuite/gtk/compose/match
@@ -1,3 +1,4 @@
 <Multi_key> <s> <e> <q> : "!"
 <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"
diff --git a/testsuite/gtk/compose/match.expected b/testsuite/gtk/compose/match.expected
index bed10c5a10..a82e7cecbf 100644
--- a/testsuite/gtk/compose/match.expected
+++ b/testsuite/gtk/compose/match.expected
@@ -1,8 +1,9 @@
-# n_sequences: 3
+# n_sequences: 4
 # max_seq_len: 7
 # n_index_size: 1
-# data_size: 24
-# n_chars: 5
+# data_size: 29
+# n_chars: 39
 <Uff20> <U73> <U65> <U71> : "!" # U21
+<Uff20> <U6c> <U6f> <U6e> <U67> : "this is a long replacement string"
 <Uff20> <U73> <U65> <U71> <U75> : "?" # U3f
 <Uff20> <U7a> <U77> <U69> <U6e> <U65> <U73> : "πŸ₯‚" # U1f942
diff --git a/testsuite/gtk/composetable.c b/testsuite/gtk/composetable.c
index 564416ceb8..baa83e961d 100644
--- a/testsuite/gtk/composetable.c
+++ b/testsuite/gtk/composetable.c
@@ -229,6 +229,19 @@ compose_table_match (void)
   g_assert_true (match);
   g_assert_cmpstr (output->str, ==, "?");
 
+  g_string_set_size (output, 0);
+
+  buffer[0] = GDK_KEY_Multi_key;
+  buffer[1] = GDK_KEY_l;
+  buffer[2] = GDK_KEY_o;
+  buffer[3] = GDK_KEY_n;
+  buffer[4] = GDK_KEY_g;
+  ret = gtk_compose_table_check (table, buffer, 5, &finish, &match, output);
+  g_assert_true (ret);
+  g_assert_true (finish);
+  g_assert_true (match);
+  g_assert_cmpstr (output->str, ==, "this is a long replacement string");
+
   g_string_free (output, TRUE);
   g_free (file);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]