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>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
diff --git a/src/keymap-dump.c b/src/keymap-dump.c
index 91f8506..431bc2e 100644
--- a/src/keymap-dump.c
+++ b/src/keymap-dump.c
@@ -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));
diff --git a/src/misc.c b/src/misc.c
index 7a7ed7f..696ca8c 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -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;
-}
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 59d2821..07c5129 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -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)
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index cb4c09c..449825b 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -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);
- }
+ 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)
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index f6cd1aa..419eb23 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -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;
- }
+ $$= &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; }
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c
index 9ffef7b..1bccb7a 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/parseutils.c
@@ -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)
{
diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h
index e931d77..74de816 100644
--- a/src/xkbcomp/parseutils.h
+++ b/src/xkbcomp/parseutils.h
@@ -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);
diff --git a/src/xkbcomp/xkbcomp.h b/src/xkbcomp/xkbcomp.h
index cf6b5ee..8cd3fe5 100644
--- a/src/xkbcomp/xkbcomp.h
+++ b/src/xkbcomp/xkbcomp.h
@@ -83,7 +83,6 @@ enum merge_mode {
MERGE_AUGMENT,
MERGE_OVERRIDE,
MERGE_REPLACE,
- MERGE_ALT_FORM,
};
#define AutoKeyNames (1L << 0)