expr: make ResolveLevel return zero-based level

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-08-05 14:10:45 +03:00
parent 59d947c9c1
commit 15541766b0
2 changed files with 3 additions and 6 deletions

View File

@ -536,7 +536,8 @@ ExprResolveLevel(struct xkb_context *ctx, const ExprDef *expr,
return false; return false;
} }
*level_rtrn = (unsigned int) result; /* Level is zero-indexed from now on. */
*level_rtrn = (unsigned int) (result - 1);
return true; return true;
} }

View File

@ -532,7 +532,6 @@ static bool
SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
ExprDef *value) ExprDef *value)
{ {
unsigned int level;
struct xkb_kt_map_entry entry; struct xkb_kt_map_entry entry;
xkb_mod_mask_t mask; xkb_mod_mask_t mask;
@ -559,15 +558,13 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
entry.mods.vmods &= type->vmask; 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, log_err(info->keymap->ctx,
"Level specifications in a key type must be integer; " "Level specifications in a key type must be integer; "
"Ignoring malformed level specification\n"); "Ignoring malformed level specification\n");
return false; return false;
} }
/* level is always >= 1 */
entry.level = level - 1;
return AddMapEntry(info, type, &entry, true, true); return AddMapEntry(info, type, &entry, true, true);
} }
@ -680,7 +677,6 @@ SetLevelName(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
if (!ExprResolveLevel(ctx, arrayNdx, &level)) if (!ExprResolveLevel(ctx, arrayNdx, &level))
return ReportTypeBadType(info, type, "level name", "integer"); return ReportTypeBadType(info, type, "level name", "integer");
level--;
if (!ExprResolveString(ctx, value, &str)) { if (!ExprResolveString(ctx, value, &str)) {
log_err(info->keymap->ctx, log_err(info->keymap->ctx,