action: add missing array_ndx checks
authorRan Benita <ran234@gmail.com>
Sat, 15 Feb 2014 20:16:41 +0000 (22:16 +0200)
committerRan Benita <ran234@gmail.com>
Sat, 15 Feb 2014 20:47:57 +0000 (22:47 +0200)
Only the "data" field can have them, and every other field needs to
error out if it appears. But some didn't check.

Signed-off-by: Ran Benita <ran234@gmail.com>
src/xkbcomp/action.c

index 4cb7b67..a4344c6 100644 (file)
@@ -422,14 +422,14 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
 {
     struct xkb_pointer_action *act = &action->ptr;
 
-    if (array_ndx && (field == ACTION_FIELD_X || field == ACTION_FIELD_Y))
-        return ReportActionNotArray(keymap, action->type, field);
-
     if (field == ACTION_FIELD_X || field == ACTION_FIELD_Y) {
         int val;
         const bool absolute = (value->expr.op != EXPR_NEGATE &&
                                value->expr.op != EXPR_UNARY_PLUS);
 
+        if (array_ndx)
+            return ReportActionNotArray(keymap, action->type, field);
+
         if (!ExprResolveInteger(keymap->ctx, value, &val))
             return ReportMismatch(keymap, action->type, field, "integer");
 
@@ -458,6 +458,9 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action,
     else if (field == ACTION_FIELD_ACCEL) {
         bool set;
 
+        if (array_ndx)
+            return ReportActionNotArray(keymap, action->type, field);
+
         if (!ExprResolveBoolean(keymap->ctx, value, &set))
             return ReportMismatch(keymap, action->type, field, "boolean");
 
@@ -687,6 +690,9 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action,
     if (field == ACTION_FIELD_TYPE) {
         int type;
 
+        if (array_ndx)
+            return ReportActionNotArray(keymap, action->type, field);
+
         if (!ExprResolveInteger(keymap->ctx, value, &type))
             return ReportMismatch(keymap, ACTION_TYPE_PRIVATE, field, "integer");
 
@@ -880,7 +886,6 @@ HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
     return true;
 }
 
-
 bool
 SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field,
                ExprDef *array_ndx, ExprDef *value, ActionsInfo *info)