Commit Graph

36 Commits

Author SHA1 Message Date
Matthias Clasen
915e3f0e28 composetable: Remove some redundant code
Pointed out by Peter Bloomfield.
2021-02-23 19:14:26 -05:00
Matthias Clasen
baec7079e0 imcontext: Take out the warnings
Don't warn about Compose file constructs we don't
support. We haven't supported these for a long time,
and nobody has every complained. No need to wake
up sleeping dogs.
2021-02-22 15:08:58 -05:00
Matthias Clasen
2f43b8dc49 imcontext: Improve compose table parsing
Avoid leaking value in error cases, and actually
emit a warning for a missing quote. Pointed out
by Peter Bloomfield.
2021-02-15 01:46:00 -05:00
Matthias Clasen
d2e074e36b imcontext: Be more lenient in parsing Compose
X11 allows keysyms to be specified in addition to strings.
We only support the strings. In the past, we ignored everything
after the string. Go back to doing that, but issue a warning
that we've ignored the keysym.
2021-02-14 12:56:00 -05:00
Matthias Clasen
f15aa2f3e5 imcontext: Fix a regression in Compose file parsing
We accidentally dropped the handing of # comments.
Bring it back. Test included.

Fixes: #3664
2021-02-14 11:56:24 -05:00
Matthias Clasen
e91e75173d composetable: Remove a redundant check
We already know seq_index is not NULL here.

Pointed out in https://www.viva64.com/en/b/0793/
2021-02-04 00:22:52 -05:00
Matthias Clasen
949c783187 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
2021-02-02 12:05:19 -05:00
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