return true;
}
else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) {
- if (array_ndx != NULL)
+ unsigned int val;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
+
+ if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
return ReportMismatch(keymap, action->type, field,
"lock or unlock");
+
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
- act->flags |= rtrn.ival;
+ act->flags |= val;
return true;
}
else if (field == F_Count) {
act = (struct xkb_pointer_default_action *) action;
if (field == F_Affect) {
- if (array_ndx != NULL)
+ unsigned int val;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveEnum(keymap->ctx, value, &rtrn, ptrDflts))
+
+ if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts))
return ReportMismatch(keymap, action->type, field,
"pointer component");
- act->affect = rtrn.uval;
+ act->affect = val;
return true;
}
else if ((field == F_Button) || (field == F_Value)) {
act->button = val;
return true;
}
- else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect)) {
- if (array_ndx != NULL)
+ else if (action->type == XkbSA_LockDeviceBtn && field == F_Affect) {
+ unsigned int val;
+
+ if (array_ndx)
return ReportActionNotArray(keymap, action->type, field);
- if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
+
+ if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich))
return ReportMismatch(keymap, action->type, field,
"lock or unlock");
+
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
- act->flags |= rtrn.ival;
+ act->flags |= val;
return true;
}
else if (field == F_Count) {
SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field,
ExprDef *arrayNdx, ExprDef *value)
{
- int ok = 1;
- ExprResult tmp;
struct xkb_keymap *keymap = info->keymap;
+ ExprResult tmp;
if (istreq(field, "action")) {
- if (arrayNdx != NULL)
+ if (arrayNdx)
return ReportSINotArray(info, si, field);
- ok = HandleActionDef(value, keymap, &si->interp.act.any,
- info->act);
- if (ok)
- si->defined |= _SI_Action;
+
+ if (!HandleActionDef(value, keymap, &si->interp.act.any, info->act))
+ return false;
+
+ si->defined |= _SI_Action;
}
else if (istreq(field, "virtualmodifier") ||
istreq(field, "virtualmod")) {
- if (arrayNdx != NULL)
+ if (arrayNdx)
return ReportSINotArray(info, si, field);
- ok = ResolveVirtualModifier(value, keymap, &tmp, &info->vmods);
- if (ok) {
- si->interp.virtual_mod = tmp.uval;
- si->defined |= _SI_VirtualMod;
- }
- else
+
+ if (!ResolveVirtualModifier(value, keymap, &tmp, &info->vmods))
return ReportSIBadType(info, si, field, "virtual modifier");
+
+ si->interp.virtual_mod = tmp.uval;
+ si->defined |= _SI_VirtualMod;
}
else if (istreq(field, "repeat")) {
bool set;
}
else if (istreq(field, "usemodmap") ||
istreq(field, "usemodmapmods")) {
- if (arrayNdx != NULL)
+ unsigned int val;
+
+ if (arrayNdx)
return ReportSINotArray(info, si, field);
- ok = ExprResolveEnum(keymap->ctx, value, &tmp, useModMapValues);
- if (ok) {
- if (tmp.uval)
- si->interp.match |= XkbSI_LevelOneOnly;
- else
- si->interp.match &= ~XkbSI_LevelOneOnly;
- si->defined |= _SI_LevelOneOnly;
- }
- else
+
+ if (!ExprResolveEnum(keymap->ctx, value, &val, useModMapValues))
return ReportSIBadType(info, si, field, "level specification");
+
+ if (val)
+ si->interp.match |= XkbSI_LevelOneOnly;
+ else
+ si->interp.match &= ~XkbSI_LevelOneOnly;
+
+ si->defined |= _SI_LevelOneOnly;
}
else {
- ok = ReportBadField(keymap, "symbol interpretation", field,
- siText(si, info));
+ return ReportBadField(keymap, "symbol interpretation", field,
+ siText(si, info));
}
- return ok;
+
+ return true;
}
static const LookupEntry modComponentNames[] = {
return false;
}
-/***====================================================================***/
-
-int
+bool
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn, const LookupEntry *values)
+ unsigned int *val_rtrn, const LookupEntry *values)
{
+ ExprResult result;
+
if (expr->op != EXPR_IDENT) {
log_err(ctx, "Found a %s where an enumerated value was expected\n",
exprOpText(expr->op));
return false;
}
- if (!SimpleLookup(ctx, values, expr->value.str, EXPR_TYPE_INT,
- val_rtrn)) {
+
+ if (!SimpleLookup(ctx, values, expr->value.str, EXPR_TYPE_INT, &result)) {
int nOut = 0;
log_err(ctx, "Illegal identifier %s (expected one of: ",
xkb_atom_text(ctx, expr->value.str));
log_info(ctx, ")\n");
return false;
}
+
+ *val_rtrn = result.uval;
return true;
}
ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
char name[XkbKeyNameLength]);
-extern int
-ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
- const LookupEntry *values);
+bool
+ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
+ unsigned int *val_rtrn, const LookupEntry *values);
bool
ExprResolveMask(struct xkb_context *ctx, ExprDef *expr,
ExprDef *arrayNdx, ExprDef *value)
{
bool ok = true;
- ExprResult tmp;
struct xkb_context *ctx = info->keymap->ctx;
if (istreq(field, "type")) {
else if (istreq(field, "locking") ||
istreq(field, "lock") ||
istreq(field, "locks")) {
- ok = ExprResolveEnum(ctx, value, &tmp, lockingEntries);
+ unsigned int val;
+
+ ok = ExprResolveEnum(ctx, value, &val, lockingEntries);
if (ok)
- keyi->behavior.type = tmp.uval;
+ keyi->behavior.type = val;
keyi->defined |= _Key_Behavior;
}
else if (istreq(field, "radiogroup") ||
else if (istreq(field, "repeating") ||
istreq(field, "repeats") ||
istreq(field, "repeat")) {
- ok = ExprResolveEnum(ctx, value, &tmp, repeatEntries);
+ unsigned int val;
+
+ ok = ExprResolveEnum(ctx, value, &val, repeatEntries);
if (!ok) {
log_err(info->keymap->ctx,
"Illegal repeat setting for %s; "
longText(keyi->name));
return false;
}
- keyi->repeat = tmp.uval;
+ keyi->repeat = val;
keyi->defined |= _Key_Repeat;
}
else if (istreq(field, "groupswrap") ||