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