Commit Graph

29 Commits

Author SHA1 Message Date
Matthias Clasen
676f875bf6 composetable: Support string values in the cache
Change the cache format to include the character
data that we need to hold string values in the table.
2021-02-02 11:55:00 -05:00
Matthias Clasen
140c5c5333 composetable: Don't use GSlice for big blobs
This just doesn't make sense. This will use malloc
anyway, so just call malloc directly.
2021-02-02 11:55:00 -05:00
Matthias Clasen
cebf2b2009 composetable: Keep multi-char values
Keep string values in the table, and return them
from the check function. This commit temporarily
disables the table caching, since the cache format
does not handle string values yet.

Fixes: #186
2021-02-02 11:54:53 -05:00
Matthias Clasen
773ae0cd0f composetable: Parse multi-char values
Rewrite the value parsing function to accept strings
that hold more than a single Unicode character.
2021-02-02 09:03:53 -05:00
Matthias Clasen
564793d5b5 composetable: Another step towards multi-char values
Change the parser data structures to hold a string, rather
than a gunichar. We still only put a single Unicode character
into it, currently.
2021-02-02 09:02:46 -05:00
Matthias Clasen
9142aa0f51 composetable: Prepare for multi character values
Make it possible for gtk_compose_table_check to return
a string instead of just a single Unicode character.
Currently, we only ever return strings holding a single
character, still.
2021-02-02 09:02:00 -05:00
Matthias Clasen
ef053ebb4a composetable: Fix algorithmic matching
The code wasn't paying attention to (lack of) nul-termination
in one place, causing it to not match when it should.
2021-02-01 21:51:51 -05:00
Matthias Clasen
5d9509c51b imcontext: Move code around
Move all the checking code to gtkcomposetable.c, and
add api that we can use in tests.
2021-02-01 20:27:38 -05:00
Matthias Clasen
9ebf3fac73 composetable: Add api to check tables
This copies the check_table code from gtkimcontextsimple.c,
in order to have an api for tests.
2021-02-01 19:40:22 -05:00
Matthias Clasen
be35c46ce9 composetable: Drop table debug code
This is better off in the tests that we are going to add.
2021-02-01 19:02:21 -05:00
Matthias Clasen
dbbcb13721 composetable: Parser fixes
We were not handling octal escapes right.
2021-02-01 16:05:05 -05:00
Matthias Clasen
61f709811c composetable: Warn when ignoring things
We should at least give a hint that we've seen the line,
otherwise people will wonder why nothing happened.
2021-02-01 12:27:41 -05:00
Matthias Clasen
f7c4375509 composetable: parse long sequences
Allow compose sequences of up to 20 code points.

Fixes: #3521
2021-02-01 12:27:35 -05:00
Matthias Clasen
52fb900ced composetable: Fix an off-by-one
Fix an off-by-one in the code parsing octal escapes
in compose files.
2021-02-01 12:10:05 -05:00
Matthias Clasen
094a346539 imcontext: Allow sequences of length GTK_MAX_COMPOSE_LEN
There was an off-by-one error, making us reject sequences
of this length. But the rest of the code handles them
just fine.

Fixes: #2319
2021-02-01 00:55:25 -05:00
Matthias Clasen
162814f969 imcontext: Improve an error message
This error message was misleading, as pointed out
by Ralf Jung.
2021-02-01 00:44:41 -05:00
Matthias Clasen
929a56e53c Clean up lots of GTK+ -> GTK
Replace most remaining uses of GTK+ in the docs and
user-visible strings by GTK. Also remove some leftover
"Was added in 3.x" sentences from the docs.
2020-09-12 12:01:04 -04:00
Benjamin Otte
d375dce9f5 Replace "gchar" with "char" 2020-07-25 00:47:36 +02:00
Benjamin Otte
d7266b25ba Replace "gint" with "int" 2020-07-25 00:47:36 +02:00
Christoph Reiter
b66e4cd64c gtkcomposetable: use g_size_checked_mul() for overflow checking
The check was added in !741, this replaces it with g_size_checked_mul()
2019-04-12 22:41:58 +02:00
Emmanuele Bassi
b4c8ba4de7 Check the size of the g_new arguments
We're passing integers without validating their size, and newer GCC are
very cross about it, with warnings like:

    warning: argument 1 range [18446744071562067968, 18446744073709551615]
    exceeds maximum object size 9223372036854775807 [-Walloc-size-larger-than=]

We should check we're not overflowing the allocation size, by limiting
the range of values we can use.

First of all, we need to use `gsize` instead of a random `int`, since we're
allocating data.

Additionally, we need to check that the multiplication that computes the
size of the allocation doesn't overflow the maximum value of a `gsize`.
2019-04-12 18:58:34 +01:00
Mohammed Sadiq
bdf3b6f64d Revert "imcontext: Make size arguments be gsize and not int"
This was committed accidently.

This reverts commit eefd2d6f10.
2018-06-14 11:15:14 +05:30
Benjamin Otte
eefd2d6f10 imcontext: Make size arguments be gsize and not int
Otherwise gcc complains when we use these as arguments to g_new() on
32bit architectures with:

../gtk/gtkcomposetable.c: In function ‘gtk_compose_table_list_add_array’:
/usr/include/glib-2.0/glib/gmem.h:217:10: warning: argument 1 range [2147483648, 4294967295] exceeds maximum object size 2147483647 [-Walloc-size-larger-than=]
      __p = g_##func##_n (__n, __s);   \
      ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/glib-2.0/glib/gmem.h:279:42: note: in expansion of macro ‘_G_NEW’
 #define g_new0(struct_type, n_structs)   _G_NEW (struct_type, n_structs, malloc0)
                                          ^~~~~~
../gtk/gtkcomposetable.c:851:22: note: in expansion of macro ‘g_new0’
   gtk_compose_seqs = g_new0 (guint16, length);
                      ^~~~~~
/usr/include/glib-2.0/glib/gmem.h:96:10: note: in a call to allocation function ‘g_malloc0_n’ declared here
 gpointer g_malloc0_n      (gsize  n_blocks,
          ^~~~~~~~~~~
2018-06-14 06:37:00 +05:30
Thibaut Girka
641b42f9f5 Fix loading cached compose tables
https://bugzilla.gnome.org/show_bug.cgi?id=773916
2016-11-10 14:32:59 -05:00
Rico Tzschichholz
8abf05e194 gtk: Update path references from gtk-3.0 to gtk-4.0 2016-10-23 20:22:38 +02:00
Benjamin Otte
35c96c2c1f Add braces to appease gcc
-ftrack-macro-expansion=0 doesn't like if statements without braces when
evaluating indentation levels.
2016-08-25 23:02:27 +02:00
Benjamin Otte
9708ecdd5b composetable: Fix gcc warnings 2016-02-03 23:06:53 +01:00
Matthias Clasen
03f4666994 composetable: Don't abort on unsupported escape sequences
People might put all sorts of gunk in their .XCompose file, in
the hope that XLib makes sense of it. Even if we don't make sense
of it, we shouldn't abort, but instead ignore the lines we can't
understand. Pointed out in
https://bugzilla.redhat.com/show_bug.cgi?id=1301254
2016-01-27 23:22:02 -05:00
Takao Fujiwara
138187755f Add gtk_compose_table_new_with_file() to create GtkComposeTable
https://bugzilla.gnome.org/show_bug.cgi?id=721120
2015-10-09 00:19:41 -04:00