summaryrefslogtreecommitdiff
path: root/app/xkbcomp/misc.c
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu@cvs.openbsd.org>2024-05-04 09:53:36 +0000
committerMatthieu Herrb <matthieu@cvs.openbsd.org>2024-05-04 09:53:36 +0000
commit4aee1dfe48599aa35e8c060a981e593624676da4 (patch)
tree34e5ea33e2133249d05ab854ba5520021d53740f /app/xkbcomp/misc.c
parentd8ed9f2d52e8459079947e2f774e3e37022c49af (diff)
Revert to xkbcomp 1.4.6. for now.
version 1.4.7 has memory management issues found by mbuhl@
Diffstat (limited to 'app/xkbcomp/misc.c')
-rw-r--r--app/xkbcomp/misc.c267
1 files changed, 130 insertions, 137 deletions
diff --git a/app/xkbcomp/misc.c b/app/xkbcomp/misc.c
index 0b5f4330a..5faa6c1cb 100644
--- a/app/xkbcomp/misc.c
+++ b/app/xkbcomp/misc.c
@@ -53,6 +53,7 @@ ProcessIncludeFile(IncludeStmt * stmt,
unsigned file_type,
XkbFile ** file_rtrn, unsigned *merge_rtrn)
{
+ FILE *file;
XkbFile *rtrn, *mapToUse;
char oldFile[1024] = {0};
int oldLine = lineNum;
@@ -62,7 +63,7 @@ ProcessIncludeFile(IncludeStmt * stmt,
{
/* file not in cache, open it, parse it and store it in cache for next
time. */
- FILE *file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
+ file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
if (file == NULL)
{
ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
@@ -73,10 +74,8 @@ ProcessIncludeFile(IncludeStmt * stmt,
strcpy(oldFile, scanFile);
oldLine = lineNum;
setScanState(stmt->file, 1);
-#ifdef DEBUG
if (debugFlags & 2)
INFO("About to parse include file %s\n", stmt->file);
-#endif
/* parse the file */
if ((XKBParseFile(file, &rtrn) == 0) || (rtrn == NULL))
{
@@ -177,7 +176,6 @@ ReportBadType(const char *type, const char *field,
return False;
}
-#if 0
int
ReportBadIndexType(char *type, char *field, char *name, char *wanted)
{
@@ -185,7 +183,6 @@ ReportBadIndexType(char *type, char *field, char *name, char *wanted)
ACTION("Ignoring assignment to illegal field in %s\n", name);
return False;
}
-#endif
int
ReportBadField(const char *type, const char *field, const char *name)
@@ -195,7 +192,6 @@ ReportBadField(const char *type, const char *field, const char *name)
return False;
}
-#if 0
int
ReportMultipleDefs(char *type, char *field, char *name)
{
@@ -203,13 +199,12 @@ ReportMultipleDefs(char *type, char *field, char *name)
ACTION("Using last definition\n");
return False;
}
-#endif
/***====================================================================***/
Bool
-UseNewField(unsigned field, const CommonInfo *oldDefs,
- const CommonInfo *newDefs, unsigned *pCollide)
+UseNewField(unsigned field,
+ CommonInfo * oldDefs, CommonInfo * newDefs, unsigned *pCollide)
{
Bool useNew;
@@ -232,10 +227,9 @@ UseNewField(unsigned field, const CommonInfo *oldDefs,
return useNew;
}
-#if 0
-static Bool
-MergeNewField(unsigned field, const CommonInfo *oldDefs,
- const CommonInfo *newDefs, unsigned *pCollide)
+Bool
+MergeNewField(unsigned field,
+ CommonInfo * oldDefs, CommonInfo * newDefs, unsigned *pCollide)
{
if ((oldDefs->defined & field) && (newDefs->defined & field))
{
@@ -249,7 +243,6 @@ MergeNewField(unsigned field, const CommonInfo *oldDefs,
}
return False;
}
-#endif
XPointer
ClearCommonInfo(CommonInfo * cmn)
@@ -260,7 +253,7 @@ ClearCommonInfo(CommonInfo * cmn)
for (this = cmn; this != NULL; this = next)
{
next = this->next;
- free(this);
+ uFree(this);
}
}
return NULL;
@@ -296,140 +289,141 @@ typedef struct _KeyNameDesc
} KeyNameDesc;
static KeyNameDesc dfltKeys[] = {
- {XK_Escape, NoSymbol, "ESC\0", 0},
- {XK_quoteleft, XK_asciitilde, "TLDE", 0},
- {XK_1, XK_exclam, "AE01", 0},
- {XK_2, XK_at, "AE02", 0},
- {XK_3, XK_numbersign, "AE03", 0},
- {XK_4, XK_dollar, "AE04", 0},
- {XK_5, XK_percent, "AE05", 0},
- {XK_6, XK_asciicircum, "AE06", 0},
- {XK_7, XK_ampersand, "AE07", 0},
- {XK_8, XK_asterisk, "AE08", 0},
- {XK_9, XK_parenleft, "AE09", 0},
- {XK_0, XK_parenright, "AE10", 0},
- {XK_minus, XK_underscore, "AE11", 0},
- {XK_equal, XK_plus, "AE12", 0},
- {XK_BackSpace, NoSymbol, "BKSP", 0},
- {XK_Tab, NoSymbol, "TAB\0", 0},
- {XK_q, XK_Q, "AD01", 0},
- {XK_w, XK_W, "AD02", 0},
- {XK_e, XK_E, "AD03", 0},
- {XK_r, XK_R, "AD04", 0},
- {XK_t, XK_T, "AD05", 0},
- {XK_y, XK_Y, "AD06", 0},
- {XK_u, XK_U, "AD07", 0},
- {XK_i, XK_I, "AD08", 0},
- {XK_o, XK_O, "AD09", 0},
- {XK_p, XK_P, "AD10", 0},
- {XK_bracketleft, XK_braceleft, "AD11", 0},
- {XK_bracketright, XK_braceright, "AD12", 0},
- {XK_Return, NoSymbol, "RTRN", 0},
- {XK_Caps_Lock, NoSymbol, "CAPS", 0},
- {XK_a, XK_A, "AC01", 0},
- {XK_s, XK_S, "AC02", 0},
- {XK_d, XK_D, "AC03", 0},
- {XK_f, XK_F, "AC04", 0},
- {XK_g, XK_G, "AC05", 0},
- {XK_h, XK_H, "AC06", 0},
- {XK_j, XK_J, "AC07", 0},
- {XK_k, XK_K, "AC08", 0},
- {XK_l, XK_L, "AC09", 0},
- {XK_semicolon, XK_colon, "AC10", 0},
- {XK_quoteright, XK_quotedbl, "AC11", 0},
- {XK_Shift_L, NoSymbol, "LFSH", 0},
- {XK_z, XK_Z, "AB01", 0},
- {XK_x, XK_X, "AB02", 0},
- {XK_c, XK_C, "AB03", 0},
- {XK_v, XK_V, "AB04", 0},
- {XK_b, XK_B, "AB05", 0},
- {XK_n, XK_N, "AB06", 0},
- {XK_m, XK_M, "AB07", 0},
- {XK_comma, XK_less, "AB08", 0},
- {XK_period, XK_greater, "AB09", 0},
- {XK_slash, XK_question, "AB10", 0},
- {XK_backslash, XK_bar, "BKSL", 0},
- {XK_Control_L, NoSymbol, "LCTL", 0},
- {XK_space, NoSymbol, "SPCE", 0},
- {XK_Shift_R, NoSymbol, "RTSH", 0},
- {XK_Alt_L, NoSymbol, "LALT", 0},
- {XK_space, NoSymbol, "SPCE", 0},
- {XK_Control_R, NoSymbol, "RCTL", 0},
- {XK_Alt_R, NoSymbol, "RALT", 0},
- {XK_F1, NoSymbol, "FK01", 0},
- {XK_F2, NoSymbol, "FK02", 0},
- {XK_F3, NoSymbol, "FK03", 0},
- {XK_F4, NoSymbol, "FK04", 0},
- {XK_F5, NoSymbol, "FK05", 0},
- {XK_F6, NoSymbol, "FK06", 0},
- {XK_F7, NoSymbol, "FK07", 0},
- {XK_F8, NoSymbol, "FK08", 0},
- {XK_F9, NoSymbol, "FK09", 0},
- {XK_F10, NoSymbol, "FK10", 0},
- {XK_F11, NoSymbol, "FK11", 0},
- {XK_F12, NoSymbol, "FK12", 0},
- {XK_Print, NoSymbol, "PRSC", 0},
- {XK_Scroll_Lock, NoSymbol, "SCLK", 0},
- {XK_Pause, NoSymbol, "PAUS", 0},
- {XK_Insert, NoSymbol, "INS\0", 0},
- {XK_Home, NoSymbol, "HOME", 0},
- {XK_Prior, NoSymbol, "PGUP", 0},
- {XK_Delete, NoSymbol, "DELE", 0},
- {XK_End, NoSymbol, "END", 0},
- {XK_Next, NoSymbol, "PGDN", 0},
- {XK_Up, NoSymbol, "UP\0\0", 0},
- {XK_Left, NoSymbol, "LEFT", 0},
- {XK_Down, NoSymbol, "DOWN", 0},
- {XK_Right, NoSymbol, "RGHT", 0},
- {XK_Num_Lock, NoSymbol, "NMLK", 0},
- {XK_KP_Divide, NoSymbol, "KPDV", 0},
- {XK_KP_Multiply, NoSymbol, "KPMU", 0},
- {XK_KP_Subtract, NoSymbol, "KPSU", 0},
- {NoSymbol, XK_KP_7, "KP7\0", 0},
- {NoSymbol, XK_KP_8, "KP8\0", 0},
- {NoSymbol, XK_KP_9, "KP9\0", 0},
- {XK_KP_Add, NoSymbol, "KPAD", 0},
- {NoSymbol, XK_KP_4, "KP4\0", 0},
- {NoSymbol, XK_KP_5, "KP5\0", 0},
- {NoSymbol, XK_KP_6, "KP6\0", 0},
- {NoSymbol, XK_KP_1, "KP1\0", 0},
- {NoSymbol, XK_KP_2, "KP2\0", 0},
- {NoSymbol, XK_KP_3, "KP3\0", 0},
- {XK_KP_Enter, NoSymbol, "KPEN", 0},
- {NoSymbol, XK_KP_0, "KP0\0", 0},
- {XK_KP_Delete, NoSymbol, "KPDL", 0},
- {XK_less, XK_greater, "LSGT", 0},
- {XK_KP_Separator, NoSymbol, "KPCO", 0},
- {XK_Find, NoSymbol, "FIND", 0},
- {NoSymbol, NoSymbol, "\0\0\0\0", 0}
+ {XK_Escape, NoSymbol, "ESC\0"},
+ {XK_quoteleft, XK_asciitilde, "TLDE"},
+ {XK_1, XK_exclam, "AE01"},
+ {XK_2, XK_at, "AE02"},
+ {XK_3, XK_numbersign, "AE03"},
+ {XK_4, XK_dollar, "AE04"},
+ {XK_5, XK_percent, "AE05"},
+ {XK_6, XK_asciicircum, "AE06"},
+ {XK_7, XK_ampersand, "AE07"},
+ {XK_8, XK_asterisk, "AE08"},
+ {XK_9, XK_parenleft, "AE09"},
+ {XK_0, XK_parenright, "AE10"},
+ {XK_minus, XK_underscore, "AE11"},
+ {XK_equal, XK_plus, "AE12"},
+ {XK_BackSpace, NoSymbol, "BKSP"},
+ {XK_Tab, NoSymbol, "TAB\0"},
+ {XK_q, XK_Q, "AD01"},
+ {XK_w, XK_W, "AD02"},
+ {XK_e, XK_E, "AD03"},
+ {XK_r, XK_R, "AD04"},
+ {XK_t, XK_T, "AD05"},
+ {XK_y, XK_Y, "AD06"},
+ {XK_u, XK_U, "AD07"},
+ {XK_i, XK_I, "AD08"},
+ {XK_o, XK_O, "AD09"},
+ {XK_p, XK_P, "AD10"},
+ {XK_bracketleft, XK_braceleft, "AD11"},
+ {XK_bracketright, XK_braceright, "AD12"},
+ {XK_Return, NoSymbol, "RTRN"},
+ {XK_Caps_Lock, NoSymbol, "CAPS"},
+ {XK_a, XK_A, "AC01"},
+ {XK_s, XK_S, "AC02"},
+ {XK_d, XK_D, "AC03"},
+ {XK_f, XK_F, "AC04"},
+ {XK_g, XK_G, "AC05"},
+ {XK_h, XK_H, "AC06"},
+ {XK_j, XK_J, "AC07"},
+ {XK_k, XK_K, "AC08"},
+ {XK_l, XK_L, "AC09"},
+ {XK_semicolon, XK_colon, "AC10"},
+ {XK_quoteright, XK_quotedbl, "AC11"},
+ {XK_Shift_L, NoSymbol, "LFSH"},
+ {XK_z, XK_Z, "AB01"},
+ {XK_x, XK_X, "AB02"},
+ {XK_c, XK_C, "AB03"},
+ {XK_v, XK_V, "AB04"},
+ {XK_b, XK_B, "AB05"},
+ {XK_n, XK_N, "AB06"},
+ {XK_m, XK_M, "AB07"},
+ {XK_comma, XK_less, "AB08"},
+ {XK_period, XK_greater, "AB09"},
+ {XK_slash, XK_question, "AB10"},
+ {XK_backslash, XK_bar, "BKSL"},
+ {XK_Control_L, NoSymbol, "LCTL"},
+ {XK_space, NoSymbol, "SPCE"},
+ {XK_Shift_R, NoSymbol, "RTSH"},
+ {XK_Alt_L, NoSymbol, "LALT"},
+ {XK_space, NoSymbol, "SPCE"},
+ {XK_Control_R, NoSymbol, "RCTL"},
+ {XK_Alt_R, NoSymbol, "RALT"},
+ {XK_F1, NoSymbol, "FK01"},
+ {XK_F2, NoSymbol, "FK02"},
+ {XK_F3, NoSymbol, "FK03"},
+ {XK_F4, NoSymbol, "FK04"},
+ {XK_F5, NoSymbol, "FK05"},
+ {XK_F6, NoSymbol, "FK06"},
+ {XK_F7, NoSymbol, "FK07"},
+ {XK_F8, NoSymbol, "FK08"},
+ {XK_F9, NoSymbol, "FK09"},
+ {XK_F10, NoSymbol, "FK10"},
+ {XK_F11, NoSymbol, "FK11"},
+ {XK_F12, NoSymbol, "FK12"},
+ {XK_Print, NoSymbol, "PRSC"},
+ {XK_Scroll_Lock, NoSymbol, "SCLK"},
+ {XK_Pause, NoSymbol, "PAUS"},
+ {XK_Insert, NoSymbol, "INS\0"},
+ {XK_Home, NoSymbol, "HOME"},
+ {XK_Prior, NoSymbol, "PGUP"},
+ {XK_Delete, NoSymbol, "DELE"},
+ {XK_End, NoSymbol, "END"},
+ {XK_Next, NoSymbol, "PGDN"},
+ {XK_Up, NoSymbol, "UP\0\0"},
+ {XK_Left, NoSymbol, "LEFT"},
+ {XK_Down, NoSymbol, "DOWN"},
+ {XK_Right, NoSymbol, "RGHT"},
+ {XK_Num_Lock, NoSymbol, "NMLK"},
+ {XK_KP_Divide, NoSymbol, "KPDV"},
+ {XK_KP_Multiply, NoSymbol, "KPMU"},
+ {XK_KP_Subtract, NoSymbol, "KPSU"},
+ {NoSymbol, XK_KP_7, "KP7\0"},
+ {NoSymbol, XK_KP_8, "KP8\0"},
+ {NoSymbol, XK_KP_9, "KP9\0"},
+ {XK_KP_Add, NoSymbol, "KPAD"},
+ {NoSymbol, XK_KP_4, "KP4\0"},
+ {NoSymbol, XK_KP_5, "KP5\0"},
+ {NoSymbol, XK_KP_6, "KP6\0"},
+ {NoSymbol, XK_KP_1, "KP1\0"},
+ {NoSymbol, XK_KP_2, "KP2\0"},
+ {NoSymbol, XK_KP_3, "KP3\0"},
+ {XK_KP_Enter, NoSymbol, "KPEN"},
+ {NoSymbol, XK_KP_0, "KP0\0"},
+ {XK_KP_Delete, NoSymbol, "KPDL"},
+ {XK_less, XK_greater, "LSGT"},
+ {XK_KP_Separator, NoSymbol, "KPCO"},
+ {XK_Find, NoSymbol, "FIND"},
+ {NoSymbol, NoSymbol, "\0\0\0\0"}
};
Status
ComputeKbdDefaults(XkbDescPtr xkb)
{
- int nUnknown;
+ Status rtrn;
+ register int i, tmp, nUnknown;
+ KeyNameDesc *name;
+ KeySym *syms;
+ char tmpname[XkbKeyNameLength + 1];
if ((xkb->names == NULL) || (xkb->names->keys == NULL))
{
- Status rtrn;
if ((rtrn = XkbAllocNames(xkb, XkbKeyNamesMask, 0, 0)) != Success)
return rtrn;
}
- for (KeyNameDesc *name = dfltKeys; (name->name[0] != '\0'); name++)
+ for (name = dfltKeys; (name->name[0] != '\0'); name++)
{
name->used = False;
}
nUnknown = 0;
- for (int i = xkb->min_key_code; i <= xkb->max_key_code; i++)
+ for (i = xkb->min_key_code; i <= xkb->max_key_code; i++)
{
- int tmp = XkbKeyNumSyms(xkb, i);
+ 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 (KeyNameDesc *name = dfltKeys; (name->name[0] != '\0'); name++)
+ for (name = dfltKeys; (name->name[0] != '\0'); name++)
{
Bool match = True;
if (((name->level1 != syms[0])
@@ -450,8 +444,6 @@ ComputeKbdDefaults(XkbDescPtr xkb)
}
else
{
- char tmpname[XkbKeyNameLength + 1];
-
if (warningLevel > 2)
{
WARN
@@ -472,8 +464,6 @@ 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++);
@@ -504,6 +494,8 @@ FindNamedKey(XkbDescPtr xkb,
unsigned int *kc_rtrn,
Bool use_aliases, Bool create, int start_from)
{
+ register unsigned n;
+
if (start_from < xkb->min_key_code)
{
start_from = xkb->min_key_code;
@@ -516,7 +508,7 @@ FindNamedKey(XkbDescPtr xkb,
*kc_rtrn = 0; /* some callers rely on this */
if (xkb && xkb->names && xkb->names->keys)
{
- for (unsigned n = start_from; n <= xkb->max_key_code; n++)
+ for (n = start_from; n <= xkb->max_key_code; n++)
{
unsigned long tmp;
tmp = KeyNameToLong(xkb->names->keys[n].name);
@@ -554,7 +546,7 @@ FindNamedKey(XkbDescPtr xkb,
}
}
/* Find first unused keycode and store our key here */
- for (unsigned n = xkb->min_key_code; n <= xkb->max_key_code; n++)
+ for (n = xkb->min_key_code; n <= xkb->max_key_code; n++)
{
if (xkb->names->keys[n].name[0] == '\0')
{
@@ -573,6 +565,7 @@ Bool
FindKeyNameForAlias(XkbDescPtr xkb, unsigned long lname,
unsigned long *real_name)
{
+ register int i;
char name[XkbKeyNameLength + 1];
if (xkb && xkb->geom && xkb->geom->key_aliases)
@@ -581,7 +574,7 @@ FindKeyNameForAlias(XkbDescPtr xkb, unsigned long lname,
a = xkb->geom->key_aliases;
LongToKeyName(lname, name);
name[XkbKeyNameLength] = '\0';
- for (int i = 0; i < xkb->geom->num_key_aliases; i++, a++)
+ for (i = 0; i < xkb->geom->num_key_aliases; i++, a++)
{
if (strncmp(name, a->alias, XkbKeyNameLength) == 0)
{
@@ -596,7 +589,7 @@ FindKeyNameForAlias(XkbDescPtr xkb, unsigned long lname,
a = xkb->names->key_aliases;
LongToKeyName(lname, name);
name[XkbKeyNameLength] = '\0';
- for (int i = 0; i < xkb->names->num_key_aliases; i++, a++)
+ for (i = 0; i < xkb->names->num_key_aliases; i++, a++)
{
if (strncmp(name, a->alias, XkbKeyNameLength) == 0)
{