compose: drop the 65535 node limit (#343)

In commit 1638409b22, the number of
compose nodes was limited to 65535 to enable "future optimizations",
which apparently means slightly reduced memory usage due to fitting in
a uint16_t. At this time, it was mentioned that the author was not
aware of "any compose files which come close".

However, I'm one of the users that actually do require a larger number
of nodes for their compose file. Thus, use a uint32_t again and raise
the limit significantly.
master
alois31 2023-05-15 14:23:16 +02:00 committed by GitHub
parent 64aaa7cda2
commit f3210cbf27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 10 deletions

View File

@ -332,8 +332,8 @@ add_production(struct xkb_compose_table *table, struct scanner *s,
const struct production *production) const struct production *production)
{ {
unsigned lhs_pos = 0; unsigned lhs_pos = 0;
uint16_t curr = darray_size(table->nodes) == 1 ? 0 : 1; uint32_t curr = darray_size(table->nodes) == 1 ? 0 : 1;
uint16_t *pptr = NULL; uint32_t *pptr = NULL;
struct compose_node *node = NULL; struct compose_node *node = NULL;
/* Warn before potentially going over the limit, discard silently after. */ /* Warn before potentially going over the limit, discard silently after. */

View File

@ -41,8 +41,8 @@ struct xkb_compose_state {
* This is also sufficient for inferring the current status; see * This is also sufficient for inferring the current status; see
* xkb_compose_state_get_status(). * xkb_compose_state_get_status().
*/ */
uint16_t prev_context; uint32_t prev_context;
uint16_t context; uint32_t context;
}; };
XKB_EXPORT struct xkb_compose_state * XKB_EXPORT struct xkb_compose_state *
@ -91,7 +91,7 @@ xkb_compose_state_get_compose_table(struct xkb_compose_state *state)
XKB_EXPORT enum xkb_compose_feed_result XKB_EXPORT enum xkb_compose_feed_result
xkb_compose_state_feed(struct xkb_compose_state *state, xkb_keysym_t keysym) xkb_compose_state_feed(struct xkb_compose_state *state, xkb_keysym_t keysym)
{ {
uint16_t context; uint32_t context;
const struct compose_node *node; const struct compose_node *node;
/* /*

View File

@ -75,16 +75,17 @@
* \0 is so offset 0 points to an empty string). * \0 is so offset 0 points to an empty string).
*/ */
/* Fits in uint16_t, also a good idea to have some limit. */ /* 7 nodes for every potential Unicode character and then some should be
#define MAX_COMPOSE_NODES 65535 * enough for all purposes. */
#define MAX_COMPOSE_NODES (1 << 23)
struct compose_node { struct compose_node {
xkb_keysym_t keysym; xkb_keysym_t keysym;
/* Offset into xkb_compose_table::nodes or 0. */ /* Offset into xkb_compose_table::nodes or 0. */
uint16_t lokid; uint32_t lokid;
/* Offset into xkb_compose_table::nodes or 0. */ /* Offset into xkb_compose_table::nodes or 0. */
uint16_t hikid; uint32_t hikid;
union { union {
struct { struct {
@ -95,7 +96,7 @@ struct compose_node {
uint32_t _pad:31; uint32_t _pad:31;
bool is_leaf:1; bool is_leaf:1;
/* Offset into xkb_compose_table::nodes or 0. */ /* Offset into xkb_compose_table::nodes or 0. */
uint16_t eqkid; uint32_t eqkid;
} internal; } internal;
struct { struct {
/* Offset into xkb_compose_table::utf8. */ /* Offset into xkb_compose_table::utf8. */