menu: skip whitespace and unicode emojis before defining accelerators

Skip any character whose value in the ASCII table is larger than
127 (I think all non-ASCII chars follow this rule).

Also skip any whitespace.
This commit is contained in:
Alex Chernika 2026-04-11 21:21:10 +02:00
parent 667707c029
commit cea22422d5
No known key found for this signature in database
GPG key ID: 6029FAD8ABFB076A

View file

@ -145,6 +145,17 @@ item_create(struct menu *menu, const char *text, const char *icon_name, bool sho
menuitem->arrow = show_arrow ? "" : NULL;
const char *it = text;
/* Skip emojis and whitespace */
while (*it != '\0') {
unsigned char c = (unsigned char)*it;
if (isspace(c) || c > 127) {
it++;
} else {
break;
}
}
menuitem->accelerator = tolower(*it);
while (*it != '\0') {
if (*it == '_') {