Constify global tables
authorRan Benita <ran234@gmail.com>
Fri, 2 Mar 2012 15:40:19 +0000 (17:40 +0200)
committerRan Benita <ran234@gmail.com>
Fri, 2 Mar 2012 23:17:57 +0000 (01:17 +0200)
Signed-off-by: Ran Benita <ran234@gmail.com>
src/xkbcomp/action.c
src/xkbcomp/action.h
src/xkbcomp/compat.c
src/xkbcomp/expr.c
src/xkbcomp/expr.h
src/xkbcomp/indicators.c
src/xkbcomp/symbols.c
src/xkbcomp/vmod.c

index c2cbd01..ae21a21 100644 (file)
@@ -609,7 +609,7 @@ HandleMovePtr(struct xkb_desc * xkb,
     return ReportIllegal(action->type, field);
 }
 
-static LookupEntry lockWhich[] = {
+static const LookupEntry lockWhich[] = {
     {"both", 0},
     {"lock", XkbSA_LockNoUnlock},
     {"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)},
@@ -670,7 +670,7 @@ HandlePtrBtn(struct xkb_desc * xkb,
     return ReportIllegal(action->type, field);
 }
 
-static LookupEntry ptrDflts[] = {
+static const LookupEntry ptrDflts[] = {
     {"dfltbtn", XkbSA_AffectDfltBtn},
     {"defaultbutton", XkbSA_AffectDfltBtn},
     {"button", XkbSA_AffectDfltBtn},
@@ -735,7 +735,7 @@ HandleSetPtrDflt(struct xkb_desc * xkb,
     return ReportIllegal(action->type, field);
 }
 
-static LookupEntry isoNames[] = {
+static const LookupEntry isoNames[] = {
     {"mods", XkbSA_ISONoAffectMods},
     {"modifiers", XkbSA_ISONoAffectMods},
     {"group", XkbSA_ISONoAffectGroup},
@@ -850,41 +850,24 @@ HandleSwitchScreen(struct xkb_desc * xkb,
     return ReportIllegal(action->type, field);
 }
 
-LookupEntry ctrlNames[] = {
-    {"repeatkeys", XkbRepeatKeysMask}
-    ,
-    {"repeat", XkbRepeatKeysMask}
-    ,
-    {"autorepeat", XkbRepeatKeysMask}
-    ,
-    {"slowkeys", XkbSlowKeysMask}
-    ,
-    {"bouncekeys", XkbBounceKeysMask}
-    ,
-    {"stickykeys", XkbStickyKeysMask}
-    ,
-    {"mousekeys", XkbMouseKeysMask}
-    ,
-    {"mousekeysaccel", XkbMouseKeysAccelMask}
-    ,
-    {"accessxkeys", XkbAccessXKeysMask}
-    ,
-    {"accessxtimeout", XkbAccessXTimeoutMask}
-    ,
-    {"accessxfeedback", XkbAccessXFeedbackMask}
-    ,
-    {"audiblebell", XkbAudibleBellMask}
-    ,
-    {"overlay1", XkbOverlay1Mask}
-    ,
-    {"overlay2", XkbOverlay2Mask}
-    ,
-    {"ignoregrouplock", XkbIgnoreGroupLockMask}
-    ,
-    {"all", XkbAllBooleanCtrlsMask}
-    ,
-    {"none", 0}
-    ,
+const LookupEntry ctrlNames[] = {
+    {"repeatkeys", XkbRepeatKeysMask},
+    {"repeat", XkbRepeatKeysMask},
+    {"autorepeat", XkbRepeatKeysMask},
+    {"slowkeys", XkbSlowKeysMask},
+    {"bouncekeys", XkbBounceKeysMask},
+    {"stickykeys", XkbStickyKeysMask},
+    {"mousekeys", XkbMouseKeysMask},
+    {"mousekeysaccel", XkbMouseKeysAccelMask},
+    {"accessxkeys", XkbAccessXKeysMask},
+    {"accessxtimeout", XkbAccessXTimeoutMask},
+    {"accessxfeedback", XkbAccessXFeedbackMask},
+    {"audiblebell", XkbAudibleBellMask},
+    {"overlay1", XkbOverlay1Mask},
+    {"overlay2", XkbOverlay2Mask},
+    {"ignoregrouplock", XkbIgnoreGroupLockMask},
+    {"all", XkbAllBooleanCtrlsMask},
+    {"none", 0},
     {NULL, 0}
 };
 
@@ -909,7 +892,7 @@ HandleSetLockControls(struct xkb_desc * xkb,
     return ReportIllegal(action->type, field);
 }
 
-static LookupEntry evNames[] = {
+static const LookupEntry evNames[] = {
     {"press", XkbSA_MessageOnPress},
     {"keypress", XkbSA_MessageOnPress},
     {"release", XkbSA_MessageOnRelease},
@@ -1210,7 +1193,7 @@ typedef Bool(*actionHandler) (struct xkb_desc * /* xkb */ ,
                               ExprDef * /* value */
     );
 
-static actionHandler handleAction[XkbSA_NumActions + 1] = {
+static const actionHandler handleAction[XkbSA_NumActions + 1] = {
     HandleNoAction /* NoAction     */ ,
     HandleSetLatchMods /* SetMods      */ ,
     HandleSetLatchMods /* LatchMods    */ ,
index 8d52d29..7dd7fdc 100644 (file)
@@ -79,6 +79,6 @@ extern int SetActionField(struct xkb_desc * /* xkb */ ,
                           ActionInfo ** /* info_rtrn */
     );
 
-extern LookupEntry ctrlNames[];
+extern const LookupEntry ctrlNames[];
 
 #endif /* ACTION_H */
index 97171b7..e535248 100644 (file)
@@ -477,7 +477,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
     return (info->errorCount == 0);
 }
 
-static LookupEntry useModMapValues[] = {
+static const LookupEntry useModMapValues[] = {
     {"levelone", 1},
     {"level1", 1},
     {"anylevel", 0},
index dcf6ead..f682186 100644 (file)
@@ -33,7 +33,7 @@
 
 /***====================================================================***/
 
-typedef Bool(*IdentLookupFunc) (void * /* priv */ ,
+typedef Bool(*IdentLookupFunc) (const void * /* priv */ ,
                                 uint32_t /* field */ ,
                                 unsigned /* type */ ,
                                 ExprResult *    /* val_rtrn */
@@ -163,10 +163,10 @@ ExprResolveLhs(ExprDef * expr,
 }
 
 static Bool
-SimpleLookup(void * priv, uint32_t field, unsigned type,
+SimpleLookup(const void * priv, uint32_t field, unsigned type,
              ExprResult * val_rtrn)
 {
-    LookupEntry *entry;
+    const LookupEntry *entry;
     const char *str;
 
     if ((priv == NULL) || (field == None) ||
@@ -189,7 +189,7 @@ SimpleLookup(void * priv, uint32_t field, unsigned type,
 }
 
 static Bool
-RadioLookup(void * priv, uint32_t field, unsigned type, ExprResult * val_rtrn)
+RadioLookup(const void * priv, uint32_t field, unsigned type, ExprResult * val_rtrn)
 {
     const char *str;
     int rg;
@@ -215,7 +215,7 @@ RadioLookup(void * priv, uint32_t field, unsigned type, ExprResult * val_rtrn)
     return True;
 }
 
-static LookupEntry modIndexNames[] = {
+static const LookupEntry modIndexNames[] = {
     {"shift", ShiftMapIndex},
     {"control", ControlMapIndex},
     {"lock", LockMapIndex},
@@ -229,14 +229,14 @@ static LookupEntry modIndexNames[] = {
 };
 
 int
-LookupModIndex(void * priv, uint32_t field, unsigned type,
+LookupModIndex(const void * priv, uint32_t field, unsigned type,
                ExprResult * val_rtrn)
 {
     return SimpleLookup(modIndexNames, field, type, val_rtrn);
 }
 
 int
-LookupModMask(void * priv, uint32_t field, unsigned type,
+LookupModMask(const void * priv, uint32_t field, unsigned type,
               ExprResult * val_rtrn)
 {
     char *str;
@@ -518,7 +518,7 @@ ExprResolveKeyCode(ExprDef * expr,
 static int
 ExprResolveIntegerLookup(ExprDef * expr,
                          ExprResult * val_rtrn,
-                         IdentLookupFunc lookup, void * lookupPriv)
+                         IdentLookupFunc lookup, const void * lookupPriv)
 {
     int ok = 0;
     ExprResult leftRtrn, rightRtrn;
@@ -643,7 +643,7 @@ ExprResolveGroup(ExprDef * expr,
                  ExprResult * val_rtrn)
 {
     int ret;
-    static LookupEntry group_names[] = {
+    static const LookupEntry group_names[] = {
         { "group1", 1 },
         { "group2", 2 },
         { "group3", 3 },
@@ -672,7 +672,7 @@ int
 ExprResolveLevel(ExprDef * expr,
                  ExprResult * val_rtrn)
 {
-    static LookupEntry level_names[] = {
+    static const LookupEntry level_names[] = {
         { "level1", 1 },
         { "level2", 2 },
         { "level3", 3 },
@@ -692,7 +692,7 @@ int
 ExprResolveButton(ExprDef * expr,
                   ExprResult * val_rtrn)
 {
-    static LookupEntry button_names[] = {
+    static const LookupEntry button_names[] = {
         { "button1", 1 },
         { "button2", 2 },
         { "button3", 3 },
@@ -856,7 +856,7 @@ ExprResolveKeyName(ExprDef * expr,
 /***====================================================================***/
 
 int
-ExprResolveEnum(ExprDef * expr, ExprResult * val_rtrn, LookupEntry * values)
+ExprResolveEnum(ExprDef * expr, ExprResult * val_rtrn, const LookupEntry * values)
 {
     if (expr->op != ExprIdent)
     {
@@ -888,7 +888,7 @@ static int
 ExprResolveMaskLookup(ExprDef * expr,
                       ExprResult * val_rtrn,
                       IdentLookupFunc lookup,
-                      void * lookupPriv)
+                      const void * lookupPriv)
 {
     int ok = 0;
     ExprResult leftRtrn, rightRtrn;
@@ -984,7 +984,7 @@ ExprResolveMaskLookup(ExprDef * expr,
 int
 ExprResolveMask(ExprDef * expr,
                 ExprResult * val_rtrn,
-                LookupEntry * values)
+                const LookupEntry * values)
 {
     return ExprResolveMaskLookup(expr, val_rtrn, SimpleLookup, values);
 }
index 46b89c8..00eaf02 100644 (file)
@@ -51,19 +51,19 @@ typedef struct _LookupEntry
 extern char *exprOpText(unsigned        /* type */
     );
 
-extern int LookupModMask(void * /* priv */ ,
+extern int LookupModMask(const void * /* priv */ ,
                          uint32_t /* field */ ,
                          unsigned /* type */ ,
                          ExprResult *  /* val_rtrn */
     );
 
-extern int LookupVModMask(void * /* priv */ ,
+extern int LookupVModMask(const void * /* priv */ ,
                           uint32_t /* field */ ,
                           unsigned /* type */ ,
                           ExprResult *  /* val_rtrn */
     );
 
-extern int LookupModIndex(void * /* priv */ ,
+extern int LookupModIndex(const void * /* priv */ ,
                           uint32_t /* field */ ,
                           unsigned /* type */ ,
                           ExprResult *  /* val_rtrn */
@@ -120,12 +120,12 @@ extern int ExprResolveKeyName(ExprDef * /* expr */ ,
 
 extern int ExprResolveEnum(ExprDef * /* expr */ ,
                            ExprResult * /* val_rtrn */ ,
-                           LookupEntry *        /* values */
+                           const LookupEntry *  /* values */
     );
 
 extern int ExprResolveMask(ExprDef * /* expr */ ,
                            ExprResult * /* val_rtrn */ ,
-                           LookupEntry * /* values */
+                           const LookupEntry * /* values */
     );
 
 extern int ExprResolveKeySym(ExprDef * /* expr */ ,
index 98825ce..24ea8dd 100644 (file)
@@ -161,60 +161,37 @@ AddIndicatorMap(LEDInfo * oldLEDs, LEDInfo * new)
     return old;
 }
 
-static LookupEntry modComponentNames[] = {
-    {"base", XkbIM_UseBase}
-    ,
-    {"latched", XkbIM_UseLatched}
-    ,
-    {"locked", XkbIM_UseLocked}
-    ,
-    {"effective", XkbIM_UseEffective}
-    ,
-    {"compat", XkbIM_UseCompat}
-    ,
-    {"any", XkbIM_UseAnyMods}
-    ,
-    {"none", 0}
-    ,
+static const LookupEntry modComponentNames[] = {
+    {"base", XkbIM_UseBase},
+    {"latched", XkbIM_UseLatched},
+    {"locked", XkbIM_UseLocked},
+    {"effective", XkbIM_UseEffective},
+    {"compat", XkbIM_UseCompat},
+    {"any", XkbIM_UseAnyMods},
+    {"none", 0},
     {NULL, 0}
 };
-static LookupEntry groupComponentNames[] = {
-    {"base", XkbIM_UseBase}
-    ,
-    {"latched", XkbIM_UseLatched}
-    ,
-    {"locked", XkbIM_UseLocked}
-    ,
-    {"effective", XkbIM_UseEffective}
-    ,
-    {"any", XkbIM_UseAnyGroup}
-    ,
-    {"none", 0}
-    ,
+static const LookupEntry groupComponentNames[] = {
+    {"base", XkbIM_UseBase},
+    {"latched", XkbIM_UseLatched},
+    {"locked", XkbIM_UseLocked},
+    {"effective", XkbIM_UseEffective},
+    {"any", XkbIM_UseAnyGroup},
+    {"none", 0},
     {NULL, 0}
 };
 
-static LookupEntry groupNames[] = {
-    {"group1", 0x01}
-    ,
-    {"group2", 0x02}
-    ,
-    {"group3", 0x04}
-    ,
-    {"group4", 0x08}
-    ,
-    {"group5", 0x10}
-    ,
-    {"group6", 0x20}
-    ,
-    {"group7", 0x40}
-    ,
-    {"group8", 0x80}
-    ,
-    {"none", 0x00}
-    ,
-    {"all", 0xff}
-    ,
+static const LookupEntry groupNames[] = {
+    {"group1", 0x01},
+    {"group2", 0x02},
+    {"group3", 0x04},
+    {"group4", 0x08},
+    {"group5", 0x10},
+    {"group6", 0x20},
+    {"group7", 0x40},
+    {"group8", 0x80},
+    {"none", 0x00},
+    {"all", 0xff},
     {NULL, 0}
 };
 
index e6f8022..decea71 100644 (file)
@@ -1049,7 +1049,7 @@ SetAllowNone(KeyInfo * key, ExprDef * arrayNdx, ExprDef * value)
 }
 
 
-static LookupEntry lockingEntries[] = {
+static const LookupEntry lockingEntries[] = {
     {"true", XkbKB_Lock},
     {"yes", XkbKB_Lock},
     {"on", XkbKB_Lock},
@@ -1060,7 +1060,7 @@ static LookupEntry lockingEntries[] = {
     {NULL, 0}
 };
 
-static LookupEntry repeatEntries[] = {
+static const LookupEntry repeatEntries[] = {
     {"true", RepeatYes},
     {"yes", RepeatYes},
     {"on", RepeatYes},
index 3a3c05d..b313cdd 100644 (file)
@@ -159,7 +159,7 @@ HandleVModDef(VModDef * stmt, struct xkb_desc *xkb, unsigned mergeMode,
  * undefined.
  */
 static int
-LookupVModIndex(struct xkb_desc *xkb, uint32_t field, unsigned type,
+LookupVModIndex(const struct xkb_desc *xkb, uint32_t field, unsigned type,
                 ExprResult * val_rtrn)
 {
     int i;
@@ -195,7 +195,7 @@ LookupVModIndex(struct xkb_desc *xkb, uint32_t field, unsigned type,
  * undefined.
  */
 int
-LookupVModMask(void * priv, uint32_t field, unsigned type,
+LookupVModMask(const void * priv, uint32_t field, unsigned type,
                ExprResult * val_rtrn)
 {
     if (LookupModMask(NULL, field, type, val_rtrn))