#include "keysym.h"
-// TODO: convert log_err to log_err_with_code
-// TODO: convert log_vrb to log_vrb_with_code
-
enum key_repeat {
KEY_REPEAT_UNDEFINED = 0,
KEY_REPEAT_YES = 1,
xkb_atom_t ignore = (clobber ? into->type : from->type);
if (report) {
- log_warn_with_code(info->ctx,
- XKB_WARNING_CONFLICTING_KEY_TYPE,
+ log_warn(info->ctx,
+ XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS,
"Multiple definitions for group %d type of key %s; "
"Using %s, ignoring %s\n",
group + 1, KeyNameText(info->ctx, key_name),
ignore = (clobber ? &intoLevel->action : &fromLevel->action);
if (report) {
- log_warn_with_code(info->ctx,
+ log_warn(info->ctx,
XKB_WARNING_CONFLICTING_KEY_ACTION,
"Multiple actions for level %d/group %u on key %s; "
"Using %s, ignoring %s\n",
}
else if (!XkbLevelsSameSyms(fromLevel, intoLevel)) {
if (report) {
- log_warn_with_code(info->ctx,
+ log_warn(info->ctx,
XKB_WARNING_CONFLICTING_KEY_SYMBOL,
"Multiple symbols for level %d/group %u on key %s; "
"Using %s, ignoring %s\n",
}
if (collide) {
- log_warn_with_code(info->ctx,
+ log_warn(info->ctx,
XKB_WARNING_CONFLICTING_KEY_FIELDS,
"Symbol map for key %s redefined; "
"Using %s definition for conflicting fields\n",
ignore = (clobber ? old->modifier : new->modifier);
if (new->haveSymbol) {
- log_warn_with_code(info->ctx,
+ log_warn(info->ctx,
XKB_WARNING_CONFLICTING_MODMAP,
"Symbol \"%s\" added to modifier map for multiple modifiers; "
"Using %s, ignoring %s\n",
ModIndexText(info->ctx, &info->mods, use),
ModIndexText(info->ctx, &info->mods, ignore));
} else {
- log_warn_with_code(info->ctx,
+ log_warn(info->ctx,
XKB_WARNING_CONFLICTING_MODMAP,
"Key \"%s\" added to modifier map for multiple modifiers; "
"Using %s, ignoring %s\n",
{
SymbolsInfo included;
+ if (!include)
+ return false;
+
InitSymbolsInfo(&included, info->keymap, info->actions, &info->mods);
included.name = include->stmt;
include->stmt = NULL;
next_incl.explicit_group = atoi(stmt->modifier) - 1;
if (next_incl.explicit_group >= XKB_MAX_GROUPS) {
log_err(info->ctx,
+ XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
"Cannot set explicit group to %d - must be between 1..%d; "
"Ignoring group number\n",
next_incl.explicit_group + 1, XKB_MAX_GROUPS);
if (i >= XKB_MAX_GROUPS) {
log_err(info->ctx,
+ XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
"Too many groups of %s for key %s (max %u); "
"Ignoring %s defined for extra groups\n",
name, KeyInfoText(info, keyi), XKB_MAX_GROUPS, name);
}
if (!ExprResolveGroup(info->ctx, arrayNdx, ndx_rtrn)) {
- log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
+ log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
"Illegal group index for %s of key %s\n"
"Definition with non-integer array index ignored\n",
name, KeyInfoText(info, keyi));
if (value->expr.op != EXPR_KEYSYM_LIST) {
log_err(info->ctx,
+ XKB_ERROR_WRONG_FIELD_TYPE,
"Expected a list of symbols, found %s; "
"Ignoring symbols for group %u of %s\n",
expr_op_type_to_string(value->expr.op), ndx + 1,
if (groupi->defined & GROUP_FIELD_SYMS) {
log_err(info->ctx,
+ XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY,
"Symbols for key %s, group %u already defined; "
"Ignoring duplicate definition\n",
KeyInfoText(info, keyi), ndx + 1);
sym_index = darray_item(value->keysym_list.symsMapIndex, i);
leveli->num_syms = darray_item(value->keysym_list.symsNumEntries, i);
- if (leveli->num_syms > 1)
+ if (leveli->num_syms > 1) {
leveli->u.syms = calloc(leveli->num_syms, sizeof(*leveli->u.syms));
+ if (!leveli->u.syms) {
+ log_err(info->ctx, "Failed to allocate memory for leveli->u.syms\n");
+ continue;
+ }
+ }
for (unsigned j = 0; j < leveli->num_syms; j++) {
xkb_keysym_t keysym = darray_item(value->keysym_list.syms,
}
if (value->expr.op != EXPR_ACTION_LIST) {
- log_wsgo(info->ctx,
+ log_wsgo(info->ctx, XKB_LOG_MESSAGE_NO_ID,
"Bad expression type (%d) for action list value; "
"Ignoring actions for group %u of %s\n",
value->expr.op, ndx, KeyInfoText(info, keyi));
}
if (groupi->defined & GROUP_FIELD_ACTS) {
- log_wsgo(info->ctx,
+ log_wsgo(info->ctx, XKB_LOG_MESSAGE_NO_ID,
"Actions for key %s, group %u already defined\n",
KeyInfoText(info, keyi), ndx);
return false;
if (!HandleActionDef(info->ctx, info->actions, &info->mods, act, toAct))
log_err(info->ctx,
+ XKB_ERROR_INVALID_VALUE,
"Illegal action definition for %s; "
"Action for group %u/level %u ignored\n",
KeyInfoText(info, keyi), ndx + 1, i + 1);
if (!ExprResolveString(info->ctx, value, &val)) {
log_err(info->ctx,
+ XKB_ERROR_WRONG_FIELD_TYPE,
"The type field of a key symbol map must be a string; "
"Ignoring illegal type definition\n");
return false;
keyi->defined |= KEY_FIELD_DEFAULT_TYPE;
}
else if (!ExprResolveGroup(info->ctx, arrayNdx, &ndx)) {
- log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
+ log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
"Illegal group index for type of key %s; "
"Definition with non-integer array index ignored\n",
KeyInfoText(info, keyi));
if (!ExprResolveModMask(info->ctx, value, MOD_VIRT, &info->mods,
&mask)) {
log_err(info->ctx,
+ XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
"Expected a virtual modifier mask, found %s; "
"Ignoring virtual modifiers definition for key %s\n",
expr_op_type_to_string(value->expr.op),
istreq(field, "lock") ||
istreq(field, "locks")) {
log_vrb(info->ctx, 1,
+ XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
"Key behaviors not supported; "
"Ignoring locking specification for key %s\n",
KeyInfoText(info, keyi));
istreq(field, "permanentradiogroup") ||
istreq(field, "allownone")) {
log_vrb(info->ctx, 1,
+ XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
"Radio groups not supported; "
"Ignoring radio group specification for key %s\n",
KeyInfoText(info, keyi));
else if (istreq_prefix("overlay", field) ||
istreq_prefix("permanentoverlay", field)) {
log_vrb(info->ctx, 1,
+ XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
"Overlays not supported; "
"Ignoring overlay specification for key %s\n",
KeyInfoText(info, keyi));
if (!ExprResolveEnum(info->ctx, value, &val, repeatEntries)) {
log_err(info->ctx,
+ XKB_ERROR_INVALID_VALUE,
"Illegal repeat setting for %s; "
"Non-boolean repeat setting ignored\n",
KeyInfoText(info, keyi));
if (!ExprResolveBoolean(info->ctx, value, &set)) {
log_err(info->ctx,
+ XKB_ERROR_INVALID_VALUE,
"Illegal groupsWrap setting for %s; "
"Non-boolean value ignored\n",
KeyInfoText(info, keyi));
if (!ExprResolveBoolean(info->ctx, value, &set)) {
log_err(info->ctx,
+ XKB_ERROR_INVALID_VALUE,
"Illegal groupsClamp setting for %s; "
"Non-boolean value ignored\n",
KeyInfoText(info, keyi));
xkb_layout_index_t grp;
if (!ExprResolveGroup(info->ctx, value, &grp)) {
- log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
+ log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
"Illegal group index for redirect of key %s; "
"Definition with non-integer group ignored\n",
KeyInfoText(info, keyi));
}
else {
log_err(info->ctx,
+ XKB_ERROR_UNKNOWN_FIELD,
"Unknown field %s in a symbol interpretation; "
"Definition ignored\n",
field);
if (!arrayNdx) {
log_vrb(info->ctx, 1,
+ XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX,
"You must specify an index when specifying a group name; "
"Group name definition without array subscript ignored\n");
return false;
}
if (!ExprResolveGroup(info->ctx, arrayNdx, &group)) {
- log_err_with_code(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
+ log_err(info->ctx, XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
"Illegal index in group name definition; "
"Definition with non-integer array index ignored\n");
return false;
if (!ExprResolveString(info->ctx, value, &name)) {
log_err(info->ctx,
+ XKB_ERROR_WRONG_FIELD_TYPE,
"Group name must be a string; "
"Illegal name for group %d ignored\n", group);
return false;
group_to_use = info->explicit_group;
}
else {
- log_warn_with_code(info->ctx,
+ log_warn(info->ctx,
XKB_WARNING_NON_BASE_GROUP_NAME,
"An explicit group was specified for the '%s' map, "
"but it provides a name for a group other than Group1 (%d); "
else if (!elem && (istreq(field, "groupswrap") ||
istreq(field, "wrapgroups"))) {
log_err(info->ctx,
+ XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
"Global \"groupswrap\" not supported; Ignored\n");
ret = true;
}
else if (!elem && (istreq(field, "groupsclamp") ||
istreq(field, "clampgroups"))) {
log_err(info->ctx,
+ XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
"Global \"groupsclamp\" not supported; Ignored\n");
ret = true;
}
else if (!elem && (istreq(field, "groupsredirect") ||
istreq(field, "redirectgroups"))) {
log_err(info->ctx,
+ XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
"Global \"groupsredirect\" not supported; Ignored\n");
ret = true;
}
else if (!elem && istreq(field, "allownone")) {
log_err(info->ctx,
+ XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
"Radio groups not supported; "
"Ignoring \"allownone\" specification\n");
ret = true;
for (; def; def = (VarDef *) def->common.next) {
if (def->name && def->name->expr.op == EXPR_FIELD_REF) {
log_err(info->ctx,
+ XKB_ERROR_WRONG_SCOPE,
"Cannot set a global default value from within a key statement; "
"Move statements to the global file scope\n");
continue;
}
if (warn) {
- log_warn_with_code(info->ctx,
+ log_warn(info->ctx,
XKB_WARNING_MULTIPLE_GROUPS_AT_ONCE,
"For the map %s an explicit group specified, "
"but key %s has more than one group defined; "
ndx = XkbModNameToIndex(&info->mods, def->modifier, MOD_REAL);
if (ndx == XKB_MOD_INVALID) {
log_err(info->ctx,
+ XKB_ERROR_INVALID_REAL_MODIFIER,
"Illegal modifier map definition; "
"Ignoring map for non-modifier \"%s\"\n",
xkb_atom_text(ctx, def->modifier));
}
else {
log_err(info->ctx,
+ XKB_ERROR_INVALID_MODMAP_ENTRY,
"Modmap entries may contain only key names or keysyms; "
"Illegal definition for %s modifier ignored\n",
ModIndexText(info->ctx, &info->mods, tmp.modifier));
break;
default:
log_err(info->ctx,
+ XKB_ERROR_WRONG_STATEMENT_TYPE,
"Symbols files may not include other types; "
"Ignoring %s\n", stmt_type_to_string(stmt->type));
ok = false;
info->errorCount++;
if (info->errorCount > 10) {
- log_err(info->ctx, "Abandoning symbols file \"%s\"\n",
+ log_err(info->ctx,
+ XKB_ERROR_INVALID_SYNTAX,
+ "Abandoning symbols file \"%s\"\n",
file->name);
break;
}
}
if (type_name == XKB_ATOM_NONE) {
- log_warn_with_code(keymap->ctx,
+ log_warn(keymap->ctx,
XKB_WARNING_CANNOT_INFER_KEY_TYPE,
"Couldn't find an automatic type for key '%s' group %d with %lu levels; "
"Using the default type\n",
break;
if (i >= keymap->num_types) {
- log_warn_with_code(keymap->ctx,
+ log_warn(keymap->ctx,
XKB_WARNING_UNDEFINED_KEY_TYPE,
"The type \"%s\" for key '%s' group %d was not previously defined; "
"Using the default type\n",
*/
key = XkbKeyByName(keymap, keyi->name, false);
if (!key) {
- log_vrb_with_code(info->ctx, 5,
+ log_vrb(info->ctx, 5,
XKB_WARNING_UNDEFINED_KEYCODE,
"Key %s not found in keycodes; Symbols ignored\n",
KeyInfoText(info, keyi));
}
key->groups = calloc(key->num_groups, sizeof(*key->groups));
+ if (!key->groups) {
+ log_err(info->ctx, "Failed to allocate memory for key->groups\n");
+ return false;
+ }
/* Find and assign the groups' types in the keymap. */
darray_enumerate(i, groupi, keyi->groups) {
if (type->num_levels < darray_size(groupi->levels)) {
struct xkb_level *leveli;
- log_vrb_with_code(info->ctx, 1,
+ log_vrb(info->ctx, 1,
XKB_WARNING_EXTRA_SYMBOLS_IGNORED,
"Type \"%s\" has %d levels, but %s has %d levels; "
"Ignoring extra symbols\n",
if (!entry->haveSymbol) {
key = XkbKeyByName(keymap, entry->u.keyName, true);
if (!key) {
- log_vrb_with_code(info->ctx, 5,
+ log_vrb(info->ctx, 5,
XKB_WARNING_UNDEFINED_KEYCODE,
"Key %s not found in keycodes; "
"Modifier map entry for %s not updated\n",
else {
key = FindKeyForSymbol(keymap, entry->u.keySym);
if (!key) {
- log_vrb_with_code(info->ctx, 5,
+ log_vrb(info->ctx, 5,
XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL,
"Key \"%s\" not found in symbol map; "
"Modifier map entry for %s not updated\n",
continue;
if (key->num_groups < 1)
- log_info(info->ctx,
+ log_info(info->ctx, XKB_LOG_MESSAGE_NO_ID,
"No symbols defined for %s\n",
KeyNameText(info->ctx, key->name));
}