summaryrefslogtreecommitdiff
path: root/src/xkbcomp
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2014-02-22 23:37:37 +0200
committerRan Benita <ran234@gmail.com>2014-02-22 23:45:52 +0200
commit09bcf0ffc0de321415fb52e62dd96caac5031c3c (patch)
tree4a91bdae9c63550a55d83526c7a323580aa4fc81 /src/xkbcomp
parent35dea49b0a1c2c5c832a612027c797f5c688aa13 (diff)
downloadlibxkbcommon-09bcf0ffc0de321415fb52e62dd96caac5031c3c.tar.gz
libxkbcommon-09bcf0ffc0de321415fb52e62dd96caac5031c3c.tar.bz2
libxkbcommon-09bcf0ffc0de321415fb52e62dd96caac5031c3c.zip
symbols: cleanup SetSymbolsField
Normalize the style and error message levels. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/xkbcomp')
-rw-r--r--src/xkbcomp/symbols.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 7ff8b71..f850feb 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -779,7 +779,6 @@ static bool
SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
ExprDef *arrayNdx, ExprDef *value)
{
- bool ok = true;
struct xkb_context *ctx = info->keymap->ctx;
if (istreq(field, "type")) {
@@ -793,7 +792,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
return false;
}
- if (arrayNdx == NULL) {
+ if (!arrayNdx) {
keyi->default_type = val;
keyi->defined |= KEY_FIELD_DEFAULT_TYPE;
}
@@ -812,32 +811,33 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
darray_item(keyi->groups, ndx).defined |= GROUP_FIELD_TYPE;
}
}
- else if (istreq(field, "symbols"))
+ else if (istreq(field, "symbols")) {
return AddSymbolsToKey(info, keyi, arrayNdx, value);
- else if (istreq(field, "actions"))
+ }
+ else if (istreq(field, "actions")) {
return AddActionsToKey(info, keyi, arrayNdx, value);
+ }
else if (istreq(field, "vmods") ||
istreq(field, "virtualmods") ||
istreq(field, "virtualmodifiers")) {
xkb_mod_mask_t mask;
- ok = ExprResolveModMask(info->keymap, value, MOD_VIRT, &mask);
- if (ok) {
- keyi->vmodmap = mask;
- keyi->defined |= KEY_FIELD_VMODMAP;
- }
- else {
- log_err(info->keymap->ctx,
+ if (!ExprResolveModMask(info->keymap, value, MOD_VIRT, &mask)) {
+ log_err(ctx,
"Expected a virtual modifier mask, found %s; "
"Ignoring virtual modifiers definition for key %s\n",
expr_op_type_to_string(value->expr.op),
KeyInfoText(info, keyi));
+ return false;
}
+
+ keyi->vmodmap = mask;
+ keyi->defined |= KEY_FIELD_VMODMAP;
}
else if (istreq(field, "locking") ||
istreq(field, "lock") ||
istreq(field, "locks")) {
- log_err(info->keymap->ctx,
+ log_vrb(ctx, 1,
"Key behaviors not supported; "
"Ignoring locking specification for key %s\n",
KeyInfoText(info, keyi));
@@ -845,14 +845,14 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
else if (istreq(field, "radiogroup") ||
istreq(field, "permanentradiogroup") ||
istreq(field, "allownone")) {
- log_err(info->keymap->ctx,
+ log_vrb(ctx, 1,
"Radio groups not supported; "
"Ignoring radio group specification for key %s\n",
KeyInfoText(info, keyi));
}
else if (istreq_prefix("overlay", field) ||
istreq_prefix("permanentoverlay", field)) {
- log_err(info->keymap->ctx,
+ log_vrb(ctx, 1,
"Overlays not supported; "
"Ignoring overlay specification for key %s\n",
KeyInfoText(info, keyi));
@@ -862,14 +862,14 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
istreq(field, "repeat")) {
unsigned int val;
- ok = ExprResolveEnum(ctx, value, &val, repeatEntries);
- if (!ok) {
- log_err(info->keymap->ctx,
+ if (!ExprResolveEnum(ctx, value, &val, repeatEntries)) {
+ log_err(ctx,
"Illegal repeat setting for %s; "
"Non-boolean repeat setting ignored\n",
KeyInfoText(info, keyi));
return false;
}
+
keyi->repeat = val;
keyi->defined |= KEY_FIELD_REPEAT;
}
@@ -878,18 +878,14 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
bool set;
if (!ExprResolveBoolean(ctx, value, &set)) {
- log_err(info->keymap->ctx,
+ log_err(ctx,
"Illegal groupsWrap setting for %s; "
"Non-boolean value ignored\n",
KeyInfoText(info, keyi));
return false;
}
- if (set)
- keyi->out_of_range_group_action = RANGE_WRAP;
- else
- keyi->out_of_range_group_action = RANGE_SATURATE;
-
+ keyi->out_of_range_group_action = (set ? RANGE_WRAP : RANGE_SATURATE);
keyi->defined |= KEY_FIELD_GROUPINFO;
}
else if (istreq(field, "groupsclamp") ||
@@ -897,18 +893,14 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
bool set;
if (!ExprResolveBoolean(ctx, value, &set)) {
- log_err(info->keymap->ctx,
+ log_err(ctx,
"Illegal groupsClamp setting for %s; "
"Non-boolean value ignored\n",
KeyInfoText(info, keyi));
return false;
}
- if (set)
- keyi->out_of_range_group_action = RANGE_SATURATE;
- else
- keyi->out_of_range_group_action = RANGE_WRAP;
-
+ keyi->out_of_range_group_action = (set ? RANGE_SATURATE : RANGE_WRAP);
keyi->defined |= KEY_FIELD_GROUPINFO;
}
else if (istreq(field, "groupsredirect") ||
@@ -916,7 +908,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
xkb_layout_index_t grp;
if (!ExprResolveGroup(ctx, value, &grp)) {
- log_err(info->keymap->ctx,
+ log_err(ctx,
"Illegal group index for redirect of key %s; "
"Definition with non-integer group ignored\n",
KeyInfoText(info, keyi));
@@ -928,14 +920,14 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
keyi->defined |= KEY_FIELD_GROUPINFO;
}
else {
- log_err(info->keymap->ctx,
+ log_err(ctx,
"Unknown field %s in a symbol interpretation; "
"Definition ignored\n",
field);
- ok = false;
+ return false;
}
- return ok;
+ return true;
}
static int