expr: drop ExprResult from ResolveButton 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 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index d73bc13..9c9c546 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -486,18 +486,23 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act = (struct xkb_pointer_button_action *) action;
if (field == F_Button) {
- if (array_ndx != NULL)
+ int btn;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveButton(keymap->ctx, value, &rtrn))
+
+ if (!ExprResolveButton(keymap->ctx, value, &btn))
return ReportMismatch(keymap, action->type, field,
"integer (range 1..5)");
- if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
+
+ if (btn < 0 || btn > 5) {
log_err(keymap->ctx,
"Button must specify default or be in the range 1..5; "
- "Illegal button value %d ignored\n", rtrn.ival);
+ "Illegal button value %d ignored\n", btn);
return false;
}
- act->button = rtrn.ival;
+
+ act->button = btn;
return true;
}
else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) {
@@ -511,17 +516,23 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
return true;
}
else if (field == F_Count) {
- if (array_ndx != NULL)
+ int btn;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveButton(keymap->ctx, value, &rtrn))
+
+ /* XXX: Should this actually be ResolveButton? */
+ if (!ExprResolveButton(keymap->ctx, value, &btn))
return ReportMismatch(keymap, action->type, field, "integer");
- if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
+
+ if (btn < 0 || btn > 255) {
log_err(keymap->ctx,
"The count field must have a value in the range 0..255; "
"Illegal count %d ignored\n", rtrn.ival);
return false;
}
- act->count = rtrn.ival;
+
+ act->count = btn;
return true;
}
return ReportIllegal(keymap, action->type, field);
@@ -552,37 +563,42 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
return true;
}
else if ((field == F_Button) || (field == F_Value)) {
- ExprDef *btn;
- if (array_ndx != NULL)
+ ExprDef *button;
+ int btn;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
+
if (value->op == EXPR_NEGATE || value->op == EXPR_UNARY_PLUS) {
act->flags &= ~XkbSA_DfltBtnAbsolute;
- btn = value->value.child;
+ button = value->value.child;
}
else {
act->flags |= XkbSA_DfltBtnAbsolute;
- btn = value;
+ button = value;
}
- if (!ExprResolveButton(keymap->ctx, btn, &rtrn))
+ if (!ExprResolveButton(keymap->ctx, button, &btn))
return ReportMismatch(keymap, action->type, field,
"integer (range 1..5)");
- if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
+
+ if (btn < 0 || btn > 5) {
log_err(keymap->ctx,
"New default button value must be in the range 1..5; "
"Illegal default button value %d ignored\n", rtrn.ival);
return false;
}
- if (rtrn.ival == 0) {
+ if (btn == 0) {
log_err(keymap->ctx,
"Cannot set default pointer button to \"default\"; "
"Illegal default button setting ignored\n");
return false;
}
- act->value = (value->op == EXPR_NEGATE ? -rtrn.ival : rtrn.ival);
+ act->value = (value->op == EXPR_NEGATE ? -btn: btn);
return true;
}
+
return ReportIllegal(keymap, action->type, field);
}
@@ -924,17 +940,23 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
return true;
}
else if (field == F_Count) {
- if (array_ndx != NULL)
+ int btn;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveButton(keymap->ctx, value, &rtrn))
+
+ /* XXX: Should this actually be ResolveButton? */
+ if (!ExprResolveButton(keymap->ctx, value, &btn))
return ReportMismatch(keymap, action->type, field, "integer");
- if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
+
+ if (btn < 0 || btn > 255) {
log_err(keymap->ctx,
"The count field must have a value in the range 0..255; "
"Illegal count %d ignored\n", rtrn.ival);
return false;
}
- act->count = rtrn.ival;
+
+ act->count = btn;
return true;
}
else if (field == F_Device) {
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index c1d79ee..0d67c2d 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -561,10 +561,11 @@ ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr,
return true;
}
-int
-ExprResolveButton(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn)
+bool
+ExprResolveButton(struct xkb_context *ctx, ExprDef *expr, int *btn_rtrn)
{
+ bool ok;
+ ExprResult result;
static const LookupEntry button_names[] = {
{ "button1", 1 },
{ "button2", 2 },
@@ -575,8 +576,11 @@ ExprResolveButton(struct xkb_context *ctx, ExprDef *expr,
{ NULL, 0 }
};
- return ExprResolveIntegerLookup(ctx, expr, val_rtrn, SimpleLookup,
- button_names);
+ ok = ExprResolveIntegerLookup(ctx, expr, &result, SimpleLookup,
+ button_names);
+ if (ok)
+ *btn_rtrn = result.ival;
+ return ok;
}
bool
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index bf7891b..d4a0560 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -84,9 +84,8 @@ bool
ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr,
xkb_group_index_t *group_rtrn);
-extern int
-ExprResolveButton(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn);
+bool
+ExprResolveButton(struct xkb_context *ctx, ExprDef *expr, int *btn_rtrn);
bool
ExprResolveString(struct xkb_context *ctx, ExprDef *expr,