xkb_mod_mask_t mods;
};
-static uint32_t
+static uint16_t
add_node(struct xkb_compose_table *table, xkb_keysym_t keysym)
{
struct compose_node new = {
const struct production *production)
{
unsigned lhs_pos;
- uint32_t curr;
+ uint16_t curr;
struct compose_node *node;
+ if (darray_size(table->nodes) + 1 == MAX_COMPOSE_NODES)
+ scanner_warn(s, "too many sequences for one Compose file; will ignore further lines");
+ if (darray_size(table->nodes) >= MAX_COMPOSE_NODES)
+ return;
+
curr = 0;
node = &darray_item(table->nodes, curr);
for (lhs_pos = 0; lhs_pos < production->len; lhs_pos++) {
while (production->lhs[lhs_pos] != node->keysym) {
if (node->next == 0) {
- uint32_t next = add_node(table, production->lhs[lhs_pos]);
+ uint16_t next = add_node(table, production->lhs[lhs_pos]);
/* Refetch since add_node could have realloc()ed. */
node = &darray_item(table->nodes, curr);
node->next = next;
}
{
- uint32_t successor = add_node(table, production->lhs[lhs_pos + 1]);
+ uint16_t successor = add_node(table, production->lhs[lhs_pos + 1]);
/* Refetch since add_node could have realloc()ed. */
node = &darray_item(table->nodes, curr);
node->is_leaf = false;
* This is also sufficient for inferring the current status; see
* xkb_compose_state_get_status().
*/
- uint32_t prev_context;
- uint32_t context;
+ uint16_t prev_context;
+ uint16_t context;
};
XKB_EXPORT struct xkb_compose_state *
XKB_EXPORT enum xkb_compose_feed_result
xkb_compose_state_feed(struct xkb_compose_state *state, xkb_keysym_t keysym)
{
- uint32_t context;
+ uint16_t context;
const struct compose_node *node;
/*
* \0 is so offset 0 points to an empty string).
*/
+/* Fits in uint16_t, also a good idea to have some limit. */
+#define MAX_COMPOSE_NODES 65535
+
struct compose_node {
xkb_keysym_t keysym;
/* Offset into xkb_compose_table::nodes. */
- unsigned int next:31;
- bool is_leaf:1;
+ uint16_t next;
+ bool is_leaf;
union {
/* Offset into xkb_compose_table::nodes. */
- uint32_t successor;
+ uint16_t successor;
struct {
/* Offset into xkb_compose_table::utf8. */
uint32_t utf8;