Commit 15541766b09dff7c26508f91d3ca88d254840af5

Ran Benita 2012-08-05T14:10:45

expr: make ResolveLevel return zero-based level Signed-off-by: Ran Benita <ran234@gmail.com>

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,