summaryrefslogtreecommitdiff
path: root/keytypes.c
diff options
context:
space:
mode:
Diffstat (limited to 'keytypes.c')
-rw-r--r--keytypes.c53
1 files changed, 22 insertions, 31 deletions
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];
}