Merge remote-tracking branch 'ran/fixes-cont'
Conflicts: src/xkbcomp/expr.c Signed-off-by: Daniel Stone <daniel@fooishbar.org>master
commit
ed18e65eac
|
@ -39,7 +39,7 @@ authorization from the authors.
|
|||
#define _XkbTypedCalloc(n,t) ((t *)calloc((n),sizeof(t)))
|
||||
#define _XkbTypedRealloc(o,n,t) \
|
||||
((o)?(t *)realloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
|
||||
#define _XkbClearElems(a,f,l,t) bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
|
||||
#define _XkbClearElems(a,f,l,t) memset(&(a)[f], 0, ((l) - (f) + 1) * sizeof(t))
|
||||
|
||||
#define _XkbDupString(s) ((s) ? strdup(s) : NULL)
|
||||
#define _XkbStrCaseCmp strcasecmp
|
||||
|
|
109
src/alloc.c
109
src/alloc.c
|
@ -79,7 +79,7 @@ XkbcAllocCompatMap(struct xkb_desc * xkb, unsigned which, unsigned nSI)
|
|||
}
|
||||
compat->size_si = nSI;
|
||||
compat->num_si = 0;
|
||||
bzero(&compat->groups[0], XkbNumKbdGroups * sizeof(struct xkb_mods));
|
||||
memset(&compat->groups[0], 0, XkbNumKbdGroups * sizeof(struct xkb_mods));
|
||||
xkb->compat = compat;
|
||||
|
||||
return Success;
|
||||
|
@ -87,7 +87,7 @@ XkbcAllocCompatMap(struct xkb_desc * xkb, unsigned which, unsigned nSI)
|
|||
|
||||
|
||||
static void
|
||||
XkbcFreeCompatMap(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
||||
XkbcFreeCompatMap(struct xkb_desc * xkb)
|
||||
{
|
||||
struct xkb_compat_map * compat;
|
||||
|
||||
|
@ -95,23 +95,10 @@ XkbcFreeCompatMap(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
|||
return;
|
||||
|
||||
compat = xkb->compat;
|
||||
if (freeMap)
|
||||
which = XkbAllCompatMask;
|
||||
|
||||
if (which & XkbGroupCompatMask)
|
||||
bzero(&compat->groups[0], XkbNumKbdGroups * sizeof(struct xkb_mods));
|
||||
|
||||
if (which & XkbSymInterpMask) {
|
||||
if (compat->sym_interpret && (compat->size_si > 0))
|
||||
free(compat->sym_interpret);
|
||||
compat->size_si = compat->num_si = 0;
|
||||
compat->sym_interpret = NULL;
|
||||
}
|
||||
|
||||
if (freeMap) {
|
||||
free(compat);
|
||||
xkb->compat = NULL;
|
||||
}
|
||||
free(compat->sym_interpret);
|
||||
free(compat);
|
||||
xkb->compat = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -202,55 +189,32 @@ XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalRG, int nTotalAl
|
|||
}
|
||||
|
||||
static void
|
||||
XkbcFreeNames(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
||||
XkbcFreeNames(struct xkb_desc * xkb)
|
||||
{
|
||||
struct xkb_names * names;
|
||||
struct xkb_client_map * map;
|
||||
|
||||
if (!xkb || !xkb->names)
|
||||
return;
|
||||
|
||||
names = xkb->names;
|
||||
if (freeMap)
|
||||
which = XkbAllNamesMask;
|
||||
map = xkb->map;
|
||||
|
||||
if (which & XkbKTLevelNamesMask) {
|
||||
struct xkb_client_map * map = xkb->map;
|
||||
if (map && map->types) {
|
||||
int i;
|
||||
struct xkb_key_type * type = map->types;
|
||||
|
||||
if (map && map->types) {
|
||||
int i;
|
||||
struct xkb_key_type * type = map->types;
|
||||
|
||||
for (i = 0; i < map->num_types; i++, type++) {
|
||||
if (type->level_names) {
|
||||
free(type->level_names);
|
||||
type->level_names = NULL;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < map->num_types; i++, type++) {
|
||||
free(type->level_names);
|
||||
type->level_names = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((which & XkbKeyNamesMask) && names->keys) {
|
||||
free(names->keys);
|
||||
names->keys = NULL;
|
||||
names->num_keys = 0;
|
||||
}
|
||||
|
||||
if ((which & XkbKeyAliasesMask) && names->key_aliases) {
|
||||
free(names->key_aliases);
|
||||
names->key_aliases = NULL;
|
||||
names->num_key_aliases = 0;
|
||||
}
|
||||
|
||||
if ((which & XkbRGNamesMask) && names->radio_groups) {
|
||||
free(names->radio_groups);
|
||||
names->radio_groups = NULL;
|
||||
names->num_rg = 0;
|
||||
}
|
||||
|
||||
if (freeMap) {
|
||||
free(names);
|
||||
xkb->names = NULL;
|
||||
}
|
||||
free(names->keys);
|
||||
free(names->key_aliases);
|
||||
free(names->radio_groups);
|
||||
free(names);
|
||||
xkb->names = NULL;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -276,9 +240,9 @@ XkbcAllocControls(struct xkb_desc * xkb, unsigned which)
|
|||
}
|
||||
|
||||
static void
|
||||
XkbcFreeControls(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
||||
XkbcFreeControls(struct xkb_desc * xkb)
|
||||
{
|
||||
if (freeMap && xkb && xkb->ctrls) {
|
||||
if (xkb && xkb->ctrls) {
|
||||
free(xkb->ctrls->per_key_repeat);
|
||||
free(xkb->ctrls);
|
||||
xkb->ctrls = NULL;
|
||||
|
@ -303,7 +267,7 @@ XkbcAllocIndicatorMaps(struct xkb_desc * xkb)
|
|||
static void
|
||||
XkbcFreeIndicatorMaps(struct xkb_desc * xkb)
|
||||
{
|
||||
if (xkb && xkb->indicators) {
|
||||
if (xkb) {
|
||||
free(xkb->indicators);
|
||||
xkb->indicators = NULL;
|
||||
}
|
||||
|
@ -321,28 +285,17 @@ XkbcAllocKeyboard(void)
|
|||
}
|
||||
|
||||
void
|
||||
XkbcFreeKeyboard(struct xkb_desc * xkb, unsigned which, Bool freeAll)
|
||||
XkbcFreeKeyboard(struct xkb_desc * xkb)
|
||||
{
|
||||
if (!xkb)
|
||||
return;
|
||||
|
||||
if (freeAll)
|
||||
which = XkbAllComponentsMask;
|
||||
|
||||
if (which & XkbClientMapMask)
|
||||
XkbcFreeClientMap(xkb, XkbAllClientInfoMask, True);
|
||||
if (which & XkbServerMapMask)
|
||||
XkbcFreeServerMap(xkb, XkbAllServerInfoMask, True);
|
||||
if (which & XkbCompatMapMask)
|
||||
XkbcFreeCompatMap(xkb, XkbAllCompatMask, True);
|
||||
if (which & XkbIndicatorMapMask)
|
||||
XkbcFreeIndicatorMaps(xkb);
|
||||
if (which & XkbNamesMask)
|
||||
XkbcFreeNames(xkb, XkbAllNamesMask, True);
|
||||
if ((which & XkbGeometryMask) && xkb->geom)
|
||||
XkbcFreeGeometry(xkb->geom, XkbGeomAllMask, True);
|
||||
if (which & XkbControlsMask)
|
||||
XkbcFreeControls(xkb, XkbAllControlsMask, True);
|
||||
if (freeAll)
|
||||
free(xkb);
|
||||
XkbcFreeClientMap(xkb);
|
||||
XkbcFreeServerMap(xkb);
|
||||
XkbcFreeCompatMap(xkb);
|
||||
XkbcFreeIndicatorMaps(xkb);
|
||||
XkbcFreeNames(xkb);
|
||||
XkbcFreeGeometry(xkb);
|
||||
XkbcFreeControls(xkb);
|
||||
free(xkb);
|
||||
}
|
||||
|
|
28
src/atom.c
28
src/atom.c
|
@ -103,7 +103,6 @@ xkb_init_atoms(InternAtomFuncPtr intern, GetAtomValueFuncPtr get_atom_value)
|
|||
return;
|
||||
do_intern_atom = intern;
|
||||
do_get_atom_value = get_atom_value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -171,11 +170,11 @@ xkb_intern_atom(const char *string)
|
|||
if (makeit) {
|
||||
NodePtr nd;
|
||||
|
||||
nd = (NodePtr)malloc(sizeof(NodeRec));
|
||||
nd = malloc(sizeof(NodeRec));
|
||||
if (!nd)
|
||||
return BAD_RESOURCE;
|
||||
|
||||
nd->string = (char *)malloc(len + 1);
|
||||
nd->string = malloc(len + 1);
|
||||
if (!nd->string) {
|
||||
free(nd);
|
||||
return BAD_RESOURCE;
|
||||
|
@ -216,3 +215,26 @@ xkb_intern_atom(const char *string)
|
|||
else
|
||||
return None;
|
||||
}
|
||||
|
||||
static void
|
||||
FreeAtom(NodePtr patom)
|
||||
{
|
||||
if (patom->left)
|
||||
FreeAtom(patom->left);
|
||||
if (patom->right)
|
||||
FreeAtom(patom->right);
|
||||
free(patom->string);
|
||||
free(patom);
|
||||
}
|
||||
|
||||
void
|
||||
XkbcFreeAllAtoms(void)
|
||||
{
|
||||
if (atomRoot == NULL)
|
||||
return;
|
||||
FreeAtom(atomRoot);
|
||||
atomRoot = NULL;
|
||||
free(nodeTable);
|
||||
nodeTable = NULL;
|
||||
lastAtom = None;
|
||||
}
|
||||
|
|
371
src/galloc.c
371
src/galloc.c
|
@ -31,310 +31,181 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include "XKBcommonint.h"
|
||||
#include <X11/extensions/XKB.h>
|
||||
|
||||
static void
|
||||
_XkbFreeGeomLeafElems(Bool freeAll, int first, int count,
|
||||
unsigned short *num_inout, unsigned short *sz_inout,
|
||||
char **elems, unsigned int elem_sz)
|
||||
{
|
||||
if (freeAll || !(*elems)) {
|
||||
*num_inout = *sz_inout = 0;
|
||||
if (*elems) {
|
||||
free(*elems);
|
||||
*elems = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((first >= (*num_inout)) || (first < 0) || (count < 1))
|
||||
return;
|
||||
|
||||
if (first + count >= (*num_inout))
|
||||
/* truncating the array is easy */
|
||||
(*num_inout) = first;
|
||||
else {
|
||||
char *ptr = *elems;
|
||||
int extra = ((*num_inout) - first + count) * elem_sz;
|
||||
|
||||
if (extra > 0)
|
||||
memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz],
|
||||
extra);
|
||||
|
||||
(*num_inout) -= count;
|
||||
}
|
||||
}
|
||||
|
||||
typedef void (*ContentsClearFunc)(char *priv);
|
||||
typedef void (*ContentsClearFunc)(void *priv);
|
||||
|
||||
static void
|
||||
_XkbFreeGeomNonLeafElems(Bool freeAll, int first, int count,
|
||||
unsigned short *num_inout, unsigned short *sz_inout,
|
||||
char **elems, unsigned int elem_sz,
|
||||
_XkbFreeGeomNonLeafElems(unsigned short *num_inout, unsigned short *sz_inout,
|
||||
void *elems, size_t elem_sz,
|
||||
ContentsClearFunc freeFunc)
|
||||
{
|
||||
int i;
|
||||
char *ptr;
|
||||
char *start, *ptr;
|
||||
|
||||
if (freeAll) {
|
||||
first = 0;
|
||||
count = *num_inout;
|
||||
}
|
||||
else if ((first >= (*num_inout)) || (first < 0) || (count < 1))
|
||||
return;
|
||||
else if (first + count > (*num_inout))
|
||||
count = (*num_inout) - first;
|
||||
|
||||
if (!(*elems))
|
||||
if (!elems)
|
||||
return;
|
||||
|
||||
if (freeFunc) {
|
||||
ptr = *elems;
|
||||
ptr += first * elem_sz;
|
||||
for (i = 0; i < count; i++) {
|
||||
(*freeFunc)(ptr);
|
||||
ptr += elem_sz;
|
||||
}
|
||||
start = *(char **)elems;
|
||||
if (!start)
|
||||
return;
|
||||
|
||||
ptr = start;
|
||||
for (i = 0; i < *num_inout; i++) {
|
||||
freeFunc(ptr);
|
||||
ptr += elem_sz;
|
||||
}
|
||||
|
||||
if (freeAll) {
|
||||
*num_inout = *sz_inout = 0;
|
||||
if (*elems) {
|
||||
free(*elems);
|
||||
*elems = NULL;
|
||||
}
|
||||
}
|
||||
else if (first + count >= (*num_inout))
|
||||
*num_inout = first;
|
||||
else {
|
||||
i = ((*num_inout) - first + count) * elem_sz;
|
||||
ptr = *elems;
|
||||
memmove(&ptr[first * elem_sz], &ptr[(first + count) * elem_sz], i);
|
||||
(*num_inout) -= count;
|
||||
}
|
||||
*num_inout = *sz_inout = 0;
|
||||
free(start);
|
||||
}
|
||||
|
||||
static void
|
||||
_XkbClearProperty(char *prop_in)
|
||||
_XkbClearProperty(void *prop_in)
|
||||
{
|
||||
struct xkb_property * prop = (struct xkb_property *)prop_in;
|
||||
struct xkb_property * prop = prop_in;
|
||||
|
||||
if (prop->name) {
|
||||
free(prop->name);
|
||||
prop->name = NULL;
|
||||
}
|
||||
if (prop->value) {
|
||||
free(prop->value);
|
||||
prop->value = NULL;
|
||||
}
|
||||
free(prop->name);
|
||||
prop->name = NULL;
|
||||
free(prop->value);
|
||||
prop->value = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomProperties(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
||||
XkbcFreeGeomProperties(struct xkb_geometry * geom)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||
&geom->num_properties, &geom->sz_properties,
|
||||
(char **)&geom->properties,
|
||||
sizeof(struct xkb_property),
|
||||
_XkbFreeGeomNonLeafElems(&geom->num_properties, &geom->sz_properties,
|
||||
&geom->properties, sizeof(struct xkb_property),
|
||||
_XkbClearProperty);
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomKeyAliases(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
||||
_XkbClearColor(void *color_in)
|
||||
{
|
||||
_XkbFreeGeomLeafElems(freeAll, first, count,
|
||||
&geom->num_key_aliases, &geom->sz_key_aliases,
|
||||
(char **)&geom->key_aliases,
|
||||
sizeof(struct xkb_key_alias));
|
||||
struct xkb_color * color = color_in;
|
||||
|
||||
free(color->spec);
|
||||
}
|
||||
|
||||
static void
|
||||
_XkbClearColor(char *color_in)
|
||||
XkbcFreeGeomColors(struct xkb_geometry * geom)
|
||||
{
|
||||
struct xkb_color * color = (struct xkb_color *)color_in;
|
||||
|
||||
if (color->spec)
|
||||
free(color->spec);
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomColors(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||
&geom->num_colors, &geom->sz_colors,
|
||||
(char **)&geom->colors, sizeof(struct xkb_color),
|
||||
_XkbFreeGeomNonLeafElems(&geom->num_colors, &geom->sz_colors,
|
||||
&geom->colors, sizeof(struct xkb_color),
|
||||
_XkbClearColor);
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomPoints(struct xkb_outline * outline, int first, int count, Bool freeAll)
|
||||
_XkbClearOutline(void *outline_in)
|
||||
{
|
||||
_XkbFreeGeomLeafElems(freeAll, first, count,
|
||||
&outline->num_points, &outline->sz_points,
|
||||
(char **)&outline->points, sizeof(struct xkb_point));
|
||||
struct xkb_outline * outline = outline_in;
|
||||
|
||||
free(outline->points);
|
||||
}
|
||||
|
||||
static void
|
||||
_XkbClearOutline(char *outline_in)
|
||||
XkbcFreeGeomOutlines(struct xkb_shape * shape)
|
||||
{
|
||||
struct xkb_outline * outline = (struct xkb_outline *)outline_in;
|
||||
|
||||
if (outline->points)
|
||||
XkbcFreeGeomPoints(outline, 0, outline->num_points, True);
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomOutlines(struct xkb_shape * shape, int first, int count, Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||
&shape->num_outlines, &shape->sz_outlines,
|
||||
(char **)&shape->outlines, sizeof(struct xkb_outline),
|
||||
_XkbFreeGeomNonLeafElems(&shape->num_outlines, &shape->sz_outlines,
|
||||
&shape->outlines, sizeof(struct xkb_outline),
|
||||
_XkbClearOutline);
|
||||
}
|
||||
|
||||
static void
|
||||
_XkbClearShape(char *shape_in)
|
||||
_XkbClearShape(void *shape_in)
|
||||
{
|
||||
struct xkb_shape * shape = (struct xkb_shape *)shape_in;
|
||||
struct xkb_shape * shape = shape_in;
|
||||
|
||||
if (shape->outlines)
|
||||
XkbcFreeGeomOutlines(shape, 0, shape->num_outlines, True);
|
||||
XkbcFreeGeomOutlines(shape);
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomShapes(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
||||
XkbcFreeGeomShapes(struct xkb_geometry * geom)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||
&geom->num_shapes, &geom->sz_shapes,
|
||||
(char **)&geom->shapes, sizeof(struct xkb_shape),
|
||||
_XkbFreeGeomNonLeafElems(&geom->num_shapes, &geom->sz_shapes,
|
||||
&geom->shapes, sizeof(struct xkb_shape),
|
||||
_XkbClearShape);
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomKeys(struct xkb_row * row, int first, int count, Bool freeAll)
|
||||
_XkbClearRow(void *row_in)
|
||||
{
|
||||
_XkbFreeGeomLeafElems(freeAll, first, count,
|
||||
&row->num_keys, &row->sz_keys,
|
||||
(char **)&row->keys, sizeof(struct xkb_key));
|
||||
struct xkb_row * row = row_in;
|
||||
|
||||
free(row->keys);
|
||||
}
|
||||
|
||||
static void
|
||||
_XkbClearRow(char *row_in)
|
||||
XkbcFreeGeomRows(struct xkb_section * section)
|
||||
{
|
||||
struct xkb_row * row = (struct xkb_row *)row_in;
|
||||
|
||||
if (row->keys)
|
||||
XkbcFreeGeomKeys(row, 0, row->num_keys, True);
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomRows(struct xkb_section * section, int first, int count, Bool freeAll)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||
§ion->num_rows, §ion->sz_rows,
|
||||
(char **)§ion->rows, sizeof(struct xkb_row),
|
||||
_XkbFreeGeomNonLeafElems(§ion->num_rows, §ion->sz_rows,
|
||||
§ion->rows, sizeof(struct xkb_row),
|
||||
_XkbClearRow);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
_XkbClearDoodad(char *doodad_in)
|
||||
_XkbClearDoodad(union xkb_doodad *doodad)
|
||||
{
|
||||
union xkb_doodad * doodad = (union xkb_doodad *)doodad_in;
|
||||
|
||||
switch (doodad->any.type) {
|
||||
case XkbTextDoodad:
|
||||
if (doodad->text.text) {
|
||||
free(doodad->text.text);
|
||||
doodad->text.text = NULL;
|
||||
}
|
||||
if (doodad->text.font) {
|
||||
free(doodad->text.font);
|
||||
doodad->text.font = NULL;
|
||||
}
|
||||
free(doodad->text.text);
|
||||
doodad->text.text = NULL;
|
||||
free(doodad->text.font);
|
||||
doodad->text.font = NULL;
|
||||
break;
|
||||
|
||||
case XkbLogoDoodad:
|
||||
if (doodad->logo.logo_name) {
|
||||
free(doodad->logo.logo_name);
|
||||
doodad->logo.logo_name = NULL;
|
||||
}
|
||||
free(doodad->logo.logo_name);
|
||||
doodad->logo.logo_name = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomDoodads(union xkb_doodad * doodads, int nDoodads, Bool freeAll)
|
||||
XkbcFreeGeomDoodads(union xkb_doodad * doodads, int nDoodads)
|
||||
{
|
||||
int i;
|
||||
union xkb_doodad * doodad;
|
||||
|
||||
if (doodads) {
|
||||
for (i = 0, doodad = doodads; i < nDoodads; i++, doodad++)
|
||||
_XkbClearDoodad((char *)doodad);
|
||||
if (freeAll)
|
||||
free(doodads);
|
||||
}
|
||||
for (i = 0, doodad = doodads; i < nDoodads && doodad; i++, doodad++)
|
||||
_XkbClearDoodad(doodad);
|
||||
free(doodads);
|
||||
}
|
||||
|
||||
static void
|
||||
_XkbClearSection(char *section_in)
|
||||
_XkbClearSection(void *section_in)
|
||||
{
|
||||
struct xkb_section * section = (struct xkb_section *)section_in;
|
||||
struct xkb_section * section = section_in;
|
||||
|
||||
if (section->rows)
|
||||
XkbcFreeGeomRows(section, 0, section->num_rows, True);
|
||||
if (section->doodads) {
|
||||
XkbcFreeGeomDoodads(section->doodads, section->num_doodads, True);
|
||||
section->doodads = NULL;
|
||||
}
|
||||
XkbcFreeGeomRows(section);
|
||||
XkbcFreeGeomDoodads(section->doodads, section->num_doodads);
|
||||
section->doodads = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
XkbcFreeGeomSections(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
||||
XkbcFreeGeomSections(struct xkb_geometry * geom)
|
||||
{
|
||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
||||
&geom->num_sections, &geom->sz_sections,
|
||||
(char **)&geom->sections, sizeof(struct xkb_section),
|
||||
_XkbFreeGeomNonLeafElems(&geom->num_sections, &geom->sz_sections,
|
||||
&geom->sections, sizeof(struct xkb_section),
|
||||
_XkbClearSection);
|
||||
}
|
||||
|
||||
void
|
||||
XkbcFreeGeometry(struct xkb_geometry * geom, unsigned which, Bool freeMap)
|
||||
XkbcFreeGeometry(struct xkb_desc * xkb)
|
||||
{
|
||||
if (!geom)
|
||||
struct xkb_geometry *geom;
|
||||
|
||||
if (!xkb || !xkb->geom)
|
||||
return;
|
||||
|
||||
if (freeMap)
|
||||
which = XkbGeomAllMask;
|
||||
geom = xkb->geom;
|
||||
|
||||
if ((which & XkbGeomPropertiesMask) && geom->properties)
|
||||
XkbcFreeGeomProperties(geom, 0, geom->num_properties, True);
|
||||
|
||||
if ((which & XkbGeomColorsMask) && geom->colors)
|
||||
XkbcFreeGeomColors(geom, 0, geom->num_colors, True);
|
||||
|
||||
if ((which & XkbGeomShapesMask) && geom->shapes)
|
||||
XkbcFreeGeomShapes(geom, 0, geom->num_shapes, True);
|
||||
|
||||
if ((which & XkbGeomSectionsMask) && geom->sections)
|
||||
XkbcFreeGeomSections(geom, 0, geom->num_sections, True);
|
||||
|
||||
if ((which & XkbGeomDoodadsMask) && geom->doodads) {
|
||||
XkbcFreeGeomDoodads(geom->doodads, geom->num_doodads, True);
|
||||
geom->doodads = NULL;
|
||||
geom->num_doodads = geom->sz_doodads = 0;
|
||||
}
|
||||
|
||||
if ((which & XkbGeomKeyAliasesMask) && geom->key_aliases)
|
||||
XkbcFreeGeomKeyAliases(geom, 0, geom->num_key_aliases, True);
|
||||
|
||||
if (freeMap) {
|
||||
if (geom->label_font) {
|
||||
free(geom->label_font);
|
||||
geom->label_font = NULL;
|
||||
}
|
||||
free(geom);
|
||||
}
|
||||
XkbcFreeGeomProperties(geom);
|
||||
XkbcFreeGeomColors(geom);
|
||||
XkbcFreeGeomShapes(geom);
|
||||
XkbcFreeGeomSections(geom);
|
||||
XkbcFreeGeomDoodads(geom->doodads, geom->num_doodads);
|
||||
free(geom->key_aliases);
|
||||
free(geom->label_font);
|
||||
free(geom);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -353,9 +224,9 @@ _XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
|||
*total = (*num) + num_new;
|
||||
|
||||
if (*old)
|
||||
*old = (char *)realloc(*old, (*total) * sz_elem);
|
||||
*old = realloc(*old, (*total) * sz_elem);
|
||||
else
|
||||
*old = (char *)calloc(*total, sz_elem);
|
||||
*old = calloc(*total, sz_elem);
|
||||
if (!(*old)) {
|
||||
*total = *num = 0;
|
||||
return BadAlloc;
|
||||
|
@ -363,7 +234,7 @@ _XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
|||
|
||||
if (*num > 0) {
|
||||
char *tmp = *old;
|
||||
bzero(&tmp[sz_elem * (*num)], num_new * sz_elem);
|
||||
memset(&tmp[sz_elem * (*num)], 0, num_new * sz_elem);
|
||||
}
|
||||
|
||||
return Success;
|
||||
|
@ -468,7 +339,7 @@ XkbcAllocGeometry(struct xkb_desc * xkb, struct xkb_geometry_sizes * sizes)
|
|||
|
||||
return Success;
|
||||
bail:
|
||||
XkbcFreeGeometry(geom, XkbGeomAllMask, True);
|
||||
XkbcFreeGeometry(xkb);
|
||||
xkb->geom = NULL;
|
||||
return rtrn;
|
||||
}
|
||||
|
@ -476,18 +347,15 @@ bail:
|
|||
struct xkb_property *
|
||||
XkbcAddGeomProperty(struct xkb_geometry * geom,const char *name,const char *value)
|
||||
{
|
||||
register int i;
|
||||
register struct xkb_property * prop;
|
||||
int i;
|
||||
struct xkb_property * prop;
|
||||
|
||||
if ((!geom)||(!name)||(!value))
|
||||
return NULL;
|
||||
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
|
||||
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
|
||||
if (prop->value)
|
||||
free(prop->value);
|
||||
prop->value= (char *)malloc(strlen(value)+1);
|
||||
if (prop->value)
|
||||
strcpy(prop->value,value);
|
||||
free(prop->value);
|
||||
prop->value = strdup(value);
|
||||
return prop;
|
||||
}
|
||||
}
|
||||
|
@ -496,17 +364,15 @@ register struct xkb_property * prop;
|
|||
return NULL;
|
||||
}
|
||||
prop= &geom->properties[geom->num_properties];
|
||||
prop->name= (char *)malloc(strlen(name)+1);
|
||||
if (!name)
|
||||
prop->name = strdup(name);
|
||||
if (!prop->name)
|
||||
return NULL;
|
||||
strcpy(prop->name,name);
|
||||
prop->value= (char *)malloc(strlen(value)+1);
|
||||
if (!value) {
|
||||
prop->value = strdup(value);
|
||||
if (!prop->value) {
|
||||
free(prop->name);
|
||||
prop->name= NULL;
|
||||
return NULL;
|
||||
}
|
||||
strcpy(prop->value,value);
|
||||
geom->num_properties++;
|
||||
return prop;
|
||||
}
|
||||
|
@ -514,8 +380,8 @@ register struct xkb_property * prop;
|
|||
struct xkb_color *
|
||||
XkbcAddGeomColor(struct xkb_geometry * geom,const char *spec,unsigned int pixel)
|
||||
{
|
||||
register int i;
|
||||
register struct xkb_color * color;
|
||||
int i;
|
||||
struct xkb_color * color;
|
||||
|
||||
if ((!geom)||(!spec))
|
||||
return NULL;
|
||||
|
@ -531,10 +397,9 @@ register struct xkb_color * color;
|
|||
}
|
||||
color= &geom->colors[geom->num_colors];
|
||||
color->pixel= pixel;
|
||||
color->spec= (char *)malloc(strlen(spec)+1);
|
||||
color->spec = strdup(spec);
|
||||
if (!color->spec)
|
||||
return NULL;
|
||||
strcpy(color->spec,spec);
|
||||
geom->num_colors++;
|
||||
return color;
|
||||
}
|
||||
|
@ -551,7 +416,7 @@ struct xkb_outline * outline;
|
|||
return NULL;
|
||||
}
|
||||
outline= &shape->outlines[shape->num_outlines];
|
||||
bzero(outline,sizeof(struct xkb_outline));
|
||||
memset(outline, 0, sizeof(struct xkb_outline));
|
||||
if ((sz_points>0)&&(_XkbAllocPoints(outline,sz_points)!=Success))
|
||||
return NULL;
|
||||
shape->num_outlines++;
|
||||
|
@ -561,8 +426,8 @@ struct xkb_outline * outline;
|
|||
struct xkb_shape *
|
||||
XkbcAddGeomShape(struct xkb_geometry * geom,uint32_t name,int sz_outlines)
|
||||
{
|
||||
struct xkb_shape * shape;
|
||||
register int i;
|
||||
struct xkb_shape *shape;
|
||||
int i;
|
||||
|
||||
if ((!geom)||(!name)||(sz_outlines<0))
|
||||
return NULL;
|
||||
|
@ -576,7 +441,7 @@ register int i;
|
|||
(_XkbAllocShapes(geom,1)!=Success))
|
||||
return NULL;
|
||||
shape= &geom->shapes[geom->num_shapes];
|
||||
bzero(shape,sizeof(struct xkb_shape));
|
||||
memset(shape, 0, sizeof(struct xkb_shape));
|
||||
if ((sz_outlines>0)&&(_XkbAllocOutlines(shape,sz_outlines)!=Success))
|
||||
return NULL;
|
||||
shape->name= name;
|
||||
|
@ -594,7 +459,7 @@ struct xkb_key * key;
|
|||
if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
|
||||
return NULL;
|
||||
key= &row->keys[row->num_keys++];
|
||||
bzero(key,sizeof(struct xkb_key));
|
||||
memset(key, 0, sizeof(struct xkb_key));
|
||||
return key;
|
||||
}
|
||||
|
||||
|
@ -609,7 +474,7 @@ struct xkb_row * row;
|
|||
(_XkbAllocRows(section,1)!=Success))
|
||||
return NULL;
|
||||
row= §ion->rows[section->num_rows];
|
||||
bzero(row,sizeof(struct xkb_row));
|
||||
memset(row, 0, sizeof(struct xkb_row));
|
||||
if ((sz_keys>0)&&(_XkbAllocKeys(row,sz_keys)!=Success))
|
||||
return NULL;
|
||||
section->num_rows++;
|
||||
|
@ -623,8 +488,8 @@ XkbcAddGeomSection( struct xkb_geometry * geom,
|
|||
int sz_doodads,
|
||||
int sz_over)
|
||||
{
|
||||
register int i;
|
||||
struct xkb_section * section;
|
||||
int i;
|
||||
struct xkb_section * section;
|
||||
|
||||
if ((!geom)||(name==None)||(sz_rows<0))
|
||||
return NULL;
|
||||
|
@ -644,11 +509,9 @@ struct xkb_section * section;
|
|||
if ((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))
|
||||
return NULL;
|
||||
if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
|
||||
if (section->rows) {
|
||||
free(section->rows);
|
||||
section->rows= NULL;
|
||||
section->sz_rows= section->num_rows= 0;
|
||||
}
|
||||
free(section->rows);
|
||||
section->rows= NULL;
|
||||
section->sz_rows= section->num_rows= 0;
|
||||
return NULL;
|
||||
}
|
||||
section->name= name;
|
||||
|
@ -659,8 +522,8 @@ struct xkb_section * section;
|
|||
union xkb_doodad *
|
||||
XkbcAddGeomDoodad(struct xkb_geometry * geom,struct xkb_section * section,uint32_t name)
|
||||
{
|
||||
union xkb_doodad *old, *doodad;
|
||||
register int i,nDoodads;
|
||||
union xkb_doodad *old, *doodad;
|
||||
int i, nDoodads;
|
||||
|
||||
if ((!geom)||(name==None))
|
||||
return NULL;
|
||||
|
@ -689,7 +552,7 @@ register int i,nDoodads;
|
|||
return NULL;
|
||||
doodad= &geom->doodads[geom->num_doodads++];
|
||||
}
|
||||
bzero(doodad,sizeof(union xkb_doodad));
|
||||
memset(doodad, 0, sizeof(union xkb_doodad));
|
||||
doodad->any.name= name;
|
||||
return doodad;
|
||||
}
|
||||
|
@ -697,8 +560,8 @@ register int i,nDoodads;
|
|||
struct xkb_overlay_row *
|
||||
XkbcAddGeomOverlayRow(struct xkb_overlay * overlay,int row_under,int sz_keys)
|
||||
{
|
||||
register int i;
|
||||
struct xkb_overlay_row * row;
|
||||
int i;
|
||||
struct xkb_overlay_row *row;
|
||||
|
||||
if ((!overlay)||(sz_keys<0))
|
||||
return NULL;
|
||||
|
@ -718,7 +581,7 @@ struct xkb_overlay_row * row;
|
|||
(_XkbAllocOverlayRows(overlay,1)!=Success))
|
||||
return NULL;
|
||||
row= &overlay->rows[overlay->num_rows];
|
||||
bzero(row,sizeof(struct xkb_overlay_row));
|
||||
memset(row, 0, sizeof(struct xkb_overlay_row));
|
||||
if ((sz_keys>0)&&(_XkbAllocOverlayKeys(row,sz_keys)!=Success))
|
||||
return NULL;
|
||||
row->row_under= row_under;
|
||||
|
@ -729,8 +592,8 @@ struct xkb_overlay_row * row;
|
|||
struct xkb_overlay *
|
||||
XkbcAddGeomOverlay(struct xkb_section * section,uint32_t name,int sz_rows)
|
||||
{
|
||||
register int i;
|
||||
struct xkb_overlay * overlay;
|
||||
int i;
|
||||
struct xkb_overlay *overlay;
|
||||
|
||||
if ((!section)||(name==None)||(sz_rows==0))
|
||||
return NULL;
|
||||
|
|
16
src/geom.c
16
src/geom.c
|
@ -28,17 +28,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|||
#include <config.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include "xkbgeom.h"
|
||||
#include "xkbcommon/xkbcommon.h"
|
||||
#include "XKBcommonint.h"
|
||||
|
||||
#ifndef MINSHORT
|
||||
#define MINSHORT -32768
|
||||
#endif
|
||||
#ifndef MAXSHORT
|
||||
#define MAXSHORT 32767
|
||||
#endif
|
||||
|
||||
static void
|
||||
_XkbCheckBounds(struct xkb_bounds * bounds, int x, int y)
|
||||
{
|
||||
|
@ -62,8 +56,8 @@ XkbcComputeShapeBounds(struct xkb_shape * shape)
|
|||
if ((!shape) || (shape->num_outlines < 1))
|
||||
return False;
|
||||
|
||||
shape->bounds.x1 = shape->bounds.y1 = MAXSHORT;
|
||||
shape->bounds.x2 = shape->bounds.y2 = MINSHORT;
|
||||
shape->bounds.x1 = shape->bounds.y1 = SHRT_MAX;
|
||||
shape->bounds.x2 = shape->bounds.y2 = SHRT_MIN;
|
||||
|
||||
for (outline = shape->outlines, o = 0; o < shape->num_outlines;
|
||||
o++, outline++)
|
||||
|
@ -87,7 +81,7 @@ XkbcComputeRowBounds(struct xkb_geometry * geom, struct xkb_section * section, s
|
|||
return False;
|
||||
|
||||
bounds = &row->bounds;
|
||||
bzero(bounds, sizeof(struct xkb_bounds));
|
||||
memset(bounds, 0, sizeof(struct xkb_bounds));
|
||||
|
||||
for (key = row->keys, pos = k = 0; k < row->num_keys; k++, key++) {
|
||||
sbounds = &XkbKeyShape(geom, key)->bounds;
|
||||
|
@ -129,7 +123,7 @@ XkbcComputeSectionBounds(struct xkb_geometry * geom, struct xkb_section * sectio
|
|||
return False;
|
||||
|
||||
bounds = §ion->bounds;
|
||||
bzero(bounds, sizeof(struct xkb_bounds));
|
||||
memset(bounds, 0, sizeof(struct xkb_bounds));
|
||||
|
||||
for (i = 0, row = section->rows; i < section->num_rows; i++, row++) {
|
||||
if (!XkbcComputeRowBounds(geom, section, row))
|
||||
|
|
143
src/malloc.c
143
src/malloc.c
|
@ -75,8 +75,8 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
|
|||
}
|
||||
|
||||
map->size_types = nTotalTypes;
|
||||
bzero(&map->types[map->num_types],
|
||||
(map->size_types - map->num_types) * sizeof(struct xkb_key_type));
|
||||
memset(&map->types[map->num_types], 0,
|
||||
(map->size_types - map->num_types) * sizeof(struct xkb_key_type));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,8 +178,8 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
|
|||
}
|
||||
|
||||
map->size_acts = need;
|
||||
bzero(&map->acts[map->num_acts],
|
||||
(map->size_acts - map->num_acts) * sizeof(union xkb_action));
|
||||
memset(&map->acts[map->num_acts], 0,
|
||||
(map->size_acts - map->num_acts) * sizeof(union xkb_action));
|
||||
}
|
||||
|
||||
if (!map->key_acts) {
|
||||
|
@ -217,18 +217,12 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into)
|
|||
if (!from || !into)
|
||||
return BadMatch;
|
||||
|
||||
if (into->map) {
|
||||
free(into->map);
|
||||
into->map = NULL;
|
||||
}
|
||||
if (into->preserve) {
|
||||
free(into->preserve);
|
||||
into->preserve= NULL;
|
||||
}
|
||||
if (into->level_names) {
|
||||
free(into->level_names);
|
||||
into->level_names = NULL;
|
||||
}
|
||||
free(into->map);
|
||||
into->map = NULL;
|
||||
free(into->preserve);
|
||||
into->preserve= NULL;
|
||||
free(into->level_names);
|
||||
into->level_names = NULL;
|
||||
|
||||
*into = *from;
|
||||
|
||||
|
@ -282,8 +276,8 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
|
|||
XkbKeySymsPtr(xkb, key), nOldSyms * sizeof(uint32_t));
|
||||
|
||||
if ((needed - nOldSyms) > 0)
|
||||
bzero(&xkb->map->syms[xkb->map->num_syms + XkbKeyNumSyms(xkb, key)],
|
||||
(needed - nOldSyms) * sizeof(uint32_t));
|
||||
memset(&xkb->map->syms[xkb->map->num_syms + XkbKeyNumSyms(xkb, key)],
|
||||
0, (needed - nOldSyms) * sizeof(uint32_t));
|
||||
|
||||
xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
|
||||
xkb->map->num_syms += needed;
|
||||
|
@ -311,7 +305,8 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
|
|||
memcpy(&newSyms[nSyms], XkbKeySymsPtr(xkb, i),
|
||||
nCopy * sizeof(uint32_t));
|
||||
if (nKeySyms > nCopy)
|
||||
bzero(&newSyms[nSyms+nCopy], (nKeySyms - nCopy) * sizeof(uint32_t));
|
||||
memset(&newSyms[nSyms + nCopy], 0,
|
||||
(nKeySyms - nCopy) * sizeof(uint32_t));
|
||||
|
||||
xkb->map->key_sym_map[i].offset = nSyms;
|
||||
nSyms += nKeySyms;
|
||||
|
@ -370,8 +365,8 @@ XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed)
|
|||
memcpy(&newActs[nActs], XkbKeyActionsPtr(xkb, i),
|
||||
nCopy * sizeof(union xkb_action));
|
||||
if (nCopy < nKeyActs)
|
||||
bzero(&newActs[nActs + nCopy],
|
||||
(nKeyActs - nCopy) * sizeof(union xkb_action));
|
||||
memset(&newActs[nActs + nCopy], 0,
|
||||
(nKeyActs - nCopy) * sizeof(union xkb_action));
|
||||
|
||||
xkb->server->key_acts[i] = nActs;
|
||||
nActs += nKeyActs;
|
||||
|
@ -385,109 +380,45 @@ XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed)
|
|||
}
|
||||
|
||||
void
|
||||
XkbcFreeClientMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
|
||||
XkbcFreeClientMap(struct xkb_desc * xkb)
|
||||
{
|
||||
int i;
|
||||
struct xkb_client_map * map;
|
||||
struct xkb_key_type * type;
|
||||
|
||||
if (!xkb || !xkb->map)
|
||||
return;
|
||||
|
||||
if (freeMap)
|
||||
what = XkbAllClientInfoMask;
|
||||
map = xkb->map;
|
||||
|
||||
if (what & XkbKeyTypesMask) {
|
||||
if (map->types) {
|
||||
if (map->num_types > 0) {
|
||||
int i;
|
||||
struct xkb_key_type * type;
|
||||
|
||||
for (i = 0, type = map->types; i < map->num_types; i++, type++) {
|
||||
if (type->map) {
|
||||
free(type->map);
|
||||
type->map = NULL;
|
||||
}
|
||||
if (type->preserve) {
|
||||
free(type->preserve);
|
||||
type->preserve = NULL;
|
||||
}
|
||||
type->map_count = 0;
|
||||
if (type->level_names) {
|
||||
free(type->level_names);
|
||||
type->level_names = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(map->types);
|
||||
map->num_types = map->size_types = 0;
|
||||
map->types = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (what & XkbKeySymsMask) {
|
||||
if (map->key_sym_map) {
|
||||
free(map->key_sym_map);
|
||||
map->key_sym_map = NULL;
|
||||
}
|
||||
if (map->syms) {
|
||||
free(map->syms);
|
||||
map->size_syms = map->num_syms = 0;
|
||||
map->syms = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((what & XkbModifierMapMask) && map->modmap) {
|
||||
free(map->modmap);
|
||||
map->modmap = NULL;
|
||||
}
|
||||
|
||||
if (freeMap) {
|
||||
free(xkb->map);
|
||||
xkb->map = NULL;
|
||||
for (i = 0, type = map->types; i < map->num_types && type; i++, type++) {
|
||||
free(type->map);
|
||||
free(type->preserve);
|
||||
free(type->level_names);
|
||||
}
|
||||
free(map->types);
|
||||
free(map->key_sym_map);
|
||||
free(map->syms);
|
||||
free(map->modmap);
|
||||
free(xkb->map);
|
||||
xkb->map = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
XkbcFreeServerMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
|
||||
XkbcFreeServerMap(struct xkb_desc * xkb)
|
||||
{
|
||||
struct xkb_server_map * map;
|
||||
|
||||
if (!xkb || !xkb->server)
|
||||
return;
|
||||
|
||||
if (freeMap)
|
||||
what = XkbAllServerInfoMask;
|
||||
map = xkb->server;
|
||||
|
||||
if ((what & XkbExplicitComponentsMask) && map->explicit) {
|
||||
free(map->explicit);
|
||||
map->explicit = NULL;
|
||||
}
|
||||
|
||||
if (what & XkbKeyActionsMask) {
|
||||
if (map->key_acts) {
|
||||
free(map->key_acts);
|
||||
map->key_acts = NULL;
|
||||
}
|
||||
if (map->acts) {
|
||||
free(map->acts);
|
||||
map->num_acts = map->size_acts = 0;
|
||||
map->acts = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((what & XkbKeyBehaviorsMask) && map->behaviors) {
|
||||
free(map->behaviors);
|
||||
map->behaviors = NULL;
|
||||
}
|
||||
|
||||
if ((what & XkbVirtualModMapMask) && map->vmodmap) {
|
||||
free(map->vmodmap);
|
||||
map->vmodmap = NULL;
|
||||
}
|
||||
|
||||
if (freeMap) {
|
||||
free(xkb->server);
|
||||
xkb->server = NULL;
|
||||
}
|
||||
free(map->explicit);
|
||||
free(map->key_acts);
|
||||
free(map->acts);
|
||||
free(map->behaviors);
|
||||
free(map->vmodmap);
|
||||
free(xkb->server);
|
||||
xkb->server = NULL;
|
||||
}
|
||||
|
|
160
src/maprules.c
160
src/maprules.c
|
@ -79,7 +79,6 @@ InitInputLine(InputLine *line)
|
|||
line->num_line= 0;
|
||||
line->sz_line= DFLT_LINE_SIZE;
|
||||
line->line= line->buf;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -91,7 +90,6 @@ FreeInputLine(InputLine *line)
|
|||
line->num_line= 0;
|
||||
line->sz_line= DFLT_LINE_SIZE;
|
||||
line->line= line->buf;
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -99,11 +97,11 @@ InputLineAddChar(InputLine *line,int ch)
|
|||
{
|
||||
if (line->num_line>=line->sz_line) {
|
||||
if (line->line==line->buf) {
|
||||
line->line= (char *)malloc(line->sz_line*2);
|
||||
line->line = malloc(line->sz_line * 2);
|
||||
memcpy(line->line,line->buf,line->sz_line);
|
||||
}
|
||||
else {
|
||||
line->line=(char *)realloc((char *)line->line,line->sz_line*2);
|
||||
line->line = realloc(line->line, line->sz_line * 2);
|
||||
}
|
||||
line->sz_line*= 2;
|
||||
}
|
||||
|
@ -118,8 +116,8 @@ InputLineAddChar(InputLine *line,int ch)
|
|||
static Bool
|
||||
GetInputLine(FILE *file,InputLine *line,Bool checkbang)
|
||||
{
|
||||
int ch;
|
||||
Bool endOfFile,spacePending,slashPending,inComment;
|
||||
int ch;
|
||||
Bool endOfFile,spacePending,slashPending,inComment;
|
||||
|
||||
endOfFile= False;
|
||||
while ((!endOfFile)&&(line->num_line==0)) {
|
||||
|
@ -267,20 +265,20 @@ get_index(char *str, int *ndx)
|
|||
static void
|
||||
SetUpRemap(InputLine *line,RemapSpec *remap)
|
||||
{
|
||||
char * tok,*str;
|
||||
unsigned present, l_ndx_present, v_ndx_present;
|
||||
register int i;
|
||||
int len, ndx;
|
||||
_Xstrtokparams strtok_buf;
|
||||
char *tok, *str;
|
||||
unsigned present, l_ndx_present, v_ndx_present;
|
||||
int i;
|
||||
int len, ndx;
|
||||
_Xstrtokparams strtok_buf;
|
||||
#ifdef DEBUG
|
||||
Bool found;
|
||||
Bool found;
|
||||
#endif
|
||||
|
||||
|
||||
l_ndx_present = v_ndx_present = present= 0;
|
||||
str= &line->line[1];
|
||||
len = remap->number;
|
||||
bzero((char *)remap,sizeof(RemapSpec));
|
||||
memset(remap, 0, sizeof(RemapSpec));
|
||||
remap->number = len;
|
||||
while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) {
|
||||
#ifdef DEBUG
|
||||
|
@ -363,14 +361,13 @@ Bool found;
|
|||
return;
|
||||
}
|
||||
remap->number++;
|
||||
return;
|
||||
}
|
||||
|
||||
static Bool
|
||||
MatchOneOf(char *wanted,char *vals_defined)
|
||||
{
|
||||
char *str,*next;
|
||||
int want_len= strlen(wanted);
|
||||
char *str, *next;
|
||||
int want_len = strlen(wanted);
|
||||
|
||||
for (str=vals_defined,next=NULL;str!=NULL;str=next) {
|
||||
int len;
|
||||
|
@ -396,11 +393,11 @@ CheckLine( InputLine * line,
|
|||
XkbRF_RulePtr rule,
|
||||
XkbRF_GroupPtr group)
|
||||
{
|
||||
char * str,*tok;
|
||||
register int nread, i;
|
||||
FileSpec tmp;
|
||||
_Xstrtokparams strtok_buf;
|
||||
Bool append = False;
|
||||
char *str, *tok;
|
||||
int nread, i;
|
||||
FileSpec tmp;
|
||||
_Xstrtokparams strtok_buf;
|
||||
Bool append = False;
|
||||
|
||||
if (line->line[0]=='!') {
|
||||
if (line->line[1] == '$' ||
|
||||
|
@ -437,7 +434,7 @@ Bool append = False;
|
|||
PR_DEBUG("Illegal line of data ignored\n");
|
||||
return False;
|
||||
}
|
||||
bzero((char *)&tmp,sizeof(FileSpec));
|
||||
memset(&tmp, 0, sizeof(FileSpec));
|
||||
str= line->line;
|
||||
for (nread= 0;(tok=_XStrtok(str," ",strtok_buf))!=NULL;nread++) {
|
||||
str= NULL;
|
||||
|
@ -495,7 +492,7 @@ Bool append = False;
|
|||
static char *
|
||||
_Concat(char *str1,char *str2)
|
||||
{
|
||||
int len;
|
||||
int len;
|
||||
|
||||
if ((!str1)||(!str2))
|
||||
return str1;
|
||||
|
@ -520,7 +517,7 @@ squeeze_spaces(char *p1)
|
|||
static Bool
|
||||
MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
|
||||
{
|
||||
bzero((char *)mdefs,sizeof(XkbRF_MultiDefsRec));
|
||||
memset(mdefs, 0, sizeof(XkbRF_MultiDefsRec));
|
||||
mdefs->model = defs->model;
|
||||
mdefs->options = _XkbDupString(defs->options);
|
||||
if (mdefs->options) squeeze_spaces(mdefs->options);
|
||||
|
@ -578,13 +575,10 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
|
|||
static void
|
||||
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
|
||||
{
|
||||
if (defs->options)
|
||||
free(defs->options);
|
||||
/* Avoid -Wcast-qual warnings. */
|
||||
if (defs->layout[1])
|
||||
/* Avoid -Wcast-qual warnings. */
|
||||
free((void *)(uintptr_t)defs->layout[1]);
|
||||
if (defs->variant[1])
|
||||
free((void *)(uintptr_t)defs->variant[1]);
|
||||
free((void *)(uintptr_t)defs->variant[1]);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -715,8 +709,8 @@ XkbRF_CheckApplyRule( XkbRF_RulePtr rule,
|
|||
static void
|
||||
XkbRF_ClearPartialMatches(XkbRF_RulesPtr rules)
|
||||
{
|
||||
register int i;
|
||||
XkbRF_RulePtr rule;
|
||||
int i;
|
||||
XkbRF_RulePtr rule;
|
||||
|
||||
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
|
||||
rule->flags&= ~XkbRF_PendingMatch;
|
||||
|
@ -726,8 +720,8 @@ XkbRF_RulePtr rule;
|
|||
static void
|
||||
XkbRF_ApplyPartialMatches(XkbRF_RulesPtr rules,struct xkb_component_names * names)
|
||||
{
|
||||
int i;
|
||||
XkbRF_RulePtr rule;
|
||||
int i;
|
||||
XkbRF_RulePtr rule;
|
||||
|
||||
for (rule = rules->rules, i = 0; i < rules->num_rules; i++, rule++) {
|
||||
if ((rule->flags&XkbRF_PendingMatch)==0)
|
||||
|
@ -742,9 +736,9 @@ XkbRF_CheckApplyRules( XkbRF_RulesPtr rules,
|
|||
struct xkb_component_names * names,
|
||||
int flags)
|
||||
{
|
||||
int i;
|
||||
XkbRF_RulePtr rule;
|
||||
int skip;
|
||||
int i;
|
||||
XkbRF_RulePtr rule;
|
||||
int skip;
|
||||
|
||||
for (rule = rules->rules, i=0; i < rules->num_rules; rule++, i++) {
|
||||
if ((rule->flags & flags) != flags)
|
||||
|
@ -763,11 +757,11 @@ int skip;
|
|||
static char *
|
||||
XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs)
|
||||
{
|
||||
char *str, *outstr, *orig, *var;
|
||||
int len, ndx;
|
||||
char *str, *outstr, *orig, *var;
|
||||
int len, ndx;
|
||||
|
||||
orig= name;
|
||||
str= index(name,'%');
|
||||
str= strchr(name,'%');
|
||||
if (str==NULL)
|
||||
return name;
|
||||
len= strlen(name);
|
||||
|
@ -785,7 +779,7 @@ int len, ndx;
|
|||
var = str + 1;
|
||||
str = get_index(var + 1, &ndx);
|
||||
if (ndx == -1) {
|
||||
str = index(str,'%');
|
||||
str = strchr(str,'%');
|
||||
continue;
|
||||
}
|
||||
if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx])
|
||||
|
@ -797,9 +791,9 @@ int len, ndx;
|
|||
if ((pfx=='(')&&(*str==')')) {
|
||||
str++;
|
||||
}
|
||||
str= index(&str[0],'%');
|
||||
str= strchr(&str[0],'%');
|
||||
}
|
||||
name= (char *)malloc(len+1);
|
||||
name = malloc(len + 1);
|
||||
str= orig;
|
||||
outstr= name;
|
||||
while (*str!='\0') {
|
||||
|
@ -864,7 +858,7 @@ XkbcRF_GetComponents( XkbRF_RulesPtr rules,
|
|||
|
||||
MakeMultiDefs(&mdefs, defs);
|
||||
|
||||
bzero((char *)names,sizeof(struct xkb_component_names));
|
||||
memset(names, 0, sizeof(struct xkb_component_names));
|
||||
XkbRF_ClearPartialMatches(rules);
|
||||
XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal);
|
||||
XkbRF_ApplyPartialMatches(rules, names);
|
||||
|
@ -911,7 +905,7 @@ XkbcRF_AddRule(XkbRF_RulesPtr rules)
|
|||
#endif
|
||||
return NULL;
|
||||
}
|
||||
bzero((char *)&rules->rules[rules->num_rules],sizeof(XkbRF_RuleRec));
|
||||
memset(&rules->rules[rules->num_rules], 0, sizeof(XkbRF_RuleRec));
|
||||
return &rules->rules[rules->num_rules++];
|
||||
}
|
||||
|
||||
|
@ -933,7 +927,7 @@ XkbcRF_AddGroup(XkbRF_RulesPtr rules)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
bzero((char *)&rules->groups[rules->num_groups],sizeof(XkbRF_GroupRec));
|
||||
memset(&rules->groups[rules->num_groups], 0, sizeof(XkbRF_GroupRec));
|
||||
return &rules->groups[rules->num_groups++];
|
||||
}
|
||||
|
||||
|
@ -947,20 +941,20 @@ XkbRF_GroupRec tgroup,*group;
|
|||
|
||||
if (!(rules && file))
|
||||
return False;
|
||||
bzero((char *)&remap,sizeof(RemapSpec));
|
||||
bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
|
||||
memset(&remap, 0, sizeof(RemapSpec));
|
||||
memset(&tgroup, 0, sizeof(XkbRF_GroupRec));
|
||||
InitInputLine(&line);
|
||||
while (GetInputLine(file,&line,True)) {
|
||||
if (CheckLine(&line,&remap,&trule,&tgroup)) {
|
||||
if (tgroup.number) {
|
||||
if ((group= XkbcRF_AddGroup(rules))!=NULL) {
|
||||
*group= tgroup;
|
||||
bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
|
||||
memset(&tgroup, 0, sizeof(XkbRF_GroupRec));
|
||||
}
|
||||
} else {
|
||||
if ((rule= XkbcRF_AddRule(rules))!=NULL) {
|
||||
*rule= trule;
|
||||
bzero((char *)&trule,sizeof(XkbRF_RuleRec));
|
||||
memset(&trule, 0, sizeof(XkbRF_RuleRec));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -973,27 +967,23 @@ XkbRF_GroupRec tgroup,*group;
|
|||
static void
|
||||
XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
for (i=0;i<var->num_desc;i++) {
|
||||
if (var->desc[i].name)
|
||||
free(var->desc[i].name);
|
||||
if (var->desc[i].desc)
|
||||
free(var->desc[i].desc);
|
||||
free(var->desc[i].name);
|
||||
free(var->desc[i].desc);
|
||||
var->desc[i].name= var->desc[i].desc= NULL;
|
||||
}
|
||||
if (var->desc)
|
||||
free(var->desc);
|
||||
free(var->desc);
|
||||
var->desc= NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbcRF_Free(XkbRF_RulesPtr rules,Bool freeRules)
|
||||
XkbcRF_Free(XkbRF_RulesPtr rules)
|
||||
{
|
||||
int i;
|
||||
XkbRF_RulePtr rule;
|
||||
XkbRF_GroupPtr group;
|
||||
int i;
|
||||
XkbRF_RulePtr rule;
|
||||
XkbRF_GroupPtr group;
|
||||
|
||||
if (!rules)
|
||||
return;
|
||||
|
@ -1006,38 +996,26 @@ XkbRF_GroupPtr group;
|
|||
XkbRF_ClearVarDescriptions(&rules->extra[i]);
|
||||
}
|
||||
free(rules->extra);
|
||||
rules->num_extra= rules->sz_extra= 0;
|
||||
rules->extra= NULL;
|
||||
}
|
||||
if (rules->rules) {
|
||||
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
|
||||
if (rule->model) free(rule->model);
|
||||
if (rule->layout) free(rule->layout);
|
||||
if (rule->variant) free(rule->variant);
|
||||
if (rule->option) free(rule->option);
|
||||
if (rule->keycodes) free(rule->keycodes);
|
||||
if (rule->symbols) free(rule->symbols);
|
||||
if (rule->types) free(rule->types);
|
||||
if (rule->compat) free(rule->compat);
|
||||
if (rule->geometry) free(rule->geometry);
|
||||
if (rule->keymap) free(rule->keymap);
|
||||
bzero((char *)rule,sizeof(XkbRF_RuleRec));
|
||||
}
|
||||
free(rules->rules);
|
||||
rules->num_rules= rules->sz_rules= 0;
|
||||
rules->rules= NULL;
|
||||
for (i=0, rule = rules->rules; i < rules->num_rules && rules; i++, rule++) {
|
||||
free(rule->model);
|
||||
free(rule->layout);
|
||||
free(rule->variant);
|
||||
free(rule->option);
|
||||
free(rule->keycodes);
|
||||
free(rule->symbols);
|
||||
free(rule->types);
|
||||
free(rule->compat);
|
||||
free(rule->geometry);
|
||||
free(rule->keymap);
|
||||
}
|
||||
free(rules->rules);
|
||||
|
||||
if (rules->groups) {
|
||||
for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
|
||||
if (group->name) free(group->name);
|
||||
if (group->words) free(group->words);
|
||||
}
|
||||
free(rules->groups);
|
||||
rules->num_groups= 0;
|
||||
rules->groups= NULL;
|
||||
for (i=0, group = rules->groups; i < rules->num_groups && group; i++, group++) {
|
||||
free(group->name);
|
||||
free(group->words);
|
||||
}
|
||||
if (freeRules)
|
||||
free(rules);
|
||||
return;
|
||||
free(rules->groups);
|
||||
|
||||
free(rules);
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ XkbcComputeEffectiveMap(struct xkb_desc * xkb, struct xkb_key_type * type,
|
|||
type->mods.mask = type->mods.real_mods;
|
||||
|
||||
if (map_rtrn) {
|
||||
bzero(map_rtrn, type->mods.mask + 1);
|
||||
memset(map_rtrn, 0, type->mods.mask + 1);
|
||||
if (entry && entry->active)
|
||||
for (i = 0; i < type->map_count; i++)
|
||||
map_rtrn[type->map[i].mods.mask] = type->map[i].level;
|
||||
|
|
|
@ -48,7 +48,7 @@ extern struct xkb_desc *
|
|||
XkbcAllocKeyboard(void);
|
||||
|
||||
extern void
|
||||
XkbcFreeKeyboard(struct xkb_desc * xkb, unsigned which, Bool freeAll);
|
||||
XkbcFreeKeyboard(struct xkb_desc * xkb);
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
|
@ -68,9 +68,9 @@ extern union xkb_action *
|
|||
XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed);
|
||||
|
||||
extern void
|
||||
XkbcFreeClientMap(struct xkb_desc * xkb, unsigned what, Bool freeMap);
|
||||
XkbcFreeClientMap(struct xkb_desc * xkb);
|
||||
|
||||
extern void
|
||||
XkbcFreeServerMap(struct xkb_desc * xkb, unsigned what, Bool freeMap);
|
||||
XkbcFreeServerMap(struct xkb_desc * xkb);
|
||||
|
||||
#endif /* _XKBALLOC_H_ */
|
||||
|
|
|
@ -40,258 +40,135 @@ static ExprDef constFalse;
|
|||
|
||||
/***====================================================================***/
|
||||
|
||||
static const LookupEntry actionStrings[] = {
|
||||
{ "noaction", XkbSA_NoAction },
|
||||
{ "setmods", XkbSA_SetMods },
|
||||
{ "latchmods", XkbSA_LatchMods },
|
||||
{ "lockmods", XkbSA_LockMods },
|
||||
{ "setgroup", XkbSA_SetGroup },
|
||||
{ "latchgroup", XkbSA_LatchGroup },
|
||||
{ "lockgroup", XkbSA_LockGroup },
|
||||
{ "moveptr", XkbSA_MovePtr },
|
||||
{ "movepointer", XkbSA_MovePtr },
|
||||
{ "ptrbtn", XkbSA_PtrBtn },
|
||||
{ "pointerbutton", XkbSA_PtrBtn },
|
||||
{ "lockptrbtn", XkbSA_LockPtrBtn },
|
||||
{ "lockpointerbutton", XkbSA_LockPtrBtn },
|
||||
{ "lockptrbutton", XkbSA_LockPtrBtn },
|
||||
{ "lockpointerbtn", XkbSA_LockPtrBtn },
|
||||
{ "setptrdflt", XkbSA_SetPtrDflt },
|
||||
{ "setpointerdefault", XkbSA_SetPtrDflt },
|
||||
{ "isolock", XkbSA_ISOLock },
|
||||
{ "terminate", XkbSA_Terminate },
|
||||
{ "terminateserver", XkbSA_Terminate },
|
||||
{ "switchscreen", XkbSA_SwitchScreen },
|
||||
{ "setcontrols", XkbSA_SetControls },
|
||||
{ "lockcontrols", XkbSA_LockControls },
|
||||
{ "actionmessage", XkbSA_ActionMessage },
|
||||
{ "messageaction", XkbSA_ActionMessage },
|
||||
{ "message", XkbSA_ActionMessage },
|
||||
{ "redirect", XkbSA_RedirectKey },
|
||||
{ "redirectkey", XkbSA_RedirectKey },
|
||||
{ "devbtn", XkbSA_DeviceBtn },
|
||||
{ "devicebtn", XkbSA_DeviceBtn },
|
||||
{ "devbutton", XkbSA_DeviceBtn },
|
||||
{ "devicebutton", XkbSA_DeviceBtn },
|
||||
{ "lockdevbtn", XkbSA_DeviceBtn },
|
||||
{ "lockdevicebtn", XkbSA_LockDeviceBtn },
|
||||
{ "lockdevbutton", XkbSA_LockDeviceBtn },
|
||||
{ "lockdevicebutton", XkbSA_LockDeviceBtn },
|
||||
{ "devval", XkbSA_DeviceValuator },
|
||||
{ "deviceval", XkbSA_DeviceValuator },
|
||||
{ "devvaluator", XkbSA_DeviceValuator },
|
||||
{ "devicevaluator", XkbSA_DeviceValuator },
|
||||
{ "private", PrivateAction },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static const LookupEntry fieldStrings[] = {
|
||||
{ "clearLocks", F_ClearLocks },
|
||||
{ "latchToLock", F_LatchToLock },
|
||||
{ "genKeyEvent", F_GenKeyEvent },
|
||||
{ "generateKeyEvent", F_GenKeyEvent },
|
||||
{ "report", F_Report },
|
||||
{ "default", F_Default },
|
||||
{ "affect", F_Affect },
|
||||
{ "increment", F_Increment },
|
||||
{ "modifiers", F_Modifiers },
|
||||
{ "mods", F_Modifiers },
|
||||
{ "group", F_Group },
|
||||
{ "x", F_X },
|
||||
{ "y", F_Y },
|
||||
{ "accel", F_Accel },
|
||||
{ "accelerate", F_Accel },
|
||||
{ "repeat", F_Accel },
|
||||
{ "button", F_Button },
|
||||
{ "value", F_Value },
|
||||
{ "controls", F_Controls },
|
||||
{ "ctrls", F_Controls },
|
||||
{ "type", F_Type },
|
||||
{ "count", F_Count },
|
||||
{ "screen", F_Screen },
|
||||
{ "same", F_Same },
|
||||
{ "sameServer", F_Same },
|
||||
{ "data", F_Data },
|
||||
{ "device", F_Device },
|
||||
{ "dev", F_Device },
|
||||
{ "key", F_Keycode },
|
||||
{ "keycode", F_Keycode },
|
||||
{ "kc", F_Keycode },
|
||||
{ "clearmods", F_ModsToClear },
|
||||
{ "clearmodifiers", F_ModsToClear },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
|
||||
static Bool
|
||||
stringToValue(const LookupEntry tab[], const char *string,
|
||||
unsigned *value_rtrn)
|
||||
{
|
||||
const LookupEntry *entry;
|
||||
|
||||
if (!string)
|
||||
return False;
|
||||
|
||||
for (entry = tab; entry->name != NULL; entry++) {
|
||||
if (uStrCaseCmp(entry->name, string) == 0) {
|
||||
*value_rtrn = entry->result;
|
||||
return True;
|
||||
}
|
||||
}
|
||||
|
||||
return False;
|
||||
}
|
||||
|
||||
static const char *
|
||||
valueToString(const LookupEntry tab[], unsigned value)
|
||||
{
|
||||
const LookupEntry *entry;
|
||||
|
||||
for (entry = tab; entry->name != NULL; entry++)
|
||||
if (entry->result == value)
|
||||
return entry->name;
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static Bool
|
||||
stringToAction(const char *str, unsigned *type_rtrn)
|
||||
{
|
||||
if (str == NULL)
|
||||
return False;
|
||||
|
||||
if (uStrCaseCmp(str, "noaction") == 0)
|
||||
*type_rtrn = XkbSA_NoAction;
|
||||
else if (uStrCaseCmp(str, "setmods") == 0)
|
||||
*type_rtrn = XkbSA_SetMods;
|
||||
else if (uStrCaseCmp(str, "latchmods") == 0)
|
||||
*type_rtrn = XkbSA_LatchMods;
|
||||
else if (uStrCaseCmp(str, "lockmods") == 0)
|
||||
*type_rtrn = XkbSA_LockMods;
|
||||
else if (uStrCaseCmp(str, "setgroup") == 0)
|
||||
*type_rtrn = XkbSA_SetGroup;
|
||||
else if (uStrCaseCmp(str, "latchgroup") == 0)
|
||||
*type_rtrn = XkbSA_LatchGroup;
|
||||
else if (uStrCaseCmp(str, "lockgroup") == 0)
|
||||
*type_rtrn = XkbSA_LockGroup;
|
||||
else if (uStrCaseCmp(str, "moveptr") == 0)
|
||||
*type_rtrn = XkbSA_MovePtr;
|
||||
else if (uStrCaseCmp(str, "movepointer") == 0)
|
||||
*type_rtrn = XkbSA_MovePtr;
|
||||
else if (uStrCaseCmp(str, "ptrbtn") == 0)
|
||||
*type_rtrn = XkbSA_PtrBtn;
|
||||
else if (uStrCaseCmp(str, "pointerbutton") == 0)
|
||||
*type_rtrn = XkbSA_PtrBtn;
|
||||
else if (uStrCaseCmp(str, "lockptrbtn") == 0)
|
||||
*type_rtrn = XkbSA_LockPtrBtn;
|
||||
else if (uStrCaseCmp(str, "lockpointerbutton") == 0)
|
||||
*type_rtrn = XkbSA_LockPtrBtn;
|
||||
else if (uStrCaseCmp(str, "lockptrbutton") == 0)
|
||||
*type_rtrn = XkbSA_LockPtrBtn;
|
||||
else if (uStrCaseCmp(str, "lockpointerbtn") == 0)
|
||||
*type_rtrn = XkbSA_LockPtrBtn;
|
||||
else if (uStrCaseCmp(str, "setptrdflt") == 0)
|
||||
*type_rtrn = XkbSA_SetPtrDflt;
|
||||
else if (uStrCaseCmp(str, "setpointerdefault") == 0)
|
||||
*type_rtrn = XkbSA_SetPtrDflt;
|
||||
else if (uStrCaseCmp(str, "isolock") == 0)
|
||||
*type_rtrn = XkbSA_ISOLock;
|
||||
else if (uStrCaseCmp(str, "terminate") == 0)
|
||||
*type_rtrn = XkbSA_Terminate;
|
||||
else if (uStrCaseCmp(str, "terminateserver") == 0)
|
||||
*type_rtrn = XkbSA_Terminate;
|
||||
else if (uStrCaseCmp(str, "switchscreen") == 0)
|
||||
*type_rtrn = XkbSA_SwitchScreen;
|
||||
else if (uStrCaseCmp(str, "setcontrols") == 0)
|
||||
*type_rtrn = XkbSA_SetControls;
|
||||
else if (uStrCaseCmp(str, "lockcontrols") == 0)
|
||||
*type_rtrn = XkbSA_LockControls;
|
||||
else if (uStrCaseCmp(str, "actionmessage") == 0)
|
||||
*type_rtrn = XkbSA_ActionMessage;
|
||||
else if (uStrCaseCmp(str, "messageaction") == 0)
|
||||
*type_rtrn = XkbSA_ActionMessage;
|
||||
else if (uStrCaseCmp(str, "message") == 0)
|
||||
*type_rtrn = XkbSA_ActionMessage;
|
||||
else if (uStrCaseCmp(str, "redirect") == 0)
|
||||
*type_rtrn = XkbSA_RedirectKey;
|
||||
else if (uStrCaseCmp(str, "redirectkey") == 0)
|
||||
*type_rtrn = XkbSA_RedirectKey;
|
||||
else if (uStrCaseCmp(str, "devbtn") == 0)
|
||||
*type_rtrn = XkbSA_DeviceBtn;
|
||||
else if (uStrCaseCmp(str, "devicebtn") == 0)
|
||||
*type_rtrn = XkbSA_DeviceBtn;
|
||||
else if (uStrCaseCmp(str, "devbutton") == 0)
|
||||
*type_rtrn = XkbSA_DeviceBtn;
|
||||
else if (uStrCaseCmp(str, "devicebutton") == 0)
|
||||
*type_rtrn = XkbSA_DeviceBtn;
|
||||
else if (uStrCaseCmp(str, "lockdevbtn") == 0)
|
||||
*type_rtrn = XkbSA_DeviceBtn;
|
||||
else if (uStrCaseCmp(str, "lockdevicebtn") == 0)
|
||||
*type_rtrn = XkbSA_LockDeviceBtn;
|
||||
else if (uStrCaseCmp(str, "lockdevbutton") == 0)
|
||||
*type_rtrn = XkbSA_LockDeviceBtn;
|
||||
else if (uStrCaseCmp(str, "lockdevicebutton") == 0)
|
||||
*type_rtrn = XkbSA_LockDeviceBtn;
|
||||
else if (uStrCaseCmp(str, "devval") == 0)
|
||||
*type_rtrn = XkbSA_DeviceValuator;
|
||||
else if (uStrCaseCmp(str, "deviceval") == 0)
|
||||
*type_rtrn = XkbSA_DeviceValuator;
|
||||
else if (uStrCaseCmp(str, "devvaluator") == 0)
|
||||
*type_rtrn = XkbSA_DeviceValuator;
|
||||
else if (uStrCaseCmp(str, "devicevaluator") == 0)
|
||||
*type_rtrn = XkbSA_DeviceValuator;
|
||||
else if (uStrCaseCmp(str, "private") == 0)
|
||||
*type_rtrn = PrivateAction;
|
||||
else
|
||||
return False;
|
||||
return True;
|
||||
return stringToValue(actionStrings, str, type_rtrn);
|
||||
}
|
||||
|
||||
static Bool
|
||||
stringToField(char *str, unsigned *field_rtrn)
|
||||
stringToField(const char *str, unsigned *field_rtrn)
|
||||
{
|
||||
|
||||
if (str == NULL)
|
||||
return False;
|
||||
|
||||
if (uStrCaseCmp(str, "clearlocks") == 0)
|
||||
*field_rtrn = F_ClearLocks;
|
||||
else if (uStrCaseCmp(str, "latchtolock") == 0)
|
||||
*field_rtrn = F_LatchToLock;
|
||||
else if (uStrCaseCmp(str, "genkeyevent") == 0)
|
||||
*field_rtrn = F_GenKeyEvent;
|
||||
else if (uStrCaseCmp(str, "generatekeyevent") == 0)
|
||||
*field_rtrn = F_GenKeyEvent;
|
||||
else if (uStrCaseCmp(str, "report") == 0)
|
||||
*field_rtrn = F_Report;
|
||||
else if (uStrCaseCmp(str, "default") == 0)
|
||||
*field_rtrn = F_Default;
|
||||
else if (uStrCaseCmp(str, "affect") == 0)
|
||||
*field_rtrn = F_Affect;
|
||||
else if (uStrCaseCmp(str, "increment") == 0)
|
||||
*field_rtrn = F_Increment;
|
||||
else if (uStrCaseCmp(str, "mods") == 0)
|
||||
*field_rtrn = F_Modifiers;
|
||||
else if (uStrCaseCmp(str, "modifiers") == 0)
|
||||
*field_rtrn = F_Modifiers;
|
||||
else if (uStrCaseCmp(str, "group") == 0)
|
||||
*field_rtrn = F_Group;
|
||||
else if (uStrCaseCmp(str, "x") == 0)
|
||||
*field_rtrn = F_X;
|
||||
else if (uStrCaseCmp(str, "y") == 0)
|
||||
*field_rtrn = F_Y;
|
||||
else if (uStrCaseCmp(str, "accel") == 0)
|
||||
*field_rtrn = F_Accel;
|
||||
else if (uStrCaseCmp(str, "accelerate") == 0)
|
||||
*field_rtrn = F_Accel;
|
||||
else if (uStrCaseCmp(str, "repeat") == 0)
|
||||
*field_rtrn = F_Accel;
|
||||
else if (uStrCaseCmp(str, "button") == 0)
|
||||
*field_rtrn = F_Button;
|
||||
else if (uStrCaseCmp(str, "value") == 0)
|
||||
*field_rtrn = F_Value;
|
||||
else if (uStrCaseCmp(str, "controls") == 0)
|
||||
*field_rtrn = F_Controls;
|
||||
else if (uStrCaseCmp(str, "ctrls") == 0)
|
||||
*field_rtrn = F_Controls;
|
||||
else if (uStrCaseCmp(str, "type") == 0)
|
||||
*field_rtrn = F_Type;
|
||||
else if (uStrCaseCmp(str, "count") == 0)
|
||||
*field_rtrn = F_Count;
|
||||
else if (uStrCaseCmp(str, "screen") == 0)
|
||||
*field_rtrn = F_Screen;
|
||||
else if (uStrCaseCmp(str, "same") == 0)
|
||||
*field_rtrn = F_Same;
|
||||
else if (uStrCaseCmp(str, "sameserver") == 0)
|
||||
*field_rtrn = F_Same;
|
||||
else if (uStrCaseCmp(str, "data") == 0)
|
||||
*field_rtrn = F_Data;
|
||||
else if (uStrCaseCmp(str, "device") == 0)
|
||||
*field_rtrn = F_Device;
|
||||
else if (uStrCaseCmp(str, "dev") == 0)
|
||||
*field_rtrn = F_Device;
|
||||
else if (uStrCaseCmp(str, "key") == 0)
|
||||
*field_rtrn = F_Keycode;
|
||||
else if (uStrCaseCmp(str, "keycode") == 0)
|
||||
*field_rtrn = F_Keycode;
|
||||
else if (uStrCaseCmp(str, "kc") == 0)
|
||||
*field_rtrn = F_Keycode;
|
||||
else if (uStrCaseCmp(str, "clearmods") == 0)
|
||||
*field_rtrn = F_ModsToClear;
|
||||
else if (uStrCaseCmp(str, "clearmodifiers") == 0)
|
||||
*field_rtrn = F_ModsToClear;
|
||||
else
|
||||
return False;
|
||||
return True;
|
||||
return stringToValue(fieldStrings, str, field_rtrn);
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
fieldText(unsigned field)
|
||||
{
|
||||
static char buf[32];
|
||||
|
||||
switch (field)
|
||||
{
|
||||
case F_ClearLocks:
|
||||
strcpy(buf, "clearLocks");
|
||||
break;
|
||||
case F_LatchToLock:
|
||||
strcpy(buf, "latchToLock");
|
||||
break;
|
||||
case F_GenKeyEvent:
|
||||
strcpy(buf, "genKeyEvent");
|
||||
break;
|
||||
case F_Report:
|
||||
strcpy(buf, "report");
|
||||
break;
|
||||
case F_Default:
|
||||
strcpy(buf, "default");
|
||||
break;
|
||||
case F_Affect:
|
||||
strcpy(buf, "affect");
|
||||
break;
|
||||
case F_Increment:
|
||||
strcpy(buf, "increment");
|
||||
break;
|
||||
case F_Modifiers:
|
||||
strcpy(buf, "modifiers");
|
||||
break;
|
||||
case F_Group:
|
||||
strcpy(buf, "group");
|
||||
break;
|
||||
case F_X:
|
||||
strcpy(buf, "x");
|
||||
break;
|
||||
case F_Y:
|
||||
strcpy(buf, "y");
|
||||
break;
|
||||
case F_Accel:
|
||||
strcpy(buf, "accel");
|
||||
break;
|
||||
case F_Button:
|
||||
strcpy(buf, "button");
|
||||
break;
|
||||
case F_Value:
|
||||
strcpy(buf, "value");
|
||||
break;
|
||||
case F_Controls:
|
||||
strcpy(buf, "controls");
|
||||
break;
|
||||
case F_Type:
|
||||
strcpy(buf, "type");
|
||||
break;
|
||||
case F_Count:
|
||||
strcpy(buf, "count");
|
||||
break;
|
||||
case F_Screen:
|
||||
strcpy(buf, "screen");
|
||||
break;
|
||||
case F_Same:
|
||||
strcpy(buf, "sameServer");
|
||||
break;
|
||||
case F_Data:
|
||||
strcpy(buf, "data");
|
||||
break;
|
||||
case F_Device:
|
||||
strcpy(buf, "device");
|
||||
break;
|
||||
case F_Keycode:
|
||||
strcpy(buf, "keycode");
|
||||
break;
|
||||
case F_ModsToClear:
|
||||
strcpy(buf, "clearmods");
|
||||
break;
|
||||
default:
|
||||
strcpy(buf, "unknown");
|
||||
break;
|
||||
}
|
||||
return buf;
|
||||
return valueToString(fieldStrings, field);
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
@ -609,7 +486,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 +547,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 +612,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 +727,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 +769,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 +1070,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 */ ,
|
||||
|
@ -1250,7 +1110,6 @@ ApplyActionFactoryDefaults(union xkb_action * action)
|
|||
{
|
||||
action->iso.real_mods = LockMask;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1422,8 +1281,8 @@ ActionsInit(void)
|
|||
{
|
||||
if (!actionsInitialized)
|
||||
{
|
||||
bzero((char *) &constTrue, sizeof(constTrue));
|
||||
bzero((char *) &constFalse, sizeof(constFalse));
|
||||
memset(&constTrue, 0, sizeof(constTrue));
|
||||
memset(&constFalse, 0, sizeof(constFalse));
|
||||
constTrue.common.stmtType = StmtExpr;
|
||||
constTrue.common.next = NULL;
|
||||
constTrue.op = ExprIdent;
|
||||
|
@ -1436,5 +1295,4 @@ ActionsInit(void)
|
|||
constFalse.value.str = xkb_intern_atom("false");
|
||||
actionsInitialized = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,6 @@ extern int SetActionField(struct xkb_desc * /* xkb */ ,
|
|||
ActionInfo ** /* info_rtrn */
|
||||
);
|
||||
|
||||
extern LookupEntry ctrlNames[];
|
||||
extern const LookupEntry ctrlNames[];
|
||||
|
||||
#endif /* ACTION_H */
|
||||
|
|
|
@ -71,19 +71,17 @@ HandleCollision(AliasInfo * old, AliasInfo * new)
|
|||
}
|
||||
old->def.fileID = new->def.fileID;
|
||||
old->def.merge = new->def.merge;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
InitAliasInfo(AliasInfo * info,
|
||||
unsigned merge, unsigned file_id, char *alias, char *real)
|
||||
{
|
||||
bzero(info, sizeof(AliasInfo));
|
||||
memset(info, 0, sizeof(AliasInfo));
|
||||
info->def.merge = merge;
|
||||
info->def.fileID = file_id;
|
||||
strncpy(info->alias, alias, XkbKeyNameLength);
|
||||
strncpy(info->real, real, XkbKeyNameLength);
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -122,7 +120,6 @@ ClearAliases(AliasInfo ** info_in)
|
|||
{
|
||||
if ((info_in) && (*info_in))
|
||||
ClearCommonInfo(&(*info_in)->def);
|
||||
return;
|
||||
}
|
||||
|
||||
Bool
|
||||
|
@ -139,7 +136,7 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge, unsigned how_merge)
|
|||
*merge = NULL;
|
||||
return True;
|
||||
}
|
||||
bzero((char *) &def, sizeof(KeyAliasDef));
|
||||
memset(&def, 0, sizeof(KeyAliasDef));
|
||||
for (tmp = *merge; tmp != NULL; tmp = (AliasInfo *) tmp->def.next)
|
||||
{
|
||||
if (how_merge == MergeDefault)
|
||||
|
@ -157,7 +154,7 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge, unsigned how_merge)
|
|||
int
|
||||
ApplyAliases(struct xkb_desc * xkb, Bool toGeom, AliasInfo ** info_in)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
struct xkb_key_alias *old, *a;
|
||||
AliasInfo *info;
|
||||
int nNew, nOld;
|
||||
|
@ -235,7 +232,7 @@ ApplyAliases(struct xkb_desc * xkb, Bool toGeom, AliasInfo ** info_in)
|
|||
if (!xkb->geom)
|
||||
{
|
||||
struct xkb_geometry_sizes sizes;
|
||||
bzero((char *) &sizes, sizeof(struct xkb_geometry_sizes));
|
||||
memset(&sizes, 0, sizeof(struct xkb_geometry_sizes));
|
||||
sizes.which = XkbGeomKeyAliasesMask;
|
||||
sizes.num_key_aliases = nOld + nNew;
|
||||
status = XkbcAllocGeometry(xkb, &sizes);
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef struct _CompatInfo
|
|||
|
||||
/***====================================================================***/
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
siText(SymInterpInfo * si, CompatInfo * info)
|
||||
{
|
||||
static char buf[128];
|
||||
|
@ -102,7 +102,7 @@ siText(SymInterpInfo * si, CompatInfo * info)
|
|||
static void
|
||||
InitCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
info->xkb = xkb;
|
||||
info->name = NULL;
|
||||
|
@ -125,20 +125,19 @@ InitCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
|||
info->ledDflt.defs.fileID = info->fileID;
|
||||
info->ledDflt.defs.defined = 0;
|
||||
info->ledDflt.defs.merge = MergeOverride;
|
||||
bzero((char *) &info->groupCompat[0],
|
||||
XkbNumKbdGroups * sizeof(GroupCompatInfo));
|
||||
memset(&info->groupCompat[0], 0,
|
||||
XkbNumKbdGroups * sizeof(GroupCompatInfo));
|
||||
info->leds = NULL;
|
||||
InitVModInfo(&info->vmods, xkb);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
ClearCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
ActionInfo *next;
|
||||
|
||||
if (info->name != NULL)
|
||||
free(info->name);
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
info->dflt.defs.defined = 0;
|
||||
info->dflt.defs.merge = MergeAugment;
|
||||
|
@ -152,12 +151,15 @@ ClearCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
|||
ClearIndicatorMapInfo(&info->ledDflt);
|
||||
info->nInterps = 0;
|
||||
info->interps = (SymInterpInfo *) ClearCommonInfo(&info->interps->defs);
|
||||
bzero((char *) &info->groupCompat[0],
|
||||
XkbNumKbdGroups * sizeof(GroupCompatInfo));
|
||||
memset(&info->groupCompat[0], 0,
|
||||
XkbNumKbdGroups * sizeof(GroupCompatInfo));
|
||||
info->leds = (LEDInfo *) ClearCommonInfo(&info->leds->defs);
|
||||
/* 3/30/94 (ef) -- XXX! Should free action info here */
|
||||
while (info->act) {
|
||||
next = info->act->next;
|
||||
free(info->act);
|
||||
info->act = next;
|
||||
}
|
||||
ClearVModInfo(&info->vmods, xkb);
|
||||
return;
|
||||
}
|
||||
|
||||
static SymInterpInfo *
|
||||
|
@ -168,7 +170,7 @@ NextInterp(CompatInfo * info)
|
|||
si = uTypedAlloc(SymInterpInfo);
|
||||
if (si)
|
||||
{
|
||||
bzero((char *) si, sizeof(SymInterpInfo));
|
||||
memset(si, 0, sizeof(SymInterpInfo));
|
||||
info->interps =
|
||||
(SymInterpInfo *) AddCommonInfo(&info->interps->defs,
|
||||
(CommonInfo *) si);
|
||||
|
@ -351,7 +353,7 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
|
|||
SymInterpInfo *si;
|
||||
LEDInfo *led, *rtrn, *next;
|
||||
GroupCompatInfo *gcm;
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
if (from->errorCount > 0)
|
||||
{
|
||||
|
@ -388,7 +390,6 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
|
|||
else
|
||||
into->errorCount++;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
typedef void (*FileHandler) (XkbFile * /* rtrn */ ,
|
||||
|
@ -411,7 +412,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
|
|||
{
|
||||
haveSelf = True;
|
||||
included = *info;
|
||||
bzero(info, sizeof(CompatInfo));
|
||||
memset(info, 0, sizeof(CompatInfo));
|
||||
}
|
||||
else if (ProcessIncludeFile(stmt, XkmCompatMapIndex, &rtrn, &newMerge))
|
||||
{
|
||||
|
@ -426,11 +427,13 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
|
|||
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
if (info->act != NULL)
|
||||
included.act = NULL;
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -463,7 +466,10 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
|
|||
next_incl.act = info->act;
|
||||
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
|
||||
MergeIncludedCompatMaps(&included, &next_incl, op);
|
||||
if (info->act != NULL)
|
||||
next_incl.act = NULL;
|
||||
ClearCompatInfo(&next_incl, xkb);
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -482,7 +488,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
|
|||
return (info->errorCount == 0);
|
||||
}
|
||||
|
||||
static LookupEntry useModMapValues[] = {
|
||||
static const LookupEntry useModMapValues[] = {
|
||||
{"levelone", 1},
|
||||
{"level1", 1},
|
||||
{"anylevel", 0},
|
||||
|
@ -705,6 +711,7 @@ HandleCompatMapFile(XkbFile * file,
|
|||
|
||||
if (merge == MergeDefault)
|
||||
merge = MergeAugment;
|
||||
free(info->name);
|
||||
info->name = _XkbDupString(file->name);
|
||||
stmt = file->defs;
|
||||
while (stmt)
|
||||
|
@ -764,7 +771,6 @@ HandleCompatMapFile(XkbFile * file,
|
|||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -787,7 +793,6 @@ CopyInterps(CompatInfo * info,
|
|||
}
|
||||
compat->sym_interpret[compat->num_si++] = si->interp;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Bool
|
||||
|
@ -857,7 +862,6 @@ CompileCompatMap(XkbFile *file, struct xkb_desc * xkb, unsigned merge,
|
|||
ClearCompatInfo(&info, xkb);
|
||||
return True;
|
||||
}
|
||||
if (info.interps != NULL)
|
||||
free(info.interps);
|
||||
free(info.interps);
|
||||
return False;
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
/***====================================================================***/
|
||||
|
||||
typedef Bool(*IdentLookupFunc) (void * /* priv */ ,
|
||||
typedef Bool(*IdentLookupFunc) (const void * /* priv */ ,
|
||||
uint32_t /* field */ ,
|
||||
unsigned /* type */ ,
|
||||
ExprResult * /* val_rtrn */
|
||||
|
@ -41,7 +41,7 @@ typedef Bool(*IdentLookupFunc) (void * /* priv */ ,
|
|||
|
||||
/***====================================================================***/
|
||||
|
||||
char *
|
||||
const char *
|
||||
exprOpText(unsigned type)
|
||||
{
|
||||
static char buf[32];
|
||||
|
@ -103,7 +103,7 @@ exprOpText(unsigned type)
|
|||
return buf;
|
||||
}
|
||||
|
||||
static char *
|
||||
static const char *
|
||||
exprTypeText(unsigned type)
|
||||
{
|
||||
static char buf[20];
|
||||
|
@ -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 },
|
||||
|
@ -673,7 +673,7 @@ ExprResolveLevel(ExprDef * expr,
|
|||
ExprResult * val_rtrn)
|
||||
{
|
||||
int ret;
|
||||
static LookupEntry level_names[] = {
|
||||
static const LookupEntry level_names[] = {
|
||||
{ "level1", 1 },
|
||||
{ "level2", 2 },
|
||||
{ "level3", 3 },
|
||||
|
@ -702,7 +702,7 @@ int
|
|||
ExprResolveButton(ExprDef * expr,
|
||||
ExprResult * val_rtrn)
|
||||
{
|
||||
static LookupEntry button_names[] = {
|
||||
static const LookupEntry button_names[] = {
|
||||
{ "button1", 1 },
|
||||
{ "button2", 2 },
|
||||
{ "button3", 3 },
|
||||
|
@ -756,7 +756,7 @@ ExprResolveString(ExprDef * expr,
|
|||
int len;
|
||||
char *new;
|
||||
len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
|
||||
new = (char *) malloc(len);
|
||||
new = malloc(len);
|
||||
if (new)
|
||||
{ sprintf(new, "%s%s", leftRtrn.str, rightRtrn.str);
|
||||
free(leftRtrn.str);
|
||||
|
@ -866,7 +866,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)
|
||||
{
|
||||
|
@ -898,7 +898,7 @@ static int
|
|||
ExprResolveMaskLookup(ExprDef * expr,
|
||||
ExprResult * val_rtrn,
|
||||
IdentLookupFunc lookup,
|
||||
void * lookupPriv)
|
||||
const void * lookupPriv)
|
||||
{
|
||||
int ok = 0;
|
||||
ExprResult leftRtrn, rightRtrn;
|
||||
|
@ -994,7 +994,7 @@ ExprResolveMaskLookup(ExprDef * expr,
|
|||
int
|
||||
ExprResolveMask(ExprDef * expr,
|
||||
ExprResult * val_rtrn,
|
||||
LookupEntry * values)
|
||||
const LookupEntry * values)
|
||||
{
|
||||
return ExprResolveMaskLookup(expr, val_rtrn, SimpleLookup, values);
|
||||
}
|
||||
|
|
|
@ -48,22 +48,22 @@ typedef struct _LookupEntry
|
|||
} LookupEntry;
|
||||
|
||||
|
||||
extern char *exprOpText(unsigned /* type */
|
||||
extern const 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 */ ,
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
#include "action.h"
|
||||
#include "keycodes.h"
|
||||
#include "alias.h"
|
||||
#include "parseutils.h"
|
||||
|
||||
#define DFLT_FONT "helvetica"
|
||||
#define DFLT_SLANT "r"
|
||||
|
@ -276,7 +277,6 @@ InitPropertyInfo(PropertyInfo * pi, GeometryInfo * info)
|
|||
pi->defs.fileID = info->fileID;
|
||||
pi->defs.merge = info->merge;
|
||||
pi->name = pi->value = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -292,15 +292,12 @@ FreeProperties(PropertyInfo * pi, GeometryInfo * info)
|
|||
}
|
||||
for (tmp = pi; tmp != NULL; tmp = next)
|
||||
{
|
||||
if (tmp->name)
|
||||
free(tmp->name);
|
||||
if (tmp->value)
|
||||
free(tmp->value);
|
||||
free(tmp->name);
|
||||
free(tmp->value);
|
||||
tmp->name = tmp->value = NULL;
|
||||
next = (PropertyInfo *) tmp->defs.next;
|
||||
free(tmp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -315,7 +312,7 @@ InitKeyInfo(KeyInfo * key, RowInfo * row, GeometryInfo * info)
|
|||
}
|
||||
else
|
||||
{
|
||||
bzero(key, sizeof(KeyInfo));
|
||||
memset(key, 0, sizeof(KeyInfo));
|
||||
strcpy(key->name, "default");
|
||||
key->defs.defined = _GK_Default;
|
||||
key->defs.fileID = info->fileID;
|
||||
|
@ -323,7 +320,6 @@ InitKeyInfo(KeyInfo * key, RowInfo * row, GeometryInfo * info)
|
|||
key->defs.next = NULL;
|
||||
key->row = row;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -334,7 +330,6 @@ ClearKeyInfo(KeyInfo * key)
|
|||
key->gap = 0;
|
||||
key->shape = None;
|
||||
key->color = None;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -354,7 +349,6 @@ FreeKeys(KeyInfo * key, RowInfo * row, GeometryInfo * info)
|
|||
next = (KeyInfo *) tmp->defs.next;
|
||||
free(tmp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -367,7 +361,7 @@ InitRowInfo(RowInfo * row, SectionInfo * section, GeometryInfo * info)
|
|||
}
|
||||
else
|
||||
{
|
||||
bzero(row, sizeof(RowInfo));
|
||||
memset(row, 0, sizeof(RowInfo));
|
||||
row->defs.defined = _GR_Default;
|
||||
row->defs.fileID = info->fileID;
|
||||
row->defs.merge = info->merge;
|
||||
|
@ -377,7 +371,6 @@ InitRowInfo(RowInfo * row, SectionInfo * section, GeometryInfo * info)
|
|||
row->keys = NULL;
|
||||
InitKeyInfo(&row->dfltKey, row, info);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -391,7 +384,6 @@ ClearRowInfo(RowInfo * row, GeometryInfo * info)
|
|||
FreeKeys(row->keys, row, info);
|
||||
ClearKeyInfo(&row->dfltKey);
|
||||
row->dfltKey.defs.defined |= _GK_Default;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -411,7 +403,6 @@ FreeRows(RowInfo * row, SectionInfo * section, GeometryInfo * info)
|
|||
next = (RowInfo *) tmp->defs.next;
|
||||
free(tmp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static DoodadInfo *
|
||||
|
@ -456,7 +447,7 @@ InitDoodadInfo(DoodadInfo * di, unsigned type, SectionInfo * si,
|
|||
}
|
||||
else
|
||||
{
|
||||
bzero(di, sizeof(DoodadInfo));
|
||||
memset(di, 0, sizeof(DoodadInfo));
|
||||
di->defs.fileID = info->fileID;
|
||||
di->type = type;
|
||||
}
|
||||
|
@ -475,7 +466,6 @@ InitDoodadInfo(DoodadInfo * di, unsigned type, SectionInfo * si,
|
|||
if (info->nextPriority > XkbGeomMaxPriority)
|
||||
info->nextPriority = XkbGeomMaxPriority;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -484,10 +474,9 @@ ClearDoodadInfo(DoodadInfo * di)
|
|||
CommonInfo defs;
|
||||
|
||||
defs = di->defs;
|
||||
bzero(di, sizeof(DoodadInfo));
|
||||
memset(di, 0, sizeof(DoodadInfo));
|
||||
di->defs = defs;
|
||||
di->defs.defined = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -498,7 +487,6 @@ ClearOverlayInfo(OverlayInfo * ol)
|
|||
ol->keys = (OverlayKeyInfo *) ClearCommonInfo(&ol->keys->defs);
|
||||
ol->nKeys = 0;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -530,7 +518,6 @@ FreeDoodads(DoodadInfo * di, SectionInfo * si, GeometryInfo * info)
|
|||
ClearDoodadInfo(tmp);
|
||||
free(tmp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -547,7 +534,7 @@ InitSectionInfo(SectionInfo * si, GeometryInfo * info)
|
|||
}
|
||||
else
|
||||
{
|
||||
bzero(si, sizeof(SectionInfo));
|
||||
memset(si, 0, sizeof(SectionInfo));
|
||||
si->defs.fileID = info->fileID;
|
||||
si->defs.merge = info->merge;
|
||||
si->defs.next = NULL;
|
||||
|
@ -555,7 +542,6 @@ InitSectionInfo(SectionInfo * si, GeometryInfo * info)
|
|||
si->name = xkb_intern_atom("default");
|
||||
InitRowInfo(&si->dfltRow, si, info);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -574,7 +560,6 @@ DupSectionInfo(SectionInfo * into, SectionInfo * from, GeometryInfo * info)
|
|||
into->dfltRow.dfltKey.defs.merge = defs.merge;
|
||||
into->dfltRow.dfltKey.defs.next = NULL;
|
||||
into->dfltRow.dfltKey.row = &into->dfltRow;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -598,7 +583,6 @@ ClearSectionInfo(SectionInfo * si, GeometryInfo * info)
|
|||
si->doodads = NULL;
|
||||
}
|
||||
si->dfltRow.defs.defined = _GR_Default;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -618,7 +602,6 @@ FreeSections(SectionInfo * si, GeometryInfo * info)
|
|||
next = (SectionInfo *) tmp->defs.next;
|
||||
free(tmp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -636,7 +619,7 @@ FreeShapes(ShapeInfo * si, GeometryInfo * info)
|
|||
{
|
||||
if (tmp->outlines)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
for (i = 0; i < tmp->nOutlines; i++)
|
||||
{
|
||||
if (tmp->outlines[i].points != NULL)
|
||||
|
@ -655,7 +638,6 @@ FreeShapes(ShapeInfo * si, GeometryInfo * info)
|
|||
next = (ShapeInfo *) tmp->defs.next;
|
||||
free(tmp);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
@ -663,19 +645,17 @@ FreeShapes(ShapeInfo * si, GeometryInfo * info)
|
|||
static void
|
||||
InitGeometryInfo(GeometryInfo * info, unsigned fileID, unsigned merge)
|
||||
{
|
||||
bzero(info, sizeof(GeometryInfo));
|
||||
memset(info, 0, sizeof(GeometryInfo));
|
||||
info->fileID = fileID;
|
||||
info->merge = merge;
|
||||
InitSectionInfo(&info->dfltSection, info);
|
||||
info->dfltSection.defs.defined = _GS_Default;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
ClearGeometryInfo(GeometryInfo * info)
|
||||
{
|
||||
if (info->name)
|
||||
free(info->name);
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
if (info->props)
|
||||
FreeProperties(info->props, info);
|
||||
|
@ -683,6 +663,10 @@ ClearGeometryInfo(GeometryInfo * info)
|
|||
FreeShapes(info->shapes, info);
|
||||
if (info->sections)
|
||||
FreeSections(info->sections, info);
|
||||
if (info->doodads)
|
||||
FreeDoodads(info->doodads, NULL, info);
|
||||
if (info->dfltDoodads)
|
||||
FreeDoodads(info->dfltDoodads, NULL, info);
|
||||
info->widthMM = 0;
|
||||
info->heightMM = 0;
|
||||
info->dfltCornerRadius = 0;
|
||||
|
@ -690,7 +674,6 @@ ClearGeometryInfo(GeometryInfo * info)
|
|||
info->dfltSection.defs.defined = _GS_Default;
|
||||
if (info->aliases)
|
||||
ClearAliases(&info->aliases);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
@ -703,7 +686,7 @@ NextProperty(GeometryInfo * info)
|
|||
pi = uTypedAlloc(PropertyInfo);
|
||||
if (pi)
|
||||
{
|
||||
bzero((char *) pi, sizeof(PropertyInfo));
|
||||
memset(pi, 0, sizeof(PropertyInfo));
|
||||
info->props = (PropertyInfo *) AddCommonInfo(&info->props->defs,
|
||||
(CommonInfo *) pi);
|
||||
info->nProps++;
|
||||
|
@ -748,8 +731,7 @@ AddProperty(GeometryInfo * info, PropertyInfo * new)
|
|||
ACTION("Ignoring \"%s\", using \"%s\"\n", old->value,
|
||||
new->value);
|
||||
}
|
||||
if (old->value)
|
||||
free(old->value);
|
||||
free(old->value);
|
||||
old->value = _XkbDupString(new->value);
|
||||
return True;
|
||||
}
|
||||
|
@ -781,7 +763,7 @@ NextShape(GeometryInfo * info)
|
|||
si = uTypedAlloc(ShapeInfo);
|
||||
if (si)
|
||||
{
|
||||
bzero((char *) si, sizeof(ShapeInfo));
|
||||
memset(si, 0, sizeof(ShapeInfo));
|
||||
info->shapes = (ShapeInfo *) AddCommonInfo(&info->shapes->defs,
|
||||
(CommonInfo *) si);
|
||||
info->nShapes++;
|
||||
|
@ -872,7 +854,6 @@ ReplaceDoodad(DoodadInfo * into, DoodadInfo * from)
|
|||
next = from->defs.next;
|
||||
ClearDoodadInfo(from);
|
||||
from->defs.next = next;
|
||||
return;
|
||||
}
|
||||
|
||||
static DoodadInfo *
|
||||
|
@ -1310,7 +1291,6 @@ MergeIncludedGeometry(GeometryInfo * into, GeometryInfo * from,
|
|||
}
|
||||
if (!MergeAliases(&into->aliases, &from->aliases, merge))
|
||||
into->errorCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
typedef void (*FileHandler) (XkbFile * /* file */ ,
|
||||
|
@ -1333,7 +1313,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
|
|||
{
|
||||
haveSelf = True;
|
||||
included = *info;
|
||||
bzero(info, sizeof(GeometryInfo));
|
||||
memset(info, 0, sizeof(GeometryInfo));
|
||||
}
|
||||
else if (ProcessIncludeFile(stmt, XkmGeometryIndex, &rtrn, &newMerge))
|
||||
{
|
||||
|
@ -1344,11 +1324,11 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
|
|||
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1379,6 +1359,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
|
|||
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
|
||||
MergeIncludedGeometry(&included, &next_incl, op);
|
||||
ClearGeometryInfo(&next_incl);
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2080,7 +2061,7 @@ SetKeyField(KeyInfo * key,
|
|||
return ReportBadType("key", field, keyText(key), "key name");
|
||||
}
|
||||
key->defs.defined |= _GK_Name;
|
||||
bzero(key->name, XkbKeyNameLength + 1);
|
||||
memset(key->name, 0, XkbKeyNameLength + 1);
|
||||
strncpy(key->name, tmp.keyName.name, XkbKeyNameLength);
|
||||
}
|
||||
else
|
||||
|
@ -2497,7 +2478,7 @@ HandleShapeDef(ShapeDef * def, struct xkb_desc * xkb, unsigned merge,
|
|||
if (def->merge != MergeDefault)
|
||||
merge = def->merge;
|
||||
|
||||
bzero(&si, sizeof(ShapeInfo));
|
||||
memset(&si, 0, sizeof(ShapeInfo));
|
||||
si.defs.merge = merge;
|
||||
si.name = def->name;
|
||||
si.dfltCornerRadius = info->dfltCornerRadius;
|
||||
|
@ -2566,7 +2547,7 @@ HandleOverlayDef(OverlayDef * def,
|
|||
ACTION("Overlay ignored\n");
|
||||
return True;
|
||||
}
|
||||
bzero(&ol, sizeof(OverlayInfo));
|
||||
memset(&ol, 0, sizeof(OverlayInfo));
|
||||
ol.name = def->name;
|
||||
for (keyDef = def->keys; keyDef;
|
||||
keyDef = (OverlayKeyDef *) keyDef->common.next)
|
||||
|
@ -2718,7 +2699,7 @@ HandleRowBody(RowDef * def, RowInfo * row, unsigned merge,
|
|||
ACTION("Section not compiled\n");
|
||||
return False;
|
||||
}
|
||||
bzero(key.name, XkbKeyNameLength + 1);
|
||||
memset(key.name, 0, XkbKeyNameLength + 1);
|
||||
strncpy(key.name, keyDef->name, XkbKeyNameLength);
|
||||
key.defs.defined |= _GK_Name;
|
||||
}
|
||||
|
@ -2863,6 +2844,7 @@ HandleGeometryFile(XkbFile * file,
|
|||
|
||||
if (merge == MergeDefault)
|
||||
merge = MergeAugment;
|
||||
free(info->name);
|
||||
info->name = _XkbDupString(file->name);
|
||||
stmt = file->defs;
|
||||
while (stmt)
|
||||
|
@ -2930,7 +2912,6 @@ HandleGeometryFile(XkbFile * file,
|
|||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
@ -2938,7 +2919,7 @@ HandleGeometryFile(XkbFile * file,
|
|||
static Bool
|
||||
CopyShapeDef(struct xkb_geometry * geom, ShapeInfo * si)
|
||||
{
|
||||
register int i, n;
|
||||
int i, n;
|
||||
struct xkb_shape * shape;
|
||||
struct xkb_outline *old_outline, *outline;
|
||||
uint32_t name;
|
||||
|
@ -3391,7 +3372,7 @@ VerifyOverlayInfo(struct xkb_geometry * geom,
|
|||
OverlayInfo * oi,
|
||||
GeometryInfo * info, short rowMap[256], short rowSize[256])
|
||||
{
|
||||
register OverlayKeyInfo *ki, *next;
|
||||
OverlayKeyInfo *ki, *next;
|
||||
unsigned long oKey, uKey, sKey;
|
||||
struct xkb_row * row;
|
||||
struct xkb_key * key;
|
||||
|
@ -3466,7 +3447,7 @@ VerifyOverlayInfo(struct xkb_geometry * geom,
|
|||
return False;
|
||||
}
|
||||
/* now figure out how many rows are defined for the overlay */
|
||||
bzero(rowSize, sizeof(short) * 256);
|
||||
memset(rowSize, 0, sizeof(short) * 256);
|
||||
for (k = 0; k < 256; k++)
|
||||
{
|
||||
rowMap[k] = -1;
|
||||
|
@ -3525,7 +3506,7 @@ CopyOverlayDef(struct xkb_geometry * geom,
|
|||
{
|
||||
row = &ol->rows[ki->overlayRow];
|
||||
key = &row->keys[row->num_keys++];
|
||||
bzero(key, sizeof(struct xkb_overlay_key));
|
||||
memset(key, 0, sizeof(struct xkb_overlay_key));
|
||||
strncpy(key->over.name, ki->over, XkbKeyNameLength);
|
||||
strncpy(key->under.name, ki->under, XkbKeyNameLength);
|
||||
}
|
||||
|
@ -3649,7 +3630,7 @@ CompileGeometry(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
|||
{
|
||||
struct xkb_geometry * geom;
|
||||
struct xkb_geometry_sizes sizes;
|
||||
bzero(&sizes, sizeof(sizes));
|
||||
memset(&sizes, 0, sizeof(sizes));
|
||||
sizes.which = XkbGeomAllMask;
|
||||
sizes.num_properties = info.nProps;
|
||||
sizes.num_colors = 8;
|
||||
|
|
|
@ -51,7 +51,6 @@ ClearIndicatorMapInfo(LEDInfo * info)
|
|||
info->vmods = 0;
|
||||
info->which_groups = info->groups = 0;
|
||||
info->ctrls = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
LEDInfo *
|
||||
|
@ -162,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}
|
||||
};
|
||||
|
||||
|
@ -434,7 +410,7 @@ CopyIndicatorMapDefs(struct xkb_desc * xkb, LEDInfo *leds, LEDInfo **unboundRtrn
|
|||
}
|
||||
else
|
||||
{
|
||||
register struct xkb_indicator_map * im;
|
||||
struct xkb_indicator_map * im;
|
||||
im = &xkb->indicators->maps[led->indicator - 1];
|
||||
im->flags = led->flags;
|
||||
im->which_groups = led->which_groups;
|
||||
|
@ -460,8 +436,8 @@ Bool
|
|||
BindIndicators(struct xkb_desc * xkb, Bool force, LEDInfo *unbound,
|
||||
LEDInfo **unboundRtrn)
|
||||
{
|
||||
register int i;
|
||||
register LEDInfo *led, *next, *last;
|
||||
int i;
|
||||
LEDInfo *led, *next, *last;
|
||||
|
||||
if (xkb->names != NULL)
|
||||
{
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "keycodes.h"
|
||||
#include "misc.h"
|
||||
#include "alias.h"
|
||||
#include "parseutils.h"
|
||||
|
||||
const char *
|
||||
longText(unsigned long val)
|
||||
|
@ -50,7 +51,6 @@ LongToKeyName(unsigned long val, char *name)
|
|||
name[1] = ((val >> 16) & 0xff);
|
||||
name[2] = ((val >> 8) & 0xff);
|
||||
name[3] = (val & 0xff);
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
@ -143,7 +143,6 @@ InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
|
|||
ii->ndx = 0;
|
||||
ii->name = None;
|
||||
ii->virtual = False;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -154,7 +153,6 @@ ClearIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
|
|||
ClearCommonInfo(&ii->defs);
|
||||
info->leds = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static IndicatorNameInfo *
|
||||
|
@ -320,8 +318,7 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
|
|||
static void
|
||||
ClearKeyNamesInfo(KeyNamesInfo * info)
|
||||
{
|
||||
if (info->name != NULL)
|
||||
free(info->name);
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
info->computedMax = info->explicitMax = info->explicitMin = 0;
|
||||
info->computedMin = XKB_KEYCODE_MAX;
|
||||
|
@ -336,7 +333,6 @@ ClearKeyNamesInfo(KeyNamesInfo * info)
|
|||
ClearIndicatorNameInfo(info->leds, info);
|
||||
if (info->aliases)
|
||||
ClearAliases(&info->aliases);
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -350,13 +346,12 @@ InitKeyNamesInfo(KeyNamesInfo * info)
|
|||
info->has_alt_forms = NULL;
|
||||
ClearKeyNamesInfo(info);
|
||||
info->errorCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
static int
|
||||
FindKeyByLong(KeyNamesInfo * info, unsigned long name)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
for (i = info->computedMin; i <= info->computedMax; i++)
|
||||
{
|
||||
|
@ -479,7 +474,7 @@ static void
|
|||
MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
|
||||
unsigned merge)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
char buf[5];
|
||||
|
||||
if (from->errorCount > 0)
|
||||
|
@ -540,7 +535,6 @@ MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
|
|||
|| (into->explicitMax < from->explicitMax))
|
||||
into->explicitMax = from->explicitMax;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -563,7 +557,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
|
|||
{
|
||||
haveSelf = True;
|
||||
included = *info;
|
||||
bzero(info, sizeof(KeyNamesInfo));
|
||||
memset(info, 0, sizeof(KeyNamesInfo));
|
||||
}
|
||||
else if (stmt->file && strcmp(stmt->file, "computed") == 0)
|
||||
{
|
||||
|
@ -578,11 +572,11 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
|
|||
HandleKeycodesFile(rtrn, xkb, MergeOverride, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -610,6 +604,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
|
|||
HandleKeycodesFile(rtrn, xkb, MergeOverride, &next_incl);
|
||||
MergeIncludedKeycodes(&included, &next_incl, op);
|
||||
ClearKeyNamesInfo(&next_incl);
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -679,7 +674,7 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
|||
{
|
||||
ERROR("Unknown element %s encountered\n", tmp.str);
|
||||
ACTION("Default for field %s ignored\n", field.str);
|
||||
return 0;
|
||||
goto err_out;
|
||||
}
|
||||
if (uStrCaseCmp(field.str, "minimum") == 0)
|
||||
which = MIN_KEYCODE_DEF;
|
||||
|
@ -689,19 +684,19 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
|||
{
|
||||
ERROR("Unknown field encountered\n");
|
||||
ACTION("Assigment to field %s ignored\n", field.str);
|
||||
return 0;
|
||||
goto err_out;
|
||||
}
|
||||
if (arrayNdx != NULL)
|
||||
{
|
||||
ERROR("The %s setting is not an array\n", field.str);
|
||||
ACTION("Illegal array reference ignored\n");
|
||||
return 0;
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
if (ExprResolveKeyCode(stmt->value, &tmp) == 0)
|
||||
{
|
||||
ACTION("Assignment to field %s ignored\n", field.str);
|
||||
return 0;
|
||||
goto err_out;
|
||||
}
|
||||
if (tmp.uval > XKB_KEYCODE_MAX)
|
||||
{
|
||||
|
@ -709,7 +704,7 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
|||
("Illegal keycode %d (must be in the range %d-%d inclusive)\n",
|
||||
tmp.uval, 0, XKB_KEYCODE_MAX);
|
||||
ACTION("Value of \"%s\" not changed\n", field.str);
|
||||
return 0;
|
||||
goto err_out;
|
||||
}
|
||||
if (which == MIN_KEYCODE_DEF)
|
||||
{
|
||||
|
@ -719,7 +714,7 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
|||
("Minimum key code (%d) must be <= maximum key code (%d)\n",
|
||||
tmp.uval, info->explicitMax);
|
||||
ACTION("Minimum key code value not changed\n");
|
||||
return 0;
|
||||
goto err_out;
|
||||
}
|
||||
if ((info->computedMax > 0) && (info->computedMin < tmp.uval))
|
||||
{
|
||||
|
@ -727,7 +722,7 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
|||
("Minimum key code (%d) must be <= lowest defined key (%d)\n",
|
||||
tmp.uval, info->computedMin);
|
||||
ACTION("Minimum key code value not changed\n");
|
||||
return 0;
|
||||
goto err_out;
|
||||
}
|
||||
info->explicitMin = tmp.uval;
|
||||
}
|
||||
|
@ -738,7 +733,7 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
|||
ERROR("Maximum code (%d) must be >= minimum key code (%d)\n",
|
||||
tmp.uval, info->explicitMin);
|
||||
ACTION("Maximum code value not changed\n");
|
||||
return 0;
|
||||
goto err_out;
|
||||
}
|
||||
if ((info->computedMax > 0) && (info->computedMax > tmp.uval))
|
||||
{
|
||||
|
@ -746,11 +741,17 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
|||
("Maximum code (%d) must be >= highest defined key (%d)\n",
|
||||
tmp.uval, info->computedMax);
|
||||
ACTION("Maximum code value not changed\n");
|
||||
return 0;
|
||||
goto err_out;
|
||||
}
|
||||
info->explicitMax = tmp.uval;
|
||||
}
|
||||
|
||||
free(field.str);
|
||||
return 1;
|
||||
|
||||
err_out:
|
||||
free(field.str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -803,6 +804,7 @@ HandleKeycodesFile(XkbFile * file,
|
|||
{
|
||||
ParseCommon *stmt;
|
||||
|
||||
free(info->name);
|
||||
info->name = _XkbDupString(file->name);
|
||||
stmt = file->defs;
|
||||
while (stmt)
|
||||
|
@ -857,7 +859,6 @@ HandleKeycodesFile(XkbFile * file,
|
|||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -893,7 +894,7 @@ CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
|||
if (XkbcAllocNames(xkb, XkbKeyNamesMask | XkbIndicatorNamesMask, 0, 0)
|
||||
== Success)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
xkb->names->keycodes = xkb_intern_atom(info.name);
|
||||
for (i = info.computedMin; i <= info.computedMax; i++)
|
||||
{
|
||||
|
@ -919,7 +920,7 @@ CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
|||
xkb->names->indicators[ii->ndx - 1] = ii->name;
|
||||
if (xkb->indicators != NULL)
|
||||
{
|
||||
register unsigned bit;
|
||||
unsigned bit;
|
||||
bit = 1 << (ii->ndx - 1);
|
||||
if (ii->virtual)
|
||||
xkb->indicators->phys_indicators &= ~bit;
|
||||
|
@ -930,6 +931,7 @@ CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
|||
}
|
||||
if (info.aliases)
|
||||
ApplyAliases(xkb, False, &info.aliases);
|
||||
ClearKeyNamesInfo(&info);
|
||||
return True;
|
||||
}
|
||||
ClearKeyNamesInfo(&info);
|
||||
|
|
|
@ -39,8 +39,6 @@
|
|||
#define SYMBOLS 4
|
||||
#define MAX_SECTIONS 5
|
||||
|
||||
static XkbFile *sections[MAX_SECTIONS];
|
||||
|
||||
/**
|
||||
* Compile the given file and store the output in xkb.
|
||||
* @param file A list of XkbFiles, each denoting one type (e.g.
|
||||
|
@ -55,8 +53,9 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
|||
unsigned mainType;
|
||||
char *mainName;
|
||||
LEDInfo *unbound = NULL;
|
||||
XkbFile *sections[MAX_SECTIONS];
|
||||
|
||||
bzero(sections, MAX_SECTIONS * sizeof(XkbFile *));
|
||||
memset(sections, 0, sizeof(sections));
|
||||
mainType = file->type;
|
||||
mainName = file->name;
|
||||
switch (mainType)
|
||||
|
@ -84,7 +83,10 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
|||
/* Check for duplicate entries in the input file */
|
||||
while ((file) && (ok))
|
||||
{
|
||||
file->topName = mainName;
|
||||
if (file->topName != mainName) {
|
||||
free(file->topName);
|
||||
file->topName = strdup(mainName);
|
||||
}
|
||||
if ((have & (1 << file->type)) != 0)
|
||||
{
|
||||
ERROR("More than one %s section in a %s file\n",
|
||||
|
@ -158,7 +160,7 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
|||
xkb->defined = have;
|
||||
if (required & (~have))
|
||||
{
|
||||
register int i, bit;
|
||||
int i, bit;
|
||||
unsigned missing;
|
||||
missing = required & (~have);
|
||||
for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "vmod.h"
|
||||
#include "action.h"
|
||||
#include "misc.h"
|
||||
#include "parseutils.h"
|
||||
|
||||
typedef struct _PreserveInfo
|
||||
{
|
||||
|
@ -77,10 +78,10 @@ typedef struct _KeyTypesInfo
|
|||
VModInfo vmods;
|
||||
} KeyTypesInfo;
|
||||
|
||||
uint32_t tok_ONE_LEVEL;
|
||||
uint32_t tok_TWO_LEVEL;
|
||||
static uint32_t tok_ONE_LEVEL;
|
||||
static uint32_t tok_TWO_LEVEL;
|
||||
static uint32_t tok_ALPHABETIC;
|
||||
uint32_t tok_KEYPAD;
|
||||
static uint32_t tok_KEYPAD;
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
|
@ -149,7 +150,7 @@ InitKeyTypesInfo(KeyTypesInfo * info, struct xkb_desc * xkb, KeyTypesInfo * from
|
|||
info->dflt.lvlNames = uTypedCalloc(from->dflt.szNames, uint32_t);
|
||||
if (info->dflt.lvlNames)
|
||||
{
|
||||
register unsigned sz = from->dflt.szNames * sizeof(uint32_t);
|
||||
unsigned sz = from->dflt.szNames * sizeof(uint32_t);
|
||||
memcpy(info->dflt.lvlNames, from->dflt.lvlNames, sz);
|
||||
}
|
||||
}
|
||||
|
@ -173,39 +174,30 @@ InitKeyTypesInfo(KeyTypesInfo * info, struct xkb_desc * xkb, KeyTypesInfo * from
|
|||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
FreeKeyTypeInfo(KeyTypeInfo * type)
|
||||
{
|
||||
if (type->entries != NULL)
|
||||
{
|
||||
free(type->entries);
|
||||
type->entries = NULL;
|
||||
}
|
||||
if (type->lvlNames != NULL)
|
||||
{
|
||||
free(type->lvlNames);
|
||||
type->lvlNames = NULL;
|
||||
}
|
||||
free(type->entries);
|
||||
type->entries = NULL;
|
||||
free(type->lvlNames);
|
||||
type->lvlNames = NULL;
|
||||
if (type->preserve != NULL)
|
||||
{
|
||||
ClearCommonInfo(&type->preserve->defs);
|
||||
type->preserve = NULL;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
FreeKeyTypesInfo(KeyTypesInfo * info)
|
||||
{
|
||||
if (info->name)
|
||||
free(info->name);
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
if (info->types)
|
||||
{
|
||||
register KeyTypeInfo *type;
|
||||
KeyTypeInfo *type;
|
||||
for (type = info->types; type; type = (KeyTypeInfo *) type->defs.next)
|
||||
{
|
||||
FreeKeyTypeInfo(type);
|
||||
|
@ -213,7 +205,6 @@ FreeKeyTypesInfo(KeyTypesInfo * info)
|
|||
info->types = (KeyTypeInfo *) ClearCommonInfo(&info->types->defs);
|
||||
}
|
||||
FreeKeyTypeInfo(&info->dflt);
|
||||
return;
|
||||
}
|
||||
|
||||
static KeyTypeInfo *
|
||||
|
@ -224,7 +215,7 @@ NextKeyType(KeyTypesInfo * info)
|
|||
type = uTypedAlloc(KeyTypeInfo);
|
||||
if (type != NULL)
|
||||
{
|
||||
bzero(type, sizeof(KeyTypeInfo));
|
||||
memset(type, 0, sizeof(KeyTypeInfo));
|
||||
type->defs.fileID = info->fileID;
|
||||
info->types = (KeyTypeInfo *) AddCommonInfo(&info->types->defs,
|
||||
(CommonInfo *) type);
|
||||
|
@ -363,7 +354,6 @@ MergeIncludedKeyTypes(KeyTypesInfo * into,
|
|||
into->errorCount++;
|
||||
}
|
||||
into->stdPresent |= from->stdPresent;
|
||||
return;
|
||||
}
|
||||
|
||||
typedef void (*FileHandler) (XkbFile * /* file */ ,
|
||||
|
@ -386,7 +376,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
|
|||
{
|
||||
haveSelf = True;
|
||||
included = *info;
|
||||
bzero(info, sizeof(KeyTypesInfo));
|
||||
memset(info, 0, sizeof(KeyTypesInfo));
|
||||
}
|
||||
else if (ProcessIncludeFile(stmt, XkmTypesIndex, &rtrn, &newMerge))
|
||||
{
|
||||
|
@ -397,11 +387,11 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
|
|||
(*hndlr) (rtrn, xkb, newMerge, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -430,6 +420,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
|
|||
(*hndlr) (rtrn, xkb, op, &next_incl);
|
||||
MergeIncludedKeyTypes(&included, &next_incl, op, xkb);
|
||||
FreeKeyTypesInfo(&next_incl);
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -454,7 +445,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
|
|||
static struct xkb_kt_map_entry *
|
||||
FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
struct xkb_kt_map_entry * entry;
|
||||
|
||||
for (i = 0, entry = type->entries; i < type->nEntries; i++, entry++)
|
||||
|
@ -468,7 +459,7 @@ FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
|
|||
static void
|
||||
DeleteLevel1MapEntries(KeyTypeInfo * type)
|
||||
{
|
||||
register int i, n;
|
||||
int i, n;
|
||||
|
||||
for (i = 0; i < type->nEntries; i++)
|
||||
{
|
||||
|
@ -481,7 +472,6 @@ DeleteLevel1MapEntries(KeyTypeInfo * type)
|
|||
type->nEntries--;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -939,7 +929,7 @@ static int
|
|||
HandleKeyTypeDef(KeyTypeDef * def,
|
||||
struct xkb_desc * xkb, unsigned merge, KeyTypesInfo * info)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
KeyTypeInfo type;
|
||||
|
||||
if (def->merge != MergeDefault)
|
||||
|
@ -1021,6 +1011,7 @@ HandleKeyTypesFile(XkbFile * file,
|
|||
{
|
||||
ParseCommon *stmt;
|
||||
|
||||
free(info->name);
|
||||
info->name = _XkbDupString(file->name);
|
||||
stmt = file->defs;
|
||||
while (stmt)
|
||||
|
@ -1074,13 +1065,12 @@ HandleKeyTypesFile(XkbFile * file,
|
|||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static Bool
|
||||
CopyDefToKeyType(struct xkb_desc * xkb, struct xkb_key_type * type, KeyTypeInfo * def)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
PreserveInfo *pre;
|
||||
|
||||
for (pre = def->preserve; pre != NULL;
|
||||
|
@ -1161,9 +1151,9 @@ CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
|||
|
||||
if (info.errorCount == 0)
|
||||
{
|
||||
register int i;
|
||||
register KeyTypeInfo *def;
|
||||
register struct xkb_key_type *type, *next;
|
||||
int i;
|
||||
KeyTypeInfo *def;
|
||||
struct xkb_key_type *type, *next;
|
||||
|
||||
if (info.name != NULL)
|
||||
{
|
||||
|
|
|
@ -355,6 +355,8 @@ AddDirectory(CompPair *cp, char *head, char *ptrn, char *rest, char *map,
|
|||
}
|
||||
#ifdef WIN32
|
||||
while (FindNextFile(dirh, &file));
|
||||
#else
|
||||
closedir(dirp);
|
||||
#endif
|
||||
return nMatch;
|
||||
}
|
||||
|
|
|
@ -53,48 +53,53 @@ ProcessIncludeFile(IncludeStmt * stmt,
|
|||
XkbFile ** file_rtrn, unsigned *merge_rtrn)
|
||||
{
|
||||
FILE *file;
|
||||
XkbFile *rtrn, *mapToUse;
|
||||
XkbFile *rtrn, *mapToUse, *next;
|
||||
char oldFile[1024] = {0};
|
||||
int oldLine = lineNum;
|
||||
|
||||
rtrn = XkbFindFileInCache(stmt->file, file_type, &stmt->path);
|
||||
if (rtrn == NULL)
|
||||
file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
|
||||
if (file == NULL)
|
||||
{
|
||||
/* file not in cache, open it, parse it and store it in cache for next
|
||||
time. */
|
||||
file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
|
||||
if (file == NULL)
|
||||
{
|
||||
ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
|
||||
XkbDirectoryForInclude(file_type));
|
||||
return False;
|
||||
}
|
||||
if (scanFile)
|
||||
strcpy(oldFile, scanFile);
|
||||
else
|
||||
memset(oldFile, 0, sizeof(oldFile));
|
||||
oldLine = lineNum;
|
||||
setScanState(stmt->file, 1);
|
||||
if (debugFlags & 2)
|
||||
INFO("About to parse include file %s\n", stmt->file);
|
||||
/* parse the file */
|
||||
if ((XKBParseFile(file, &rtrn) == 0) || (rtrn == NULL))
|
||||
{
|
||||
setScanState(oldFile, oldLine);
|
||||
ERROR("Error interpreting include file \"%s\"\n", stmt->file);
|
||||
fclose(file);
|
||||
return False;
|
||||
}
|
||||
fclose(file);
|
||||
XkbAddFileToCache(stmt->file, file_type, stmt->path, rtrn);
|
||||
ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
|
||||
XkbDirectoryForInclude(file_type));
|
||||
return False;
|
||||
}
|
||||
if (scanFile)
|
||||
strcpy(oldFile, scanFile);
|
||||
else
|
||||
memset(oldFile, 0, sizeof(oldFile));
|
||||
oldLine = lineNum;
|
||||
setScanState(stmt->file, 1);
|
||||
if (debugFlags & 2)
|
||||
INFO("About to parse include file %s\n", stmt->file);
|
||||
/* parse the file */
|
||||
if ((XKBParseFile(file, &rtrn) == 0) || (rtrn == NULL))
|
||||
{
|
||||
setScanState(oldFile, oldLine);
|
||||
ERROR("Error interpreting include file \"%s\"\n", stmt->file);
|
||||
fclose(file);
|
||||
return False;
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
mapToUse = rtrn;
|
||||
if (stmt->map != NULL)
|
||||
{
|
||||
while ((mapToUse) && ((!uStringEqual(mapToUse->name, stmt->map)) ||
|
||||
(mapToUse->type != file_type)))
|
||||
while (mapToUse)
|
||||
{
|
||||
mapToUse = (XkbFile *) mapToUse->common.next;
|
||||
next = (XkbFile *)mapToUse->common.next;
|
||||
mapToUse->common.next = NULL;
|
||||
if (uStringEqual(mapToUse->name, stmt->map) &&
|
||||
mapToUse->type == file_type)
|
||||
{
|
||||
FreeXKBFile(next);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
FreeXKBFile(mapToUse);
|
||||
}
|
||||
mapToUse = next;
|
||||
}
|
||||
if (!mapToUse)
|
||||
{
|
||||
|
@ -249,7 +254,7 @@ FindNamedKey(struct xkb_desc * xkb,
|
|||
xkb_keycode_t *kc_rtrn,
|
||||
Bool use_aliases, Bool create, int start_from)
|
||||
{
|
||||
register unsigned n;
|
||||
unsigned n;
|
||||
|
||||
if (start_from < xkb->min_key_code)
|
||||
{
|
||||
|
@ -315,7 +320,7 @@ Bool
|
|||
FindKeyNameForAlias(struct xkb_desc * xkb, unsigned long lname,
|
||||
unsigned long *real_name)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
char name[XkbKeyNameLength + 1];
|
||||
|
||||
if (xkb && xkb->geom && xkb->geom->key_aliases)
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "parseutils.h"
|
||||
#include "xkbmisc.h"
|
||||
#include "xkbpath.h"
|
||||
#include "xkbparse.h"
|
||||
#include <X11/keysym.h>
|
||||
#include <X11/Xalloca.h>
|
||||
|
||||
|
@ -270,7 +271,7 @@ SymbolsCreate(char *keyName, ExprDef * symbols)
|
|||
def->common.stmtType = StmtSymbolsDef;
|
||||
def->common.next = NULL;
|
||||
def->merge = MergeDefault;
|
||||
bzero(def->keyName, 5);
|
||||
memset(def->keyName, 0, 5);
|
||||
strncpy(def->keyName, keyName, 4);
|
||||
def->symbols = symbols;
|
||||
}
|
||||
|
@ -420,7 +421,7 @@ ShapeDeclCreate(uint32_t name, OutlineDef * outlines)
|
|||
shape = uTypedAlloc(ShapeDef);
|
||||
if (shape != NULL)
|
||||
{
|
||||
bzero(shape, sizeof(ShapeDef));
|
||||
memset(shape, 0, sizeof(ShapeDef));
|
||||
shape->common.stmtType = StmtShapeDef;
|
||||
shape->common.next = NULL;
|
||||
shape->merge = MergeDefault;
|
||||
|
@ -445,7 +446,7 @@ OutlineCreate(uint32_t field, ExprDef * points)
|
|||
outline = uTypedAlloc(OutlineDef);
|
||||
if (outline != NULL)
|
||||
{
|
||||
bzero(outline, sizeof(OutlineDef));
|
||||
memset(outline, 0, sizeof(OutlineDef));
|
||||
outline->common.stmtType = StmtOutlineDef;
|
||||
outline->common.next = NULL;
|
||||
outline->field = field;
|
||||
|
@ -470,7 +471,7 @@ KeyDeclCreate(char *name, ExprDef * expr)
|
|||
key = uTypedAlloc(KeyDef);
|
||||
if (key != NULL)
|
||||
{
|
||||
bzero(key, sizeof(KeyDef));
|
||||
memset(key, 0, sizeof(KeyDef));
|
||||
key->common.stmtType = StmtKeyDef;
|
||||
key->common.next = NULL;
|
||||
if (name)
|
||||
|
@ -490,7 +491,7 @@ RowDeclCreate(KeyDef * keys)
|
|||
row = uTypedAlloc(RowDef);
|
||||
if (row != NULL)
|
||||
{
|
||||
bzero(row, sizeof(RowDef));
|
||||
memset(row, 0, sizeof(RowDef));
|
||||
row->common.stmtType = StmtRowDef;
|
||||
row->common.next = NULL;
|
||||
row->nKeys = 0;
|
||||
|
@ -513,7 +514,7 @@ SectionDeclCreate(uint32_t name, RowDef * rows)
|
|||
section = uTypedAlloc(SectionDef);
|
||||
if (section != NULL)
|
||||
{
|
||||
bzero(section, sizeof(SectionDef));
|
||||
memset(section, 0, sizeof(SectionDef));
|
||||
section->common.stmtType = StmtSectionDef;
|
||||
section->common.next = NULL;
|
||||
section->name = name;
|
||||
|
@ -536,14 +537,12 @@ OverlayKeyCreate(char *under, char *over)
|
|||
key = uTypedAlloc(OverlayKeyDef);
|
||||
if (key != NULL)
|
||||
{
|
||||
bzero(key, sizeof(OverlayKeyDef));
|
||||
memset(key, 0, sizeof(OverlayKeyDef));
|
||||
key->common.stmtType = StmtOverlayKeyDef;
|
||||
strncpy(key->over, over, XkbKeyNameLength);
|
||||
strncpy(key->under, under, XkbKeyNameLength);
|
||||
if (over)
|
||||
free(over);
|
||||
if (under)
|
||||
free(under);
|
||||
free(over);
|
||||
free(under);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
@ -557,7 +556,7 @@ OverlayDeclCreate(uint32_t name, OverlayKeyDef * keys)
|
|||
ol = uTypedAlloc(OverlayDef);
|
||||
if (ol != NULL)
|
||||
{
|
||||
bzero(ol, sizeof(OverlayDef));
|
||||
memset(ol, 0, sizeof(OverlayDef));
|
||||
ol->common.stmtType = StmtOverlayDef;
|
||||
ol->name = name;
|
||||
ol->keys = keys;
|
||||
|
@ -578,7 +577,7 @@ DoodadCreate(unsigned type, uint32_t name, VarDef * body)
|
|||
doodad = uTypedAlloc(DoodadDef);
|
||||
if (doodad != NULL)
|
||||
{
|
||||
bzero(doodad, sizeof(DoodadDef));
|
||||
memset(doodad, 0, sizeof(DoodadDef));
|
||||
doodad->common.stmtType = StmtDoodadDef;
|
||||
doodad->common.next = NULL;
|
||||
doodad->type = type;
|
||||
|
@ -634,6 +633,9 @@ LookupKeysym(char *str, uint32_t * sym_rtrn)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
FreeInclude(IncludeStmt *incl);
|
||||
|
||||
IncludeStmt *
|
||||
IncludeCreate(char *str, unsigned merge)
|
||||
{
|
||||
|
@ -694,29 +696,15 @@ IncludeCreate(char *str, unsigned merge)
|
|||
}
|
||||
if (first)
|
||||
first->stmt = stmt;
|
||||
else if (stmt)
|
||||
else
|
||||
free(stmt);
|
||||
return first;
|
||||
BAIL:
|
||||
|
||||
BAIL:
|
||||
ERROR("Illegal include statement \"%s\"\n", stmt);
|
||||
ACTION("Ignored\n");
|
||||
while (first)
|
||||
{
|
||||
incl = first->next;
|
||||
if (first->file)
|
||||
free(first->file);
|
||||
if (first->map)
|
||||
free(first->map);
|
||||
if (first->modifier)
|
||||
free(first->modifier);
|
||||
if (first->path)
|
||||
free(first->path);
|
||||
first->file = first->map = first->path = NULL;
|
||||
free(first);
|
||||
first = incl;
|
||||
}
|
||||
if (stmt)
|
||||
free(stmt);
|
||||
FreeInclude(first);
|
||||
free(stmt);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -765,7 +753,6 @@ CheckDefaultMap(XkbFile * maps)
|
|||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
XkbFile *
|
||||
|
@ -778,7 +765,7 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags)
|
|||
if (file)
|
||||
{
|
||||
XkbcEnsureSafeMapName(name);
|
||||
bzero(file, sizeof(XkbFile));
|
||||
memset(file, 0, sizeof(XkbFile));
|
||||
file->type = type;
|
||||
file->topName = _XkbDupString(name);
|
||||
file->name = name;
|
||||
|
@ -800,3 +787,183 @@ StmtSetMerge(ParseCommon * stmt, unsigned merge)
|
|||
}
|
||||
return merge;
|
||||
}
|
||||
|
||||
static void
|
||||
FreeStmt(ParseCommon *stmt);
|
||||
|
||||
static void
|
||||
FreeExpr(ExprDef *expr)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!expr)
|
||||
return;
|
||||
|
||||
switch (expr->op)
|
||||
{
|
||||
case ExprActionList:
|
||||
case OpNegate:
|
||||
case OpUnaryPlus:
|
||||
case OpNot:
|
||||
case OpInvert:
|
||||
FreeStmt(&expr->value.child->common);
|
||||
break;
|
||||
case OpDivide:
|
||||
case OpAdd:
|
||||
case OpSubtract:
|
||||
case OpMultiply:
|
||||
case OpAssign:
|
||||
FreeStmt(&expr->value.binary.left->common);
|
||||
FreeStmt(&expr->value.binary.right->common);
|
||||
break;
|
||||
case ExprActionDecl:
|
||||
FreeStmt(&expr->value.action.args->common);
|
||||
break;
|
||||
case ExprArrayRef:
|
||||
FreeStmt(&expr->value.array.entry->common);
|
||||
break;
|
||||
case ExprKeysymList:
|
||||
for (i = 0; i < expr->value.list.nSyms; i++)
|
||||
free(expr->value.list.syms[i]);
|
||||
free(expr->value.list.syms);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
FreeInclude(IncludeStmt *incl)
|
||||
{
|
||||
IncludeStmt *next;
|
||||
|
||||
while (incl)
|
||||
{
|
||||
next = incl->next;
|
||||
|
||||
free(incl->file);
|
||||
free(incl->map);
|
||||
free(incl->modifier);
|
||||
free(incl->path);
|
||||
free(incl->stmt);
|
||||
|
||||
free(incl);
|
||||
incl = next;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
FreeStmt(ParseCommon *stmt)
|
||||
{
|
||||
ParseCommon *next;
|
||||
YYSTYPE u;
|
||||
|
||||
while (stmt)
|
||||
{
|
||||
next = stmt->next;
|
||||
u.any = stmt;
|
||||
|
||||
switch (stmt->stmtType)
|
||||
{
|
||||
case StmtInclude:
|
||||
FreeInclude((IncludeStmt *)stmt);
|
||||
/* stmt is already free'd here. */
|
||||
stmt = NULL;
|
||||
break;
|
||||
case StmtExpr:
|
||||
FreeExpr(u.expr);
|
||||
break;
|
||||
case StmtVarDef:
|
||||
FreeStmt(&u.var->name->common);
|
||||
FreeStmt(&u.var->value->common);
|
||||
break;
|
||||
case StmtKeyTypeDef:
|
||||
FreeStmt(&u.keyType->body->common);
|
||||
break;
|
||||
case StmtInterpDef:
|
||||
free(u.interp->sym);
|
||||
FreeStmt(&u.interp->match->common);
|
||||
FreeStmt(&u.interp->def->common);
|
||||
break;
|
||||
case StmtVModDef:
|
||||
FreeStmt(&u.vmod->value->common);
|
||||
break;
|
||||
case StmtSymbolsDef:
|
||||
FreeStmt(&u.syms->symbols->common);
|
||||
break;
|
||||
case StmtModMapDef:
|
||||
FreeStmt(&u.modMask->keys->common);
|
||||
break;
|
||||
case StmtGroupCompatDef:
|
||||
FreeStmt(&u.groupCompat->def->common);
|
||||
break;
|
||||
case StmtIndicatorMapDef:
|
||||
FreeStmt(&u.ledMap->body->common);
|
||||
break;
|
||||
case StmtIndicatorNameDef:
|
||||
FreeStmt(&u.ledName->name->common);
|
||||
break;
|
||||
case StmtOutlineDef:
|
||||
FreeStmt(&u.outline->points->common);
|
||||
break;
|
||||
case StmtShapeDef:
|
||||
FreeStmt(&u.shape->outlines->common);
|
||||
break;
|
||||
case StmtKeyDef:
|
||||
free(u.key->name);
|
||||
FreeStmt(&u.key->expr->common);
|
||||
break;
|
||||
case StmtRowDef:
|
||||
FreeStmt(&u.row->keys->common);
|
||||
break;
|
||||
case StmtSectionDef:
|
||||
FreeStmt(&u.section->rows->common);
|
||||
break;
|
||||
case StmtOverlayKeyDef:
|
||||
break;
|
||||
case StmtOverlayDef:
|
||||
FreeStmt(&u.overlay->keys->common);
|
||||
break;
|
||||
case StmtDoodadDef:
|
||||
FreeStmt(&u.doodad->body->common);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
free(stmt);
|
||||
stmt = next;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
FreeXKBFile(XkbFile *file)
|
||||
{
|
||||
XkbFile *next;
|
||||
|
||||
while (file)
|
||||
{
|
||||
next = (XkbFile *)file->common.next;
|
||||
|
||||
switch (file->type)
|
||||
{
|
||||
case XkmKeymapFile:
|
||||
case XkmSemanticsFile:
|
||||
case XkmLayoutFile:
|
||||
FreeXKBFile((XkbFile *)file->defs);
|
||||
break;
|
||||
case XkmTypesIndex:
|
||||
case XkmCompatMapIndex:
|
||||
case XkmSymbolsIndex:
|
||||
case XkmKeyNamesIndex:
|
||||
case XkmGeometryIndex:
|
||||
FreeStmt(file->defs);
|
||||
break;
|
||||
}
|
||||
|
||||
free(file->name);
|
||||
free(file->topName);
|
||||
free(file);
|
||||
file = next;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,6 +177,8 @@ extern XkbFile *CreateXKBFile(int /* type */ ,
|
|||
unsigned /* flags */
|
||||
);
|
||||
|
||||
extern void FreeXKBFile(XkbFile *file);
|
||||
|
||||
extern void yyerror(const char * /* msg */
|
||||
);
|
||||
|
||||
|
|
|
@ -40,10 +40,6 @@
|
|||
#include "misc.h"
|
||||
#include "alias.h"
|
||||
|
||||
extern uint32_t tok_ONE_LEVEL;
|
||||
extern uint32_t tok_TWO_LEVEL;
|
||||
extern uint32_t tok_KEYPAD;
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
#define RepeatYes 1
|
||||
|
@ -85,7 +81,7 @@ typedef struct _KeyInfo
|
|||
static void
|
||||
InitKeyInfo(KeyInfo * info)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
static char dflt[4] = "*";
|
||||
|
||||
info->defs.defined = 0;
|
||||
|
@ -109,7 +105,6 @@ InitKeyInfo(KeyInfo * info)
|
|||
info->nameForOverlayKey = 0;
|
||||
info->repeat = RepeatUndefined;
|
||||
info->allowNone = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -118,7 +113,7 @@ InitKeyInfo(KeyInfo * info)
|
|||
static void
|
||||
FreeKeyInfo(KeyInfo * info)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
info->defs.defined = 0;
|
||||
info->defs.fileID = 0;
|
||||
|
@ -130,11 +125,9 @@ FreeKeyInfo(KeyInfo * info)
|
|||
{
|
||||
info->numLevels[i] = 0;
|
||||
info->types[i] = None;
|
||||
if (info->syms[i] != NULL)
|
||||
free(info->syms[i]);
|
||||
free(info->syms[i]);
|
||||
info->syms[i] = NULL;
|
||||
if (info->acts[i] != NULL)
|
||||
free(info->acts[i]);
|
||||
free(info->acts[i]);
|
||||
info->acts[i] = NULL;
|
||||
}
|
||||
info->dfltType = None;
|
||||
|
@ -144,7 +137,6 @@ FreeKeyInfo(KeyInfo * info)
|
|||
info->nameForOverlayKey = 0;
|
||||
info->repeat = RepeatUndefined;
|
||||
info->allowNone = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -155,7 +147,7 @@ FreeKeyInfo(KeyInfo * info)
|
|||
static Bool
|
||||
CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
*new = *old;
|
||||
new->defs.next = NULL;
|
||||
|
@ -183,8 +175,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
|
|||
new->numLevels[i] = 0;
|
||||
return False;
|
||||
}
|
||||
memcpy((char *) new->syms[i], (char *) old->syms[i],
|
||||
width * sizeof(uint32_t));
|
||||
memcpy(new->syms[i], old->syms[i], width * sizeof(uint32_t));
|
||||
}
|
||||
if (old->acts[i] != NULL)
|
||||
{
|
||||
|
@ -194,7 +185,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
|
|||
new->acts[i] = NULL;
|
||||
return False;
|
||||
}
|
||||
memcpy((char *) new->acts[i], (char *) old->acts[i],
|
||||
memcpy(new->acts[i], old->acts[i],
|
||||
width * sizeof(union xkb_action));
|
||||
}
|
||||
}
|
||||
|
@ -241,11 +232,8 @@ typedef struct _SymbolsInfo
|
|||
static void
|
||||
InitSymbolsInfo(SymbolsInfo * info, struct xkb_desc * xkb)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
tok_ONE_LEVEL = xkb_intern_atom("ONE_LEVEL");
|
||||
tok_TWO_LEVEL = xkb_intern_atom("TWO_LEVEL");
|
||||
tok_KEYPAD = xkb_intern_atom("KEYPAD");
|
||||
info->name = NULL;
|
||||
info->explicit_group = 0;
|
||||
info->errorCount = 0;
|
||||
|
@ -262,38 +250,25 @@ InitSymbolsInfo(SymbolsInfo * info, struct xkb_desc * xkb)
|
|||
InitVModInfo(&info->vmods, xkb);
|
||||
info->action = NULL;
|
||||
info->aliases = NULL;
|
||||
return;
|
||||
}
|
||||
|
||||
static void
|
||||
FreeSymbolsInfo(SymbolsInfo * info)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
if (info->name)
|
||||
free(info->name);
|
||||
info->name = NULL;
|
||||
free(info->name);
|
||||
if (info->keys)
|
||||
{
|
||||
for (i = 0; i < info->nKeys; i++)
|
||||
{
|
||||
FreeKeyInfo(&info->keys[i]);
|
||||
}
|
||||
free(info->keys);
|
||||
info->keys = NULL;
|
||||
}
|
||||
if (info->modMap)
|
||||
{
|
||||
ClearCommonInfo(&info->modMap->defs);
|
||||
info->modMap = NULL;
|
||||
}
|
||||
if (info->aliases)
|
||||
{
|
||||
ClearAliases(&info->aliases);
|
||||
info->aliases = NULL;
|
||||
}
|
||||
bzero((char *) info, sizeof(SymbolsInfo));
|
||||
return;
|
||||
memset(info, 0, sizeof(SymbolsInfo));
|
||||
}
|
||||
|
||||
static Bool
|
||||
|
@ -337,7 +312,7 @@ MergeKeyGroups(SymbolsInfo * info,
|
|||
uint32_t *resultSyms;
|
||||
union xkb_action *resultActs;
|
||||
int resultWidth;
|
||||
register int i;
|
||||
int i;
|
||||
Bool report, clobber;
|
||||
|
||||
clobber = (from->defs.merge != MergeAugment);
|
||||
|
@ -374,6 +349,9 @@ MergeKeyGroups(SymbolsInfo * info,
|
|||
WSGO("Could not allocate actions for group merge\n");
|
||||
ACTION("Group %d of key %s not merged\n", group,
|
||||
longText(into->name));
|
||||
if (resultSyms != into->syms[group] &&
|
||||
resultSyms != from->syms[group])
|
||||
free(resultSyms);
|
||||
return False;
|
||||
}
|
||||
}
|
||||
|
@ -457,13 +435,13 @@ MergeKeyGroups(SymbolsInfo * info,
|
|||
}
|
||||
}
|
||||
}
|
||||
if ((into->syms[group] != NULL) && (resultSyms != into->syms[group]))
|
||||
if (resultSyms != into->syms[group])
|
||||
free(into->syms[group]);
|
||||
if ((from->syms[group] != NULL) && (resultSyms != from->syms[group]))
|
||||
if (resultSyms != from->syms[group])
|
||||
free(from->syms[group]);
|
||||
if ((into->acts[group] != NULL) && (resultActs != into->acts[group]))
|
||||
if (resultActs != into->acts[group])
|
||||
free(into->acts[group]);
|
||||
if ((from->acts[group] != NULL) && (resultActs != from->acts[group]))
|
||||
if (resultActs != from->acts[group])
|
||||
free(from->acts[group]);
|
||||
into->numLevels[group] = resultWidth;
|
||||
into->syms[group] = resultSyms;
|
||||
|
@ -480,7 +458,7 @@ MergeKeyGroups(SymbolsInfo * info,
|
|||
static Bool
|
||||
MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
unsigned collide = 0;
|
||||
Bool report;
|
||||
|
||||
|
@ -490,14 +468,12 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
|
|||
{
|
||||
if (into->numLevels[i] != 0)
|
||||
{
|
||||
if (into->syms[i])
|
||||
free(into->syms[i]);
|
||||
if (into->acts[i])
|
||||
free(into->acts[i]);
|
||||
free(into->syms[i]);
|
||||
free(into->acts[i]);
|
||||
}
|
||||
}
|
||||
*into = *from;
|
||||
bzero(from, sizeof(KeyInfo));
|
||||
memset(from, 0, sizeof(KeyInfo));
|
||||
return True;
|
||||
}
|
||||
report = ((warningLevel > 9) ||
|
||||
|
@ -604,7 +580,7 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
|
|||
static Bool
|
||||
AddKeySymbols(SymbolsInfo * info, KeyInfo * key, struct xkb_desc * xkb)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
unsigned long real_name;
|
||||
|
||||
for (i = 0; i < info->nKeys; i++)
|
||||
|
@ -716,7 +692,7 @@ static void
|
|||
MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
|
||||
unsigned merge, struct xkb_desc * xkb)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
KeyInfo *key;
|
||||
|
||||
if (from->errorCount > 0)
|
||||
|
@ -760,7 +736,6 @@ MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
|
|||
}
|
||||
if (!MergeAliases(&into->aliases, &from->aliases, merge))
|
||||
into->errorCount++;
|
||||
return;
|
||||
}
|
||||
|
||||
typedef void (*FileHandler) (XkbFile * /* rtrn */ ,
|
||||
|
@ -783,7 +758,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
|
|||
{
|
||||
haveSelf = True;
|
||||
included = *info;
|
||||
bzero(info, sizeof(SymbolsInfo));
|
||||
memset(info, 0, sizeof(SymbolsInfo));
|
||||
}
|
||||
else if (ProcessIncludeFile(stmt, XkmSymbolsIndex, &rtrn, &newMerge))
|
||||
{
|
||||
|
@ -801,11 +776,11 @@ HandleIncludeSymbols(IncludeStmt * stmt,
|
|||
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
||||
if (stmt->stmt != NULL)
|
||||
{
|
||||
if (included.name != NULL)
|
||||
free(included.name);
|
||||
free(included.name);
|
||||
included.name = stmt->stmt;
|
||||
stmt->stmt = NULL;
|
||||
}
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -842,6 +817,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
|
|||
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
|
||||
MergeIncludedSymbols(&included, &next_incl, op, xkb);
|
||||
FreeSymbolsInfo(&next_incl);
|
||||
FreeXKBFile(rtrn);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -877,7 +853,7 @@ GetGroupIndex(KeyInfo * key,
|
|||
|
||||
if (arrayNdx == NULL)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
unsigned defined;
|
||||
if (what == SYMBOLS)
|
||||
defined = key->symsDefined;
|
||||
|
@ -968,7 +944,7 @@ AddActionsToKey(KeyInfo * key,
|
|||
char *field,
|
||||
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
unsigned ndx, nActs;
|
||||
ExprDef *act;
|
||||
struct xkb_any_action *toAct;
|
||||
|
@ -1071,7 +1047,7 @@ SetAllowNone(KeyInfo * key, ExprDef * arrayNdx, ExprDef * value)
|
|||
}
|
||||
|
||||
|
||||
static LookupEntry lockingEntries[] = {
|
||||
static const LookupEntry lockingEntries[] = {
|
||||
{"true", XkbKB_Lock},
|
||||
{"yes", XkbKB_Lock},
|
||||
{"on", XkbKB_Lock},
|
||||
|
@ -1082,7 +1058,7 @@ static LookupEntry lockingEntries[] = {
|
|||
{NULL, 0}
|
||||
};
|
||||
|
||||
static LookupEntry repeatEntries[] = {
|
||||
static const LookupEntry repeatEntries[] = {
|
||||
{"true", RepeatYes},
|
||||
{"yes", RepeatYes},
|
||||
{"on", RepeatYes},
|
||||
|
@ -1507,13 +1483,11 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
|
|||
for (i = 1; i < XkbNumKbdGroups; i++)
|
||||
{
|
||||
key->numLevels[i] = 0;
|
||||
if (key->syms[i] != NULL)
|
||||
free(key->syms[i]);
|
||||
key->syms[i] = (uint32_t *) NULL;
|
||||
if (key->acts[i] != NULL)
|
||||
free(key->acts[i]);
|
||||
key->acts[i] = (union xkb_action *) NULL;
|
||||
key->types[i] = (uint32_t) 0;
|
||||
free(key->syms[i]);
|
||||
key->syms[i] = NULL;
|
||||
free(key->acts[i]);
|
||||
key->acts[i] = NULL;
|
||||
key->types[i] = 0;
|
||||
}
|
||||
}
|
||||
key->typesDefined = key->symsDefined = key->actsDefined = 1 << group;
|
||||
|
@ -1521,11 +1495,11 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
|
|||
key->numLevels[group] = key->numLevels[0];
|
||||
key->numLevels[0] = 0;
|
||||
key->syms[group] = key->syms[0];
|
||||
key->syms[0] = (uint32_t *) NULL;
|
||||
key->syms[0] = NULL;
|
||||
key->acts[group] = key->acts[0];
|
||||
key->acts[0] = (union xkb_action *) NULL;
|
||||
key->acts[0] = NULL;
|
||||
key->types[group] = key->types[0];
|
||||
key->types[0] = (uint32_t) 0;
|
||||
key->types[0] = 0;
|
||||
return True;
|
||||
}
|
||||
|
||||
|
@ -1608,6 +1582,7 @@ HandleSymbolsFile(XkbFile * file,
|
|||
{
|
||||
ParseCommon *stmt;
|
||||
|
||||
free(info->name);
|
||||
info->name = _XkbDupString(file->name);
|
||||
stmt = file->defs;
|
||||
while (stmt)
|
||||
|
@ -1660,14 +1635,13 @@ HandleSymbolsFile(XkbFile * file,
|
|||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
static Bool
|
||||
FindKeyForSymbol(struct xkb_desc * xkb, uint32_t sym, xkb_keycode_t *kc_rtrn)
|
||||
{
|
||||
register int i, j;
|
||||
register Bool gotOne;
|
||||
int i, j;
|
||||
Bool gotOne;
|
||||
|
||||
j = 0;
|
||||
do
|
||||
|
@ -1702,7 +1676,7 @@ FindKeyForSymbol(struct xkb_desc * xkb, uint32_t sym, xkb_keycode_t *kc_rtrn)
|
|||
static Bool
|
||||
FindNamedType(struct xkb_desc * xkb, uint32_t name, unsigned *type_rtrn)
|
||||
{
|
||||
register unsigned n;
|
||||
unsigned n;
|
||||
|
||||
if (xkb && xkb->map && xkb->map->types)
|
||||
{
|
||||
|
@ -1822,7 +1796,7 @@ PrepareKeyDef(KeyInfo * key)
|
|||
key->acts[i] = uTypedCalloc(width, union xkb_action);
|
||||
if (key->acts[i] == NULL)
|
||||
continue;
|
||||
memcpy((void *) key->acts[i], (void *) key->acts[0],
|
||||
memcpy(key->acts[i], key->acts[0],
|
||||
width * sizeof(union xkb_action));
|
||||
key->actsDefined |= 1 << i;
|
||||
}
|
||||
|
@ -1831,8 +1805,7 @@ PrepareKeyDef(KeyInfo * key)
|
|||
key->syms[i] = uTypedCalloc(width, uint32_t);
|
||||
if (key->syms[i] == NULL)
|
||||
continue;
|
||||
memcpy((void *) key->syms[i], (void *) key->syms[0],
|
||||
width * sizeof(uint32_t));
|
||||
memcpy(key->syms[i], key->syms[0], width * sizeof(uint32_t));
|
||||
key->symsDefined |= 1 << i;
|
||||
}
|
||||
if (defined & 1)
|
||||
|
@ -1853,7 +1826,7 @@ PrepareKeyDef(KeyInfo * key)
|
|||
}
|
||||
if ((key->syms[i] != key->syms[0]) &&
|
||||
(key->syms[i] == NULL || key->syms[0] == NULL ||
|
||||
memcmp((void *) key->syms[i], (void *) key->syms[0],
|
||||
memcmp(key->syms[i], key->syms[0],
|
||||
sizeof(uint32_t) * key->numLevels[0])))
|
||||
{
|
||||
identical = False;
|
||||
|
@ -1861,7 +1834,7 @@ PrepareKeyDef(KeyInfo * key)
|
|||
}
|
||||
if ((key->acts[i] != key->acts[0]) &&
|
||||
(key->acts[i] == NULL || key->acts[0] == NULL ||
|
||||
memcmp((void *) key->acts[i], (void *) key->acts[0],
|
||||
memcmp(key->acts[i], key->acts[0],
|
||||
sizeof(union xkb_action) * key->numLevels[0])))
|
||||
{
|
||||
identical = False;
|
||||
|
@ -1873,19 +1846,16 @@ PrepareKeyDef(KeyInfo * key)
|
|||
for (i = lastGroup; i > 0; i--)
|
||||
{
|
||||
key->numLevels[i] = 0;
|
||||
if (key->syms[i] != NULL)
|
||||
free(key->syms[i]);
|
||||
key->syms[i] = (uint32_t *) NULL;
|
||||
if (key->acts[i] != NULL)
|
||||
free(key->acts[i]);
|
||||
key->acts[i] = (union xkb_action *) NULL;
|
||||
key->types[i] = (uint32_t) 0;
|
||||
free(key->syms[i]);
|
||||
key->syms[i] = NULL;
|
||||
free(key->acts[i]);
|
||||
key->acts[i] = NULL;
|
||||
key->types[i] = 0;
|
||||
}
|
||||
key->symsDefined &= 1;
|
||||
key->actsDefined &= 1;
|
||||
key->typesDefined &= 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1896,7 +1866,7 @@ PrepareKeyDef(KeyInfo * key)
|
|||
static Bool
|
||||
CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
xkb_keycode_t okc, kc;
|
||||
unsigned width, tmp, nGroups;
|
||||
struct xkb_key_type * type;
|
||||
|
@ -2148,7 +2118,7 @@ CopyModMapDef(struct xkb_desc * xkb, ModMapEntry *entry)
|
|||
Bool
|
||||
CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
SymbolsInfo info;
|
||||
|
||||
InitSymbolsInfo(&info, xkb);
|
||||
|
|
|
@ -36,16 +36,16 @@ recalloc(void * old, unsigned nOld, unsigned nNew, unsigned itemSize)
|
|||
char *rtrn;
|
||||
|
||||
if (old == NULL)
|
||||
rtrn = (char *) calloc(nNew, itemSize);
|
||||
rtrn = calloc(nNew, itemSize);
|
||||
else
|
||||
{
|
||||
rtrn = (char *) realloc((char *) old, nNew * itemSize);
|
||||
rtrn = realloc(old, nNew * itemSize);
|
||||
if ((rtrn) && (nNew > nOld))
|
||||
{
|
||||
bzero(&rtrn[nOld * itemSize], (nNew - nOld) * itemSize);
|
||||
memset(&rtrn[nOld * itemSize], 0, (nNew - nOld) * itemSize);
|
||||
}
|
||||
}
|
||||
return (void *) rtrn;
|
||||
return rtrn;
|
||||
}
|
||||
|
||||
static FILE *errorFile = NULL;
|
||||
|
@ -205,7 +205,7 @@ uStrCaseCmp(const char *str1, const char *str2)
|
|||
{
|
||||
char buf1[512], buf2[512];
|
||||
char c, *s;
|
||||
register int n;
|
||||
int n;
|
||||
|
||||
for (n = 0, s = buf1; (c = *str1++); n++)
|
||||
{
|
||||
|
|
|
@ -70,10 +70,10 @@ recalloc(void * old, unsigned nOld, unsigned nNew, unsigned newSize);
|
|||
|
||||
#define uTypedAlloc(t) ((t *)malloc((unsigned)sizeof(t)))
|
||||
#define uTypedCalloc(n,t) ((t *)calloc((unsigned)n,(unsigned)sizeof(t)))
|
||||
#define uTypedRealloc(pO,n,t) ((t *)realloc((void *)pO,((unsigned)n)*sizeof(t)))
|
||||
#define uTypedRecalloc(pO,o,n,t) ((t *)recalloc((void *)pO,((unsigned)o),((unsigned)n),sizeof(t)))
|
||||
#define uTypedRealloc(pO,n,t) ((t *)realloc(pO,((unsigned)n)*sizeof(t)))
|
||||
#define uTypedRecalloc(pO,o,n,t) ((t *)recalloc(pO,((unsigned)o),((unsigned)n),sizeof(t)))
|
||||
#if (defined mdHasAlloca) && (mdHasAlloca)
|
||||
#define uTmpAlloc(n) ((void *)alloca((unsigned)n))
|
||||
#define uTmpAlloc(n) alloca((unsigned)n)
|
||||
#define uTmpFree(p)
|
||||
#else
|
||||
#define uTmpAlloc(n) malloc(n)
|
||||
|
|
|
@ -41,13 +41,12 @@ InitVModInfo(VModInfo * info, struct xkb_desc * xkb)
|
|||
{
|
||||
ClearVModInfo(info, xkb);
|
||||
info->errorCount = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
ClearVModInfo(VModInfo * info, struct xkb_desc * xkb)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
if (XkbcAllocNames(xkb, XkbVirtualModNamesMask, 0, 0) != Success)
|
||||
return;
|
||||
|
@ -57,14 +56,13 @@ ClearVModInfo(VModInfo * info, struct xkb_desc * xkb)
|
|||
info->newlyDefined = info->defined = info->available = 0;
|
||||
if (xkb && xkb->names)
|
||||
{
|
||||
register int bit;
|
||||
int bit;
|
||||
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
|
||||
{
|
||||
if (xkb->names->vmods[i] != None)
|
||||
info->defined |= bit;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
@ -81,7 +79,7 @@ Bool
|
|||
HandleVModDef(VModDef * stmt, struct xkb_desc *xkb, unsigned mergeMode,
|
||||
VModInfo * info)
|
||||
{
|
||||
register int i, bit, nextFree;
|
||||
int i, bit, nextFree;
|
||||
ExprResult mod;
|
||||
struct xkb_server_map * srv;
|
||||
struct xkb_names * names;
|
||||
|
@ -161,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;
|
||||
|
@ -197,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))
|
||||
|
@ -206,7 +204,7 @@ LookupVModMask(void * priv, uint32_t field, unsigned type,
|
|||
}
|
||||
else if (LookupVModIndex(priv, field, type, val_rtrn))
|
||||
{
|
||||
register unsigned ndx = val_rtrn->uval;
|
||||
unsigned ndx = val_rtrn->uval;
|
||||
val_rtrn->uval = (1 << (XkbNumModifiers + ndx));
|
||||
return True;
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@ authorization from the authors.
|
|||
#include "xkballoc.h"
|
||||
#include "xkbrules.h"
|
||||
#include "xkbpath.h"
|
||||
#include "xkbmisc.h"
|
||||
#include "parseutils.h"
|
||||
#include "utils.h"
|
||||
|
||||
|
@ -77,36 +78,23 @@ XkbComponentsFromRules(const char *rules, const XkbRF_VarDefsPtr defs)
|
|||
{
|
||||
FILE *rulesFile = NULL;
|
||||
char *rulesPath = NULL;
|
||||
static XkbRF_RulesPtr loaded = NULL;
|
||||
static char *cached_name = NULL;
|
||||
XkbRF_RulesPtr loaded = NULL;
|
||||
struct xkb_component_names * names = NULL;
|
||||
|
||||
if (!cached_name || strcmp(rules, cached_name) != 0) {
|
||||
if (loaded)
|
||||
XkbcRF_Free(loaded, True);
|
||||
loaded = NULL;
|
||||
free(cached_name);
|
||||
cached_name = NULL;
|
||||
rulesFile = XkbFindFileInPath(rules, XkmRulesFile, &rulesPath);
|
||||
if (!rulesFile) {
|
||||
ERROR("could not find \"%s\" rules in XKB path\n", rules);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!loaded) {
|
||||
rulesFile = XkbFindFileInPath(rules, XkmRulesFile, &rulesPath);
|
||||
if (!rulesFile) {
|
||||
ERROR("could not find \"%s\" rules in XKB path\n", rules);
|
||||
goto out;
|
||||
}
|
||||
if (!(loaded = _XkbTypedCalloc(1, XkbRF_RulesRec))) {
|
||||
ERROR("failed to allocate XKB rules\n");
|
||||
goto unwind_file;
|
||||
}
|
||||
|
||||
if (!(loaded = _XkbTypedCalloc(1, XkbRF_RulesRec))) {
|
||||
ERROR("failed to allocate XKB rules\n");
|
||||
goto unwind_file;
|
||||
}
|
||||
|
||||
if (!XkbcRF_LoadRules(rulesFile, loaded)) {
|
||||
ERROR("failed to load XKB rules \"%s\"\n", rulesPath);
|
||||
goto unwind_file;
|
||||
}
|
||||
|
||||
cached_name = strdup(rules);
|
||||
if (!XkbcRF_LoadRules(rulesFile, loaded)) {
|
||||
ERROR("failed to load XKB rules \"%s\"\n", rulesPath);
|
||||
goto unwind_file;
|
||||
}
|
||||
|
||||
if (!(names = _XkbTypedCalloc(1, struct xkb_component_names))) {
|
||||
|
@ -127,10 +115,10 @@ XkbComponentsFromRules(const char *rules, const XkbRF_VarDefsPtr defs)
|
|||
}
|
||||
|
||||
unwind_file:
|
||||
XkbcRF_Free(loaded);
|
||||
if (rulesFile)
|
||||
fclose(rulesFile);
|
||||
free(rulesPath);
|
||||
out:
|
||||
return names;
|
||||
}
|
||||
|
||||
|
@ -209,7 +197,7 @@ struct xkb_desc *
|
|||
xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
|
||||
{
|
||||
XkbFile *file, *mapToUse;
|
||||
struct xkb_desc * xkb;
|
||||
struct xkb_desc * xkb = NULL;
|
||||
|
||||
uSetErrorFile(NULL);
|
||||
|
||||
|
@ -235,23 +223,23 @@ xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
|
|||
|
||||
if (!CompileKeymap(mapToUse, xkb, MergeReplace)) {
|
||||
ERROR("failed to compile keymap\n");
|
||||
goto unwind_xkb;
|
||||
XkbcFreeKeyboard(xkb);
|
||||
xkb = NULL;
|
||||
}
|
||||
|
||||
return xkb;
|
||||
unwind_xkb:
|
||||
XkbcFreeKeyboard(xkb, XkbAllComponentsMask, True);
|
||||
unwind_file:
|
||||
/* XXX: here's where we would free the XkbFile */
|
||||
FreeXKBFile(file);
|
||||
free(scanFile);
|
||||
XkbFreeIncludePath();
|
||||
fail:
|
||||
return NULL;
|
||||
return xkb;
|
||||
}
|
||||
|
||||
static struct xkb_desc *
|
||||
compile_keymap(XkbFile *file, const char *mapName)
|
||||
{
|
||||
XkbFile *mapToUse;
|
||||
struct xkb_desc * xkb;
|
||||
struct xkb_desc * xkb = NULL;
|
||||
|
||||
/* Find map to use */
|
||||
if (!(mapToUse = XkbChooseMap(file, mapName)))
|
||||
|
@ -275,16 +263,15 @@ compile_keymap(XkbFile *file, const char *mapName)
|
|||
|
||||
if (!CompileKeymap(mapToUse, xkb, MergeReplace)) {
|
||||
ERROR("failed to compile keymap\n");
|
||||
goto unwind_xkb;
|
||||
XkbcFreeKeyboard(xkb);
|
||||
xkb = NULL;
|
||||
}
|
||||
|
||||
return xkb;
|
||||
unwind_xkb:
|
||||
XkbcFreeKeyboard(xkb, XkbAllComponentsMask, True);
|
||||
unwind_file:
|
||||
/* XXX: here's where we would free the XkbFile */
|
||||
|
||||
return NULL;
|
||||
FreeXKBFile(file);
|
||||
free(scanFile);
|
||||
XkbFreeIncludePath();
|
||||
return xkb;
|
||||
}
|
||||
|
||||
struct xkb_desc *
|
||||
|
@ -328,5 +315,6 @@ xkb_compile_keymap_from_file(FILE *inputFile, const char *mapName)
|
|||
void
|
||||
xkb_free_keymap(struct xkb_desc *xkb)
|
||||
{
|
||||
XkbcFreeKeyboard(xkb, 0, True);
|
||||
XkbcFreeKeyboard(xkb);
|
||||
XkbcFreeAllAtoms();
|
||||
}
|
||||
|
|
|
@ -332,8 +332,7 @@ KeyNameDecl : KeyName EQUALS KeyCode SEMI
|
|||
KeycodeDef *def;
|
||||
|
||||
def= KeycodeCreate($1,$3);
|
||||
if ($1)
|
||||
free($1);
|
||||
free($1);
|
||||
$$= def;
|
||||
}
|
||||
;
|
||||
|
@ -342,8 +341,8 @@ KeyAliasDecl : ALIAS KeyName EQUALS KeyName SEMI
|
|||
{
|
||||
KeyAliasDef *def;
|
||||
def= KeyAliasCreate($2,$4);
|
||||
if ($2) free($2);
|
||||
if ($4) free($4);
|
||||
free($2);
|
||||
free($4);
|
||||
$$= def;
|
||||
}
|
||||
;
|
||||
|
@ -732,7 +731,7 @@ KeySym : IDENT { $$= strdup(scanBuf); }
|
|||
}
|
||||
else {
|
||||
$$= malloc(17);
|
||||
snprintf($$, 17, "%x", $1);
|
||||
snprintf($$, 17, "0x%x", $1);
|
||||
}
|
||||
}
|
||||
;
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#define DEBUG_VAR debugFlags
|
||||
#include "utils.h"
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "xkbpath.h"
|
||||
#include "xkbcommon/xkbcommon.h"
|
||||
|
@ -170,7 +171,7 @@ XkbInitIncludePath(void)
|
|||
return True;
|
||||
|
||||
szPath = PATH_CHUNK;
|
||||
includePath = (char **) calloc(szPath, sizeof(char *));
|
||||
includePath = calloc(szPath, sizeof(char *));
|
||||
if (!includePath)
|
||||
return False;
|
||||
|
||||
|
@ -184,7 +185,7 @@ XkbInitIncludePath(void)
|
|||
static void
|
||||
XkbClearIncludePath(void)
|
||||
{
|
||||
register int i;
|
||||
int i;
|
||||
|
||||
if (szPath > 0)
|
||||
{
|
||||
|
@ -199,7 +200,14 @@ XkbClearIncludePath(void)
|
|||
nPathEntries = 0;
|
||||
}
|
||||
noDefaultPath = True;
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
XkbFreeIncludePath(void)
|
||||
{
|
||||
XkbClearIncludePath();
|
||||
free(includePath);
|
||||
includePath = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -232,7 +240,7 @@ XkbAddDirectoryToPath(const char *dir)
|
|||
if (nPathEntries >= szPath)
|
||||
{
|
||||
szPath += PATH_CHUNK;
|
||||
includePath = (char **) realloc(includePath, szPath * sizeof(char *));
|
||||
includePath = realloc(includePath, szPath * sizeof(char *));
|
||||
if (includePath == NULL)
|
||||
{
|
||||
WSGO("Allocation failed (includePath)\n");
|
||||
|
@ -263,127 +271,34 @@ XkbAddDefaultDirectoriesToPath(void)
|
|||
|
||||
/**
|
||||
* Return the xkb directory based on the type.
|
||||
* Do not free the memory returned by this function.
|
||||
*/
|
||||
char *
|
||||
const char *
|
||||
XkbDirectoryForInclude(unsigned type)
|
||||
{
|
||||
static char buf[32];
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case XkmSemanticsFile:
|
||||
strcpy(buf, "semantics");
|
||||
break;
|
||||
return "semantics";
|
||||
case XkmLayoutFile:
|
||||
strcpy(buf, "layout");
|
||||
break;
|
||||
return "layout";
|
||||
case XkmKeymapFile:
|
||||
strcpy(buf, "keymap");
|
||||
break;
|
||||
return "keymap";
|
||||
case XkmKeyNamesIndex:
|
||||
strcpy(buf, "keycodes");
|
||||
break;
|
||||
return "keycodes";
|
||||
case XkmTypesIndex:
|
||||
strcpy(buf, "types");
|
||||
break;
|
||||
return "types";
|
||||
case XkmSymbolsIndex:
|
||||
strcpy(buf, "symbols");
|
||||
break;
|
||||
return "symbols";
|
||||
case XkmCompatMapIndex:
|
||||
strcpy(buf, "compat");
|
||||
break;
|
||||
return "compat";
|
||||
case XkmGeometryFile:
|
||||
case XkmGeometryIndex:
|
||||
strcpy(buf, "geometry");
|
||||
break;
|
||||
return "geometry";
|
||||
case XkmRulesFile:
|
||||
strcpy(buf, "rules");
|
||||
break;
|
||||
return "rules";
|
||||
default:
|
||||
strcpy(buf, "");
|
||||
break;
|
||||
return "";
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
typedef struct _FileCacheEntry
|
||||
{
|
||||
char *name;
|
||||
unsigned type;
|
||||
char *path;
|
||||
void *data;
|
||||
struct _FileCacheEntry *next;
|
||||
} FileCacheEntry;
|
||||
static FileCacheEntry *fileCache;
|
||||
|
||||
/**
|
||||
* Add the file with the given name to the internal cache to avoid opening and
|
||||
* parsing the file multiple times. If a cache entry for the same name + type
|
||||
* is already present, the entry is overwritten and the data belonging to the
|
||||
* previous entry is returned.
|
||||
*
|
||||
* @parameter name The name of the file (e.g. evdev).
|
||||
* @parameter type Type of the file (XkbTypesIdx, ... or XkbSemanticsFile, ...)
|
||||
* @parameter path The full path to the file.
|
||||
* @parameter data Already parsed data.
|
||||
*
|
||||
* @return The data from the overwritten file or NULL.
|
||||
*/
|
||||
void *
|
||||
XkbAddFileToCache(char *name, unsigned type, char *path, void *data)
|
||||
{
|
||||
FileCacheEntry *entry;
|
||||
|
||||
for (entry = fileCache; entry != NULL; entry = entry->next)
|
||||
{
|
||||
if ((type == entry->type) && (uStringEqual(name, entry->name)))
|
||||
{
|
||||
void *old = entry->data;
|
||||
WSGO("Replacing file cache entry (%s/%d)\n", name, type);
|
||||
entry->path = path;
|
||||
entry->data = data;
|
||||
return old;
|
||||
}
|
||||
}
|
||||
entry = uTypedAlloc(FileCacheEntry);
|
||||
if (entry != NULL)
|
||||
{
|
||||
entry->name = name;
|
||||
entry->type = type;
|
||||
entry->path = path;
|
||||
entry->data = data;
|
||||
entry->next = fileCache;
|
||||
fileCache = entry;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for the given name + type in the cache.
|
||||
*
|
||||
* @parameter name The name of the file (e.g. evdev).
|
||||
* @parameter type Type of the file (XkbTypesIdx, ... or XkbSemanticsFile, ...)
|
||||
* @parameter pathRtrn Set to the full path of the given entry.
|
||||
*
|
||||
* @return the data from the cache entry or NULL if no matching entry was found.
|
||||
*/
|
||||
void *
|
||||
XkbFindFileInCache(char *name, unsigned type, char **pathRtrn)
|
||||
{
|
||||
FileCacheEntry *entry;
|
||||
|
||||
for (entry = fileCache; entry != NULL; entry = entry->next)
|
||||
{
|
||||
if ((type == entry->type) && (uStringEqual(name, entry->name)))
|
||||
{
|
||||
*pathRtrn = entry->path;
|
||||
return entry->data;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/***====================================================================***/
|
||||
|
@ -401,41 +316,40 @@ XkbFindFileInCache(char *name, unsigned type, char **pathRtrn)
|
|||
FILE *
|
||||
XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
|
||||
{
|
||||
register int i;
|
||||
int i, ret;
|
||||
FILE *file = NULL;
|
||||
int nameLen, typeLen, pathLen;
|
||||
char buf[PATH_MAX], *typeDir;
|
||||
char buf[PATH_MAX];
|
||||
const char *typeDir;
|
||||
|
||||
if (!XkbInitIncludePath())
|
||||
return NULL;
|
||||
|
||||
typeDir = XkbDirectoryForInclude(type);
|
||||
nameLen = strlen(name);
|
||||
typeLen = strlen(typeDir);
|
||||
for (i = 0; i < nPathEntries; i++)
|
||||
{
|
||||
pathLen = strlen(includePath[i]);
|
||||
if (typeLen < 1)
|
||||
if (includePath[i] == NULL || *includePath[i] == '\0')
|
||||
continue;
|
||||
|
||||
if ((nameLen + typeLen + pathLen + 2) >= PATH_MAX)
|
||||
ret = snprintf(buf, sizeof(buf), "%s/%s/%s",
|
||||
includePath[i], typeDir, name);
|
||||
if (ret >= sizeof(buf))
|
||||
{
|
||||
ERROR("File name (%s/%s/%s) too long\n", includePath[i],
|
||||
typeDir, name);
|
||||
ACTION("Ignored\n");
|
||||
continue;
|
||||
}
|
||||
snprintf(buf, sizeof(buf), "%s/%s/%s", includePath[i], typeDir, name);
|
||||
file = fopen(buf, "r");
|
||||
if (file != NULL)
|
||||
break;
|
||||
if (file == NULL) {
|
||||
ERROR("Couldn't open file (%s/%s/%s): %s\n", includePath[i],
|
||||
typeDir, name, strerror(-errno));
|
||||
ACTION("Ignored\n");
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if ((file != NULL) && (pathRtrn != NULL))
|
||||
{
|
||||
*pathRtrn = (char *) calloc(strlen(buf) + 1, sizeof(char));
|
||||
if (*pathRtrn != NULL)
|
||||
strcpy(*pathRtrn, buf);
|
||||
}
|
||||
*pathRtrn = strdup(buf);
|
||||
return file;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include <X11/X.h>
|
||||
#include <X11/Xdefs.h>
|
||||
|
||||
extern char *XkbDirectoryForInclude(unsigned /* type */
|
||||
extern const char *XkbDirectoryForInclude(unsigned /* type */
|
||||
);
|
||||
|
||||
extern FILE *XkbFindFileInPath(const char * /* name */ ,
|
||||
|
@ -39,17 +39,6 @@ extern FILE *XkbFindFileInPath(const char * /* name */ ,
|
|||
char ** /* pathRtrn */
|
||||
);
|
||||
|
||||
extern void *XkbAddFileToCache(char * /* name */ ,
|
||||
unsigned /* type */ ,
|
||||
char * /* path */ ,
|
||||
void * /* data */
|
||||
);
|
||||
|
||||
extern void *XkbFindFileInCache(char * /* name */ ,
|
||||
unsigned /* type */ ,
|
||||
char ** /* pathRtrn */
|
||||
);
|
||||
|
||||
extern Bool XkbParseIncludeMap(char ** /* str_inout */ ,
|
||||
char ** /* file_rtrn */ ,
|
||||
char ** /* map_rtrn */ ,
|
||||
|
@ -57,4 +46,6 @@ extern Bool XkbParseIncludeMap(char ** /* str_inout */ ,
|
|||
char ** /* extra_data */
|
||||
);
|
||||
|
||||
extern void XkbFreeIncludePath(void);
|
||||
|
||||
#endif /* _XKBPATH_H_ */
|
||||
|
|
|
@ -199,8 +199,7 @@ yyerror(const char *msg)
|
|||
void setScanState(const char *file, int lineno)
|
||||
{
|
||||
yylineno = 1;
|
||||
if (scanFile)
|
||||
free(scanFile);
|
||||
free(scanFile);
|
||||
scanFile = strdup(file);
|
||||
}
|
||||
|
||||
|
@ -230,20 +229,18 @@ XKBParseString(const char *string, XkbFile ** pRtrn)
|
|||
int
|
||||
XKBParseFile(FILE * file, XkbFile ** pRtrn)
|
||||
{
|
||||
if (file)
|
||||
{
|
||||
yyin = file;
|
||||
rtrnValue = NULL;
|
||||
if (yyparse() == 0)
|
||||
{
|
||||
*pRtrn = rtrnValue;
|
||||
CheckDefaultMap(rtrnValue);
|
||||
rtrnValue = NULL;
|
||||
return 1;
|
||||
}
|
||||
*pRtrn = NULL;
|
||||
return 0;
|
||||
}
|
||||
*pRtrn = NULL;
|
||||
if (!file)
|
||||
return 1;
|
||||
|
||||
yyin = file;
|
||||
rtrnValue = NULL;
|
||||
if (yyparse() != 0)
|
||||
return 0;
|
||||
|
||||
yylex_destroy();
|
||||
*pRtrn = rtrnValue;
|
||||
CheckDefaultMap(rtrnValue);
|
||||
rtrnValue = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ authorization from the authors.
|
|||
#include "xkbcommon/xkbcommon.h"
|
||||
|
||||
extern void
|
||||
XkbcFreeGeometry(struct xkb_geometry * geom, unsigned which, Bool freeMap);
|
||||
XkbcFreeGeometry(struct xkb_desc * xkb);
|
||||
|
||||
extern int
|
||||
XkbcAllocGeomKeyAliases(struct xkb_geometry * geom, int nKeyAliases);
|
||||
|
|
|
@ -70,6 +70,9 @@ XkbcNameMatchesPattern(char *name, char *ptrn);
|
|||
extern char *
|
||||
XkbcAtomGetString(uint32_t atom);
|
||||
|
||||
extern void
|
||||
XkbcFreeAllAtoms(void);
|
||||
|
||||
/***====================================================================***/
|
||||
|
||||
extern const char *
|
||||
|
|
|
@ -156,6 +156,6 @@ extern Bool
|
|||
XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
|
||||
|
||||
extern void
|
||||
XkbcRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
|
||||
XkbcRF_Free(XkbRF_RulesPtr rules);
|
||||
|
||||
#endif /* _XKBRULES_H_ */
|
||||
|
|
Loading…
Reference in New Issue