compat: disallow changing global defaults from within an interpret

It's currently possible to write something like this:
    interpret Num_Lock+Any {
        virtualModifier = NumLock;
        action = LockMods(modifiers=NumLock);
        !indicator.allowExplicit;
    };
The final statement has the same effect as writing it in the global file
scope, which changes the default indicator (which all subsequent
indicators start off as). This very strange and also unused; if someone
does it he probably expects it to affect only the local scope, and he
might then get unexpected behavior. So don't allow it.

Also, HandleInterpVar is clearly a misnomer (as it can also change
indicator defaults) so rename it.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-09-02 11:49:43 +03:00
parent c9466b32df
commit e5fdbcbb99
1 changed files with 6 additions and 3 deletions

View File

@ -804,7 +804,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led,
} }
static bool static bool
HandleInterpVar(CompatInfo *info, VarDef *stmt) HandleGlobalVar(CompatInfo *info, VarDef *stmt)
{ {
const char *elem, *field; const char *elem, *field;
ExprDef *ndx; ExprDef *ndx;
@ -832,7 +832,10 @@ HandleInterpBody(CompatInfo *info, VarDef *def, SymInterpInfo *si)
for (; def; def = (VarDef *) def->common.next) { for (; def; def = (VarDef *) def->common.next) {
if (def->name && def->name->op == EXPR_FIELD_REF) { if (def->name && def->name->op == EXPR_FIELD_REF) {
ok = HandleInterpVar(info, def); log_err(info->keymap->ctx,
"Cannot set a global default value from within an interpret statement; "
"Move statements to the global file scope\n");
ok = false;
continue; continue;
} }
@ -961,7 +964,7 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge)
ok = HandleIndicatorMapDef(info, (IndicatorMapDef *) stmt, merge); ok = HandleIndicatorMapDef(info, (IndicatorMapDef *) stmt, merge);
break; break;
case STMT_VAR: case STMT_VAR:
ok = HandleInterpVar(info, (VarDef *) stmt); ok = HandleGlobalVar(info, (VarDef *) stmt);
break; break;
case STMT_VMOD: case STMT_VMOD:
ok = HandleVModDef((VModDef *) stmt, info->keymap, merge, ok = HandleVModDef((VModDef *) stmt, info->keymap, merge,