kbproto untanglement: XkbKeyNameLength Define it ourselves as XKB_KEY_NAME_LENGTH and use that, instead of the one from XKB.h. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
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/text.c b/src/text.c
index 297da59..4e22f82 100644
--- a/src/text.c
+++ b/src/text.c
@@ -426,7 +426,7 @@ KeysymText(xkb_keysym_t sym)
}
const char *
-KeyNameText(const char name[XkbKeyNameLength])
+KeyNameText(const char name[XKB_KEY_NAME_LENGTH])
{
char *buf;
int len;
diff --git a/src/text.h b/src/text.h
index 098936f..d7fb6fc 100644
--- a/src/text.h
+++ b/src/text.h
@@ -74,7 +74,7 @@ const char *
KeysymText(xkb_keysym_t sym);
const char *
-KeyNameText(const char name[XkbKeyNameLength]);
+KeyNameText(const char name[XKB_KEY_NAME_LENGTH]);
const char *
SIMatchText(unsigned type);
diff --git a/src/xkb-priv.h b/src/xkb-priv.h
index 4e08bd0..f40095c 100644
--- a/src/xkb-priv.h
+++ b/src/xkb-priv.h
@@ -95,6 +95,8 @@ typedef uint32_t xkb_atom_t;
#define XKB_ATOM_NONE 0
#define XKB_LEVEL_INVALID 0xffffffff
+#define XKB_KEY_NAME_LENGTH 4
+
struct xkb_context {
int refcnt;
@@ -275,8 +277,8 @@ struct xkb_indicator_map {
};
struct xkb_key_alias {
- char real[XkbKeyNameLength];
- char alias[XkbKeyNameLength];
+ char real[XKB_KEY_NAME_LENGTH];
+ char alias[XKB_KEY_NAME_LENGTH];
};
struct xkb_controls {
@@ -296,7 +298,7 @@ struct xkb_controls {
};
struct xkb_key {
- char name[XkbKeyNameLength];
+ char name[XKB_KEY_NAME_LENGTH];
unsigned char explicit;
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index 4e903bd..114d4ea 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -887,7 +887,7 @@ HandleRedirectKey(struct xkb_keymap *keymap, union xkb_action *action,
unsigned t1;
xkb_mod_mask_t t2;
unsigned long tmp;
- char key_name[XkbKeyNameLength];
+ char key_name[XKB_KEY_NAME_LENGTH];
if (array_ndx != NULL)
return ReportActionNotArray(keymap, action->type, field);
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index a16c771..5291bfd 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -110,7 +110,7 @@ ExprCreateBinary(enum expr_op_type op, ExprDef *left, ExprDef *right)
}
KeycodeDef *
-KeycodeCreate(char keyName[XkbKeyNameLength], unsigned long value)
+KeycodeCreate(char keyName[XKB_KEY_NAME_LENGTH], unsigned long value)
{
KeycodeDef *def;
@@ -118,13 +118,13 @@ KeycodeCreate(char keyName[XkbKeyNameLength], unsigned long value)
def->common.type = STMT_KEYCODE;
def->common.next = NULL;
- strncpy(def->name, keyName, XkbKeyNameLength);
+ strncpy(def->name, keyName, XKB_KEY_NAME_LENGTH);
def->value = value;
return def;
}
KeyAliasDef *
-KeyAliasCreate(char alias[XkbKeyNameLength], char real[XkbKeyNameLength])
+KeyAliasCreate(char alias[XKB_KEY_NAME_LENGTH], char real[XKB_KEY_NAME_LENGTH])
{
KeyAliasDef *def;
@@ -132,8 +132,8 @@ KeyAliasCreate(char alias[XkbKeyNameLength], char real[XkbKeyNameLength])
def->common.type = STMT_ALIAS;
def->common.next = NULL;
- strncpy(def->alias, alias, XkbKeyNameLength);
- strncpy(def->real, real, XkbKeyNameLength);
+ strncpy(def->alias, alias, XKB_KEY_NAME_LENGTH);
+ strncpy(def->real, real, XKB_KEY_NAME_LENGTH);
return def;
}
@@ -206,7 +206,7 @@ KeyTypeCreate(xkb_atom_t name, VarDef * body)
}
SymbolsDef *
-SymbolsCreate(char keyName[XkbKeyNameLength], ExprDef *symbols)
+SymbolsCreate(char keyName[XKB_KEY_NAME_LENGTH], ExprDef *symbols)
{
SymbolsDef *def;
@@ -215,7 +215,7 @@ SymbolsCreate(char keyName[XkbKeyNameLength], ExprDef *symbols)
def->common.type = STMT_SYMBOLS;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
- strncpy(def->keyName, keyName, XkbKeyNameLength);
+ strncpy(def->keyName, keyName, XKB_KEY_NAME_LENGTH);
def->symbols = symbols;
return def;
}
diff --git a/src/xkbcomp/ast-build.h b/src/xkbcomp/ast-build.h
index ec5ef38..4f19d2c 100644
--- a/src/xkbcomp/ast-build.h
+++ b/src/xkbcomp/ast-build.h
@@ -41,10 +41,10 @@ ExprDef *
ExprCreateBinary(enum expr_op_type op, ExprDef *left, ExprDef *right);
KeycodeDef *
-KeycodeCreate(char keyName[XkbKeyNameLength], unsigned long value);
+KeycodeCreate(char keyName[XKB_KEY_NAME_LENGTH], unsigned long value);
KeyAliasDef *
-KeyAliasCreate(char keyName[XkbKeyNameLength], char real[XkbKeyNameLength]);
+KeyAliasCreate(char keyName[XKB_KEY_NAME_LENGTH], char real[XKB_KEY_NAME_LENGTH]);
VModDef *
VModCreate(xkb_atom_t name, ExprDef *value);
@@ -62,7 +62,7 @@ KeyTypeDef *
KeyTypeCreate(xkb_atom_t name, VarDef *body);
SymbolsDef *
-SymbolsCreate(char keyName[XkbKeyNameLength], ExprDef *symbols);
+SymbolsCreate(char keyName[XKB_KEY_NAME_LENGTH], ExprDef *symbols);
GroupCompatDef *
GroupCompatCreate(int group, ExprDef *def);
diff --git a/src/xkbcomp/ast.h b/src/xkbcomp/ast.h
index dbbe3c5..ccef461 100644
--- a/src/xkbcomp/ast.h
+++ b/src/xkbcomp/ast.h
@@ -166,7 +166,7 @@ typedef struct _Expr {
xkb_atom_t str;
unsigned uval;
int ival;
- char keyName[XkbKeyNameLength];
+ char keyName[XKB_KEY_NAME_LENGTH];
} value;
} ExprDef;
@@ -187,15 +187,15 @@ typedef struct _VModDef {
typedef struct _KeycodeDef {
ParseCommon common;
enum merge_mode merge;
- char name[XkbKeyNameLength];
+ char name[XKB_KEY_NAME_LENGTH];
unsigned long value;
} KeycodeDef;
typedef struct _KeyAliasDef {
ParseCommon common;
enum merge_mode merge;
- char alias[XkbKeyNameLength];
- char real[XkbKeyNameLength];
+ char alias[XKB_KEY_NAME_LENGTH];
+ char real[XKB_KEY_NAME_LENGTH];
} KeyAliasDef;
typedef struct _KeyTypeDef {
@@ -208,7 +208,7 @@ typedef struct _KeyTypeDef {
typedef struct _SymbolsDef {
ParseCommon common;
enum merge_mode merge;
- char keyName[XkbKeyNameLength];
+ char keyName[XKB_KEY_NAME_LENGTH];
ExprDef *symbols;
} SymbolsDef;
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 6fe4029..d42556d 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -490,7 +490,7 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr,
bool
ExprResolveKeyName(struct xkb_context *ctx, const ExprDef *expr,
- char name[XkbKeyNameLength])
+ char name[XKB_KEY_NAME_LENGTH])
{
switch (expr->op) {
case EXPR_VALUE:
@@ -499,7 +499,7 @@ ExprResolveKeyName(struct xkb_context *ctx, const ExprDef *expr,
expr_value_type_to_string(expr->value_type));
return false;
}
- strncpy(name, expr->value.keyName, XkbKeyNameLength);
+ strncpy(name, expr->value.keyName, XKB_KEY_NAME_LENGTH);
return true;
case EXPR_IDENT:
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index e30f43e..e7ed86e 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -82,7 +82,7 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr,
bool
ExprResolveKeyName(struct xkb_context *ctx, const ExprDef *expr,
- char name[XkbKeyNameLength]);
+ char name[XKB_KEY_NAME_LENGTH]);
bool
ExprResolveEnum(struct xkb_context *ctx, const ExprDef *expr,
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index 1e3d605..3688af4 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -164,7 +164,7 @@ ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
static void
InitAliasInfo(AliasInfo *info, enum merge_mode merge, unsigned file_id,
- char alias[XkbKeyNameLength], char real[XkbKeyNameLength])
+ char alias[XKB_KEY_NAME_LENGTH], char real[XKB_KEY_NAME_LENGTH])
{
memset(info, 0, sizeof(*info));
info->merge = merge;
@@ -886,12 +886,12 @@ bool
FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname,
unsigned long *real_name)
{
- char name[XkbKeyNameLength];
+ char name[XKB_KEY_NAME_LENGTH];
struct xkb_key_alias *a;
LongToKeyName(lname, name);
darray_foreach(a, keymap->key_aliases) {
- if (strncmp(name, a->alias, XkbKeyNameLength) == 0) {
+ if (strncmp(name, a->alias, XKB_KEY_NAME_LENGTH) == 0) {
*real_name = KeyNameToLong(a->real);
return true;
}
diff --git a/src/xkbcomp/keycodes.h b/src/xkbcomp/keycodes.h
index cb75250..d95e16a 100644
--- a/src/xkbcomp/keycodes.h
+++ b/src/xkbcomp/keycodes.h
@@ -28,7 +28,7 @@
#define XKBCOMP_KEYCODES_H
static inline unsigned long
-KeyNameToLong(const char name[XkbKeyNameLength])
+KeyNameToLong(const char name[XKB_KEY_NAME_LENGTH])
{
return
(((unsigned long)name[0]) << 24) |
@@ -38,7 +38,7 @@ KeyNameToLong(const char name[XkbKeyNameLength])
}
static inline void
-LongToKeyName(unsigned long val, char name[XkbKeyNameLength])
+LongToKeyName(unsigned long val, char name[XKB_KEY_NAME_LENGTH])
{
name[0] = ((val >> 24) & 0xff);
name[1] = ((val >> 16) & 0xff);
@@ -49,7 +49,7 @@ LongToKeyName(unsigned long val, char name[XkbKeyNameLength])
static inline const char *
LongKeyNameText(unsigned long val)
{
- char buf[XkbKeyNameLength];
+ char buf[XKB_KEY_NAME_LENGTH];
LongToKeyName(val, buf);
return KeyNameText(buf);
}
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index b038371..b46cbfb 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -122,7 +122,7 @@ yyerror(struct YYLTYPE *loc, struct parser_param *param, const char *msg)
int64_t num;
enum xkb_file_type file_type;
char *str;
- char keyName[XkbKeyNameLength];
+ char keyName[XKB_KEY_NAME_LENGTH];
xkb_atom_t sval;
enum merge_mode merge;
ParseCommon *any;
@@ -678,7 +678,7 @@ Terminal : String
{
ExprDef *expr;
expr = ExprCreate(EXPR_VALUE, EXPR_TYPE_KEYNAME);
- strncpy(expr->value.keyName, $1, XkbKeyNameLength);
+ strncpy(expr->value.keyName, $1, XKB_KEY_NAME_LENGTH);
$$ = expr;
}
;
@@ -734,7 +734,7 @@ Integer : INTEGER { $$ = $1; }
KeyCode : INTEGER { $$ = $1; }
;
-KeyName : KEYNAME { strncpy($$, $1, XkbKeyNameLength); }
+KeyName : KEYNAME { strncpy($$, $1, XKB_KEY_NAME_LENGTH); }
;
Ident : IDENT { $$ = xkb_atom_steal(param->ctx, $1); }
diff --git a/src/xkbcomp/scanner.l b/src/xkbcomp/scanner.l
index b29b711..37e798b 100644
--- a/src/xkbcomp/scanner.l
+++ b/src/xkbcomp/scanner.l
@@ -81,13 +81,13 @@ scanner_error_extra(struct YYLTYPE *loc, struct scanner_extra *extra,
BEGIN(INITIAL);
*yyextra->s = '\0';
- if (yyextra->s - yyextra->scanBuf > XkbKeyNameLength) {
+ if (yyextra->s - yyextra->scanBuf > XKB_KEY_NAME_LENGTH) {
scanner_error_extra(yylloc, yyextra,
"Key name too long");
return ERROR_TOK;
}
- strncpy(yylval->keyName, yyextra->scanBuf, XkbKeyNameLength);
+ strncpy(yylval->keyName, yyextra->scanBuf, XKB_KEY_NAME_LENGTH);
return KEYNAME;
}