keycodes: remove unneeded alias conflict check This is already checked when adding a new alias and merging aliases, so it can never happen when we get to copying to the keymap. Also the log verbosity decision there is quite useless, we should just warn always and be done with it. So we can remove the file_id from AliasInfo, and collapse the alias functions together. 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
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index ae17caf..5b262d9 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -104,7 +104,6 @@
typedef struct {
enum merge_mode merge;
- unsigned file_id;
xkb_atom_t alias;
xkb_atom_t real;
@@ -141,12 +140,11 @@ typedef struct {
/***====================================================================***/
static void
-InitAliasInfo(AliasInfo *info, enum merge_mode merge, unsigned file_id,
+InitAliasInfo(AliasInfo *info, enum merge_mode merge,
xkb_atom_t alias, xkb_atom_t real)
{
memset(info, 0, sizeof(*info));
info->merge = merge;
- info->file_id = file_id;
info->alias = alias;
info->real = real;
}
@@ -344,8 +342,7 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, xkb_atom_t name,
/***====================================================================***/
static int
-HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge,
- unsigned file_id);
+HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge);
static bool
MergeAliases(KeyNamesInfo *into, KeyNamesInfo *from, enum merge_mode merge)
@@ -369,7 +366,7 @@ MergeAliases(KeyNamesInfo *into, KeyNamesInfo *from, enum merge_mode merge)
def.alias = alias->alias;
def.real = alias->real;
- if (!HandleAliasDef(into, &def, def.merge, alias->file_id))
+ if (!HandleAliasDef(into, &def, def.merge))
return false;
}
@@ -479,55 +476,42 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge)
info->file_id, true);
}
-static void
-HandleAliasCollision(KeyNamesInfo *info, AliasInfo *old, AliasInfo *new)
+static int
+HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge)
{
- const int verbosity = xkb_context_get_log_verbosity(info->ctx);
- const bool report = ((new->file_id == old->file_id && verbosity > 0) ||
- verbosity > 9);
-
- if (new->real == old->real) {
- if (report)
- log_warn(info->ctx, "Alias of %s for %s declared more than once; "
- "First definition ignored\n",
- KeyNameText(info->ctx, new->alias),
- KeyNameText(info->ctx, new->real));
- }
- else {
- xkb_atom_t use, ignore;
+ AliasInfo *old, new;
+
+ darray_foreach(old, info->aliases) {
+ if (old->alias == def->alias) {
+ if (def->real == old->real) {
+ log_vrb(info->ctx, 1,
+ "Alias of %s for %s declared more than once; "
+ "First definition ignored\n",
+ KeyNameText(info->ctx, def->alias),
+ KeyNameText(info->ctx, def->real));
+ }
+ else {
+ xkb_atom_t use, ignore;
+
+ use = (merge == MERGE_AUGMENT ? old->real : def->real);
+ ignore = (merge == MERGE_AUGMENT ? def->real : old->real);
- use = (new->merge == MERGE_AUGMENT ? old->real : new->real);
- ignore = (new->merge == MERGE_AUGMENT ? new->real : old->real);
-
- if (report)
- log_warn(info->ctx, "Multiple definitions for alias %s; "
- "Using %s, ignoring %s\n",
- KeyNameText(info->ctx, old->alias),
- KeyNameText(info->ctx, use),
- KeyNameText(info->ctx, ignore));
-
- old->real = use;
- }
-
- old->file_id = new->file_id;
- old->merge = new->merge;
-}
+ log_warn(info->ctx,
+ "Multiple definitions for alias %s; "
+ "Using %s, ignoring %s\n",
+ KeyNameText(info->ctx, old->alias),
+ KeyNameText(info->ctx, use),
+ KeyNameText(info->ctx, ignore));
-static int
-HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge,
- unsigned file_id)
-{
- AliasInfo *alias, new;
+ old->real = use;
+ }
- darray_foreach(alias, info->aliases) {
- if (alias->alias == def->alias) {
- InitAliasInfo(&new, merge, file_id, def->alias, def->real);
- HandleAliasCollision(info, alias, &new);
+ old->merge = merge;
return true;
}
}
- InitAliasInfo(&new, merge, file_id, def->alias, def->real);
+ InitAliasInfo(&new, merge, def->alias, def->real);
darray_append(info->aliases, new);
return true;
}
@@ -602,8 +586,7 @@ HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge)
ok = HandleKeycodeDef(info, (KeycodeDef *) stmt, merge);
break;
case STMT_ALIAS:
- ok = HandleAliasDef(info, (KeyAliasDef *) stmt, merge,
- info->file_id);
+ ok = HandleAliasDef(info, (KeyAliasDef *) stmt, merge);
break;
case STMT_VAR:
ok = HandleKeyNameVar(info, (VarDef *) stmt);
@@ -635,11 +618,12 @@ HandleKeycodesFile(KeyNamesInfo *info, XkbFile *file, enum merge_mode merge)
static void
CopyAliasesToKeymap(KeyNamesInfo *info, struct xkb_keymap *keymap)
{
- struct xkb_key *key;
- struct xkb_key_alias *a, new;
AliasInfo *alias;
darray_foreach(alias, info->aliases) {
+ struct xkb_key *key;
+ struct xkb_key_alias new;
+
/* Check that ->real is a key. */
key = FindNamedKey(keymap, alias->real, false);
if (!key) {
@@ -661,22 +645,6 @@ CopyAliasesToKeymap(KeyNamesInfo *info, struct xkb_keymap *keymap)
continue;
}
- /* Check that ->alias in not already an alias, and if so handle it. */
- darray_foreach(a, keymap->key_aliases) {
- AliasInfo old_alias;
-
- if (a->alias != alias->alias)
- continue;
-
- InitAliasInfo(&old_alias, MERGE_AUGMENT, 0, a->alias, a->real);
- HandleAliasCollision(info, &old_alias, alias);
- a->alias = old_alias.alias;
- a->real = old_alias.real;
- alias->alias = 0;
- }
- if (alias->alias == 0)
- continue;
-
/* Add the alias. */
new.alias = alias->alias;
new.real = alias->real;