Remove MERGE_ALT_FORM merge mode

The mode comes from the "alternate" keyword, which is unused in
xkeyboard-config and mostly undocumented. Its purpose is to allow to
assign the same key name to multiple key codes, which is not allowed
otherwise (and doesn't make much sense). The xkblib specification
implies that this was part of the overlay functionality, which we also
no longer support.

If we do encounter this keyword, we just treat it as MERGE_DEFAULT. The
keycodes.c code will detect a collision and will ignore all but the
first key code (and the error count is not incremented).

Some peripheral code is also removed as a result.

Signed-off-by: Ran Benita <ran234@gmail.com>
master
Ran Benita 2012-07-13 18:34:11 +03:00
parent dd85790c73
commit 0765064b35
8 changed files with 28 additions and 102 deletions

View File

@ -323,15 +323,10 @@ write_keycodes(struct xkb_keymap *keymap, char **buf, size_t *size,
keymap->max_key_code);
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
const char *alternate = "";
if (darray_item(keymap->names->keys, key).name[0] == '\0')
continue;
if (XkbcFindKeycodeByName(keymap,
darray_item(keymap->names->keys, key).name,
true) != key)
alternate = "alternate ";
write_buf(keymap, buf, size, offset, "\t\t%s%6s = %d;\n", alternate,
write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n",
XkbcKeyNameText(darray_item(keymap->names->keys, key).name),
key);
}
@ -780,10 +775,6 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
if (xkb_key_num_groups(keymap, key) == 0)
continue;
if (XkbcFindKeycodeByName(keymap,
darray_item(keymap->names->keys, key).name,
true) != key)
continue;
write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
XkbcKeyNameText(darray_item(keymap->names->keys, key).name));

View File

@ -122,27 +122,3 @@ _XkbcKSCheckCase(xkb_keysym_t ks)
return rtrn;
}
xkb_keycode_t
XkbcFindKeycodeByName(struct xkb_keymap *keymap, const char *name,
bool use_aliases)
{
struct xkb_key_alias *alias;
xkb_keycode_t i;
for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) {
if (strncmp(darray_item(keymap->names->keys, i).name, name,
XkbKeyNameLength) == 0)
return i;
}
if (!use_aliases)
return 0;
darray_foreach(alias, keymap->names->key_aliases)
if (strncmp(name, alias->alias, XkbKeyNameLength) == 0)
return XkbcFindKeycodeByName(keymap, alias->real, false);
return 0;
}

View File

@ -459,10 +459,6 @@ xkb_context_take_file_id(struct xkb_context *ctx);
extern unsigned
_XkbcKSCheckCase(xkb_keysym_t sym);
extern xkb_keycode_t
XkbcFindKeycodeByName(struct xkb_keymap *keymap, const char *name,
bool use_aliases);
#define _XkbKSLower (1 << 0)
#define _XkbKSUpper (1 << 1)

View File

@ -71,7 +71,6 @@ typedef struct _KeyNamesInfo
xkb_keycode_t explicitMax;
darray(unsigned long) names;
darray(unsigned int) files;
darray(unsigned char) has_alt_forms;
IndicatorNameInfo *leds;
AliasInfo *aliases;
} KeyNamesInfo;
@ -87,7 +86,6 @@ ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
darray_resize0(info->names, newMax + 1);
darray_resize0(info->files, newMax + 1);
darray_resize0(info->has_alt_forms, newMax + 1);
}
static void
@ -281,7 +279,6 @@ ClearKeyNamesInfo(KeyNamesInfo * info)
info->computedMin = XKB_KEYCODE_MAX;
darray_free(info->names);
darray_free(info->files);
darray_free(info->has_alt_forms);
if (info->leds)
ClearIndicatorNameInfo(info->leds, info);
if (info->aliases)
@ -296,7 +293,6 @@ InitKeyNamesInfo(KeyNamesInfo * info)
info->aliases = NULL;
darray_init(info->names);
darray_init(info->files);
darray_init(info->has_alt_forms);
ClearKeyNamesInfo(info);
info->errorCount = 0;
}
@ -347,16 +343,11 @@ AddKeyName(KeyNamesInfo * info,
LongToKeyName(darray_item(info->names, kc), buf);
buf[4] = '\0';
if (darray_item(info->names, kc) == lval)
if (darray_item(info->names, kc) == lval && reportCollisions)
{
if (darray_item(info->has_alt_forms, kc) || (merge == MERGE_ALT_FORM)) {
darray_item(info->has_alt_forms, kc) = true;
}
else if (reportCollisions) {
WARN("Multiple identical key name definitions\n");
ACTION("Later occurences of \"<%s> = %d\" ignored\n",
buf, kc);
}
return true;
}
if (merge == MERGE_AUGMENT)
@ -386,32 +377,24 @@ AddKeyName(KeyNamesInfo * info,
{
darray_item(info->names, old) = 0;
darray_item(info->files, old) = 0;
darray_item(info->has_alt_forms, old) = true;
if (reportCollisions)
{
WARN("Key name <%s> assigned to multiple keys\n", name);
ACTION("Using %d, ignoring %d\n", kc, old);
}
}
else if (merge != MERGE_ALT_FORM)
else
{
if ((reportCollisions) && (warningLevel > 3))
{
WARN("Key name <%s> assigned to multiple keys\n", name);
ACTION("Using %d, ignoring %d\n", old, kc);
ACTION
("Use 'alternate' keyword to assign the same name to multiple keys\n");
}
return true;
}
else
{
darray_item(info->has_alt_forms, old) = true;
}
}
darray_item(info->names, kc) = lval;
darray_item(info->files, kc) = fileID;
darray_item(info->has_alt_forms, kc) = (merge == MERGE_ALT_FORM);
return true;
}
@ -439,16 +422,11 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
for (i = from->computedMin; i <= from->computedMax; i++)
{
unsigned thisMerge;
if (darray_item(from->names, i) == 0)
continue;
LongToKeyName(darray_item(from->names, i), buf);
buf[4] = '\0';
if (darray_item(from->has_alt_forms, i))
thisMerge = MERGE_ALT_FORM;
else
thisMerge = merge;
if (!AddKeyName(into, i, buf, thisMerge, from->fileID, false))
if (!AddKeyName(into, i, buf, merge, from->fileID, false))
into->errorCount++;
}
if (from->leds)

View File

@ -264,57 +264,57 @@ DeclList : DeclList Decl
Decl : OptMergeMode VarDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode VModDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode InterpretDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode KeyNameDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode KeyAliasDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode KeyTypeDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode SymbolsDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode ModMapDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode GroupCompatDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode IndicatorMapDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode IndicatorNameDecl
{
$2->merge= StmtSetMerge(&$2->common,$1,&@1,scanner);
$2->merge= $1;
$$= &$2->common;
}
| OptMergeMode ShapeDecl
@ -328,14 +328,7 @@ Decl : OptMergeMode VarDecl
}
| MergeMode STRING
{
if ($1==MERGE_ALT_FORM) {
yyerror(&@1, scanner,
"cannot use 'alternate' to include other maps");
$$= &IncludeCreate($2,MERGE_DEFAULT)->common;
}
else {
$$= &IncludeCreate($2,$1)->common;
}
free($2);
}
;
@ -596,7 +589,14 @@ MergeMode : INCLUDE { $$= MERGE_DEFAULT; }
| AUGMENT { $$= MERGE_AUGMENT; }
| OVERRIDE { $$= MERGE_OVERRIDE; }
| REPLACE { $$= MERGE_REPLACE; }
| ALTERNATE { $$= MERGE_ALT_FORM; }
| ALTERNATE
{
/*
* This used to be MERGE_ALT_FORM. This functionality was
* unused and has been removed.
*/
$$ = MERGE_DEFAULT;
}
;
OptExprList : ExprList { $$= $1; }

View File

@ -626,17 +626,6 @@ CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name,
return file;
}
unsigned
StmtSetMerge(ParseCommon * stmt, enum merge_mode merge, struct YYLTYPE *loc, void *scanner)
{
if ((merge == MERGE_ALT_FORM) && (stmt->stmtType != StmtKeycodeDef))
{
yyerror(loc, scanner, "illegal use of 'alternate' merge mode");
merge = MERGE_DEFAULT;
}
return merge;
}
static void
FreeExpr(ExprDef *expr)
{

View File

@ -113,9 +113,6 @@ LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn);
extern IncludeStmt *
IncludeCreate(char *str, enum merge_mode merge);
extern unsigned
StmtSetMerge(ParseCommon *stmt, enum merge_mode merge, struct YYLTYPE *loc, void *scanner);
extern void
CheckDefaultMap(XkbFile *maps, const char *fileName);

View File

@ -83,7 +83,6 @@ enum merge_mode {
MERGE_AUGMENT,
MERGE_OVERRIDE,
MERGE_REPLACE,
MERGE_ALT_FORM,
};
#define AutoKeyNames (1L << 0)