symbols: cleanup SetSymbolsField Normalize the style and error message levels. 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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
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