Add ExprResolveGroup helper
Just a dumb wrapper around ExprResolveInteger. Signed-off-by: Daniel Stone <daniel@fooishbar.org>master
parent
8b47dbbf61
commit
e314931e8f
|
@ -462,18 +462,6 @@ HandleLockMods(struct xkb_desc * xkb,
|
||||||
return ReportIllegal(action->type, field);
|
return ReportIllegal(action->type, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LookupEntry groupNames[] = {
|
|
||||||
{"group1", 1},
|
|
||||||
{"group2", 2},
|
|
||||||
{"group3", 3},
|
|
||||||
{"group4", 4},
|
|
||||||
{"group5", 5},
|
|
||||||
{"group6", 6},
|
|
||||||
{"group7", 7},
|
|
||||||
{"group8", 8},
|
|
||||||
{NULL, 0},
|
|
||||||
};
|
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
CheckGroupField(unsigned action,
|
CheckGroupField(unsigned action,
|
||||||
ExprDef * value, unsigned *flags_inout, int *grp_rtrn)
|
ExprDef * value, unsigned *flags_inout, int *grp_rtrn)
|
||||||
|
@ -492,7 +480,7 @@ CheckGroupField(unsigned action,
|
||||||
spec = value;
|
spec = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ExprResolveInteger(spec, &rtrn, SimpleLookup, (char *) groupNames))
|
if (!ExprResolveGroup(spec, &rtrn))
|
||||||
return ReportMismatch(action, F_Group, "integer (range 1..8)");
|
return ReportMismatch(action, F_Group, "integer (range 1..8)");
|
||||||
if ((rtrn.ival < 1) || (rtrn.ival > XkbNumKbdGroups))
|
if ((rtrn.ival < 1) || (rtrn.ival > XkbNumKbdGroups))
|
||||||
{
|
{
|
||||||
|
|
|
@ -657,6 +657,26 @@ ExprResolveRadioGroup(ExprDef * expr,
|
||||||
return ExprResolveInteger(expr, val_rtrn, RadioLookup, NULL);
|
return ExprResolveInteger(expr, val_rtrn, RadioLookup, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
ExprResolveGroup(ExprDef * expr,
|
||||||
|
ExprResult * val_rtrn)
|
||||||
|
{
|
||||||
|
static LookupEntry group_names[] = {
|
||||||
|
{ "group1", 1 },
|
||||||
|
{ "group2", 2 },
|
||||||
|
{ "group3", 3 },
|
||||||
|
{ "group4", 4 },
|
||||||
|
{ "group5", 5 },
|
||||||
|
{ "group6", 6 },
|
||||||
|
{ "group7", 7 },
|
||||||
|
{ "group8", 8 },
|
||||||
|
{ NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
return ExprResolveInteger(expr, val_rtrn, SimpleLookup,
|
||||||
|
(char *) group_names);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
ExprResolveLevel(ExprDef * expr,
|
ExprResolveLevel(ExprDef * expr,
|
||||||
ExprResult * val_rtrn)
|
ExprResult * val_rtrn)
|
||||||
|
|
|
@ -124,6 +124,10 @@ extern int ExprResolveLevel(ExprDef * /* expr */ ,
|
||||||
ExprResult * /* val_rtrn */
|
ExprResult * /* val_rtrn */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
extern int ExprResolveGroup(ExprDef * /* expr */ ,
|
||||||
|
ExprResult * /* val_rtrn */
|
||||||
|
);
|
||||||
|
|
||||||
extern int ExprResolveButton(ExprDef * /* expr */ ,
|
extern int ExprResolveButton(ExprDef * /* expr */ ,
|
||||||
ExprResult * /* val_rtrn */
|
ExprResult * /* val_rtrn */
|
||||||
);
|
);
|
||||||
|
|
|
@ -860,19 +860,6 @@ HandleIncludeSymbols(IncludeStmt * stmt,
|
||||||
return (info->errorCount == 0);
|
return (info->errorCount == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LookupEntry groupNames[] = {
|
|
||||||
{"group1", 1},
|
|
||||||
{"group2", 2},
|
|
||||||
{"group3", 3},
|
|
||||||
{"group4", 4},
|
|
||||||
{"group5", 5},
|
|
||||||
{"group6", 6},
|
|
||||||
{"group7", 7},
|
|
||||||
{"group8", 8},
|
|
||||||
{NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#define SYMBOLS 1
|
#define SYMBOLS 1
|
||||||
#define ACTIONS 2
|
#define ACTIONS 2
|
||||||
|
|
||||||
|
@ -910,8 +897,7 @@ GetGroupIndex(KeyInfo * key,
|
||||||
ACTION("Ignoring %s defined for extra groups\n", name);
|
ACTION("Ignoring %s defined for extra groups\n", name);
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
if (!ExprResolveInteger
|
if (!ExprResolveGroup(arrayNdx, &tmp))
|
||||||
(arrayNdx, &tmp, SimpleLookup, (char *) groupNames))
|
|
||||||
{
|
{
|
||||||
ERROR("Illegal group index for %s of key %s\n", name,
|
ERROR("Illegal group index for %s of key %s\n", name,
|
||||||
longText(key->name));
|
longText(key->name));
|
||||||
|
@ -1142,8 +1128,7 @@ SetSymbolsField(KeyInfo * key,
|
||||||
key->dfltType = xkb_intern_atom(tmp.str);
|
key->dfltType = xkb_intern_atom(tmp.str);
|
||||||
key->defs.defined |= _Key_Type_Dflt;
|
key->defs.defined |= _Key_Type_Dflt;
|
||||||
}
|
}
|
||||||
else if (!ExprResolveInteger(arrayNdx, &ndx, SimpleLookup,
|
else if (!ExprResolveGroup(arrayNdx, &ndx))
|
||||||
(char *) groupNames))
|
|
||||||
{
|
{
|
||||||
ERROR("Illegal group index for type of key %s\n",
|
ERROR("Illegal group index for type of key %s\n",
|
||||||
longText(key->name));
|
longText(key->name));
|
||||||
|
@ -1343,8 +1328,7 @@ SetSymbolsField(KeyInfo * key,
|
||||||
else if ((uStrCaseCmp(field, "groupsredirect") == 0) ||
|
else if ((uStrCaseCmp(field, "groupsredirect") == 0) ||
|
||||||
(uStrCaseCmp(field, "redirectgroups") == 0))
|
(uStrCaseCmp(field, "redirectgroups") == 0))
|
||||||
{
|
{
|
||||||
if (!ExprResolveInteger
|
if (!ExprResolveGroup(value, &tmp))
|
||||||
(value, &tmp, SimpleLookup, (char *) groupNames))
|
|
||||||
{
|
{
|
||||||
ERROR("Illegal group index for redirect of key %s\n",
|
ERROR("Illegal group index for redirect of key %s\n",
|
||||||
longText(key->name));
|
longText(key->name));
|
||||||
|
@ -1382,8 +1366,7 @@ SetGroupName(SymbolsInfo * info, ExprDef * arrayNdx, ExprDef * value)
|
||||||
ACTION("Group name definition without array subscript ignored\n");
|
ACTION("Group name definition without array subscript ignored\n");
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
if (!ExprResolveInteger
|
if (!ExprResolveGroup(arrayNdx, &tmp))
|
||||||
(arrayNdx, &tmp, SimpleLookup, (char *) groupNames))
|
|
||||||
{
|
{
|
||||||
ERROR("Illegal index in group name definition\n");
|
ERROR("Illegal index in group name definition\n");
|
||||||
ACTION("Definition with non-integer array index ignored\n");
|
ACTION("Definition with non-integer array index ignored\n");
|
||||||
|
@ -1470,8 +1453,7 @@ HandleSymbolsVar(VarDef * stmt, struct xkb_desc * xkb, SymbolsInfo * info)
|
||||||
&& ((uStrCaseCmp(field.str, "groupsredirect") == 0)
|
&& ((uStrCaseCmp(field.str, "groupsredirect") == 0)
|
||||||
|| (uStrCaseCmp(field.str, "redirectgroups") == 0)))
|
|| (uStrCaseCmp(field.str, "redirectgroups") == 0)))
|
||||||
{
|
{
|
||||||
if (!ExprResolveInteger(stmt->value, &tmp,
|
if (!ExprResolveGroup(stmt->value, &tmp))
|
||||||
SimpleLookup, (char *) groupNames))
|
|
||||||
{
|
{
|
||||||
ERROR("Illegal group index for global groupsRedirect\n");
|
ERROR("Illegal group index for global groupsRedirect\n");
|
||||||
ACTION("Definition with non-integer group ignored\n");
|
ACTION("Definition with non-integer group ignored\n");
|
||||||
|
|
Loading…
Reference in New Issue