*
********************************************************/
+#include "config.h"
+
#include "xkbcomp-priv.h"
#include "text.h"
#include "vmod.h"
}
static inline bool
-ReportTypeBadType(KeyTypesInfo *info, KeyTypeInfo *type,
- const char *field, const char *wanted)
+ReportTypeBadType(KeyTypesInfo *info, xkb_message_code_t code,
+ KeyTypeInfo *type, const char *field, const char *wanted)
{
- return ReportBadType(info->ctx, "key type", field,
+ return ReportBadType(info->ctx, code, "key type", field,
TypeTxt(info, type), wanted);
}
if (new->merge == MERGE_REPLACE || new->merge == MERGE_OVERRIDE) {
if ((same_file && verbosity > 0) || verbosity > 9) {
log_warn(info->ctx,
+ XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS,
"Multiple definitions of the %s key type; "
"Earlier definition ignored\n",
xkb_atom_text(info->ctx, new->name));
if (same_file)
log_vrb(info->ctx, 4,
+ XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS,
"Multiple definitions of the %s key type; "
"Later definition ignored\n",
xkb_atom_text(info->ctx, new->name));
{
KeyTypesInfo included;
+ if (!include)
+ return false;
+
InitKeyTypesInfo(&included, info->ctx, &info->mods);
included.name = include->stmt;
include->stmt = NULL;
xkb_mod_mask_t mods;
if (arrayNdx)
- log_warn(info->ctx,
+ log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID,
"The modifiers field of a key type is not an array; "
"Illegal array subscript ignored\n");
if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods, &mods)) {
log_err(info->ctx,
+ XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
"Key type mask field must be a modifier mask; "
"Key type definition ignored\n");
return false;
}
if (type->defined & TYPE_FIELD_MASK) {
- log_warn(info->ctx,
+ log_warn(info->ctx, XKB_LOG_MESSAGE_NO_ID,
"Multiple modifier mask definitions for key type %s; "
"Using %s, ignoring %s\n",
xkb_atom_text(info->ctx, type->name),
if (old) {
if (report && old->level != new->level) {
log_warn(info->ctx,
+ XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY,
"Multiple map entries for %s in %s; "
"Using %d, ignoring %d\n",
MapEntryTxt(info, new), TypeTxt(info, type),
}
else {
log_vrb(info->ctx, 10,
+ XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY,
"Multiple occurrences of map[%s]= %d in %s; Ignored\n",
MapEntryTxt(info, new), new->level + 1,
TypeTxt(info, type));
if (!ExprResolveModMask(info->ctx, arrayNdx, MOD_BOTH, &info->mods,
&entry.mods.mods))
- return ReportTypeBadType(info, type, "map entry", "modifier mask");
+ return ReportTypeBadType(info, XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
+ type, "map entry", "modifier mask");
if (entry.mods.mods & (~type->mods)) {
log_vrb(info->ctx, 1,
- "Map entry for unused modifiers in %s; "
+ XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE,
+ "Map entry for modifiers not used by type %s; "
"Using %s instead of %s\n",
TypeTxt(info, type),
ModMaskText(info->ctx, &info->mods,
}
if (!ExprResolveLevel(info->ctx, value, &entry.level)) {
- log_err(info->ctx,
- "Level specifications in a key type must be integer; "
- "Ignoring malformed level specification\n");
+ log_err(info->ctx, XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL,
+ "Level specifications in a key type must be integer; "
+ "Ignoring malformed level specification\n");
return false;
}
/* Map exists with same preserve; do nothing. */
if (entry->preserve.mods == preserve_mods) {
log_vrb(info->ctx, 10,
+ XKB_WARNING_DUPLICATE_ENTRY,
"Identical definitions for preserve[%s] in %s; "
"Ignored\n",
ModMaskText(info->ctx, &info->mods, mods),
/* Map exists with different preserve; latter wins. */
log_vrb(info->ctx, 1,
+ XKB_WARNING_CONFLICTING_KEY_TYPE_PRESERVE_ENTRIES,
"Multiple definitions for preserve[%s] in %s; "
"Using %s, ignoring %s\n",
ModMaskText(info->ctx, &info->mods, mods),
return ReportTypeShouldBeArray(info, type, "preserve entry");
if (!ExprResolveModMask(info->ctx, arrayNdx, MOD_BOTH, &info->mods, &mods))
- return ReportTypeBadType(info, type, "preserve entry",
- "modifier mask");
+ return ReportTypeBadType(info, XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
+ type, "preserve entry", "modifier mask");
if (mods & ~type->mods) {
const char *before, *after;
after = ModMaskText(info->ctx, &info->mods, mods);
log_vrb(info->ctx, 1,
- "Preserve for modifiers not used by the %s type; "
+ XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE,
+ "Preserve entry for modifiers not used by the %s type; "
"Index %s converted to %s\n",
TypeTxt(info, type), before, after);
}
if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods,
&preserve_mods)) {
log_err(info->ctx,
+ XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
"Preserve value in a key type is not a modifier mask; "
"Ignoring preserve[%s] in type %s\n",
ModMaskText(info->ctx, &info->mods, mods),
after = ModMaskText(info->ctx, &info->mods, preserve_mods);
log_vrb(info->ctx, 1,
+ XKB_WARNING_ILLEGAL_KEY_TYPE_PRESERVE_RESULT,
"Illegal value for preserve[%s] in type %s; "
"Converted %s to %s\n",
ModMaskText(info->ctx, &info->mods, mods),
/* Same level, same name. */
if (darray_item(type->level_names, level) == name) {
log_vrb(info->ctx, 10,
+ XKB_WARNING_DUPLICATE_ENTRY,
"Duplicate names for level %d of key type %s; Ignored\n",
level + 1, TypeTxt(info, type));
return true;
darray_item(type->level_names, level));
new = xkb_atom_text(info->ctx, name);
log_vrb(info->ctx, 1,
+ XKB_WARNING_CONFLICTING_KEY_TYPE_LEVEL_NAMES,
"Multiple names for level %d of key type %s; "
"Using %s, ignoring %s\n",
level + 1, TypeTxt(info, type),
return ReportTypeShouldBeArray(info, type, "level name");
if (!ExprResolveLevel(info->ctx, arrayNdx, &level))
- return ReportTypeBadType(info, type, "level name", "integer");
+ return ReportTypeBadType(info, XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL,
+ type, "level name", "integer");
if (!ExprResolveString(info->ctx, value, &level_name)) {
log_err(info->ctx,
+ XKB_ERROR_WRONG_FIELD_TYPE,
"Non-string name for level %d in key type %s; "
"Ignoring illegal level name definition\n",
level + 1, xkb_atom_text(info->ctx, type->name));
ok = SetLevelName(info, type, arrayNdx, value);
} else {
log_err(info->ctx,
+ XKB_ERROR_UNKNOWN_FIELD,
"Unknown field %s in key type %s; Definition ignored\n",
field, TypeTxt(info, type));
}
if (elem && istreq(elem, "type")) {
log_err(info->ctx,
+ XKB_ERROR_INVALID_SET_DEFAULT_STATEMENT,
"Support for changing the default type has been removed; "
"Statement ignored\n");
continue;
break;
case STMT_VAR:
log_err(info->ctx,
+ XKB_ERROR_WRONG_STATEMENT_TYPE,
"Support for changing the default type has been removed; "
"Statement ignored\n");
ok = true;
break;
default:
log_err(info->ctx,
+ XKB_ERROR_WRONG_STATEMENT_TYPE,
"Key type files may not include other declarations; "
"Ignoring %s\n", stmt_type_to_string(stmt->type));
ok = false;
if (info->errorCount > 10) {
log_err(info->ctx,
+ XKB_ERROR_INVALID_SYNTAX,
"Abandoning keytypes file \"%s\"\n", file->name);
break;
}
type->num_entries = 0;
type->name = xkb_atom_intern_literal(keymap->ctx, "default");
type->level_names = NULL;
+ type->num_level_names = 0;
}
else {
for (unsigned i = 0; i < num_types; i++) {
type->name = def->name;
type->mods.mods = def->mods;
type->num_levels = def->num_levels;
- darray_steal(def->level_names,
- &type->level_names, NULL);
- darray_steal(def->entries,
- &type->entries, &type->num_entries);
+ darray_steal(def->level_names, &type->level_names, &type->num_level_names);
+ darray_steal(def->entries, &type->entries, &type->num_entries);
}
}