summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--action.c62
-rw-r--r--compat.c33
-rw-r--r--expr.c6
-rw-r--r--geometry.c96
-rw-r--r--indicators.c16
-rw-r--r--keycodes.c26
-rw-r--r--keytypes.c53
-rw-r--r--listing.c19
-rw-r--r--misc.c35
-rw-r--r--parseutils.c25
-rw-r--r--symbols.c89
-rw-r--r--utils.c3
-rw-r--r--vmod.c8
-rw-r--r--xkbcomp.c3
-rw-r--r--xkbpath.c11
-rw-r--r--xkbscan.c4
16 files changed, 222 insertions, 267 deletions
diff --git a/action.c b/action.c
index fc675c9..7d66e54 100644
--- a/action.c
+++ b/action.c
@@ -396,8 +396,6 @@ HandleSetLatchMods(XkbDescPtr xkb,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbModAction *act;
- unsigned rtrn;
- unsigned t1, t2;
act = (XkbModAction *) action;
if (array_ndx != NULL)
@@ -414,15 +412,18 @@ HandleSetLatchMods(XkbDescPtr xkb,
{
case F_ClearLocks:
case F_LatchToLock:
- rtrn = act->flags;
+ {
+ unsigned rtrn = act->flags;
if (CheckLatchLockFlags(action->type, field, value, &rtrn))
{
act->flags = rtrn;
return True;
}
return False;
+ }
case F_Modifiers:
- t1 = act->flags;
+ {
+ unsigned t1 = act->flags, t2;
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
{
act->flags = t1;
@@ -433,6 +434,7 @@ HandleSetLatchMods(XkbDescPtr xkb,
}
return False;
}
+ }
return ReportIllegal(action->type, field);
}
@@ -450,8 +452,6 @@ HandleLockMods(XkbDescPtr xkb,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbModAction *act;
- unsigned t1, t2;
- ExprResult rtrn;
act = (XkbModAction *) action;
if ((array_ndx != NULL) && (field == F_Modifiers || field == F_Affect))
@@ -459,13 +459,17 @@ HandleLockMods(XkbDescPtr xkb,
switch (field)
{
case F_Affect:
+ {
+ ExprResult rtrn;
if (!ExprResolveEnum(value, &rtrn, lockWhich))
return ReportMismatch(action->type, field, "lock or unlock");
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
act->flags |= rtrn.uval;
return True;
+ }
case F_Modifiers:
- t1 = act->flags;
+ {
+ unsigned t1 = act->flags, t2;
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
{
act->flags = t1;
@@ -476,6 +480,7 @@ HandleLockMods(XkbDescPtr xkb,
}
return False;
}
+ }
return ReportIllegal(action->type, field);
}
@@ -534,9 +539,6 @@ HandleSetLatchGroup(XkbDescPtr xkb,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbGroupAction *act;
- unsigned rtrn;
- unsigned t1;
- int t2;
act = (XkbGroupAction *) action;
if (array_ndx != NULL)
@@ -553,15 +555,19 @@ HandleSetLatchGroup(XkbDescPtr xkb,
{
case F_ClearLocks:
case F_LatchToLock:
- rtrn = act->flags;
+ {
+ unsigned rtrn = act->flags;
if (CheckLatchLockFlags(action->type, field, value, &rtrn))
{
act->flags = rtrn;
return True;
}
return False;
+ }
case F_Group:
- t1 = act->flags;
+ {
+ unsigned t1 = act->flags;
+ int t2;
if (CheckGroupField(action->type, value, &t1, &t2))
{
act->flags = t1;
@@ -570,6 +576,7 @@ HandleSetLatchGroup(XkbDescPtr xkb,
}
return False;
}
+ }
return ReportIllegal(action->type, field);
}
@@ -579,15 +586,14 @@ HandleLockGroup(XkbDescPtr xkb,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbGroupAction *act;
- unsigned t1;
- int t2;
act = (XkbGroupAction *) action;
if ((array_ndx != NULL) && (field == F_Group))
return ReportActionNotArray(action->type, field);
if (field == F_Group)
{
- t1 = act->flags;
+ unsigned t1 = act->flags;
+ int t2;
if (CheckGroupField(action->type, value, &t1, &t2))
{
act->flags = t1;
@@ -606,7 +612,6 @@ HandleMovePtr(XkbDescPtr xkb,
{
ExprResult rtrn;
XkbPtrAction *act;
- Bool absolute;
act = (XkbPtrAction *) action;
if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
@@ -614,6 +619,8 @@ HandleMovePtr(XkbDescPtr xkb,
if ((field == F_X) || (field == F_Y))
{
+ Bool absolute;
+
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
absolute = False;
else
@@ -803,13 +810,14 @@ HandleISOLock(XkbDescPtr xkb,
{
ExprResult rtrn;
XkbISOAction *act;
- unsigned flags, mods;
- int group;
+ unsigned flags;
act = (XkbISOAction *) action;
switch (field)
{
case F_Modifiers:
+ {
+ unsigned mods;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
flags = act->flags;
@@ -822,7 +830,10 @@ HandleISOLock(XkbDescPtr xkb,
return True;
}
return False;
+ }
case F_Group:
+ {
+ int group;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
flags = act->flags;
@@ -833,6 +844,7 @@ HandleISOLock(XkbDescPtr xkb,
return True;
}
return False;
+ }
case F_Affect:
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
@@ -1064,8 +1076,6 @@ HandleRedirectKey(XkbDescPtr xkb,
{
ExprResult rtrn;
XkbRedirectKeyAction *act;
- unsigned t1, t2, vmods, vmask;
- unsigned long tmp;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
@@ -1074,6 +1084,10 @@ HandleRedirectKey(XkbDescPtr xkb,
switch (field)
{
case F_Keycode:
+ {
+ unsigned int t1;
+ unsigned long tmp;
+
if (!ExprResolveKeyName(value, &rtrn, NULL, NULL))
return ReportMismatch(action->type, field, "key name");
tmp = KeyNameToLong(rtrn.keyName.name);
@@ -1085,11 +1099,16 @@ HandleRedirectKey(XkbDescPtr xkb,
}
act->new_key = t1;
return True;
+ }
case F_ModsToClear:
case F_Modifiers:
- t1 = 0;
+ {
+ unsigned t1 = 0, t2;
+
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
{
+ unsigned vmods, vmask;
+
act->mods_mask |= (t2 & 0xff);
if (field == F_Modifiers)
act->mods |= (t2 & 0xff);
@@ -1110,6 +1129,7 @@ HandleRedirectKey(XkbDescPtr xkb,
}
return True;
}
+ }
return ReportIllegal(action->type, field);
}
diff --git a/compat.c b/compat.c
index 92bd3c1..1902401 100644
--- a/compat.c
+++ b/compat.c
@@ -102,8 +102,6 @@ siText(SymInterpInfo * si, CompatInfo * info)
static void
InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
{
- int i;
-
info->xkb = xkb;
info->name = NULL;
info->fileID = 0;
@@ -117,7 +115,7 @@ InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
info->dflt.interp.flags = 0;
info->dflt.interp.virtual_mod = XkbNoModifier;
info->dflt.interp.act.type = XkbSA_NoAction;
- for (i = 0; i < XkbAnyActionDataSize; i++)
+ for (int i = 0; i < XkbAnyActionDataSize; i++)
{
info->dflt.interp.act.data[i] = 0;
}
@@ -135,8 +133,6 @@ InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
static void
ClearCompatInfo(CompatInfo * info, XkbDescPtr xkb)
{
- int i;
-
if (info->name != NULL)
uFree(info->name);
info->name = NULL;
@@ -145,7 +141,7 @@ ClearCompatInfo(CompatInfo * info, XkbDescPtr xkb)
info->dflt.interp.flags = 0;
info->dflt.interp.virtual_mod = XkbNoModifier;
info->dflt.interp.act.type = XkbSA_NoAction;
- for (i = 0; i < XkbAnyActionDataSize; i++)
+ for (int i = 0; i < XkbAnyActionDataSize; i++)
{
info->dflt.interp.act.data[i] = 0;
}
@@ -198,13 +194,13 @@ FindMatchingInterp(CompatInfo * info, SymInterpInfo * new)
static Bool
AddInterp(CompatInfo * info, SymInterpInfo * new)
{
- unsigned collide;
SymInterpInfo *old;
- collide = 0;
old = FindMatchingInterp(info, new);
if (old != NULL)
{
+ unsigned collide = 0;
+
if (new->defs.merge == MergeReplace)
{
SymInterpInfo *next = (SymInterpInfo *) old->defs.next;
@@ -349,8 +345,7 @@ ResolveStateAndPredicate(ExprDef * expr,
static void
MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
{
- SymInterpInfo *si;
- LEDInfo *led, *rtrn, *next;
+ LEDInfo *next;
GroupCompatInfo *gcm;
int i;
@@ -364,7 +359,8 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
into->name = from->name;
from->name = NULL;
}
- for (si = from->interps; si; si = (SymInterpInfo *) si->defs.next)
+ for (SymInterpInfo *si = from->interps; si;
+ si = (SymInterpInfo *) si->defs.next)
{
if (merge != MergeDefault)
si->defs.merge = merge;
@@ -378,8 +374,10 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
if (!AddGroupCompat(into, i, gcm))
into->errorCount++;
}
- for (led = from->leds; led != NULL; led = next)
+ for (LEDInfo *led = from->leds; led != NULL; led = next)
{
+ LEDInfo *rtrn;
+
next = (LEDInfo *) led->defs.next;
if (merge != MergeDefault)
led->defs.merge = merge;
@@ -794,9 +792,8 @@ static void
CopyInterps(CompatInfo * info,
XkbCompatMapPtr compat, Bool needSymbol, unsigned pred)
{
- SymInterpInfo *si;
-
- for (si = info->interps; si; si = (SymInterpInfo *) si->defs.next)
+ for (SymInterpInfo *si = info->interps; si;
+ si = (SymInterpInfo *) si->defs.next)
{
if (((si->interp.match & XkbSI_OpMask) != pred) ||
(needSymbol && (si->interp.sym == NoSymbol)) ||
@@ -817,10 +814,8 @@ Bool
CompileCompatMap(XkbFile * file,
XkbFileInfo * result, unsigned merge, LEDInfo ** unboundLEDs)
{
- int i;
CompatInfo info;
XkbDescPtr xkb;
- GroupCompatInfo *gcm;
xkb = result->xkb;
InitCompatInfo(&info, xkb);
@@ -830,7 +825,9 @@ CompileCompatMap(XkbFile * file,
if (info.errorCount == 0)
{
- int size;
+ int size, i;
+ GroupCompatInfo *gcm;
+
if (XkbAllocCompatMap(xkb, XkbAllCompatMask, info.nInterps) !=
Success)
{
diff --git a/expr.c b/expr.c
index b5e7222..2c9bb06 100644
--- a/expr.c
+++ b/expr.c
@@ -157,7 +157,6 @@ Bool
SimpleLookup(XPointer priv,
Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
{
- LookupEntry *entry;
char *str;
if ((priv == NULL) ||
@@ -167,7 +166,7 @@ SimpleLookup(XPointer priv,
return False;
}
str = XkbAtomGetString(NULL, field);
- for (entry = (LookupEntry *) priv;
+ for (LookupEntry *entry = (LookupEntry *) priv;
(entry != NULL) && (entry->name != NULL); entry++)
{
if (uStrCaseCmp(str, entry->name) == 0)
@@ -1051,11 +1050,12 @@ ExprResolveKeySym(ExprDef * expr,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
- KeySym sym;
if (expr->op == ExprIdent)
{
char *str;
+ KeySym sym;
+
str = XkbAtomGetString(NULL, expr->value.str);
if ((str != NULL) && ((sym = XStringToKeysym(str)) != NoSymbol))
{
diff --git a/geometry.c b/geometry.c
index 089ebed..46c84f0 100644
--- a/geometry.c
+++ b/geometry.c
@@ -397,14 +397,13 @@ static void
FreeRows(RowInfo * row, SectionInfo * section, GeometryInfo * info)
{
RowInfo *next;
- RowInfo *tmp;
if (row == section->rows)
{
section->nRows = 0;
section->rows = NULL;
}
- for (tmp = row; tmp != NULL; tmp = next)
+ for (RowInfo *tmp = row; tmp != NULL; tmp = next)
{
ClearRowInfo(tmp, info);
next = (RowInfo *) tmp->defs.next;
@@ -1095,9 +1094,7 @@ NextSection(GeometryInfo * info)
static SectionInfo *
FindMatchingSection(GeometryInfo * info, SectionInfo * new)
{
- SectionInfo *old;
-
- for (old = info->sections; old != NULL;
+ for (SectionInfo *old = info->sections; old != NULL;
old = (SectionInfo *) old->defs.next)
{
if (new->name == old->name)
@@ -2550,8 +2547,6 @@ static int
HandleOverlayDef(OverlayDef * def,
unsigned merge, SectionInfo * si, GeometryInfo * info)
{
- OverlayKeyDef *keyDef;
- OverlayKeyInfo *key;
OverlayInfo ol;
if ((def->nKeys < 1) && (warningLevel > 3))
@@ -2565,10 +2560,10 @@ HandleOverlayDef(OverlayDef * def,
bzero(&ol, sizeof(OverlayInfo));
ol.name =
XkbInternAtom(info->dpy, XkbAtomGetString(NULL, def->name), False);
- for (keyDef = def->keys; keyDef;
+ for (OverlayKeyDef *keyDef = def->keys; keyDef;
keyDef = (OverlayKeyDef *) keyDef->common.next)
{
- key = uTypedCalloc(1, OverlayKeyInfo);
+ OverlayKeyInfo *key = uTypedCalloc(1, OverlayKeyInfo);
if (!key)
{
if (warningLevel > 0)
@@ -2599,11 +2594,10 @@ HandleOverlayDef(OverlayDef * def,
static Bool
HandleComplexKey(KeyDef * def, KeyInfo * key, GeometryInfo * info)
{
- RowInfo *row;
- ExprDef *expr;
+ RowInfo *row = key->row;
- row = key->row;
- for (expr = def->expr; expr != NULL; expr = (ExprDef *) expr->common.next)
+ for (ExprDef *expr = def->expr; expr != NULL;
+ expr = (ExprDef *) expr->common.next)
{
if (expr->op == OpAssign)
{
@@ -2657,15 +2651,13 @@ static Bool
HandleRowBody(RowDef * def, RowInfo * row, unsigned merge,
GeometryInfo * info)
{
- KeyDef *keyDef;
-
if ((def->nKeys < 1) && (warningLevel > 3))
{
ERROR("Row in section %s has no keys\n", rowText(info->dpy, row));
ACTION("Section ignored\n");
return True;
}
- for (keyDef = def->keys; keyDef != NULL;
+ for (KeyDef *keyDef = def->keys; keyDef != NULL;
keyDef = (KeyDef *) keyDef->common.next)
{
if (keyDef->common.stmtType == StmtVarDef)
@@ -2729,10 +2721,7 @@ static Bool
HandleSectionBody(SectionDef * def,
SectionInfo * si, unsigned merge, GeometryInfo * info)
{
- RowDef *rowDef;
- DoodadInfo *di;
-
- for (rowDef = def->rows; rowDef != NULL;
+ for (RowDef *rowDef = def->rows; rowDef != NULL;
rowDef = (RowDef *) rowDef->common.next)
{
if (rowDef->common.stmtType == StmtVarDef)
@@ -2740,6 +2729,8 @@ HandleSectionBody(SectionDef * def,
VarDef *var = (VarDef *) rowDef;
ExprResult elem, field;
ExprDef *ndx;
+ DoodadInfo *di;
+
if (ExprResolveLhs(var->name, &elem, &field, &ndx) == 0)
return 0; /* internal error, already reported */
if ((elem.str == NULL) || (uStrCaseCmp(elem.str, "section") == 0))
@@ -2843,7 +2834,6 @@ HandleGeometryFile(XkbFile * file,
XkbDescPtr xkb, unsigned merge, GeometryInfo * info)
{
ParseCommon *stmt;
- const char *failWhat;
if (merge == MergeDefault)
merge = MergeAugment;
@@ -2851,7 +2841,8 @@ HandleGeometryFile(XkbFile * file,
stmt = file->defs;
while (stmt)
{
- failWhat = NULL;
+ const char *failWhat = NULL;
+
switch (stmt->stmtType)
{
case StmtInclude:
@@ -2923,9 +2914,9 @@ HandleGeometryFile(XkbFile * file,
static Bool
CopyShapeDef(Display * dpy, XkbGeometryPtr geom, ShapeInfo * si)
{
- int i, n;
+ int n;
XkbShapePtr shape;
- XkbOutlinePtr old_outline, outline;
+ XkbOutlinePtr old_outline;
Atom name;
si->index = geom->num_shapes;
@@ -2938,9 +2929,11 @@ CopyShapeDef(Display * dpy, XkbGeometryPtr geom, ShapeInfo * si)
return False;
}
old_outline = si->outlines;
- for (i = 0; i < si->nOutlines; i++, old_outline++)
+ for (int i = 0; i < si->nOutlines; i++, old_outline++)
{
- outline = XkbAddGeomOutline(shape, old_outline->num_points);
+ XkbOutlinePtr outline =
+ XkbAddGeomOutline(shape, old_outline->num_points);
+
if (!outline)
{
WSGO("Couldn't allocate outline in shape\n");
@@ -3406,7 +3399,6 @@ VerifyOverlayInfo(XkbGeometryPtr geom,
GeometryInfo * info, short rowMap[256], short rowSize[256])
{
OverlayKeyInfo *ki, *next;
- unsigned long oKey, uKey, sKey;
XkbRowPtr row;
XkbKeyPtr key;
int r, k;
@@ -3414,15 +3406,16 @@ VerifyOverlayInfo(XkbGeometryPtr geom,
/* find out which row each key is in */
for (ki = oi->keys; ki != NULL; ki = (OverlayKeyInfo *) ki->defs.next)
{
- oKey = KeyNameToLong(ki->over);
- uKey = KeyNameToLong(ki->under);
+ unsigned long oKey = KeyNameToLong(ki->over);
+ unsigned long uKey = KeyNameToLong(ki->under);
+
for (r = 0, row = section->rows; (r < section->num_rows) && oKey;
r++, row++)
{
for (k = 0, key = row->keys; (k < row->num_keys) && oKey;
k++, key++)
{
- sKey = KeyNameToLong(key->name.name);
+ unsigned long sKey = KeyNameToLong(key->name.name);
if (sKey == oKey)
{
if (warningLevel > 0)
@@ -3505,11 +3498,7 @@ CopyOverlayDef(XkbGeometryPtr geom,
{
Atom name;
XkbOverlayPtr ol;
- XkbOverlayRowPtr row;
- XkbOverlayKeyPtr key;
- OverlayKeyInfo *ki;
short rowMap[256], rowSize[256];
- int i;
if (!VerifyOverlayInfo(geom, section, oi, info, rowMap, rowSize))
return False;
@@ -3522,7 +3511,7 @@ CopyOverlayDef(XkbGeometryPtr geom,
XkbAtomText(info->dpy, section->name, XkbMessage));
return False;
}
- for (i = 0; i < oi->nRows; i++)
+ for (int i = 0; i < oi->nRows; i++)
{
int tmp, row_under;
for (tmp = 0, row_under = -1;
@@ -3540,10 +3529,11 @@ CopyOverlayDef(XkbGeometryPtr geom,
return False;
}
}
- for (ki = oi->keys; ki != NULL; ki = (OverlayKeyInfo *) ki->defs.next)
+ for (OverlayKeyInfo *ki = oi->keys; ki != NULL;
+ ki = (OverlayKeyInfo *) ki->defs.next)
{
- row = &ol->rows[ki->overlayRow];
- key = &row->keys[row->num_keys++];
+ XkbOverlayRowPtr row = &ol->rows[ki->overlayRow];
+ XkbOverlayKeyPtr key = &row->keys[row->num_keys++];
bzero(key, sizeof(XkbOverlayKeyRec));
strncpy(key->over.name, ki->over, XkbKeyNameLength);
strncpy(key->under.name, ki->under, XkbKeyNameLength);
@@ -3557,10 +3547,6 @@ static Bool
CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info)
{
XkbSectionPtr section;
- XkbRowPtr row;
- XkbKeyPtr key;
- KeyInfo *ki;
- RowInfo *ri;
Atom name;
name = XkbInternAtom(NULL, XkbAtomGetString(NULL, si->name), False);
@@ -3578,9 +3564,9 @@ CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info)
section->height = si->height;
section->angle = si->angle;
section->priority = si->priority;
- for (ri = si->rows; ri != NULL; ri = (RowInfo *) ri->defs.next)
+ for (RowInfo *ri = si->rows; ri != NULL; ri = (RowInfo *) ri->defs.next)
{
- row = XkbAddGeomRow(section, ri->nKeys);
+ XkbRowPtr row = XkbAddGeomRow(section, ri->nKeys);
if (row == NULL)
{
WSGO("Couldn't allocate row in section\n");
@@ -3590,8 +3576,9 @@ CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info)
row->top = ri->top;
row->left = ri->left;
row->vertical = ri->vertical;
- for (ki = ri->keys; ki != NULL; ki = (KeyInfo *) ki->defs.next)
+ for (KeyInfo *ki = ri->keys; ki != NULL; ki = (KeyInfo *) ki->defs.next)
{
+ XkbKeyPtr key;
XkbColorPtr color;
if ((ki->defs.defined & _GK_Name) == 0)
{
@@ -3632,16 +3619,15 @@ CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info)
}
if (si->doodads != NULL)
{
- DoodadInfo *di;
- for (di = si->doodads; di != NULL; di = (DoodadInfo *) di->defs.next)
+ for (DoodadInfo *di = si->doodads; di != NULL;
+ di = (DoodadInfo *) di->defs.next)
{
CopyDoodadDef(geom, section, di, info);
}
}
if (si->overlays != NULL)
{
- OverlayInfo *oi;
- for (oi = si->overlays; oi != NULL;
+ for (OverlayInfo *oi = si->overlays; oi != NULL;
oi = (OverlayInfo *) oi->defs.next)
{
CopyOverlayDef(geom, section, oi, info);
@@ -3724,8 +3710,7 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge)
if (info.props)
{
- PropertyInfo *pi;
- for (pi = info.props; pi != NULL;
+ for (PropertyInfo *pi = info.props; pi != NULL;
pi = (PropertyInfo *) pi->defs.next)
{
if (!XkbAddGeomProperty(geom, pi->name, pi->value))
@@ -3734,8 +3719,7 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge)
}
if (info.shapes)
{
- ShapeInfo *si;
- for (si = info.shapes; si != NULL;
+ for (ShapeInfo *si = info.shapes; si != NULL;
si = (ShapeInfo *) si->defs.next)
{
if (!CopyShapeDef(xkb->dpy, geom, si))
@@ -3744,8 +3728,7 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge)
}
if (info.sections)
{
- SectionInfo *si;
- for (si = info.sections; si != NULL;
+ for (SectionInfo *si = info.sections; si != NULL;
si = (SectionInfo *) si->defs.next)
{
if (!CopySectionDef(geom, si, &info))
@@ -3754,8 +3737,7 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge)
}
if (info.doodads)
{
- DoodadInfo *di;
- for (di = info.doodads; di != NULL;
+ for (DoodadInfo *di = info.doodads; di != NULL;
di = (DoodadInfo *) di->defs.next)
{
if (!CopyDoodadDef(geom, NULL, di, &info))
diff --git a/indicators.c b/indicators.c
index 3ed0bee..4eaa6ae 100644
--- a/indicators.c
+++ b/indicators.c
@@ -60,13 +60,14 @@ LEDInfo *
AddIndicatorMap(LEDInfo * oldLEDs, LEDInfo * new)
{
LEDInfo *old, *last;
- unsigned collide;
last = NULL;
for (old = oldLEDs; old != NULL; old = (LEDInfo *) old->defs.next)
{
if (old->name == new->name)
{
+ unsigned collide;
+
if ((old->real_mods == new->real_mods) &&
(old->vmods == new->vmods) &&
(old->groups == new->groups) &&
@@ -327,8 +328,7 @@ HandleIndicatorMapDef(IndicatorMapDef * def,
XkbDescPtr xkb,
LEDInfo * dflt, LEDInfo * oldLEDs, unsigned merge)
{
- LEDInfo led, *rtrn;
- VarDef *var;
+ LEDInfo led;
Bool ok;
if (def->merge != MergeDefault)
@@ -339,7 +339,8 @@ HandleIndicatorMapDef(IndicatorMapDef * def,
led.name = def->name;
ok = True;
- for (var = def->body; var != NULL; var = (VarDef *) var->common.next)
+ for (VarDef *var = def->body; var != NULL;
+ var = (VarDef *) var->common.next)
{
ExprResult elem, field;
ExprDef *arrayNdx;
@@ -364,7 +365,7 @@ HandleIndicatorMapDef(IndicatorMapDef * def,
}
if (ok)
{
- rtrn = AddIndicatorMap(oldLEDs, &led);
+ LEDInfo *rtrn = AddIndicatorMap(oldLEDs, &led);
return rtrn;
}
return NULL;
@@ -445,7 +446,6 @@ BindIndicators(XkbFileInfo * result,
Bool force, LEDInfo * unbound, LEDInfo ** unboundRtrn)
{
XkbDescPtr xkb;
- int i;
LEDInfo *led, *next, *last;
xkb = result->xkb;
@@ -455,7 +455,7 @@ BindIndicators(XkbFileInfo * result,
{
if (led->indicator == _LED_NotBound)
{
- for (i = 0; i < XkbNumIndicators; i++)
+ for (int i = 0; i < XkbNumIndicators; i++)
{
if (xkb->names->indicators[i] == led->name)
{
@@ -471,7 +471,7 @@ BindIndicators(XkbFileInfo * result,
{
if (led->indicator == _LED_NotBound)
{
- for (i = 0; i < XkbNumIndicators; i++)
+ for (int i = 0; i < XkbNumIndicators; i++)
{
if (xkb->names->indicators[i] == None)
{
diff --git a/keycodes.c b/keycodes.c
index d4b9b5c..6ec4435 100644
--- a/keycodes.c
+++ b/keycodes.c
@@ -130,9 +130,7 @@ NextIndicatorName(KeyNamesInfo * info)
static IndicatorNameInfo *
FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
{
- IndicatorNameInfo *old;
-
- for (old = info->leds; old != NULL;
+ for (IndicatorNameInfo *old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next)
{
if (old->ndx == ndx)
@@ -144,9 +142,7 @@ FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
static IndicatorNameInfo *
FindIndicatorByName(KeyNamesInfo * info, Atom name)
{
- IndicatorNameInfo *old;
-
- for (old = info->leds; old != NULL;
+ for (IndicatorNameInfo *old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next)
{
if (old->name == name)
@@ -200,9 +196,7 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
info->leds = (IndicatorNameInfo *) old->defs.next;
else
{
- IndicatorNameInfo *tmp;
- tmp = info->leds;
- for (; tmp != NULL;
+ for (IndicatorNameInfo *tmp = info->leds; tmp != NULL;
tmp = (IndicatorNameInfo *) tmp->defs.next)
{
if (tmp->defs.next == (CommonInfo *) old)
@@ -307,9 +301,7 @@ InitKeyNamesInfo(KeyNamesInfo * info)
static int
FindKeyByLong(KeyNamesInfo * info, unsigned long name)
{
- int i;
-
- for (i = info->effectiveMin; i <= info->effectiveMax; i++)
+ for (int i = info->effectiveMin; i <= info->effectiveMax; i++)
{
if (info->names[i] == name)
return i;
@@ -435,9 +427,6 @@ static void
MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
unsigned merge)
{
- int i;
- char buf[5];
-
if (from->errorCount > 0)
{
into->errorCount += from->errorCount;
@@ -448,9 +437,11 @@ MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
into->name = from->name;
from->name = NULL;
}
- for (i = from->computedMin; i <= from->computedMax; i++)
+ for (int i = from->computedMin; i <= from->computedMax; i++)
{
unsigned thisMerge;
+ char buf[5];
+
if (from->names[i] == 0)
continue;
LongToKeyName(from->names[i], buf);
@@ -540,11 +531,10 @@ HandleIncludeKeycodes(IncludeStmt * stmt, XkbDescPtr xkb, KeyNamesInfo * info)
/* Do we have more than one include statement? */
if ((stmt->next != NULL) && (included.errorCount < 1))
{
- IncludeStmt *next;
unsigned op;
KeyNamesInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next)
+ for (IncludeStmt *next = stmt->next; next != NULL; next = next->next)
{
if ((next->file == NULL) && (next->map == NULL))
{
diff --git a/keytypes.c b/keytypes.c
index 0735e11..1c11ff8 100644
--- a/keytypes.c
+++ b/keytypes.c
@@ -178,12 +178,12 @@ InitKeyTypesInfo(KeyTypesInfo * info, XkbDescPtr xkb, KeyTypesInfo * from)
}
if (from->dflt.preserve)
{
- PreserveInfo *old, *new, *last;
- last = NULL;
- old = from->dflt.preserve;
- for (; old; old = (PreserveInfo *) old->defs.next)
+ PreserveInfo *last = NULL;
+
+ for (PreserveInfo *old = from->dflt.preserve;
+ old; old = (PreserveInfo *) old->defs.next)
{
- new = uTypedAlloc(PreserveInfo);
+ PreserveInfo *new = uTypedAlloc(PreserveInfo);
if (!new)
return;
*new = *old;
@@ -229,8 +229,8 @@ FreeKeyTypesInfo(KeyTypesInfo * info)
info->name = NULL;
if (info->types)
{
- KeyTypeInfo *type;
- for (type = info->types; type; type = (KeyTypeInfo *) type->defs.next)
+ for (KeyTypeInfo *type = info->types; type;
+ type = (KeyTypeInfo *) type->defs.next)
{
FreeKeyTypeInfo(type);
}
@@ -261,9 +261,8 @@ NextKeyType(KeyTypesInfo * info)
static KeyTypeInfo *
FindMatchingKeyType(KeyTypesInfo * info, KeyTypeInfo * new)
{
- KeyTypeInfo *old;
-
- for (old = info->types; old; old = (KeyTypeInfo *) old->defs.next)
+ for (KeyTypeInfo *old = info->types; old;
+ old = (KeyTypeInfo *) old->defs.next)
{
if (old->name == new->name)
return old;
@@ -368,8 +367,6 @@ static void
MergeIncludedKeyTypes(KeyTypesInfo * into,
KeyTypesInfo * from, unsigned merge, XkbDescPtr xkb)
{
- KeyTypeInfo *type;
-
if (from->errorCount > 0)
{
into->errorCount += from->errorCount;
@@ -380,7 +377,8 @@ MergeIncludedKeyTypes(KeyTypesInfo * into,
into->name = from->name;
from->name = NULL;
}
- for (type = from->types; type; type = (KeyTypeInfo *) type->defs.next)
+ for (KeyTypeInfo *type = from->types; type;
+ type = (KeyTypeInfo *) type->defs.next)
{
if (merge != MergeDefault)
type->defs.merge = merge;
@@ -435,11 +433,10 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
}
if ((stmt->next != NULL) && (included.errorCount < 1))
{
- IncludeStmt *next;
unsigned op;
KeyTypesInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next)
+ for (IncludeStmt *next = stmt->next; next != NULL; next = next->next)
{
if ((next->file == NULL) && (next->map == NULL))
{
@@ -492,13 +489,11 @@ FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
static void
DeleteLevel1MapEntries(KeyTypeInfo * type)
{
- int i, n;
-
- for (i = 0; i < type->nEntries; i++)
+ for (int i = 0; i < type->nEntries; i++)
{
if (type->entries[i].level == 0)
{
- for (n = i; n < type->nEntries - 1; n++)
+ for (int n = i; n < type->nEntries - 1; n++)
{
type->entries[n] = type->entries[n + 1];
}
@@ -882,11 +877,11 @@ SetKeyTypeField(KeyTypeInfo * type,
const char *field,
ExprDef * arrayNdx, ExprDef * value, KeyTypesInfo * info)
{
- ExprResult tmp;
-
if (uStrCaseCmp(field, "modifiers") == 0)
{
+ ExprResult tmp;
unsigned mods, vmods;
+
if (arrayNdx != NULL)
{
WARN("The modifiers field of a key type is not an array\n");
@@ -992,7 +987,6 @@ static int
HandleKeyTypeDef(KeyTypeDef * def,
XkbDescPtr xkb, unsigned merge, KeyTypesInfo * info)
{
- int i;
KeyTypeInfo type;
if (def->merge != MergeDefault)
@@ -1023,7 +1017,7 @@ HandleKeyTypeDef(KeyTypeDef * def,
/* now copy any appropriate map, preserve or level names from the */
/* default type */
- for (i = 0; i < info->dflt.nEntries; i++)
+ for (int i = 0; i < info->dflt.nEntries; i++)
{
XkbKTMapEntryPtr dflt;
dflt = &info->dflt.entries[i];
@@ -1046,7 +1040,7 @@ HandleKeyTypeDef(KeyTypeDef * def,
dflt = (PreserveInfo *) dflt->defs.next;
}
}
- for (i = 0; i < info->dflt.szNames; i++)
+ for (int i = 0; i < info->dflt.szNames; i++)
{
if ((i < type.numLevels) && (info->dflt.lvlNames[i] != None))
{
@@ -1134,10 +1128,7 @@ HandleKeyTypesFile(XkbFile * file,
static Bool
CopyDefToKeyType(XkbDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
{
- int i;
- PreserveInfo *pre;
-
- for (pre = def->preserve; pre != NULL;
+ for (PreserveInfo *pre = def->preserve; pre != NULL;
pre = (PreserveInfo *) pre->defs.next)
{
XkbKTMapEntryPtr match;
@@ -1171,8 +1162,8 @@ CopyDefToKeyType(XkbDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
}
else
{
- pre = def->preserve;
- for (; pre != NULL; pre = (PreserveInfo *) pre->defs.next)
+ for (PreserveInfo *pre = def->preserve; pre != NULL;
+ pre = (PreserveInfo *) pre->defs.next)
{
int ndx = pre->matchingMapIndex;
type->preserve[ndx].mask = pre->preMods;
@@ -1189,7 +1180,7 @@ CopyDefToKeyType(XkbDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
type->level_names = uTypedCalloc(def->numLevels, Atom);
/* assert def->szNames<=def->numLevels */
- for (i = 0; i < def->szNames; i++)
+ for (int i = 0; i < def->szNames; i++)
{
type->level_names[i] = (Atom) def->lvlNames[i];
}
diff --git a/listing.c b/listing.c
index 4c8fe70..92246e2 100644
--- a/listing.c
+++ b/listing.c
@@ -400,13 +400,11 @@ AddMatchingFiles(char *head_in)
static Bool
MapMatches(char *mapToConsider, char *ptrn)
{
- int i;
-
if (ptrn != NULL)
return XkbNameMatchesPattern(mapToConsider, ptrn);
if (nMapOnly < 1)
return True;
- for (i = 0; i < nMapOnly; i++)
+ for (int i = 0; i < nMapOnly; i++)
{
if (XkbNameMatchesPattern(mapToConsider, mapOnly[i]))
return True;
@@ -417,11 +415,8 @@ MapMatches(char *mapToConsider, char *ptrn)
int
GenerateListing(char *out_name)
{
- int i;
- FILE *inputFile, *outFile;
- XkbFile *rtrn, *mapToUse;
- unsigned oldWarningLevel;
- char *mapName;
+ FILE *outFile;
+ XkbFile *rtrn;
if (nFilesListed < 1)
{
@@ -441,8 +436,9 @@ GenerateListing(char *out_name)
if (warningLevel > 9)
fprintf(stderr, "should list:\n");
#endif
- for (i = 0; i < nListed; i++)
+ for (int i = 0; i < nListed; i++)
{
+ unsigned oldWarningLevel;
#ifdef DEBUG
if (warningLevel > 9)
{
@@ -455,6 +451,7 @@ GenerateListing(char *out_name)
warningLevel = 0;
if (list[i].file)
{
+ FILE *inputFile;
struct stat sbuf;
if (stat(list[i].file, &sbuf) < 0)
@@ -480,8 +477,8 @@ GenerateListing(char *out_name)
setScanState(list[i].file, 1);
if (XKBParseFile(inputFile, &rtrn) && (rtrn != NULL))
{
- mapName = list[i].map;
- mapToUse = rtrn;
+ char *mapName = list[i].map;
+ XkbFile *mapToUse = rtrn;
for (; mapToUse; mapToUse = (XkbFile *) mapToUse->common.next)
{
if (!MapMatches(mapToUse->name, mapName))
diff --git a/misc.c b/misc.c
index 498ec71..f2e87c7 100644
--- a/misc.c
+++ b/misc.c
@@ -53,7 +53,6 @@ ProcessIncludeFile(IncludeStmt * stmt,
unsigned file_type,
XkbFile ** file_rtrn, unsigned *merge_rtrn)
{
- FILE *file;
XkbFile *rtrn, *mapToUse;
char oldFile[1024] = {0};
int oldLine = lineNum;
@@ -63,7 +62,7 @@ ProcessIncludeFile(IncludeStmt * stmt,
{
/* file not in cache, open it, parse it and store it in cache for next
time. */
- file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
+ FILE *file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
if (file == NULL)
{
ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
@@ -400,30 +399,29 @@ static KeyNameDesc dfltKeys[] = {
Status
ComputeKbdDefaults(XkbDescPtr xkb)
{
- Status rtrn;
- int i, tmp, nUnknown;
- KeyNameDesc *name;
- KeySym *syms;
- char tmpname[XkbKeyNameLength + 1];
+ int nUnknown;
if ((xkb->names == NULL) || (xkb->names->keys == NULL))
{
+ Status rtrn;
if ((rtrn = XkbAllocNames(xkb, XkbKeyNamesMask, 0, 0)) != Success)
return rtrn;
}
- for (name = dfltKeys; (name->name[0] != '\0'); name++)
+ for (KeyNameDesc *name = dfltKeys; (name->name[0] != '\0'); name++)
{
name->used = False;
}
nUnknown = 0;
- for (i = xkb->min_key_code; i <= xkb->max_key_code; i++)
+ for (int i = xkb->min_key_code; i <= xkb->max_key_code; i++)
{
- tmp = XkbKeyNumSyms(xkb, i);
+ int tmp = XkbKeyNumSyms(xkb, i);
if ((xkb->names->keys[i].name[0] == '\0') && (tmp > 0))
{
+ KeySym *syms;
+
tmp = XkbKeyGroupsWidth(xkb, i);
syms = XkbKeySymsPtr(xkb, i);
- for (name = dfltKeys; (name->name[0] != '\0'); name++)
+ for (KeyNameDesc *name = dfltKeys; (name->name[0] != '\0'); name++)
{
Bool match = True;
if (((name->level1 != syms[0])
@@ -444,6 +442,8 @@ ComputeKbdDefaults(XkbDescPtr xkb)
}
else
{
+ char tmpname[XkbKeyNameLength + 1];
+
if (warningLevel > 2)
{
WARN
@@ -464,6 +464,8 @@ ComputeKbdDefaults(XkbDescPtr xkb)
{
if (warningLevel > 2)
{
+ char tmpname[XkbKeyNameLength + 1];
+
WARN("Key %d does not match any defaults\n", i);
ACTION("Using name <U%03d>\n", nUnknown);
snprintf(tmpname, sizeof(tmpname), "U%03d", nUnknown++);
@@ -494,8 +496,6 @@ FindNamedKey(XkbDescPtr xkb,
unsigned int *kc_rtrn,
Bool use_aliases, Bool create, int start_from)
{
- unsigned n;
-
if (start_from < xkb->min_key_code)
{
start_from = xkb->min_key_code;
@@ -508,7 +508,7 @@ FindNamedKey(XkbDescPtr xkb,
*kc_rtrn = 0; /* some callers rely on this */
if (xkb && xkb->names && xkb->names->keys)
{
- for (n = start_from; n <= xkb->max_key_code; n++)
+ for (unsigned n = start_from; n <= xkb->max_key_code; n++)
{
unsigned long tmp;
tmp = KeyNameToLong(xkb->names->keys[n].name);
@@ -546,7 +546,7 @@ FindNamedKey(XkbDescPtr xkb,
}
}
/* Find first unused keycode and store our key here */
- for (n = xkb->min_key_code; n <= xkb->max_key_code; n++)
+ for (unsigned n = xkb->min_key_code; n <= xkb->max_key_code; n++)
{
if (xkb->names->keys[n].name[0] == '\0')
{
@@ -565,7 +565,6 @@ Bool
FindKeyNameForAlias(XkbDescPtr xkb, unsigned long lname,
unsigned long *real_name)
{
- int i;
char name[XkbKeyNameLength + 1];
if (xkb && xkb->geom && xkb->geom->key_aliases)
@@ -574,7 +573,7 @@ FindKeyNameForAlias(XkbDescPtr xkb, unsigned long lname,
a = xkb->geom->key_aliases;
LongToKeyName(lname, name);
name[XkbKeyNameLength] = '\0';
- for (i = 0; i < xkb->geom->num_key_aliases; i++, a++)
+ for (int i = 0; i < xkb->geom->num_key_aliases; i++, a++)
{
if (strncmp(name, a->alias, XkbKeyNameLength) == 0)
{
@@ -589,7 +588,7 @@ FindKeyNameForAlias(XkbDescPtr xkb, unsigned long lname,
a = xkb->names->key_aliases;
LongToKeyName(lname, name);
name[XkbKeyNameLength] = '\0';
- for (i = 0; i < xkb->names->num_key_aliases; i++, a++)
+ for (int i = 0; i < xkb->names->num_key_aliases; i++, a++)
{
if (strncmp(name, a->alias, XkbKeyNameLength) == 0)
{
diff --git a/parseutils.c b/parseutils.c
index 4b77c4c..d779d76 100644
--- a/parseutils.c
+++ b/parseutils.c
@@ -420,7 +420,6 @@ ShapeDef *
ShapeDeclCreate(Atom name, OutlineDef * outlines)
{
ShapeDef *shape;
- OutlineDef *ol;
shape = uTypedAlloc(ShapeDef);
if (shape != NULL)
@@ -432,7 +431,8 @@ ShapeDeclCreate(Atom name, OutlineDef * outlines)
shape->name = name;
shape->nOutlines = 0;
shape->outlines = outlines;
- for (ol = outlines; ol != NULL; ol = (OutlineDef *) ol->common.next)
+ for (OutlineDef *ol = outlines; ol != NULL;
+ ol = (OutlineDef *) ol->common.next)
{
if (ol->nPoints > 0)
shape->nOutlines++;
@@ -445,7 +445,6 @@ OutlineDef *
OutlineCreate(Atom field, ExprDef * points)
{
OutlineDef *outline;
- ExprDef *pt;
outline = uTypedAlloc(OutlineDef);
if (outline != NULL)
@@ -457,7 +456,8 @@ OutlineCreate(Atom field, ExprDef * points)
outline->nPoints = 0;
if (points->op == ExprCoord)
{
- for (pt = points; pt != NULL; pt = (ExprDef *) pt->common.next)
+ for (ExprDef *pt = points; pt != NULL;
+ pt = (ExprDef *) pt->common.next)
{
outline->nPoints++;
}
@@ -500,7 +500,6 @@ RowDef *
RowDeclCreate(KeyDef * keys)
{
RowDef *row;
- KeyDef *key;
row = uTypedAlloc(RowDef);
if (row != NULL)
@@ -510,7 +509,7 @@ RowDeclCreate(KeyDef * keys)
row->common.next = NULL;
row->nKeys = 0;
row->keys = keys;
- for (key = keys; key != NULL; key = (KeyDef *) key->common.next)
+ for (KeyDef *key = keys; key != NULL; key = (KeyDef *) key->common.next)
{
if (key->common.stmtType == StmtKeyDef)
row->nKeys++;
@@ -523,7 +522,6 @@ SectionDef *
SectionDeclCreate(Atom name, RowDef * rows)
{
SectionDef *section;
- RowDef *row;
section = uTypedAlloc(SectionDef);
if (section != NULL)
@@ -534,7 +532,7 @@ SectionDeclCreate(Atom name, RowDef * rows)
section->name = name;
section->nRows = 0;
section->rows = rows;
- for (row = rows; row != NULL; row = (RowDef *) row->common.next)
+ for (RowDef *row = rows; row != NULL; row = (RowDef *) row->common.next)
{
if (row->common.stmtType == StmtRowDef)
section->nRows++;
@@ -565,7 +563,6 @@ OverlayDef *
OverlayDeclCreate(Atom name, OverlayKeyDef * keys)
{
OverlayDef *ol;
- OverlayKeyDef *key;
ol = uTypedAlloc(OverlayDef);
if (ol != NULL)
@@ -574,7 +571,7 @@ OverlayDeclCreate(Atom name, OverlayKeyDef * keys)
ol->common.stmtType = StmtOverlayDef;
ol->name = name;
ol->keys = keys;
- for (key = keys; key != NULL;
+ for (OverlayKeyDef *key = keys; key != NULL;
key = (OverlayKeyDef *) key->common.next)
{
ol->nKeys++;
@@ -625,7 +622,6 @@ int
LookupKeysym(const char *str, KeySym * sym_rtrn)
{
KeySym sym;
- char *tmp;
if ((!str) || (uStrCaseCmp(str, "any") == 0)
|| (uStrCaseCmp(str, "nosymbol") == 0))
@@ -646,6 +642,8 @@ LookupKeysym(const char *str, KeySym * sym_rtrn)
return 1;
}
if (strlen(str) > 2 && str[0] == '0' && str[1] == 'x') {
+ char *tmp;
+
sym = strtoul(str, &tmp, 16);
if (sym != ULONG_MAX && (!tmp || *tmp == '\0')) {
*sym_rtrn = sym;
@@ -762,10 +760,9 @@ PrintStmtAddrs(ParseCommon * stmt)
static void
CheckDefaultMap(XkbFile * maps)
{
- XkbFile *dflt, *tmp;
+ XkbFile *dflt = NULL;
- dflt = NULL;
- for (tmp = maps, dflt = NULL; tmp != NULL;
+ for (XkbFile *tmp = maps; tmp != NULL;
tmp = (XkbFile *) tmp->common.next)
{
if (tmp->flags & XkbLC_Default)
diff --git a/symbols.c b/symbols.c
index 1b59475..18e9a2b 100644
--- a/symbols.c
+++ b/symbols.c
@@ -81,7 +81,6 @@ typedef struct _KeyInfo
static void
InitKeyInfo(KeyInfo * info)
{
- int i;
static char dflt[4] = "*";
info->defs.defined = 0;
@@ -91,7 +90,7 @@ InitKeyInfo(KeyInfo * info)
info->name = KeyNameToLong(dflt);
info->groupInfo = 0;
info->typesDefined = info->symsDefined = info->actsDefined = 0;
- for (i = 0; i < XkbNumKbdGroups; i++)
+ for (int i = 0; i < XkbNumKbdGroups; i++)
{
info->numLevels[i] = 0;
info->types[i] = None;
@@ -114,15 +113,13 @@ InitKeyInfo(KeyInfo * info)
static void
FreeKeyInfo(KeyInfo * info)
{
- int i;
-
info->defs.defined = 0;
info->defs.fileID = 0;
info->defs.merge = MergeOverride;
info->defs.next = NULL;
info->groupInfo = 0;
info->typesDefined = info->symsDefined = info->actsDefined = 0;
- for (i = 0; i < XkbNumKbdGroups; i++)
+ for (int i = 0; i < XkbNumKbdGroups; i++)
{
info->numLevels[i] = 0;
info->types[i] = None;
@@ -151,13 +148,11 @@ FreeKeyInfo(KeyInfo * info)
static Bool
CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
{
- int i;
-
*new = *old;
new->defs.next = NULL;
if (clearOld)
{
- for (i = 0; i < XkbNumKbdGroups; i++)
+ for (int i = 0; i < XkbNumKbdGroups; i++)
{
old->numLevels[i] = 0;
old->syms[i] = NULL;
@@ -166,10 +161,9 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
}
else
{
- int width;
- for (i = 0; i < XkbNumKbdGroups; i++)
+ for (int i = 0; i < XkbNumKbdGroups; i++)
{
- width = new->numLevels[i];
+ int width = new->numLevels[i];
if (old->syms[i] != NULL)
{
new->syms[i] = uTypedCalloc(width, KeySym);
@@ -237,8 +231,6 @@ typedef struct _SymbolsInfo
static void
InitSymbolsInfo(SymbolsInfo * info, XkbDescPtr xkb)
{
- int i;
-
tok_ONE_LEVEL = XkbInternAtom(NULL, "ONE_LEVEL", False);
tok_TWO_LEVEL = XkbInternAtom(NULL, "TWO_LEVEL", False);
tok_KEYPAD = XkbInternAtom(NULL, "KEYPAD", False);
@@ -252,7 +244,7 @@ InitSymbolsInfo(SymbolsInfo * info, XkbDescPtr xkb)
info->nKeys = 0;
info->keys = uTypedCalloc(SYMBOLS_INIT_SIZE, KeyInfo);
info->modMap = NULL;
- for (i = 0; i < XkbNumKbdGroups; i++)
+ for (int i = 0; i < XkbNumKbdGroups; i++)
info->groupNames[i] = None;
InitKeyInfo(&info->dflt);
InitVModInfo(&info->vmods, xkb);
@@ -264,14 +256,12 @@ InitSymbolsInfo(SymbolsInfo * info, XkbDescPtr xkb)
static void
FreeSymbolsInfo(SymbolsInfo * info)
{
- int i;
-
if (info->name)
uFree(info->name);
info->name = NULL;
if (info->keys)
{
- for (i = 0; i < info->nKeys; i++)
+ for (int i = 0; i < info->nKeys; i++)
{
FreeKeyInfo(&info->keys[i]);
}
@@ -333,7 +323,6 @@ MergeKeyGroups(SymbolsInfo * info,
KeySym *resultSyms;
XkbAction *resultActs;
int resultWidth;
- int i;
Bool report, clobber;
clobber = (from->defs.merge != MergeAugment);
@@ -374,7 +363,7 @@ MergeKeyGroups(SymbolsInfo * info,
return False;
}
}
- for (i = 0; i < resultWidth; i++)
+ for (int i = 0; i < resultWidth; i++)
{
KeySym fromSym, toSym;
if (from->syms[group] && (i < from->numLevels[group]))
@@ -477,13 +466,12 @@ MergeKeyGroups(SymbolsInfo * info,
static Bool
MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
{
- int i;
unsigned collide = 0;
Bool report;
if (from->defs.merge == MergeReplace)
{
- for (i = 0; i < XkbNumKbdGroups; i++)
+ for (int i = 0; i < XkbNumKbdGroups; i++)
{
if (into->numLevels[i] != 0)
{
@@ -500,7 +488,7 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
report = ((warningLevel > 9) ||
((into->defs.fileID == from->defs.fileID)
&& (warningLevel > 0)));
- for (i = 0; i < XkbNumKbdGroups; i++)
+ for (int i = 0; i < XkbNumKbdGroups; i++)
{
if (from->numLevels[i] > 0)
{
@@ -601,17 +589,16 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
static Bool
AddKeySymbols(SymbolsInfo * info, KeyInfo * key, XkbDescPtr xkb)
{
- int i;
unsigned long real_name;
- for (i = 0; i < info->nKeys; i++)
+ for (int i = 0; i < info->nKeys; i++)
{
if (info->keys[i].name == key->name)
return MergeKeys(info, &info->keys[i], key);
}
if (FindKeyNameForAlias(xkb, key->name, &real_name))
{
- for (i = 0; i < info->nKeys; i++)
+ for (int i = 0; i < info->nKeys; i++)
{
if (info->keys[i].name == real_name)
return MergeKeys(info, &info->keys[i], key);
@@ -644,9 +631,10 @@ AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
if (new->haveSymbol && mm->haveSymbol
&& (new->u.keySym == mm->u.keySym))
{
- unsigned use, ignore;
if (mm->modifier != new->modifier)
{
+ unsigned use, ignore;
+
if (clobber)
{
use = new->modifier;
@@ -670,9 +658,10 @@ AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
if ((!new->haveSymbol) && (!mm->haveSymbol) &&
(new->u.keyName == mm->u.keyName))
{
- unsigned use, ignore;
if (mm->modifier != new->modifier)
{
+ unsigned use, ignore;
+
if (clobber)
{
use = new->modifier;
@@ -887,14 +876,13 @@ GetGroupIndex(KeyInfo * key,
if (arrayNdx == NULL)
{
- int i;
unsigned defined;
if (what == SYMBOLS)
defined = key->symsDefined;
else
defined = key->actsDefined;
- for (i = 0; i < XkbNumKbdGroups; i++)
+ for (int i = 0; i < XkbNumKbdGroups; i++)
{
if ((defined & (1 << i)) == 0)
{
@@ -933,7 +921,6 @@ AddSymbolsToKey(KeyInfo * key,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{
unsigned ndx, nSyms;
- int i;
if (!GetGroupIndex(key, arrayNdx, SYMBOLS, &ndx))
return False;
@@ -966,7 +953,7 @@ AddSymbolsToKey(KeyInfo * key,
return False;
}
key->symsDefined |= (1 << ndx);
- for (i = 0; i < nSyms; i++) {
+ for (int i = 0; i < nSyms; i++) {
if (!LookupKeysym(value->value.list.syms[i], &key->syms[ndx][i])) {
if (warningLevel > 0)
{
@@ -976,7 +963,7 @@ AddSymbolsToKey(KeyInfo * key,
key->syms[ndx][i] = NoSymbol;
}
}
- for (i = key->numLevels[ndx] - 1;
+ for (int i = key->numLevels[ndx] - 1;
(i >= 0) && (key->syms[ndx][i] == NoSymbol); i--)
{
key->numLevels[ndx]--;
@@ -990,7 +977,6 @@ AddActionsToKey(KeyInfo * key,
const char *field,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{
- int i;
unsigned ndx, nActs;
ExprDef *act;
XkbAnyAction *toAct;
@@ -1037,7 +1023,7 @@ AddActionsToKey(KeyInfo * key,
toAct = (XkbAnyAction *) key->acts[ndx];
act = value->value.child;
- for (i = 0; i < nActs; i++, toAct++)
+ for (int i = 0; i < nActs; i++, toAct++)
{
if (!HandleActionDef(act, xkb, toAct, MergeOverride, info->action))
{
@@ -1493,8 +1479,6 @@ HandleSymbolsBody(VarDef * def,
XkbDescPtr xkb, KeyInfo * key, SymbolsInfo * info)
{
Bool ok = True;
- ExprResult tmp, field;
- ExprDef *arrayNdx;
for (; def != NULL; def = (VarDef *) def->common.next)
{
@@ -1505,6 +1489,9 @@ HandleSymbolsBody(VarDef * def,
}
else
{
+ ExprResult tmp, field;
+ ExprDef *arrayNdx;
+
if (def->name == NULL)
{
if ((def->value == NULL)
@@ -1536,7 +1523,6 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
if ((key->typesDefined | key->symsDefined | key->actsDefined) & ~1)
{
- int i;
if (warningLevel > 0)
{
WARN("For map %s an explicit group is specified\n", info->name);
@@ -1544,7 +1530,7 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
longText(key->name, XkbMessage));
ACTION("All groups except first one will be ignored\n");
}
- for (i = 1; i < XkbNumKbdGroups; i++)
+ for (int i = 1; i < XkbNumKbdGroups; i++)
{
key->numLevels[i] = 0;
if (key->syms[i] != NULL)
@@ -1603,7 +1589,6 @@ static Bool
HandleModMapDef(ModMapDef * def,
XkbDescPtr xkb, unsigned merge, SymbolsInfo * info)
{
- ExprDef *key;
ModMapEntry tmp;
ExprResult rtrn;
Bool ok;
@@ -1617,7 +1602,8 @@ HandleModMapDef(ModMapDef * def,
}
ok = True;
tmp.modifier = rtrn.uval;
- for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next)
+ for (ExprDef *key = def->keys; key != NULL;
+ key = (ExprDef *) key->common.next)
{
if ((key->op == ExprValue) && (key->type == TypeKeyName))
{
@@ -1706,14 +1692,14 @@ HandleSymbolsFile(XkbFile * file,
static Bool
FindKeyForSymbol(XkbDescPtr xkb, KeySym sym, unsigned int *kc_rtrn)
{
- int i, j;
+ int j;
Bool gotOne;
j = 0;
do
{
gotOne = False;
- for (i = xkb->min_key_code; i <= (int) xkb->max_key_code; i++)
+ for (int i = xkb->min_key_code; i <= (int) xkb->max_key_code; i++)
{
if (j < (int) XkbKeyNumSyms(xkb, i))
{
@@ -1742,11 +1728,9 @@ FindKeyForSymbol(XkbDescPtr xkb, KeySym sym, unsigned int *kc_rtrn)
static Bool
FindNamedType(XkbDescPtr xkb, Atom name, unsigned *type_rtrn)
{
- unsigned n;
-
if (xkb && xkb->map && xkb->map->types)
{
- for (n = 0; n < xkb->map->num_types; n++)
+ for (unsigned n = 0; n < xkb->map->num_types; n++)
{
if (xkb->map->types[n].name == (Atom) name)
{
@@ -1850,7 +1834,7 @@ FindAutomaticType(int width, KeySym * syms, Atom * typeNameRtrn,
static void
PrepareKeyDef(KeyInfo * key)
{
- int i, j, width, defined, lastGroup;
+ int i, defined, lastGroup;
Bool identical;
defined = key->symsDefined | key->actsDefined | key->typesDefined;
@@ -1870,12 +1854,14 @@ PrepareKeyDef(KeyInfo * key)
/* We can make a wrong assumption here. But leaving gaps is worse. */
for (i = lastGroup; i > 0; i--)
{
+ int width;
+
if (defined & (1 << i))
continue;
width = key->numLevels[0];
if (key->typesDefined & 1)
{
- for (j = 0; j < width; j++)
+ for (int j = 0; j < width; j++)
{
key->types[i] = key->types[0];
}
@@ -1961,7 +1947,7 @@ static Bool
CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
{
int i;
- unsigned okc, kc, width, tmp, nGroups;
+ unsigned kc, width, nGroups;
XkbKeyTypePtr type;
Bool haveActions, autoType, useAlias;
KeySym *outSyms;
@@ -2100,7 +2086,7 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
if (key->syms[i] != NULL)
{
/* fill key to "width" symbols*/
- for (tmp = 0; tmp < width; tmp++)
+ for (unsigned tmp = 0; tmp < width; tmp++)
{
if (tmp < key->numLevels[i])
outSyms[tmp] = key->syms[i][tmp];
@@ -2125,6 +2111,8 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
break;
case XkbKB_Overlay1:
case XkbKB_Overlay2:
+ {
+ unsigned okc;
/* find key by name! */
if (!FindNamedKey(xkb, key->nameForOverlayKey, &okc, True,
CreateKeyNames(xkb), 0))
@@ -2140,6 +2128,7 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
break;
}
key->behavior.data = okc;
+ }
default:
xkb->server->behaviors[kc] = key->behavior;
xkb->server->explicit[kc] |= XkbExplicitBehaviorMask;
@@ -2213,7 +2202,6 @@ CopyModMapDef(XkbFileInfo * result, ModMapEntry * entry)
Bool
CompileSymbols(XkbFile * file, XkbFileInfo * result, unsigned merge)
{
- int i;
SymbolsInfo info;
XkbDescPtr xkb;
@@ -2227,6 +2215,7 @@ CompileSymbols(XkbFile * file, XkbFileInfo * result, unsigned merge)
return True;
if (info.errorCount == 0)
{
+ int i;
KeyInfo *key;
/* alloc memory in the xkb struct */
diff --git a/utils.c b/utils.c
index 96f1702..ac920af 100644
--- a/utils.c
+++ b/utils.c
@@ -118,10 +118,9 @@ uSetDebugFile(char *name)
void
uDebug(char *s, ...)
{
- int i;
va_list args;
- for (i = (uDebugIndentLevel * uDebugIndentSize); i > 0; i--)
+ for (int i = (uDebugIndentLevel * uDebugIndentSize); i > 0; i--)
{
putc(' ', uDebugFile);
}
diff --git a/vmod.c b/vmod.c
index 81f2701..af71704 100644
--- a/vmod.c
+++ b/vmod.c
@@ -47,8 +47,6 @@ InitVModInfo(VModInfo * info, XkbDescPtr xkb)
void
ClearVModInfo(VModInfo * info, XkbDescPtr xkb)
{
- int i;
-
if (XkbAllocNames(xkb, XkbVirtualModNamesMask, 0, 0) != Success)
return;
if (XkbAllocServerMap(xkb, XkbVirtualModsMask, 0) != Success)
@@ -57,7 +55,8 @@ ClearVModInfo(VModInfo * info, XkbDescPtr xkb)
info->newlyDefined = info->defined = info->available = 0;
if (xkb && xkb->names)
{
- int bit;
+ int i, bit;
+
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
{
if (xkb->names->vmods[i] != None)
@@ -172,7 +171,6 @@ LookupVModIndex(XPointer priv,
{
int i;
char *fieldStr;
- char *modStr;
XkbDescPtr xkb;
xkb = (XkbDescPtr) priv;
@@ -192,7 +190,7 @@ LookupVModIndex(XPointer priv,
*/
for (i = 0; i < XkbNumVirtualMods; i++)
{
- modStr = XkbAtomGetString(xkb->dpy, xkb->names->vmods[i]);
+ char *modStr = XkbAtomGetString(xkb->dpy, xkb->names->vmods[i]);
if ((modStr != NULL) && (uStrCaseCmp(fieldStr, modStr) == 0))
{
val_rtrn->uval = i;
diff --git a/xkbcomp.c b/xkbcomp.c
index 6d43533..b39ac79 100644
--- a/xkbcomp.c
+++ b/xkbcomp.c
@@ -465,8 +465,7 @@ parseArgs(int argc, char *argv[])
}
else
{
- char *tmp2;
- for (tmp2 = argv[i]; (*tmp2 != '\0'); tmp2++)
+ for (char *tmp2 = argv[i]; (*tmp2 != '\0'); tmp2++)
{
switch (*tmp2)
{
diff --git a/xkbpath.c b/xkbpath.c
index 9f620e6..ee8a91e 100644
--- a/xkbpath.c
+++ b/xkbpath.c
@@ -178,11 +178,9 @@ XkbAddDefaultDirectoriesToPath(void)
void
XkbClearIncludePath(void)
{
- int i;
-
if (szPath > 0)
{
- for (i = 0; i < nPathEntries; i++)
+ for (int i = 0; i < nPathEntries; i++)
{
if (includePath[i] != NULL)
{
@@ -376,17 +374,16 @@ XkbFindFileInCache(char *name, unsigned type, char **pathRtrn)
FILE *
XkbFindFileInPath(char *name, unsigned type, char **pathRtrn)
{
- int i;
FILE *file = NULL;
- int nameLen, typeLen, pathLen;
+ int nameLen, typeLen;
char buf[PATH_MAX], *typeDir;
typeDir = XkbDirectoryForInclude(type);
nameLen = strlen(name);
typeLen = strlen(typeDir);
- for (i = 0; i < nPathEntries; i++)
+ for (int i = 0; i < nPathEntries; i++)
{
- pathLen = strlen(includePath[i]);
+ int pathLen = strlen(includePath[i]);
if (typeLen < 1)
continue;
diff --git a/xkbscan.c b/xkbscan.c
index ff4443e..9334f8a 100644
--- a/xkbscan.c
+++ b/xkbscan.c
@@ -576,7 +576,7 @@ static int numKeywords = sizeof(keywords) / sizeof(struct _Keyword);
static int
yyGetIdent(int first)
{
- int ch, i, j, found;
+ int ch, j, found;
int rtrn = IDENT;
scanBuf[0] = first;
@@ -589,7 +589,7 @@ yyGetIdent(int first)
scanBuf[j++] = '\0';
found = 0;
- for (i = 0; (!found) && (i < numKeywords); i++)
+ for (int i = 0; (!found) && (i < numKeywords); i++)
{
if (uStrCaseCmp(scanBuf, keywords[i].keyword) == 0)
{