expr: make ResolveLevel return zero-based level Signed-off-by: Ran Benita <ran234@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 8a79f00..d451f67 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -536,7 +536,8 @@ ExprResolveLevel(struct xkb_context *ctx, const ExprDef *expr,
return false;
}
- *level_rtrn = (unsigned int) result;
+ /* Level is zero-indexed from now on. */
+ *level_rtrn = (unsigned int) (result - 1);
return true;
}
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index aa7c365..0daa23e 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -532,7 +532,6 @@ static bool
SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
ExprDef *value)
{
- unsigned int level;
struct xkb_kt_map_entry entry;
xkb_mod_mask_t mask;
@@ -559,15 +558,13 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
entry.mods.vmods &= type->vmask;
}
- if (!ExprResolveLevel(info->keymap->ctx, value, &level)) {
+ if (!ExprResolveLevel(info->keymap->ctx, value, &entry.level)) {
log_err(info->keymap->ctx,
"Level specifications in a key type must be integer; "
"Ignoring malformed level specification\n");
return false;
}
- /* level is always >= 1 */
- entry.level = level - 1;
return AddMapEntry(info, type, &entry, true, true);
}
@@ -680,7 +677,6 @@ SetLevelName(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
if (!ExprResolveLevel(ctx, arrayNdx, &level))
return ReportTypeBadType(info, type, "level name", "integer");
- level--;
if (!ExprResolveString(ctx, value, &str)) {
log_err(info->keymap->ctx,