Handle key names consistently
We treat the key names as fixed length, non NUL terminated strings of length XkbKeyNameLength, and use the appropriate *Text functions to print them. We also use strncpy everywhere instead of memcpy to copy the names, because it does some NUL padding and we might as well. Signed-off-by: Ran Benita <ran234@gmail.com>master
parent
c548c81529
commit
b2c4331ac3
|
@ -276,7 +276,7 @@ KeysymText(xkb_keysym_t sym)
|
|||
}
|
||||
|
||||
const char *
|
||||
KeyNameText(char *name)
|
||||
KeyNameText(const char name[XkbKeyNameLength])
|
||||
{
|
||||
char *buf;
|
||||
int len;
|
||||
|
|
|
@ -55,7 +55,7 @@ const char *
|
|||
KeysymText(xkb_keysym_t sym);
|
||||
|
||||
const char *
|
||||
KeyNameText(char *name);
|
||||
KeyNameText(const char name[XkbKeyNameLength]);
|
||||
|
||||
const char *
|
||||
SIMatchText(unsigned type);
|
||||
|
|
|
@ -619,7 +619,7 @@ ExprResolveKeyName(struct xkb_context *ctx, const ExprDef *expr,
|
|||
exprValueTypeText(expr->value_type));
|
||||
return false;
|
||||
}
|
||||
memcpy(name, expr->value.keyName, XkbKeyNameLength);
|
||||
strncpy(name, expr->value.keyName, XkbKeyNameLength);
|
||||
return true;
|
||||
|
||||
case EXPR_IDENT:
|
||||
|
|
|
@ -121,8 +121,8 @@ typedef struct _AliasInfo {
|
|||
unsigned file_id;
|
||||
struct list entry;
|
||||
|
||||
char alias[XkbKeyNameLength + 1];
|
||||
char real[XkbKeyNameLength + 1];
|
||||
char alias[XkbKeyNameLength];
|
||||
char real[XkbKeyNameLength];
|
||||
} AliasInfo;
|
||||
|
||||
typedef struct _IndicatorNameInfo {
|
||||
|
@ -379,8 +379,8 @@ FindKeyByLong(KeyNamesInfo * info, unsigned long name)
|
|||
*/
|
||||
static bool
|
||||
AddKeyName(KeyNamesInfo * info,
|
||||
xkb_keycode_t kc, char *name, enum merge_mode merge,
|
||||
unsigned file_id, bool reportCollisions)
|
||||
xkb_keycode_t kc, char name[XkbKeyNameLength],
|
||||
enum merge_mode merge, unsigned file_id, bool reportCollisions)
|
||||
{
|
||||
xkb_keycode_t old;
|
||||
unsigned long lval;
|
||||
|
@ -400,14 +400,13 @@ AddKeyName(KeyNamesInfo * info,
|
|||
file_id == darray_item(info->files, kc)));
|
||||
|
||||
if (darray_item(info->names, kc) != 0) {
|
||||
char buf[6];
|
||||
const char *lname = LongKeyNameText(darray_item(info->names, kc));
|
||||
const char *kname = KeyNameText(name);
|
||||
|
||||
LongToKeyName(darray_item(info->names, kc), buf);
|
||||
buf[4] = '\0';
|
||||
if (darray_item(info->names, kc) == lval && reportCollisions) {
|
||||
log_warn(info->keymap->ctx,
|
||||
"Multiple identical key name definitions; "
|
||||
"Later occurences of \"<%s> = %d\" ignored\n", buf, kc);
|
||||
"Later occurences of \"%s = %d\" ignored\n", lname, kc);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -415,37 +414,40 @@ AddKeyName(KeyNamesInfo * info,
|
|||
if (reportCollisions)
|
||||
log_warn(info->keymap->ctx,
|
||||
"Multiple names for keycode %d; "
|
||||
"Using <%s>, ignoring <%s>\n", kc, buf, name);
|
||||
"Using %s, ignoring %s\n", kc, lname, kname);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (reportCollisions)
|
||||
log_warn(info->keymap->ctx,
|
||||
"Multiple names for keycode %d; "
|
||||
"Using <%s>, ignoring <%s>\n", kc, name, buf);
|
||||
"Using %s, ignoring %s\n", kc, kname, lname);
|
||||
darray_item(info->names, kc) = 0;
|
||||
darray_item(info->files, kc) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
old = FindKeyByLong(info, lval);
|
||||
if ((old != 0) && (old != kc)) {
|
||||
if (old != 0 && old != kc) {
|
||||
const char *kname = KeyNameText(name);
|
||||
|
||||
if (merge == MERGE_OVERRIDE) {
|
||||
darray_item(info->names, old) = 0;
|
||||
darray_item(info->files, old) = 0;
|
||||
if (reportCollisions)
|
||||
log_warn(info->keymap->ctx,
|
||||
"Key name <%s> assigned to multiple keys; "
|
||||
"Using %d, ignoring %d\n", name, kc, old);
|
||||
"Key name %s assigned to multiple keys; "
|
||||
"Using %d, ignoring %d\n", kname, kc, old);
|
||||
}
|
||||
else {
|
||||
if (reportCollisions && verbosity > 3)
|
||||
log_warn(info->keymap->ctx,
|
||||
"Key name <%s> assigned to multiple keys; "
|
||||
"Using %d, ignoring %d\n", name, old, kc);
|
||||
"Key name %s assigned to multiple keys; "
|
||||
"Using %d, ignoring %d\n", kname, old, kc);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
darray_item(info->names, kc) = lval;
|
||||
darray_item(info->files, kc) = file_id;
|
||||
return true;
|
||||
|
@ -476,8 +478,8 @@ MergeAliases(KeyNamesInfo *into, KeyNamesInfo *from, enum merge_mode merge)
|
|||
|
||||
list_foreach_safe(alias, next, &from->aliases, entry) {
|
||||
def.merge = (merge == MERGE_DEFAULT) ? alias->merge : merge;
|
||||
memcpy(def.alias, alias->alias, XkbKeyNameLength);
|
||||
memcpy(def.real, alias->real, XkbKeyNameLength);
|
||||
strncpy(def.alias, alias->alias, XkbKeyNameLength);
|
||||
strncpy(def.real, alias->real, XkbKeyNameLength);
|
||||
|
||||
if (!HandleAliasDef(into, &def, def.merge, alias->file_id))
|
||||
return false;
|
||||
|
@ -491,7 +493,7 @@ MergeIncludedKeycodes(KeyNamesInfo *into, KeyNamesInfo *from,
|
|||
enum merge_mode merge)
|
||||
{
|
||||
uint64_t i;
|
||||
char buf[5];
|
||||
char buf[XkbKeyNameLength];
|
||||
IndicatorNameInfo *led;
|
||||
|
||||
if (from->errorCount > 0) {
|
||||
|
@ -509,7 +511,6 @@ MergeIncludedKeycodes(KeyNamesInfo *into, KeyNamesInfo *from,
|
|||
if (darray_item(from->names, i) == 0)
|
||||
continue;
|
||||
LongToKeyName(darray_item(from->names, i), buf);
|
||||
buf[4] = '\0';
|
||||
if (!AddKeyName(into, i, buf, merge, from->file_id, false))
|
||||
into->errorCount++;
|
||||
}
|
||||
|
@ -599,9 +600,9 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge)
|
|||
if ((info->explicitMin != 0 && stmt->value < info->explicitMin) ||
|
||||
(info->explicitMax != 0 && stmt->value > info->explicitMax)) {
|
||||
log_err(info->keymap->ctx,
|
||||
"Illegal keycode %lu for name <%s>; "
|
||||
"Illegal keycode %lu for name %s; "
|
||||
"Must be in the range %d-%d inclusive\n",
|
||||
stmt->value, stmt->name, info->explicitMin,
|
||||
stmt->value, KeyNameText(stmt->name), info->explicitMin,
|
||||
info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
|
||||
return 0;
|
||||
}
|
||||
|
@ -647,7 +648,7 @@ HandleAliasCollision(KeyNamesInfo *info, AliasInfo *old, AliasInfo *new)
|
|||
KeyNameText(ignore));
|
||||
|
||||
if (use != old->real)
|
||||
memcpy(old->real, use, XkbKeyNameLength);
|
||||
strncpy(old->real, use, XkbKeyNameLength);
|
||||
}
|
||||
|
||||
old->file_id = new->file_id;
|
||||
|
@ -677,8 +678,8 @@ HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge,
|
|||
|
||||
alias->file_id = file_id;
|
||||
alias->merge = merge;
|
||||
memcpy(alias->alias, def->alias, XkbKeyNameLength);
|
||||
memcpy(alias->real, def->real, XkbKeyNameLength);
|
||||
strncpy(alias->alias, def->alias, XkbKeyNameLength);
|
||||
strncpy(alias->real, def->real, XkbKeyNameLength);
|
||||
list_append(&alias->entry, &info->aliases);
|
||||
|
||||
return true;
|
||||
|
@ -929,7 +930,7 @@ ApplyAliases(KeyNamesInfo *info)
|
|||
|
||||
InitAliasInfo(&old_alias, MERGE_AUGMENT, 0, a->alias, a->real);
|
||||
HandleAliasCollision(info, &old_alias, alias);
|
||||
memcpy(old_alias.real, a->real, XkbKeyNameLength);
|
||||
strncpy(old_alias.real, a->real, XkbKeyNameLength);
|
||||
alias->alias[0] = '\0';
|
||||
nNew--;
|
||||
break;
|
||||
|
|
|
@ -144,9 +144,7 @@ FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
|
|||
/* Find first unused key and store our key here */
|
||||
xkb_foreach_key(key, keymap) {
|
||||
if (key->name[0] == '\0') {
|
||||
char buf[XkbKeyNameLength + 1];
|
||||
LongToKeyName(name, buf);
|
||||
memcpy(key->name, buf, XkbKeyNameLength);
|
||||
LongToKeyName(name, key->name);
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
@ -159,11 +157,10 @@ bool
|
|||
FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,
|
||||
unsigned long *real_name)
|
||||
{
|
||||
char name[XkbKeyNameLength + 1];
|
||||
char name[XkbKeyNameLength];
|
||||
struct xkb_key_alias *a;
|
||||
|
||||
LongToKeyName(lname, name);
|
||||
name[XkbKeyNameLength] = '\0';
|
||||
darray_foreach(a, keymap->key_aliases) {
|
||||
if (strncmp(name, a->alias, XkbKeyNameLength) == 0) {
|
||||
*real_name = KeyNameToLong(a->real);
|
||||
|
|
|
@ -681,7 +681,7 @@ Terminal : String
|
|||
{
|
||||
ExprDef *expr;
|
||||
expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_KEYNAME);
|
||||
strncpy(expr->value.keyName, $1, 4);
|
||||
strncpy(expr->value.keyName, $1, XkbKeyNameLength);
|
||||
$$ = expr;
|
||||
}
|
||||
;
|
||||
|
|
|
@ -117,7 +117,6 @@ KeycodeCreate(char keyName[XkbKeyNameLength], unsigned long value)
|
|||
def->common.type = STMT_KEYCODE;
|
||||
def->common.next = NULL;
|
||||
strncpy(def->name, keyName, XkbKeyNameLength);
|
||||
def->name[XkbKeyNameLength] = '\0';
|
||||
def->value = value;
|
||||
return def;
|
||||
}
|
||||
|
@ -132,9 +131,7 @@ KeyAliasCreate(char alias[XkbKeyNameLength], char real[XkbKeyNameLength])
|
|||
def->common.type = STMT_ALIAS;
|
||||
def->common.next = NULL;
|
||||
strncpy(def->alias, alias, XkbKeyNameLength);
|
||||
def->alias[XkbKeyNameLength] = '\0';
|
||||
strncpy(def->real, real, XkbKeyNameLength);
|
||||
def->real[XkbKeyNameLength] = '\0';
|
||||
return def;
|
||||
}
|
||||
|
||||
|
|
|
@ -52,15 +52,6 @@ enum key_field {
|
|||
KEY_FIELD_VMODMAP = (1 << 7),
|
||||
};
|
||||
|
||||
static inline const char *
|
||||
longText(unsigned long val)
|
||||
{
|
||||
char buf[4];
|
||||
|
||||
LongToKeyName(val, buf);
|
||||
return KeyNameText(buf);
|
||||
}
|
||||
|
||||
typedef struct _KeyInfo {
|
||||
enum key_field defined;
|
||||
unsigned file_id;
|
||||
|
@ -355,7 +346,7 @@ MergeKeyGroups(SymbolsInfo * info,
|
|||
log_warn(info->keymap->ctx,
|
||||
"Multiple actions for level %d/group %u on key %s; "
|
||||
"Using %s, ignoring %s\n",
|
||||
i + 1, group + 1, longText(into->name),
|
||||
i + 1, group + 1, LongKeyNameText(into->name),
|
||||
ActionTypeText(use->type),
|
||||
ActionTypeText(ignore->type));
|
||||
if (use)
|
||||
|
@ -438,7 +429,7 @@ MergeKeyGroups(SymbolsInfo * info,
|
|||
log_info(info->keymap->ctx,
|
||||
"Multiple symbols for group %u, level %d on key %s; "
|
||||
"Using %s, ignoring %s\n",
|
||||
group + 1, i + 1, longText(into->name),
|
||||
group + 1, i + 1, LongKeyNameText(into->name),
|
||||
(use == FROM ? "from" : "to"),
|
||||
(use == FROM ? "to" : "from"));
|
||||
}
|
||||
|
@ -578,7 +569,7 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
|
|||
log_warn(info->keymap->ctx,
|
||||
"Multiple definitions for group %d type of key %s; "
|
||||
"Using %s, ignoring %s\n",
|
||||
i, longText(into->name),
|
||||
i, LongKeyNameText(into->name),
|
||||
xkb_atom_text(info->keymap->ctx, use),
|
||||
xkb_atom_text(info->keymap->ctx, ignore));
|
||||
}
|
||||
|
@ -616,7 +607,7 @@ MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
|
|||
log_warn(info->keymap->ctx,
|
||||
"Symbol map for key %s redefined; "
|
||||
"Using %s definition for conflicting fields\n",
|
||||
longText(into->name),
|
||||
LongKeyNameText(into->name),
|
||||
(from->merge == MERGE_AUGMENT ? "first" : "last"));
|
||||
|
||||
return true;
|
||||
|
@ -686,7 +677,7 @@ AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
|
|||
log_err(info->keymap->ctx,
|
||||
"Key %s added to map for multiple modifiers; "
|
||||
"Using %s, ignoring %s.\n",
|
||||
longText(new->u.keyName), ModIndexText(use),
|
||||
LongKeyNameText(new->u.keyName), ModIndexText(use),
|
||||
ModIndexText(ignore));
|
||||
mm->modifier = use;
|
||||
}
|
||||
|
@ -830,7 +821,7 @@ GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
|
|||
log_err(info->keymap->ctx,
|
||||
"Too many groups of %s for key %s (max %u); "
|
||||
"Ignoring %s defined for extra groups\n",
|
||||
name, longText(keyi->name), XkbNumKbdGroups + 1, name);
|
||||
name, LongKeyNameText(keyi->name), XkbNumKbdGroups + 1, name);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -838,7 +829,7 @@ GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
|
|||
log_err(info->keymap->ctx,
|
||||
"Illegal group index for %s of key %s\n"
|
||||
"Definition with non-integer array index ignored\n",
|
||||
name, longText(keyi->name));
|
||||
name, LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -866,14 +857,14 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
|
|||
log_err(info->keymap->ctx,
|
||||
"Expected a list of symbols, found %s; "
|
||||
"Ignoring symbols for group %u of %s\n",
|
||||
exprOpText(value->op), ndx + 1, longText(keyi->name));
|
||||
exprOpText(value->op), ndx + 1, LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
if (!darray_empty(keyi->syms[ndx])) {
|
||||
log_err(info->keymap->ctx,
|
||||
"Symbols for key %s, group %u already defined; "
|
||||
"Ignoring duplicate definition\n",
|
||||
longText(keyi->name), ndx + 1);
|
||||
LongKeyNameText(keyi->name), ndx + 1);
|
||||
return false;
|
||||
}
|
||||
nSyms = darray_size(value->value.list.syms);
|
||||
|
@ -883,7 +874,7 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
|
|||
log_wsgo(info->keymap->ctx,
|
||||
"Could not resize group %u of key %s to contain %zu levels; "
|
||||
"Symbols lost\n",
|
||||
ndx + 1, longText(keyi->name), nSyms);
|
||||
ndx + 1, LongKeyNameText(keyi->name), nSyms);
|
||||
return false;
|
||||
}
|
||||
keyi->symsDefined |= (1 << ndx);
|
||||
|
@ -906,7 +897,7 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
|
|||
log_warn(info->keymap->ctx,
|
||||
"Could not resolve keysym %s for key %s, group %u (%s), level %zu\n",
|
||||
darray_item(value->value.list.syms, i),
|
||||
longText(keyi->name),
|
||||
LongKeyNameText(keyi->name),
|
||||
ndx + 1,
|
||||
xkb_atom_text(info->keymap->ctx,
|
||||
info->groupNames[ndx]),
|
||||
|
@ -956,14 +947,14 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
|
|||
log_wsgo(info->keymap->ctx,
|
||||
"Bad expression type (%d) for action list value; "
|
||||
"Ignoring actions for group %u of %s\n",
|
||||
value->op, ndx, longText(keyi->name));
|
||||
value->op, ndx, LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!darray_empty(keyi->acts[ndx])) {
|
||||
log_wsgo(info->keymap->ctx,
|
||||
"Actions for key %s, group %u already defined\n",
|
||||
longText(keyi->name), ndx);
|
||||
LongKeyNameText(keyi->name), ndx);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -982,7 +973,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
|
|||
log_wsgo(info->keymap->ctx,
|
||||
"Could not resize group %u of key %s; "
|
||||
"Actions lost\n",
|
||||
ndx, longText(keyi->name));
|
||||
ndx, LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
keyi->actsDefined |= (1 << ndx);
|
||||
|
@ -994,7 +985,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
|
|||
log_err(info->keymap->ctx,
|
||||
"Illegal action definition for %s; "
|
||||
"Action for group %u/level %zu ignored\n",
|
||||
longText(keyi->name), ndx + 1, i + 1);
|
||||
LongKeyNameText(keyi->name), ndx + 1, i + 1);
|
||||
}
|
||||
act = (ExprDef *) act->common.next;
|
||||
}
|
||||
|
@ -1048,7 +1039,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
|||
log_err(info->keymap->ctx,
|
||||
"Illegal group index for type of key %s; "
|
||||
"Definition with non-integer array index ignored\n",
|
||||
longText(keyi->name));
|
||||
LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
|
@ -1075,7 +1066,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
|||
log_err(info->keymap->ctx,
|
||||
"Expected a virtual modifier mask, found %s; "
|
||||
"Ignoring virtual modifiers definition for key %s\n",
|
||||
exprOpText(value->op), longText(keyi->name));
|
||||
exprOpText(value->op), LongKeyNameText(keyi->name));
|
||||
}
|
||||
}
|
||||
else if (istreq(field, "locking") ||
|
||||
|
@ -1094,7 +1085,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
|||
log_err(info->keymap->ctx,
|
||||
"Radio groups not supported; "
|
||||
"Ignoring radio group specification for key %s\n",
|
||||
longText(keyi->name));
|
||||
LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
else if (istreq_prefix("overlay", field) ||
|
||||
|
@ -1102,7 +1093,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
|||
log_err(info->keymap->ctx,
|
||||
"Overlays not supported; "
|
||||
"Ignoring overlay specification for key %s\n",
|
||||
longText(keyi->name));
|
||||
LongKeyNameText(keyi->name));
|
||||
}
|
||||
else if (istreq(field, "repeating") ||
|
||||
istreq(field, "repeats") ||
|
||||
|
@ -1114,7 +1105,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
|||
log_err(info->keymap->ctx,
|
||||
"Illegal repeat setting for %s; "
|
||||
"Non-boolean repeat setting ignored\n",
|
||||
longText(keyi->name));
|
||||
LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
keyi->repeat = val;
|
||||
|
@ -1128,7 +1119,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
|||
log_err(info->keymap->ctx,
|
||||
"Illegal groupsWrap setting for %s; "
|
||||
"Non-boolean value ignored\n",
|
||||
longText(keyi->name));
|
||||
LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1147,7 +1138,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
|||
log_err(info->keymap->ctx,
|
||||
"Illegal groupsClamp setting for %s; "
|
||||
"Non-boolean value ignored\n",
|
||||
longText(keyi->name));
|
||||
LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1166,7 +1157,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
|
|||
log_err(info->keymap->ctx,
|
||||
"Illegal group index for redirect of key %s; "
|
||||
"Definition with non-integer group ignored\n",
|
||||
longText(keyi->name));
|
||||
LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1310,12 +1301,10 @@ SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
|
|||
if ((keyi->typesDefined | keyi->symsDefined | keyi->actsDefined) & ~1) {
|
||||
xkb_group_index_t i;
|
||||
log_warn(info->keymap->ctx,
|
||||
"For the map %s an explicit group specified\n",
|
||||
info->name);
|
||||
log_warn(info->keymap->ctx,
|
||||
"For the map %s an explicit group specified, "
|
||||
"but key %s has more than one group defined; "
|
||||
"All groups except first one will be ignored\n",
|
||||
longText(keyi->name));
|
||||
info->name, LongKeyNameText(keyi->name));
|
||||
for (i = 1; i < XkbNumKbdGroups; i++) {
|
||||
keyi->numLevels[i] = 0;
|
||||
darray_free(keyi->syms[i]);
|
||||
|
@ -1738,7 +1727,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
|
|||
if (start_from == 0)
|
||||
log_lvl(info->keymap->ctx, 5,
|
||||
"Key %s not found in keycodes; Symbols ignored\n",
|
||||
longText(keyi->name));
|
||||
LongKeyNameText(keyi->name));
|
||||
return false;
|
||||
}
|
||||
kc = XkbKeyGetKeycode(keymap, key);
|
||||
|
@ -1766,7 +1755,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
|
|||
"Using %s for the %s key (keycode %d)\n",
|
||||
keyi->numLevels[i],
|
||||
xkb_atom_text(keymap->ctx, keyi->types[i]),
|
||||
longText(keyi->name), kc);
|
||||
LongKeyNameText(keyi->name), kc);
|
||||
}
|
||||
if (FindNamedType(keymap, keyi->types[i], &types[i])) {
|
||||
if (!autoType || keyi->numLevels[i] > 2)
|
||||
|
@ -1777,7 +1766,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
|
|||
"Type \"%s\" is not defined; "
|
||||
"Using TWO_LEVEL for the %s key (keycode %d)\n",
|
||||
xkb_atom_text(keymap->ctx, keyi->types[i]),
|
||||
longText(keyi->name), kc);
|
||||
LongKeyNameText(keyi->name), kc);
|
||||
types[i] = XkbTwoLevelIndex;
|
||||
}
|
||||
|
||||
|
@ -1788,7 +1777,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
|
|||
"Type \"%s\" has %d levels, but %s has %d symbols; "
|
||||
"Ignoring extra symbols\n",
|
||||
type->name, type->num_levels,
|
||||
longText(keyi->name),
|
||||
LongKeyNameText(keyi->name),
|
||||
keyi->numLevels[i]);
|
||||
keyi->numLevels[i] = type->num_levels;
|
||||
}
|
||||
|
@ -1806,7 +1795,7 @@ CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
|
|||
if (outActs == NULL) {
|
||||
log_wsgo(info->keymap->ctx,
|
||||
"Could not enlarge actions for %s (key %d)\n",
|
||||
longText(keyi->name), kc);
|
||||
LongKeyNameText(keyi->name), kc);
|
||||
return false;
|
||||
}
|
||||
key->explicit |= XkbExplicitInterpretMask;
|
||||
|
@ -1897,7 +1886,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry)
|
|||
log_lvl(info->keymap->ctx, 5,
|
||||
"Key %s not found in keycodes; "
|
||||
"Modifier map entry for %s not updated\n",
|
||||
longText(entry->u.keyName),
|
||||
LongKeyNameText(entry->u.keyName),
|
||||
ModIndexText(entry->modifier));
|
||||
return false;
|
||||
}
|
||||
|
@ -1974,8 +1963,9 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
|
|||
|
||||
if (key->num_groups < 1)
|
||||
log_warn(info.keymap->ctx,
|
||||
"No symbols defined for <%.4s> (keycode %d)\n",
|
||||
key->name, XkbKeyGetKeycode(keymap, key));
|
||||
"No symbols defined for %s (keycode %d)\n",
|
||||
KeyNameText(key->name),
|
||||
XkbKeyGetKeycode(keymap, key));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ const char *
|
|||
StmtTypeToString(enum stmt_type type);
|
||||
|
||||
static inline unsigned long
|
||||
KeyNameToLong(const char *name)
|
||||
KeyNameToLong(const char name[XkbKeyNameLength])
|
||||
{
|
||||
return
|
||||
(((unsigned long)name[0]) << 24) |
|
||||
|
@ -63,7 +63,7 @@ KeyNameToLong(const char *name)
|
|||
}
|
||||
|
||||
static inline void
|
||||
LongToKeyName(unsigned long val, char *name)
|
||||
LongToKeyName(unsigned long val, char name[XkbKeyNameLength])
|
||||
{
|
||||
name[0] = ((val >> 24) & 0xff);
|
||||
name[1] = ((val >> 16) & 0xff);
|
||||
|
@ -71,6 +71,14 @@ LongToKeyName(unsigned long val, char *name)
|
|||
name[3] = ((val >> 0) & 0xff);
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
LongKeyNameText(unsigned long val)
|
||||
{
|
||||
char buf[XkbKeyNameLength];
|
||||
LongToKeyName(val, buf);
|
||||
return KeyNameText(buf);
|
||||
}
|
||||
|
||||
static inline bool
|
||||
ReportNotArray(struct xkb_keymap *keymap, const char *type, const char *field,
|
||||
const char *name)
|
||||
|
|
|
@ -130,7 +130,7 @@ typedef struct _Expr {
|
|||
xkb_atom_t str;
|
||||
unsigned uval;
|
||||
int ival;
|
||||
char keyName[5];
|
||||
char keyName[XkbKeyNameLength];
|
||||
} value;
|
||||
} ExprDef;
|
||||
|
||||
|
@ -151,15 +151,15 @@ typedef struct _VModDef {
|
|||
typedef struct _KeycodeDef {
|
||||
ParseCommon common;
|
||||
enum merge_mode merge;
|
||||
char name[5];
|
||||
char name[XkbKeyNameLength];
|
||||
unsigned long value;
|
||||
} KeycodeDef;
|
||||
|
||||
typedef struct _KeyAliasDef {
|
||||
ParseCommon common;
|
||||
enum merge_mode merge;
|
||||
char alias[5];
|
||||
char real[5];
|
||||
char alias[XkbKeyNameLength];
|
||||
char real[XkbKeyNameLength];
|
||||
} KeyAliasDef;
|
||||
|
||||
typedef struct _KeyTypeDef {
|
||||
|
@ -172,7 +172,7 @@ typedef struct _KeyTypeDef {
|
|||
typedef struct _SymbolsDef {
|
||||
ParseCommon common;
|
||||
enum merge_mode merge;
|
||||
char keyName[5];
|
||||
char keyName[XkbKeyNameLength];
|
||||
ExprDef *symbols;
|
||||
} SymbolsDef;
|
||||
|
||||
|
|
Loading…
Reference in New Issue