Commit eb738b13ce4ea8228dcc7c02949a33190e400bb4

Ran Benita 2012-03-02T17:40:19

Constify global tables 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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index c2cbd01..ae21a21 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -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    */ ,
diff --git a/src/xkbcomp/action.h b/src/xkbcomp/action.h
index 8d52d29..7dd7fdc 100644
--- a/src/xkbcomp/action.h
+++ b/src/xkbcomp/action.h
@@ -79,6 +79,6 @@ extern int SetActionField(struct xkb_desc * /* xkb */ ,
                           ActionInfo ** /* info_rtrn */
     );
 
-extern LookupEntry ctrlNames[];
+extern const LookupEntry ctrlNames[];
 
 #endif /* ACTION_H */
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 97171b7..e535248 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -477,7 +477,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
     return (info->errorCount == 0);
 }
 
-static LookupEntry useModMapValues[] = {
+static const LookupEntry useModMapValues[] = {
     {"levelone", 1},
     {"level1", 1},
     {"anylevel", 0},
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index dcf6ead..f682186 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -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);
 }
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index 46b89c8..00eaf02 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -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 */ ,
diff --git a/src/xkbcomp/indicators.c b/src/xkbcomp/indicators.c
index 98825ce..24ea8dd 100644
--- a/src/xkbcomp/indicators.c
+++ b/src/xkbcomp/indicators.c
@@ -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}
 };
 
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index e6f8022..decea71 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -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},
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index 3a3c05d..b313cdd 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -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))