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