summaryrefslogtreecommitdiff
path: root/app/xkbcomp/keycodes.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/xkbcomp/keycodes.c')
-rw-r--r--app/xkbcomp/keycodes.c63
1 files changed, 38 insertions, 25 deletions
diff --git a/app/xkbcomp/keycodes.c b/app/xkbcomp/keycodes.c
index a9dc2b4a3..4a8973c95 100644
--- a/app/xkbcomp/keycodes.c
+++ b/app/xkbcomp/keycodes.c
@@ -89,7 +89,7 @@ static void HandleKeycodesFile(XkbFile * file,
KeyNamesInfo * info);
static void
-InitIndicatorNameInfo(IndicatorNameInfo *ii, const KeyNamesInfo *info)
+InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
{
ii->defs.defined = 0;
ii->defs.merge = info->merge;
@@ -117,7 +117,7 @@ NextIndicatorName(KeyNamesInfo * info)
{
IndicatorNameInfo *ii;
- ii = malloc(sizeof(IndicatorNameInfo));
+ ii = uTypedAlloc(IndicatorNameInfo);
if (ii)
{
InitIndicatorNameInfo(ii, info);
@@ -130,7 +130,9 @@ NextIndicatorName(KeyNamesInfo * info)
static IndicatorNameInfo *
FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
{
- for (IndicatorNameInfo *old = info->leds; old != NULL;
+ IndicatorNameInfo *old;
+
+ for (old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next)
{
if (old->ndx == ndx)
@@ -142,7 +144,9 @@ FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
static IndicatorNameInfo *
FindIndicatorByName(KeyNamesInfo * info, Atom name)
{
- for (IndicatorNameInfo *old = info->leds; old != NULL;
+ IndicatorNameInfo *old;
+
+ for (old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next)
{
if (old->name == name)
@@ -196,7 +200,9 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
info->leds = (IndicatorNameInfo *) old->defs.next;
else
{
- for (IndicatorNameInfo *tmp = info->leds; tmp != NULL;
+ IndicatorNameInfo *tmp;
+ tmp = info->leds;
+ for (; tmp != NULL;
tmp = (IndicatorNameInfo *) tmp->defs.next)
{
if (tmp->defs.next == (CommonInfo *) old)
@@ -206,7 +212,7 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
}
}
}
- free(old);
+ uFree(old);
}
}
}
@@ -270,15 +276,16 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
static void
ClearKeyNamesInfo(KeyNamesInfo * info)
{
- free(info->name);
+ if (info->name != NULL)
+ uFree(info->name);
info->name = NULL;
info->computedMax = info->explicitMax = info->explicitMin = -1;
info->computedMin = 256;
info->effectiveMin = 8;
info->effectiveMax = 255;
- bzero(info->names, sizeof(info->names));
- bzero(info->files, sizeof(info->files));
- bzero(info->has_alt_forms, sizeof(info->has_alt_forms));
+ bzero((char *) info->names, sizeof(info->names));
+ bzero((char *) info->files, sizeof(info->files));
+ bzero((char *) info->has_alt_forms, sizeof(info->has_alt_forms));
if (info->leds)
ClearIndicatorNameInfo(info->leds, info);
if (info->aliases)
@@ -298,9 +305,11 @@ InitKeyNamesInfo(KeyNamesInfo * info)
}
static int
-FindKeyByLong(const KeyNamesInfo *info, unsigned long name)
+FindKeyByLong(KeyNamesInfo * info, unsigned long name)
{
- for (int i = info->effectiveMin; i <= info->effectiveMax; i++)
+ register int i;
+
+ for (i = info->effectiveMin; i <= info->effectiveMax; i++)
{
if (info->names[i] == name)
return i;
@@ -314,8 +323,9 @@ FindKeyByLong(const KeyNamesInfo *info, unsigned long name)
* Note that the key's name is stored as a long, the keycode is the index.
*/
static Bool
-AddKeyName(KeyNamesInfo *info, int kc, const char *name,
- unsigned merge, unsigned fileID, Bool reportCollisions)
+AddKeyName(KeyNamesInfo * info,
+ int kc,
+ char *name, unsigned merge, unsigned fileID, Bool reportCollisions)
{
int old;
unsigned long lval;
@@ -425,6 +435,9 @@ static void
MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
unsigned merge)
{
+ register int i;
+ char buf[5];
+
if (from->errorCount > 0)
{
into->errorCount += from->errorCount;
@@ -435,11 +448,9 @@ MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
into->name = from->name;
from->name = NULL;
}
- for (int i = from->computedMin; i <= from->computedMax; i++)
+ for (i = from->computedMin; i <= from->computedMax; i++)
{
unsigned thisMerge;
- char buf[5];
-
if (from->names[i] == 0)
continue;
LongToKeyName(from->names[i], buf);
@@ -515,7 +526,8 @@ HandleIncludeKeycodes(IncludeStmt * stmt, XkbDescPtr xkb, KeyNamesInfo * info)
HandleKeycodesFile(rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
- free(included.name);
+ if (included.name != NULL)
+ uFree(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@@ -528,10 +540,11 @@ 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 (IncludeStmt *next = stmt->next; next != NULL; next = next->next)
+ for (next = stmt->next; next != NULL; next = next->next)
{
if ((next->file == NULL) && (next->map == NULL))
{
@@ -568,7 +581,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, XkbDescPtr xkb, KeyNamesInfo * info)
* e.g. <ESC> = 9
*/
static int
-HandleKeycodeDef(const KeycodeDef *stmt, unsigned merge, KeyNamesInfo *info)
+HandleKeycodeDef(KeycodeDef * stmt, unsigned merge, KeyNamesInfo * info)
{
int code;
ExprResult result;
@@ -609,7 +622,7 @@ HandleKeycodeDef(const KeycodeDef *stmt, unsigned merge, KeyNamesInfo *info)
* @return 1 on success, 0 otherwise.
*/
static int
-HandleKeyNameVar(const VarDef *stmt, KeyNamesInfo *info)
+HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
{
ExprResult tmp, field;
ExprDef *arrayNdx;
@@ -707,7 +720,7 @@ HandleKeyNameVar(const VarDef *stmt, KeyNamesInfo *info)
}
static int
-HandleIndicatorNameDef(const IndicatorNameDef *def,
+HandleIndicatorNameDef(IndicatorNameDef * def,
unsigned merge, KeyNamesInfo * info)
{
IndicatorNameInfo ii;
@@ -847,7 +860,7 @@ CompileKeycodes(XkbFile * file, XkbFileInfo * result, unsigned merge)
if (XkbAllocNames(xkb, XkbKeyNamesMask | XkbIndicatorNamesMask, 0, 0)
== Success)
{
- int i;
+ register int i;
xkb->names->keycodes = XkbInternAtom(xkb->dpy, info.name, False);
uDEBUG2(1, "key range: %d..%d\n", xkb->min_key_code,
xkb->max_key_code);
@@ -879,8 +892,8 @@ CompileKeycodes(XkbFile * file, XkbFileInfo * result, unsigned merge)
XkbAtomGetString(NULL, ii->name), False);
if (xkb->indicators != NULL)
{
- unsigned bit = 1U << (ii->ndx - 1);
-
+ register unsigned bit;
+ bit = 1 << (ii->ndx - 1);
if (ii->virtual)
xkb->indicators->phys_indicators &= ~bit;
else