From 6ec135700d53804f9c71346daaaa3bc47485b064 Mon Sep 17 00:00:00 2001 From: Ran Benita Date: Tue, 24 Jul 2012 00:51:19 +0300 Subject: [PATCH] expr: drop ExprResult from ResolveLevel Signed-off-by: Ran Benita --- src/xkbcomp/expr.c | 20 +++++++++++--------- src/xkbcomp/expr.h | 5 +++-- src/xkbcomp/keytypes.c | 11 ++++++----- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index 7731e4a..c1d79ee 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -528,11 +528,12 @@ ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr, return true; } -int +bool ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr, - ExprResult *val_rtrn) + unsigned int *level_rtrn) { - int ret; + bool ok; + ExprResult result; static const LookupEntry level_names[] = { { "level1", 1 }, { "level2", 2 }, @@ -545,17 +546,18 @@ ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr, { NULL, 0 } }; - ret = ExprResolveIntegerLookup(ctx, expr, val_rtrn, SimpleLookup, - level_names); - if (ret == false) - return ret; + ok = ExprResolveIntegerLookup(ctx, expr, &result, SimpleLookup, + level_names); + if (!ok) + return false; - if (val_rtrn->ival < 1 || val_rtrn->ival > XkbMaxShiftLevel) { + if (result.uval < 1 || result.uval > XkbMaxShiftLevel) { log_err(ctx, "Shift level %d is out of range (1..%d)\n", - val_rtrn->ival, XkbMaxShiftLevel); + result.uval, XkbMaxShiftLevel); return false; } + *level_rtrn = result.uval; return true; } diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h index 4712ca1..bf7891b 100644 --- a/src/xkbcomp/expr.h +++ b/src/xkbcomp/expr.h @@ -76,8 +76,9 @@ extern int ExprResolveInteger(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn); -extern int -ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn); +bool +ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr, + unsigned int *level_rtrn); bool ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr, diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c index d5c75c3..b8df802 100644 --- a/src/xkbcomp/keytypes.c +++ b/src/xkbcomp/keytypes.c @@ -532,6 +532,7 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, ExprDef *value) { ExprResult rtrn; + unsigned int level; struct xkb_kt_map_entry entry; if (arrayNdx == NULL) @@ -557,14 +558,15 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, entry.mods.vmods &= type->vmask; } - if (!ExprResolveLevel(info->keymap->ctx, value, &rtrn)) { + if (!ExprResolveLevel(info->keymap->ctx, value, &level)) { log_err(info->keymap->ctx, "Level specifications in a key type must be integer; " "Ignoring malformed level specification\n"); return false; } - entry.level = rtrn.ival - 1; + /* level is always >= 1 */ + entry.level = level - 1; return AddMapEntry(info, type, &entry, true, true); } @@ -667,7 +669,6 @@ static bool SetLevelName(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, ExprDef *value) { - ExprResult rtrn; unsigned level; xkb_atom_t level_name; struct xkb_context *ctx = info->keymap->ctx; @@ -676,9 +677,9 @@ SetLevelName(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx, if (arrayNdx == NULL) return ReportTypeShouldBeArray(info, type, "level name"); - if (!ExprResolveLevel(ctx, arrayNdx, &rtrn)) + if (!ExprResolveLevel(ctx, arrayNdx, &level)) return ReportTypeBadType(info, type, "level name", "integer"); - level = rtrn.ival - 1; + level--; if (!ExprResolveString(ctx, value, &str)) { log_err(info->keymap->ctx,