Commit f5dffd2b6e6a6e3875908961bfd8cd6652c49929

Daniel Stone 2012-08-21T11:21:19

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>

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;
                     }