Skip to content

Commit

Permalink
compose: Reduce xkb_compose_state_get_utf8 buffer
Browse files Browse the repository at this point in the history
`xkb_keysym_to_utf8` does not return a keysym name but its corresponding
character, if defined.
  • Loading branch information
wismill committed Jan 10, 2024
1 parent eb69160 commit e3ad80d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/compose/state.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ 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->leaf.utf8 == 0 && node->leaf.keysym != XKB_KEY_NoSymbol) {
char name[64];
char utf8[7];
int ret;

ret = xkb_keysym_to_utf8(node->leaf.keysym, name, sizeof(name));
ret = xkb_keysym_to_utf8(node->leaf.keysym, utf8, sizeof(utf8));
if (ret < 0 || ret == 0) {
/* ret < 0 is impossible.
* ret == 0 means the keysym has no string representation. */
goto fail;
}

return snprintf(buffer, size, "%s", name);
return snprintf(buffer, size, "%s", utf8);
}

return snprintf(buffer, size, "%s",
Expand Down

0 comments on commit e3ad80d

Please sign in to comment.