parent
90e2d5ee76
commit
8b09e1772c
|
@ -382,11 +382,11 @@ add_production(struct xkb_compose_table *table, struct scanner *s,
|
|||
break;
|
||||
|
||||
if (node->is_leaf) {
|
||||
if (node->u.leaf.utf8 != 0 ||
|
||||
node->u.leaf.keysym != XKB_KEY_NoSymbol) {
|
||||
if (node->leaf.utf8 != 0 ||
|
||||
node->leaf.keysym != XKB_KEY_NoSymbol) {
|
||||
scanner_warn(s, "a sequence already exists which is a prefix of this sequence; overriding");
|
||||
node->u.leaf.utf8 = 0;
|
||||
node->u.leaf.keysym = XKB_KEY_NoSymbol;
|
||||
node->leaf.utf8 = 0;
|
||||
node->leaf.keysym = XKB_KEY_NoSymbol;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -394,11 +394,11 @@ add_production(struct xkb_compose_table *table, struct scanner *s,
|
|||
/* Refetch since add_node could have realloc()ed. */
|
||||
node = &darray_item(table->nodes, curr);
|
||||
node->is_leaf = false;
|
||||
node->u.successor = successor;
|
||||
node->internal.successor = successor;
|
||||
}
|
||||
}
|
||||
|
||||
curr = node->u.successor;
|
||||
curr = node->internal.successor;
|
||||
node = &darray_item(table->nodes, curr);
|
||||
}
|
||||
|
||||
|
@ -407,19 +407,19 @@ add_production(struct xkb_compose_table *table, struct scanner *s,
|
|||
return;
|
||||
}
|
||||
|
||||
if (node->u.leaf.utf8 != 0 || node->u.leaf.keysym != XKB_KEY_NoSymbol) {
|
||||
if (node->leaf.utf8 != 0 || node->leaf.keysym != XKB_KEY_NoSymbol) {
|
||||
bool same_string =
|
||||
(node->u.leaf.utf8 == 0 && !production->has_string) ||
|
||||
(node->leaf.utf8 == 0 && !production->has_string) ||
|
||||
(
|
||||
node->u.leaf.utf8 != 0 && production->has_string &&
|
||||
streq(&darray_item(table->utf8, node->u.leaf.utf8),
|
||||
node->leaf.utf8 != 0 && production->has_string &&
|
||||
streq(&darray_item(table->utf8, node->leaf.utf8),
|
||||
production->string)
|
||||
);
|
||||
bool same_keysym =
|
||||
(node->u.leaf.keysym == XKB_KEY_NoSymbol && !production->has_keysym) ||
|
||||
(node->leaf.keysym == XKB_KEY_NoSymbol && !production->has_keysym) ||
|
||||
(
|
||||
node->u.leaf.keysym != XKB_KEY_NoSymbol && production->has_keysym &&
|
||||
node->u.leaf.keysym == production->keysym
|
||||
node->leaf.keysym != XKB_KEY_NoSymbol && production->has_keysym &&
|
||||
node->leaf.keysym == production->keysym
|
||||
);
|
||||
if (same_string && same_keysym) {
|
||||
scanner_warn(s, "this compose sequence is a duplicate of another; skipping line");
|
||||
|
@ -429,12 +429,12 @@ add_production(struct xkb_compose_table *table, struct scanner *s,
|
|||
}
|
||||
|
||||
if (production->has_string) {
|
||||
node->u.leaf.utf8 = darray_size(table->utf8);
|
||||
node->leaf.utf8 = darray_size(table->utf8);
|
||||
darray_append_items(table->utf8, production->string,
|
||||
strlen(production->string) + 1);
|
||||
}
|
||||
if (production->has_keysym) {
|
||||
node->u.leaf.keysym = production->keysym;
|
||||
node->leaf.keysym = production->keysym;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ xkb_compose_state_feed(struct xkb_compose_state *state, xkb_keysym_t keysym)
|
|||
|
||||
node = &darray_item(state->table->nodes, state->context);
|
||||
|
||||
context = (node->is_leaf ? 0 : node->u.successor);
|
||||
context = (node->is_leaf ? 0 : node->internal.successor);
|
||||
node = &darray_item(state->table->nodes, context);
|
||||
|
||||
while (node->keysym != keysym && node->next != 0) {
|
||||
|
@ -164,11 +164,11 @@ xkb_compose_state_get_utf8(struct xkb_compose_state *state,
|
|||
|
||||
/* If there's no string specified, but only a keysym, try to do the
|
||||
* most helpful thing. */
|
||||
if (node->u.leaf.utf8 == 0 && node->u.leaf.keysym != XKB_KEY_NoSymbol) {
|
||||
if (node->leaf.utf8 == 0 && node->leaf.keysym != XKB_KEY_NoSymbol) {
|
||||
char name[64];
|
||||
int ret;
|
||||
|
||||
ret = xkb_keysym_to_utf8(node->u.leaf.keysym, name, sizeof(name));
|
||||
ret = xkb_keysym_to_utf8(node->leaf.keysym, name, sizeof(name));
|
||||
if (ret < 0 || ret == 0) {
|
||||
/* ret < 0 is impossible.
|
||||
* ret == 0 means the keysym has no string representation. */
|
||||
|
@ -179,7 +179,7 @@ xkb_compose_state_get_utf8(struct xkb_compose_state *state,
|
|||
}
|
||||
|
||||
return snprintf(buffer, size, "%s",
|
||||
&darray_item(state->table->utf8, node->u.leaf.utf8));
|
||||
&darray_item(state->table->utf8, node->leaf.utf8));
|
||||
|
||||
fail:
|
||||
if (size > 0)
|
||||
|
@ -194,5 +194,5 @@ xkb_compose_state_get_one_sym(struct xkb_compose_state *state)
|
|||
&darray_item(state->table->nodes, state->context);
|
||||
if (!node->is_leaf)
|
||||
return XKB_KEY_NoSymbol;
|
||||
return node->u.leaf.keysym;
|
||||
return node->leaf.keysym;
|
||||
}
|
||||
|
|
|
@ -61,8 +61,8 @@ xkb_compose_table_new(struct xkb_context *ctx,
|
|||
root.keysym = XKB_KEY_NoSymbol;
|
||||
root.next = 0;
|
||||
root.is_leaf = true;
|
||||
root.u.leaf.utf8 = 0;
|
||||
root.u.leaf.keysym = XKB_KEY_NoSymbol;
|
||||
root.leaf.utf8 = 0;
|
||||
root.leaf.keysym = XKB_KEY_NoSymbol;
|
||||
darray_append(table->nodes, root);
|
||||
|
||||
darray_append(table->utf8, '\0');
|
||||
|
|
|
@ -78,14 +78,16 @@ struct compose_node {
|
|||
bool is_leaf;
|
||||
|
||||
union {
|
||||
/* Offset into xkb_compose_table::nodes. */
|
||||
uint16_t successor;
|
||||
struct {
|
||||
/* Offset into xkb_compose_table::nodes. */
|
||||
uint16_t successor;
|
||||
} internal;
|
||||
struct {
|
||||
/* Offset into xkb_compose_table::utf8. */
|
||||
uint32_t utf8;
|
||||
xkb_keysym_t keysym;
|
||||
} leaf;
|
||||
} u;
|
||||
};
|
||||
};
|
||||
|
||||
struct xkb_compose_table {
|
||||
|
|
Loading…
Reference in New Issue