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 _XkbTypedCalloc(n,t) ((t *)calloc((n),sizeof(t)))
|
||||||
#define _XkbTypedRealloc(o,n,t) \
|
#define _XkbTypedRealloc(o,n,t) \
|
||||||
((o)?(t *)realloc((o),(n)*sizeof(t)):_XkbTypedCalloc(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 _XkbDupString(s) ((s) ? strdup(s) : NULL)
|
||||||
#define _XkbStrCaseCmp strcasecmp
|
#define _XkbStrCaseCmp strcasecmp
|
||||||
|
|
77
src/alloc.c
77
src/alloc.c
|
@ -79,7 +79,7 @@ XkbcAllocCompatMap(struct xkb_desc * xkb, unsigned which, unsigned nSI)
|
||||||
}
|
}
|
||||||
compat->size_si = nSI;
|
compat->size_si = nSI;
|
||||||
compat->num_si = 0;
|
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;
|
xkb->compat = compat;
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
|
@ -87,7 +87,7 @@ XkbcAllocCompatMap(struct xkb_desc * xkb, unsigned which, unsigned nSI)
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeCompatMap(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
XkbcFreeCompatMap(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
struct xkb_compat_map * compat;
|
struct xkb_compat_map * compat;
|
||||||
|
|
||||||
|
@ -95,24 +95,11 @@ XkbcFreeCompatMap(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
compat = xkb->compat;
|
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);
|
free(compat->sym_interpret);
|
||||||
compat->size_si = compat->num_si = 0;
|
|
||||||
compat->sym_interpret = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeMap) {
|
|
||||||
free(compat);
|
free(compat);
|
||||||
xkb->compat = NULL;
|
xkb->compat = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalRG, int nTotalAliases)
|
XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalRG, int nTotalAliases)
|
||||||
|
@ -202,56 +189,33 @@ XkbcAllocNames(struct xkb_desc * xkb, unsigned which, int nTotalRG, int nTotalAl
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeNames(struct xkb_desc * xkb, unsigned which, Bool freeMap)
|
XkbcFreeNames(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
struct xkb_names * names;
|
struct xkb_names * names;
|
||||||
|
struct xkb_client_map * map;
|
||||||
|
|
||||||
if (!xkb || !xkb->names)
|
if (!xkb || !xkb->names)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
names = xkb->names;
|
names = xkb->names;
|
||||||
if (freeMap)
|
map = xkb->map;
|
||||||
which = XkbAllNamesMask;
|
|
||||||
|
|
||||||
if (which & XkbKTLevelNamesMask) {
|
|
||||||
struct xkb_client_map * map = xkb->map;
|
|
||||||
|
|
||||||
if (map && map->types) {
|
if (map && map->types) {
|
||||||
int i;
|
int i;
|
||||||
struct xkb_key_type * type = map->types;
|
struct xkb_key_type * type = map->types;
|
||||||
|
|
||||||
for (i = 0; i < map->num_types; i++, type++) {
|
for (i = 0; i < map->num_types; i++, type++) {
|
||||||
if (type->level_names) {
|
|
||||||
free(type->level_names);
|
free(type->level_names);
|
||||||
type->level_names = NULL;
|
type->level_names = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((which & XkbKeyNamesMask) && names->keys) {
|
|
||||||
free(names->keys);
|
free(names->keys);
|
||||||
names->keys = NULL;
|
|
||||||
names->num_keys = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((which & XkbKeyAliasesMask) && names->key_aliases) {
|
|
||||||
free(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);
|
free(names->radio_groups);
|
||||||
names->radio_groups = NULL;
|
|
||||||
names->num_rg = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeMap) {
|
|
||||||
free(names);
|
free(names);
|
||||||
xkb->names = NULL;
|
xkb->names = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
int
|
int
|
||||||
XkbcAllocControls(struct xkb_desc * xkb, unsigned which)
|
XkbcAllocControls(struct xkb_desc * xkb, unsigned which)
|
||||||
|
@ -276,9 +240,9 @@ XkbcAllocControls(struct xkb_desc * xkb, unsigned which)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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->per_key_repeat);
|
||||||
free(xkb->ctrls);
|
free(xkb->ctrls);
|
||||||
xkb->ctrls = NULL;
|
xkb->ctrls = NULL;
|
||||||
|
@ -303,7 +267,7 @@ XkbcAllocIndicatorMaps(struct xkb_desc * xkb)
|
||||||
static void
|
static void
|
||||||
XkbcFreeIndicatorMaps(struct xkb_desc * xkb)
|
XkbcFreeIndicatorMaps(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
if (xkb && xkb->indicators) {
|
if (xkb) {
|
||||||
free(xkb->indicators);
|
free(xkb->indicators);
|
||||||
xkb->indicators = NULL;
|
xkb->indicators = NULL;
|
||||||
}
|
}
|
||||||
|
@ -321,28 +285,17 @@ XkbcAllocKeyboard(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeKeyboard(struct xkb_desc * xkb, unsigned which, Bool freeAll)
|
XkbcFreeKeyboard(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
if (!xkb)
|
if (!xkb)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeAll)
|
XkbcFreeClientMap(xkb);
|
||||||
which = XkbAllComponentsMask;
|
XkbcFreeServerMap(xkb);
|
||||||
|
XkbcFreeCompatMap(xkb);
|
||||||
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);
|
XkbcFreeIndicatorMaps(xkb);
|
||||||
if (which & XkbNamesMask)
|
XkbcFreeNames(xkb);
|
||||||
XkbcFreeNames(xkb, XkbAllNamesMask, True);
|
XkbcFreeGeometry(xkb);
|
||||||
if ((which & XkbGeometryMask) && xkb->geom)
|
XkbcFreeControls(xkb);
|
||||||
XkbcFreeGeometry(xkb->geom, XkbGeomAllMask, True);
|
|
||||||
if (which & XkbControlsMask)
|
|
||||||
XkbcFreeControls(xkb, XkbAllControlsMask, True);
|
|
||||||
if (freeAll)
|
|
||||||
free(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;
|
return;
|
||||||
do_intern_atom = intern;
|
do_intern_atom = intern;
|
||||||
do_get_atom_value = get_atom_value;
|
do_get_atom_value = get_atom_value;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,11 +170,11 @@ xkb_intern_atom(const char *string)
|
||||||
if (makeit) {
|
if (makeit) {
|
||||||
NodePtr nd;
|
NodePtr nd;
|
||||||
|
|
||||||
nd = (NodePtr)malloc(sizeof(NodeRec));
|
nd = malloc(sizeof(NodeRec));
|
||||||
if (!nd)
|
if (!nd)
|
||||||
return BAD_RESOURCE;
|
return BAD_RESOURCE;
|
||||||
|
|
||||||
nd->string = (char *)malloc(len + 1);
|
nd->string = malloc(len + 1);
|
||||||
if (!nd->string) {
|
if (!nd->string) {
|
||||||
free(nd);
|
free(nd);
|
||||||
return BAD_RESOURCE;
|
return BAD_RESOURCE;
|
||||||
|
@ -216,3 +215,26 @@ xkb_intern_atom(const char *string)
|
||||||
else
|
else
|
||||||
return None;
|
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;
|
||||||
|
}
|
||||||
|
|
317
src/galloc.c
317
src/galloc.c
|
@ -31,311 +31,182 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include "XKBcommonint.h"
|
#include "XKBcommonint.h"
|
||||||
#include <X11/extensions/XKB.h>
|
#include <X11/extensions/XKB.h>
|
||||||
|
|
||||||
static void
|
typedef void (*ContentsClearFunc)(void *priv);
|
||||||
_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);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbFreeGeomNonLeafElems(Bool freeAll, int first, int count,
|
_XkbFreeGeomNonLeafElems(unsigned short *num_inout, unsigned short *sz_inout,
|
||||||
unsigned short *num_inout, unsigned short *sz_inout,
|
void *elems, size_t elem_sz,
|
||||||
char **elems, unsigned int elem_sz,
|
|
||||||
ContentsClearFunc freeFunc)
|
ContentsClearFunc freeFunc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *ptr;
|
char *start, *ptr;
|
||||||
|
|
||||||
if (freeAll) {
|
if (!elems)
|
||||||
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))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeFunc) {
|
start = *(char **)elems;
|
||||||
ptr = *elems;
|
if (!start)
|
||||||
ptr += first * elem_sz;
|
return;
|
||||||
for (i = 0; i < count; i++) {
|
|
||||||
(*freeFunc)(ptr);
|
ptr = start;
|
||||||
|
for (i = 0; i < *num_inout; i++) {
|
||||||
|
freeFunc(ptr);
|
||||||
ptr += elem_sz;
|
ptr += elem_sz;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (freeAll) {
|
|
||||||
*num_inout = *sz_inout = 0;
|
*num_inout = *sz_inout = 0;
|
||||||
if (*elems) {
|
free(start);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
free(prop->name);
|
||||||
prop->name = NULL;
|
prop->name = NULL;
|
||||||
}
|
|
||||||
if (prop->value) {
|
|
||||||
free(prop->value);
|
free(prop->value);
|
||||||
prop->value = NULL;
|
prop->value = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomProperties(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
XkbcFreeGeomProperties(struct xkb_geometry * geom)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
_XkbFreeGeomNonLeafElems(&geom->num_properties, &geom->sz_properties,
|
||||||
&geom->num_properties, &geom->sz_properties,
|
&geom->properties, sizeof(struct xkb_property),
|
||||||
(char **)&geom->properties,
|
|
||||||
sizeof(struct xkb_property),
|
|
||||||
_XkbClearProperty);
|
_XkbClearProperty);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomKeyAliases(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
_XkbClearColor(void *color_in)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll, first, count,
|
struct xkb_color * color = color_in;
|
||||||
&geom->num_key_aliases, &geom->sz_key_aliases,
|
|
||||||
(char **)&geom->key_aliases,
|
|
||||||
sizeof(struct xkb_key_alias));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
_XkbClearColor(char *color_in)
|
|
||||||
{
|
|
||||||
struct xkb_color * color = (struct xkb_color *)color_in;
|
|
||||||
|
|
||||||
if (color->spec)
|
|
||||||
free(color->spec);
|
free(color->spec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomColors(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
XkbcFreeGeomColors(struct xkb_geometry * geom)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
_XkbFreeGeomNonLeafElems(&geom->num_colors, &geom->sz_colors,
|
||||||
&geom->num_colors, &geom->sz_colors,
|
&geom->colors, sizeof(struct xkb_color),
|
||||||
(char **)&geom->colors, sizeof(struct xkb_color),
|
|
||||||
_XkbClearColor);
|
_XkbClearColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomPoints(struct xkb_outline * outline, int first, int count, Bool freeAll)
|
_XkbClearOutline(void *outline_in)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll, first, count,
|
struct xkb_outline * outline = outline_in;
|
||||||
&outline->num_points, &outline->sz_points,
|
|
||||||
(char **)&outline->points, sizeof(struct xkb_point));
|
free(outline->points);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearOutline(char *outline_in)
|
XkbcFreeGeomOutlines(struct xkb_shape * shape)
|
||||||
{
|
{
|
||||||
struct xkb_outline * outline = (struct xkb_outline *)outline_in;
|
_XkbFreeGeomNonLeafElems(&shape->num_outlines, &shape->sz_outlines,
|
||||||
|
&shape->outlines, sizeof(struct xkb_outline),
|
||||||
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),
|
|
||||||
_XkbClearOutline);
|
_XkbClearOutline);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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);
|
||||||
XkbcFreeGeomOutlines(shape, 0, shape->num_outlines, True);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomShapes(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
XkbcFreeGeomShapes(struct xkb_geometry * geom)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
_XkbFreeGeomNonLeafElems(&geom->num_shapes, &geom->sz_shapes,
|
||||||
&geom->num_shapes, &geom->sz_shapes,
|
&geom->shapes, sizeof(struct xkb_shape),
|
||||||
(char **)&geom->shapes, sizeof(struct xkb_shape),
|
|
||||||
_XkbClearShape);
|
_XkbClearShape);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomKeys(struct xkb_row * row, int first, int count, Bool freeAll)
|
_XkbClearRow(void *row_in)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomLeafElems(freeAll, first, count,
|
struct xkb_row * row = row_in;
|
||||||
&row->num_keys, &row->sz_keys,
|
|
||||||
(char **)&row->keys, sizeof(struct xkb_key));
|
free(row->keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearRow(char *row_in)
|
XkbcFreeGeomRows(struct xkb_section * section)
|
||||||
{
|
{
|
||||||
struct xkb_row * row = (struct xkb_row *)row_in;
|
_XkbFreeGeomNonLeafElems(§ion->num_rows, §ion->sz_rows,
|
||||||
|
§ion->rows, sizeof(struct xkb_row),
|
||||||
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),
|
|
||||||
_XkbClearRow);
|
_XkbClearRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbClearDoodad(char *doodad_in)
|
_XkbClearDoodad(union xkb_doodad *doodad)
|
||||||
{
|
{
|
||||||
union xkb_doodad * doodad = (union xkb_doodad *)doodad_in;
|
|
||||||
|
|
||||||
switch (doodad->any.type) {
|
switch (doodad->any.type) {
|
||||||
case XkbTextDoodad:
|
case XkbTextDoodad:
|
||||||
if (doodad->text.text) {
|
|
||||||
free(doodad->text.text);
|
free(doodad->text.text);
|
||||||
doodad->text.text = NULL;
|
doodad->text.text = NULL;
|
||||||
}
|
|
||||||
if (doodad->text.font) {
|
|
||||||
free(doodad->text.font);
|
free(doodad->text.font);
|
||||||
doodad->text.font = NULL;
|
doodad->text.font = NULL;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XkbLogoDoodad:
|
case XkbLogoDoodad:
|
||||||
if (doodad->logo.logo_name) {
|
|
||||||
free(doodad->logo.logo_name);
|
free(doodad->logo.logo_name);
|
||||||
doodad->logo.logo_name = NULL;
|
doodad->logo.logo_name = NULL;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomDoodads(union xkb_doodad * doodads, int nDoodads, Bool freeAll)
|
XkbcFreeGeomDoodads(union xkb_doodad * doodads, int nDoodads)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
union xkb_doodad * doodad;
|
union xkb_doodad * doodad;
|
||||||
|
|
||||||
if (doodads) {
|
for (i = 0, doodad = doodads; i < nDoodads && doodad; i++, doodad++)
|
||||||
for (i = 0, doodad = doodads; i < nDoodads; i++, doodad++)
|
_XkbClearDoodad(doodad);
|
||||||
_XkbClearDoodad((char *)doodad);
|
|
||||||
if (freeAll)
|
|
||||||
free(doodads);
|
free(doodads);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
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);
|
||||||
XkbcFreeGeomRows(section, 0, section->num_rows, True);
|
XkbcFreeGeomDoodads(section->doodads, section->num_doodads);
|
||||||
if (section->doodads) {
|
|
||||||
XkbcFreeGeomDoodads(section->doodads, section->num_doodads, True);
|
|
||||||
section->doodads = NULL;
|
section->doodads = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
XkbcFreeGeomSections(struct xkb_geometry * geom, int first, int count, Bool freeAll)
|
XkbcFreeGeomSections(struct xkb_geometry * geom)
|
||||||
{
|
{
|
||||||
_XkbFreeGeomNonLeafElems(freeAll, first, count,
|
_XkbFreeGeomNonLeafElems(&geom->num_sections, &geom->sz_sections,
|
||||||
&geom->num_sections, &geom->sz_sections,
|
&geom->sections, sizeof(struct xkb_section),
|
||||||
(char **)&geom->sections, sizeof(struct xkb_section),
|
|
||||||
_XkbClearSection);
|
_XkbClearSection);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
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;
|
return;
|
||||||
|
|
||||||
if (freeMap)
|
geom = xkb->geom;
|
||||||
which = XkbGeomAllMask;
|
|
||||||
|
|
||||||
if ((which & XkbGeomPropertiesMask) && geom->properties)
|
XkbcFreeGeomProperties(geom);
|
||||||
XkbcFreeGeomProperties(geom, 0, geom->num_properties, True);
|
XkbcFreeGeomColors(geom);
|
||||||
|
XkbcFreeGeomShapes(geom);
|
||||||
if ((which & XkbGeomColorsMask) && geom->colors)
|
XkbcFreeGeomSections(geom);
|
||||||
XkbcFreeGeomColors(geom, 0, geom->num_colors, True);
|
XkbcFreeGeomDoodads(geom->doodads, geom->num_doodads);
|
||||||
|
free(geom->key_aliases);
|
||||||
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);
|
free(geom->label_font);
|
||||||
geom->label_font = NULL;
|
|
||||||
}
|
|
||||||
free(geom);
|
free(geom);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
_XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
_XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
||||||
|
@ -353,9 +224,9 @@ _XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
||||||
*total = (*num) + num_new;
|
*total = (*num) + num_new;
|
||||||
|
|
||||||
if (*old)
|
if (*old)
|
||||||
*old = (char *)realloc(*old, (*total) * sz_elem);
|
*old = realloc(*old, (*total) * sz_elem);
|
||||||
else
|
else
|
||||||
*old = (char *)calloc(*total, sz_elem);
|
*old = calloc(*total, sz_elem);
|
||||||
if (!(*old)) {
|
if (!(*old)) {
|
||||||
*total = *num = 0;
|
*total = *num = 0;
|
||||||
return BadAlloc;
|
return BadAlloc;
|
||||||
|
@ -363,7 +234,7 @@ _XkbGeomAlloc(char **old, unsigned short *num, unsigned short *total,
|
||||||
|
|
||||||
if (*num > 0) {
|
if (*num > 0) {
|
||||||
char *tmp = *old;
|
char *tmp = *old;
|
||||||
bzero(&tmp[sz_elem * (*num)], num_new * sz_elem);
|
memset(&tmp[sz_elem * (*num)], 0, num_new * sz_elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
|
@ -468,7 +339,7 @@ XkbcAllocGeometry(struct xkb_desc * xkb, struct xkb_geometry_sizes * sizes)
|
||||||
|
|
||||||
return Success;
|
return Success;
|
||||||
bail:
|
bail:
|
||||||
XkbcFreeGeometry(geom, XkbGeomAllMask, True);
|
XkbcFreeGeometry(xkb);
|
||||||
xkb->geom = NULL;
|
xkb->geom = NULL;
|
||||||
return rtrn;
|
return rtrn;
|
||||||
}
|
}
|
||||||
|
@ -476,18 +347,15 @@ bail:
|
||||||
struct xkb_property *
|
struct xkb_property *
|
||||||
XkbcAddGeomProperty(struct xkb_geometry * geom,const char *name,const char *value)
|
XkbcAddGeomProperty(struct xkb_geometry * geom,const char *name,const char *value)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register struct xkb_property * prop;
|
struct xkb_property * prop;
|
||||||
|
|
||||||
if ((!geom)||(!name)||(!value))
|
if ((!geom)||(!name)||(!value))
|
||||||
return NULL;
|
return NULL;
|
||||||
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
|
for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
|
||||||
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
|
if ((prop->name)&&(strcmp(name,prop->name)==0)) {
|
||||||
if (prop->value)
|
|
||||||
free(prop->value);
|
free(prop->value);
|
||||||
prop->value= (char *)malloc(strlen(value)+1);
|
prop->value = strdup(value);
|
||||||
if (prop->value)
|
|
||||||
strcpy(prop->value,value);
|
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -496,17 +364,15 @@ register struct xkb_property * prop;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
prop= &geom->properties[geom->num_properties];
|
prop= &geom->properties[geom->num_properties];
|
||||||
prop->name= (char *)malloc(strlen(name)+1);
|
prop->name = strdup(name);
|
||||||
if (!name)
|
if (!prop->name)
|
||||||
return NULL;
|
return NULL;
|
||||||
strcpy(prop->name,name);
|
prop->value = strdup(value);
|
||||||
prop->value= (char *)malloc(strlen(value)+1);
|
if (!prop->value) {
|
||||||
if (!value) {
|
|
||||||
free(prop->name);
|
free(prop->name);
|
||||||
prop->name= NULL;
|
prop->name= NULL;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
strcpy(prop->value,value);
|
|
||||||
geom->num_properties++;
|
geom->num_properties++;
|
||||||
return prop;
|
return prop;
|
||||||
}
|
}
|
||||||
|
@ -514,8 +380,8 @@ register struct xkb_property * prop;
|
||||||
struct xkb_color *
|
struct xkb_color *
|
||||||
XkbcAddGeomColor(struct xkb_geometry * geom,const char *spec,unsigned int pixel)
|
XkbcAddGeomColor(struct xkb_geometry * geom,const char *spec,unsigned int pixel)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register struct xkb_color * color;
|
struct xkb_color * color;
|
||||||
|
|
||||||
if ((!geom)||(!spec))
|
if ((!geom)||(!spec))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -531,10 +397,9 @@ register struct xkb_color * color;
|
||||||
}
|
}
|
||||||
color= &geom->colors[geom->num_colors];
|
color= &geom->colors[geom->num_colors];
|
||||||
color->pixel= pixel;
|
color->pixel= pixel;
|
||||||
color->spec= (char *)malloc(strlen(spec)+1);
|
color->spec = strdup(spec);
|
||||||
if (!color->spec)
|
if (!color->spec)
|
||||||
return NULL;
|
return NULL;
|
||||||
strcpy(color->spec,spec);
|
|
||||||
geom->num_colors++;
|
geom->num_colors++;
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
@ -551,7 +416,7 @@ struct xkb_outline * outline;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
outline= &shape->outlines[shape->num_outlines];
|
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))
|
if ((sz_points>0)&&(_XkbAllocPoints(outline,sz_points)!=Success))
|
||||||
return NULL;
|
return NULL;
|
||||||
shape->num_outlines++;
|
shape->num_outlines++;
|
||||||
|
@ -562,7 +427,7 @@ struct xkb_shape *
|
||||||
XkbcAddGeomShape(struct xkb_geometry * geom,uint32_t name,int sz_outlines)
|
XkbcAddGeomShape(struct xkb_geometry * geom,uint32_t name,int sz_outlines)
|
||||||
{
|
{
|
||||||
struct xkb_shape *shape;
|
struct xkb_shape *shape;
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
if ((!geom)||(!name)||(sz_outlines<0))
|
if ((!geom)||(!name)||(sz_outlines<0))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -576,7 +441,7 @@ register int i;
|
||||||
(_XkbAllocShapes(geom,1)!=Success))
|
(_XkbAllocShapes(geom,1)!=Success))
|
||||||
return NULL;
|
return NULL;
|
||||||
shape= &geom->shapes[geom->num_shapes];
|
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))
|
if ((sz_outlines>0)&&(_XkbAllocOutlines(shape,sz_outlines)!=Success))
|
||||||
return NULL;
|
return NULL;
|
||||||
shape->name= name;
|
shape->name= name;
|
||||||
|
@ -594,7 +459,7 @@ struct xkb_key * key;
|
||||||
if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
|
if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
|
||||||
return NULL;
|
return NULL;
|
||||||
key= &row->keys[row->num_keys++];
|
key= &row->keys[row->num_keys++];
|
||||||
bzero(key,sizeof(struct xkb_key));
|
memset(key, 0, sizeof(struct xkb_key));
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -609,7 +474,7 @@ struct xkb_row * row;
|
||||||
(_XkbAllocRows(section,1)!=Success))
|
(_XkbAllocRows(section,1)!=Success))
|
||||||
return NULL;
|
return NULL;
|
||||||
row= §ion->rows[section->num_rows];
|
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))
|
if ((sz_keys>0)&&(_XkbAllocKeys(row,sz_keys)!=Success))
|
||||||
return NULL;
|
return NULL;
|
||||||
section->num_rows++;
|
section->num_rows++;
|
||||||
|
@ -623,7 +488,7 @@ XkbcAddGeomSection( struct xkb_geometry * geom,
|
||||||
int sz_doodads,
|
int sz_doodads,
|
||||||
int sz_over)
|
int sz_over)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
struct xkb_section * section;
|
struct xkb_section * section;
|
||||||
|
|
||||||
if ((!geom)||(name==None)||(sz_rows<0))
|
if ((!geom)||(name==None)||(sz_rows<0))
|
||||||
|
@ -644,11 +509,9 @@ struct xkb_section * section;
|
||||||
if ((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))
|
if ((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))
|
||||||
return NULL;
|
return NULL;
|
||||||
if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
|
if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
|
||||||
if (section->rows) {
|
|
||||||
free(section->rows);
|
free(section->rows);
|
||||||
section->rows= NULL;
|
section->rows= NULL;
|
||||||
section->sz_rows= section->num_rows= 0;
|
section->sz_rows= section->num_rows= 0;
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
section->name= name;
|
section->name= name;
|
||||||
|
@ -660,7 +523,7 @@ union xkb_doodad *
|
||||||
XkbcAddGeomDoodad(struct xkb_geometry * geom,struct xkb_section * section,uint32_t name)
|
XkbcAddGeomDoodad(struct xkb_geometry * geom,struct xkb_section * section,uint32_t name)
|
||||||
{
|
{
|
||||||
union xkb_doodad *old, *doodad;
|
union xkb_doodad *old, *doodad;
|
||||||
register int i,nDoodads;
|
int i, nDoodads;
|
||||||
|
|
||||||
if ((!geom)||(name==None))
|
if ((!geom)||(name==None))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -689,7 +552,7 @@ register int i,nDoodads;
|
||||||
return NULL;
|
return NULL;
|
||||||
doodad= &geom->doodads[geom->num_doodads++];
|
doodad= &geom->doodads[geom->num_doodads++];
|
||||||
}
|
}
|
||||||
bzero(doodad,sizeof(union xkb_doodad));
|
memset(doodad, 0, sizeof(union xkb_doodad));
|
||||||
doodad->any.name= name;
|
doodad->any.name= name;
|
||||||
return doodad;
|
return doodad;
|
||||||
}
|
}
|
||||||
|
@ -697,7 +560,7 @@ register int i,nDoodads;
|
||||||
struct xkb_overlay_row *
|
struct xkb_overlay_row *
|
||||||
XkbcAddGeomOverlayRow(struct xkb_overlay * overlay,int row_under,int sz_keys)
|
XkbcAddGeomOverlayRow(struct xkb_overlay * overlay,int row_under,int sz_keys)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
struct xkb_overlay_row *row;
|
struct xkb_overlay_row *row;
|
||||||
|
|
||||||
if ((!overlay)||(sz_keys<0))
|
if ((!overlay)||(sz_keys<0))
|
||||||
|
@ -718,7 +581,7 @@ struct xkb_overlay_row * row;
|
||||||
(_XkbAllocOverlayRows(overlay,1)!=Success))
|
(_XkbAllocOverlayRows(overlay,1)!=Success))
|
||||||
return NULL;
|
return NULL;
|
||||||
row= &overlay->rows[overlay->num_rows];
|
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))
|
if ((sz_keys>0)&&(_XkbAllocOverlayKeys(row,sz_keys)!=Success))
|
||||||
return NULL;
|
return NULL;
|
||||||
row->row_under= row_under;
|
row->row_under= row_under;
|
||||||
|
@ -729,7 +592,7 @@ struct xkb_overlay_row * row;
|
||||||
struct xkb_overlay *
|
struct xkb_overlay *
|
||||||
XkbcAddGeomOverlay(struct xkb_section * section,uint32_t name,int sz_rows)
|
XkbcAddGeomOverlay(struct xkb_section * section,uint32_t name,int sz_rows)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
struct xkb_overlay *overlay;
|
struct xkb_overlay *overlay;
|
||||||
|
|
||||||
if ((!section)||(name==None)||(sz_rows==0))
|
if ((!section)||(name==None)||(sz_rows==0))
|
||||||
|
|
16
src/geom.c
16
src/geom.c
|
@ -28,17 +28,11 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <limits.h>
|
||||||
#include "xkbgeom.h"
|
#include "xkbgeom.h"
|
||||||
#include "xkbcommon/xkbcommon.h"
|
#include "xkbcommon/xkbcommon.h"
|
||||||
#include "XKBcommonint.h"
|
#include "XKBcommonint.h"
|
||||||
|
|
||||||
#ifndef MINSHORT
|
|
||||||
#define MINSHORT -32768
|
|
||||||
#endif
|
|
||||||
#ifndef MAXSHORT
|
|
||||||
#define MAXSHORT 32767
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_XkbCheckBounds(struct xkb_bounds * bounds, int x, int y)
|
_XkbCheckBounds(struct xkb_bounds * bounds, int x, int y)
|
||||||
{
|
{
|
||||||
|
@ -62,8 +56,8 @@ XkbcComputeShapeBounds(struct xkb_shape * shape)
|
||||||
if ((!shape) || (shape->num_outlines < 1))
|
if ((!shape) || (shape->num_outlines < 1))
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
shape->bounds.x1 = shape->bounds.y1 = MAXSHORT;
|
shape->bounds.x1 = shape->bounds.y1 = SHRT_MAX;
|
||||||
shape->bounds.x2 = shape->bounds.y2 = MINSHORT;
|
shape->bounds.x2 = shape->bounds.y2 = SHRT_MIN;
|
||||||
|
|
||||||
for (outline = shape->outlines, o = 0; o < shape->num_outlines;
|
for (outline = shape->outlines, o = 0; o < shape->num_outlines;
|
||||||
o++, outline++)
|
o++, outline++)
|
||||||
|
@ -87,7 +81,7 @@ XkbcComputeRowBounds(struct xkb_geometry * geom, struct xkb_section * section, s
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
bounds = &row->bounds;
|
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++) {
|
for (key = row->keys, pos = k = 0; k < row->num_keys; k++, key++) {
|
||||||
sbounds = &XkbKeyShape(geom, key)->bounds;
|
sbounds = &XkbKeyShape(geom, key)->bounds;
|
||||||
|
@ -129,7 +123,7 @@ XkbcComputeSectionBounds(struct xkb_geometry * geom, struct xkb_section * sectio
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
bounds = §ion->bounds;
|
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++) {
|
for (i = 0, row = section->rows; i < section->num_rows; i++, row++) {
|
||||||
if (!XkbcComputeRowBounds(geom, section, row))
|
if (!XkbcComputeRowBounds(geom, section, row))
|
||||||
|
|
93
src/malloc.c
93
src/malloc.c
|
@ -75,7 +75,7 @@ XkbcAllocClientMap(struct xkb_desc * xkb, unsigned which, unsigned nTotalTypes)
|
||||||
}
|
}
|
||||||
|
|
||||||
map->size_types = nTotalTypes;
|
map->size_types = nTotalTypes;
|
||||||
bzero(&map->types[map->num_types],
|
memset(&map->types[map->num_types], 0,
|
||||||
(map->size_types - map->num_types) * sizeof(struct xkb_key_type));
|
(map->size_types - map->num_types) * sizeof(struct xkb_key_type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ XkbcAllocServerMap(struct xkb_desc * xkb, unsigned which, unsigned nNewActions)
|
||||||
}
|
}
|
||||||
|
|
||||||
map->size_acts = need;
|
map->size_acts = need;
|
||||||
bzero(&map->acts[map->num_acts],
|
memset(&map->acts[map->num_acts], 0,
|
||||||
(map->size_acts - map->num_acts) * sizeof(union xkb_action));
|
(map->size_acts - map->num_acts) * sizeof(union xkb_action));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -217,18 +217,12 @@ XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into)
|
||||||
if (!from || !into)
|
if (!from || !into)
|
||||||
return BadMatch;
|
return BadMatch;
|
||||||
|
|
||||||
if (into->map) {
|
|
||||||
free(into->map);
|
free(into->map);
|
||||||
into->map = NULL;
|
into->map = NULL;
|
||||||
}
|
|
||||||
if (into->preserve) {
|
|
||||||
free(into->preserve);
|
free(into->preserve);
|
||||||
into->preserve= NULL;
|
into->preserve= NULL;
|
||||||
}
|
|
||||||
if (into->level_names) {
|
|
||||||
free(into->level_names);
|
free(into->level_names);
|
||||||
into->level_names = NULL;
|
into->level_names = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
*into = *from;
|
*into = *from;
|
||||||
|
|
||||||
|
@ -282,8 +276,8 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
|
||||||
XkbKeySymsPtr(xkb, key), nOldSyms * sizeof(uint32_t));
|
XkbKeySymsPtr(xkb, key), nOldSyms * sizeof(uint32_t));
|
||||||
|
|
||||||
if ((needed - nOldSyms) > 0)
|
if ((needed - nOldSyms) > 0)
|
||||||
bzero(&xkb->map->syms[xkb->map->num_syms + XkbKeyNumSyms(xkb, key)],
|
memset(&xkb->map->syms[xkb->map->num_syms + XkbKeyNumSyms(xkb, key)],
|
||||||
(needed - nOldSyms) * sizeof(uint32_t));
|
0, (needed - nOldSyms) * sizeof(uint32_t));
|
||||||
|
|
||||||
xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
|
xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
|
||||||
xkb->map->num_syms += needed;
|
xkb->map->num_syms += needed;
|
||||||
|
@ -311,7 +305,8 @@ XkbcResizeKeySyms(struct xkb_desc * xkb, xkb_keycode_t key,
|
||||||
memcpy(&newSyms[nSyms], XkbKeySymsPtr(xkb, i),
|
memcpy(&newSyms[nSyms], XkbKeySymsPtr(xkb, i),
|
||||||
nCopy * sizeof(uint32_t));
|
nCopy * sizeof(uint32_t));
|
||||||
if (nKeySyms > nCopy)
|
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;
|
xkb->map->key_sym_map[i].offset = nSyms;
|
||||||
nSyms += nKeySyms;
|
nSyms += nKeySyms;
|
||||||
|
@ -370,7 +365,7 @@ XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed)
|
||||||
memcpy(&newActs[nActs], XkbKeyActionsPtr(xkb, i),
|
memcpy(&newActs[nActs], XkbKeyActionsPtr(xkb, i),
|
||||||
nCopy * sizeof(union xkb_action));
|
nCopy * sizeof(union xkb_action));
|
||||||
if (nCopy < nKeyActs)
|
if (nCopy < nKeyActs)
|
||||||
bzero(&newActs[nActs + nCopy],
|
memset(&newActs[nActs + nCopy], 0,
|
||||||
(nKeyActs - nCopy) * sizeof(union xkb_action));
|
(nKeyActs - nCopy) * sizeof(union xkb_action));
|
||||||
|
|
||||||
xkb->server->key_acts[i] = nActs;
|
xkb->server->key_acts[i] = nActs;
|
||||||
|
@ -385,109 +380,45 @@ XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeClientMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
|
XkbcFreeClientMap(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
|
int i;
|
||||||
struct xkb_client_map * map;
|
struct xkb_client_map * map;
|
||||||
|
struct xkb_key_type * type;
|
||||||
|
|
||||||
if (!xkb || !xkb->map)
|
if (!xkb || !xkb->map)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeMap)
|
|
||||||
what = XkbAllClientInfoMask;
|
|
||||||
map = xkb->map;
|
map = xkb->map;
|
||||||
|
|
||||||
if (what & XkbKeyTypesMask) {
|
for (i = 0, type = map->types; i < map->num_types && type; i++, type++) {
|
||||||
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);
|
free(type->map);
|
||||||
type->map = NULL;
|
|
||||||
}
|
|
||||||
if (type->preserve) {
|
|
||||||
free(type->preserve);
|
free(type->preserve);
|
||||||
type->preserve = NULL;
|
|
||||||
}
|
|
||||||
type->map_count = 0;
|
|
||||||
if (type->level_names) {
|
|
||||||
free(type->level_names);
|
free(type->level_names);
|
||||||
type->level_names = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
free(map->types);
|
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);
|
free(map->key_sym_map);
|
||||||
map->key_sym_map = NULL;
|
|
||||||
}
|
|
||||||
if (map->syms) {
|
|
||||||
free(map->syms);
|
free(map->syms);
|
||||||
map->size_syms = map->num_syms = 0;
|
|
||||||
map->syms = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((what & XkbModifierMapMask) && map->modmap) {
|
|
||||||
free(map->modmap);
|
free(map->modmap);
|
||||||
map->modmap = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeMap) {
|
|
||||||
free(xkb->map);
|
free(xkb->map);
|
||||||
xkb->map = NULL;
|
xkb->map = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcFreeServerMap(struct xkb_desc * xkb, unsigned what, Bool freeMap)
|
XkbcFreeServerMap(struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
struct xkb_server_map * map;
|
struct xkb_server_map * map;
|
||||||
|
|
||||||
if (!xkb || !xkb->server)
|
if (!xkb || !xkb->server)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (freeMap)
|
|
||||||
what = XkbAllServerInfoMask;
|
|
||||||
map = xkb->server;
|
map = xkb->server;
|
||||||
|
|
||||||
if ((what & XkbExplicitComponentsMask) && map->explicit) {
|
|
||||||
free(map->explicit);
|
free(map->explicit);
|
||||||
map->explicit = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (what & XkbKeyActionsMask) {
|
|
||||||
if (map->key_acts) {
|
|
||||||
free(map->key_acts);
|
free(map->key_acts);
|
||||||
map->key_acts = NULL;
|
|
||||||
}
|
|
||||||
if (map->acts) {
|
|
||||||
free(map->acts);
|
free(map->acts);
|
||||||
map->num_acts = map->size_acts = 0;
|
|
||||||
map->acts = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((what & XkbKeyBehaviorsMask) && map->behaviors) {
|
|
||||||
free(map->behaviors);
|
free(map->behaviors);
|
||||||
map->behaviors = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((what & XkbVirtualModMapMask) && map->vmodmap) {
|
|
||||||
free(map->vmodmap);
|
free(map->vmodmap);
|
||||||
map->vmodmap = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (freeMap) {
|
|
||||||
free(xkb->server);
|
free(xkb->server);
|
||||||
xkb->server = NULL;
|
xkb->server = NULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -79,7 +79,6 @@ InitInputLine(InputLine *line)
|
||||||
line->num_line= 0;
|
line->num_line= 0;
|
||||||
line->sz_line= DFLT_LINE_SIZE;
|
line->sz_line= DFLT_LINE_SIZE;
|
||||||
line->line= line->buf;
|
line->line= line->buf;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -91,7 +90,6 @@ FreeInputLine(InputLine *line)
|
||||||
line->num_line= 0;
|
line->num_line= 0;
|
||||||
line->sz_line= DFLT_LINE_SIZE;
|
line->sz_line= DFLT_LINE_SIZE;
|
||||||
line->line= line->buf;
|
line->line= line->buf;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -99,11 +97,11 @@ InputLineAddChar(InputLine *line,int ch)
|
||||||
{
|
{
|
||||||
if (line->num_line>=line->sz_line) {
|
if (line->num_line>=line->sz_line) {
|
||||||
if (line->line==line->buf) {
|
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);
|
memcpy(line->line,line->buf,line->sz_line);
|
||||||
}
|
}
|
||||||
else {
|
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;
|
line->sz_line*= 2;
|
||||||
}
|
}
|
||||||
|
@ -269,7 +267,7 @@ SetUpRemap(InputLine *line,RemapSpec *remap)
|
||||||
{
|
{
|
||||||
char *tok, *str;
|
char *tok, *str;
|
||||||
unsigned present, l_ndx_present, v_ndx_present;
|
unsigned present, l_ndx_present, v_ndx_present;
|
||||||
register int i;
|
int i;
|
||||||
int len, ndx;
|
int len, ndx;
|
||||||
_Xstrtokparams strtok_buf;
|
_Xstrtokparams strtok_buf;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -280,7 +278,7 @@ Bool found;
|
||||||
l_ndx_present = v_ndx_present = present= 0;
|
l_ndx_present = v_ndx_present = present= 0;
|
||||||
str= &line->line[1];
|
str= &line->line[1];
|
||||||
len = remap->number;
|
len = remap->number;
|
||||||
bzero((char *)remap,sizeof(RemapSpec));
|
memset(remap, 0, sizeof(RemapSpec));
|
||||||
remap->number = len;
|
remap->number = len;
|
||||||
while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) {
|
while ((tok=_XStrtok(str," ",strtok_buf))!=NULL) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
@ -363,7 +361,6 @@ Bool found;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
remap->number++;
|
remap->number++;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
|
@ -397,7 +394,7 @@ CheckLine( InputLine * line,
|
||||||
XkbRF_GroupPtr group)
|
XkbRF_GroupPtr group)
|
||||||
{
|
{
|
||||||
char *str, *tok;
|
char *str, *tok;
|
||||||
register int nread, i;
|
int nread, i;
|
||||||
FileSpec tmp;
|
FileSpec tmp;
|
||||||
_Xstrtokparams strtok_buf;
|
_Xstrtokparams strtok_buf;
|
||||||
Bool append = False;
|
Bool append = False;
|
||||||
|
@ -437,7 +434,7 @@ Bool append = False;
|
||||||
PR_DEBUG("Illegal line of data ignored\n");
|
PR_DEBUG("Illegal line of data ignored\n");
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
bzero((char *)&tmp,sizeof(FileSpec));
|
memset(&tmp, 0, sizeof(FileSpec));
|
||||||
str= line->line;
|
str= line->line;
|
||||||
for (nread= 0;(tok=_XStrtok(str," ",strtok_buf))!=NULL;nread++) {
|
for (nread= 0;(tok=_XStrtok(str," ",strtok_buf))!=NULL;nread++) {
|
||||||
str= NULL;
|
str= NULL;
|
||||||
|
@ -520,7 +517,7 @@ squeeze_spaces(char *p1)
|
||||||
static Bool
|
static Bool
|
||||||
MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
|
MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
|
||||||
{
|
{
|
||||||
bzero((char *)mdefs,sizeof(XkbRF_MultiDefsRec));
|
memset(mdefs, 0, sizeof(XkbRF_MultiDefsRec));
|
||||||
mdefs->model = defs->model;
|
mdefs->model = defs->model;
|
||||||
mdefs->options = _XkbDupString(defs->options);
|
mdefs->options = _XkbDupString(defs->options);
|
||||||
if (mdefs->options) squeeze_spaces(mdefs->options);
|
if (mdefs->options) squeeze_spaces(mdefs->options);
|
||||||
|
@ -578,12 +575,9 @@ MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs)
|
||||||
static void
|
static void
|
||||||
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
|
FreeMultiDefs(XkbRF_MultiDefsPtr defs)
|
||||||
{
|
{
|
||||||
if (defs->options)
|
|
||||||
free(defs->options);
|
free(defs->options);
|
||||||
/* Avoid -Wcast-qual warnings. */
|
/* Avoid -Wcast-qual warnings. */
|
||||||
if (defs->layout[1])
|
|
||||||
free((void *)(uintptr_t)defs->layout[1]);
|
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]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,7 +709,7 @@ XkbRF_CheckApplyRule( XkbRF_RulePtr rule,
|
||||||
static void
|
static void
|
||||||
XkbRF_ClearPartialMatches(XkbRF_RulesPtr rules)
|
XkbRF_ClearPartialMatches(XkbRF_RulesPtr rules)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
XkbRF_RulePtr rule;
|
XkbRF_RulePtr rule;
|
||||||
|
|
||||||
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
|
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
|
||||||
|
@ -767,7 +761,7 @@ char *str, *outstr, *orig, *var;
|
||||||
int len, ndx;
|
int len, ndx;
|
||||||
|
|
||||||
orig= name;
|
orig= name;
|
||||||
str= index(name,'%');
|
str= strchr(name,'%');
|
||||||
if (str==NULL)
|
if (str==NULL)
|
||||||
return name;
|
return name;
|
||||||
len= strlen(name);
|
len= strlen(name);
|
||||||
|
@ -785,7 +779,7 @@ int len, ndx;
|
||||||
var = str + 1;
|
var = str + 1;
|
||||||
str = get_index(var + 1, &ndx);
|
str = get_index(var + 1, &ndx);
|
||||||
if (ndx == -1) {
|
if (ndx == -1) {
|
||||||
str = index(str,'%');
|
str = strchr(str,'%');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx])
|
if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx])
|
||||||
|
@ -797,9 +791,9 @@ int len, ndx;
|
||||||
if ((pfx=='(')&&(*str==')')) {
|
if ((pfx=='(')&&(*str==')')) {
|
||||||
str++;
|
str++;
|
||||||
}
|
}
|
||||||
str= index(&str[0],'%');
|
str= strchr(&str[0],'%');
|
||||||
}
|
}
|
||||||
name= (char *)malloc(len+1);
|
name = malloc(len + 1);
|
||||||
str= orig;
|
str= orig;
|
||||||
outstr= name;
|
outstr= name;
|
||||||
while (*str!='\0') {
|
while (*str!='\0') {
|
||||||
|
@ -864,7 +858,7 @@ XkbcRF_GetComponents( XkbRF_RulesPtr rules,
|
||||||
|
|
||||||
MakeMultiDefs(&mdefs, defs);
|
MakeMultiDefs(&mdefs, defs);
|
||||||
|
|
||||||
bzero((char *)names,sizeof(struct xkb_component_names));
|
memset(names, 0, sizeof(struct xkb_component_names));
|
||||||
XkbRF_ClearPartialMatches(rules);
|
XkbRF_ClearPartialMatches(rules);
|
||||||
XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal);
|
XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal);
|
||||||
XkbRF_ApplyPartialMatches(rules, names);
|
XkbRF_ApplyPartialMatches(rules, names);
|
||||||
|
@ -911,7 +905,7 @@ XkbcRF_AddRule(XkbRF_RulesPtr rules)
|
||||||
#endif
|
#endif
|
||||||
return NULL;
|
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++];
|
return &rules->rules[rules->num_rules++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -933,7 +927,7 @@ XkbcRF_AddGroup(XkbRF_RulesPtr rules)
|
||||||
return NULL;
|
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++];
|
return &rules->groups[rules->num_groups++];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,20 +941,20 @@ XkbRF_GroupRec tgroup,*group;
|
||||||
|
|
||||||
if (!(rules && file))
|
if (!(rules && file))
|
||||||
return False;
|
return False;
|
||||||
bzero((char *)&remap,sizeof(RemapSpec));
|
memset(&remap, 0, sizeof(RemapSpec));
|
||||||
bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
|
memset(&tgroup, 0, sizeof(XkbRF_GroupRec));
|
||||||
InitInputLine(&line);
|
InitInputLine(&line);
|
||||||
while (GetInputLine(file,&line,True)) {
|
while (GetInputLine(file,&line,True)) {
|
||||||
if (CheckLine(&line,&remap,&trule,&tgroup)) {
|
if (CheckLine(&line,&remap,&trule,&tgroup)) {
|
||||||
if (tgroup.number) {
|
if (tgroup.number) {
|
||||||
if ((group= XkbcRF_AddGroup(rules))!=NULL) {
|
if ((group= XkbcRF_AddGroup(rules))!=NULL) {
|
||||||
*group= tgroup;
|
*group= tgroup;
|
||||||
bzero((char *)&tgroup,sizeof(XkbRF_GroupRec));
|
memset(&tgroup, 0, sizeof(XkbRF_GroupRec));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((rule= XkbcRF_AddRule(rules))!=NULL) {
|
if ((rule= XkbcRF_AddRule(rules))!=NULL) {
|
||||||
*rule= trule;
|
*rule= trule;
|
||||||
bzero((char *)&trule,sizeof(XkbRF_RuleRec));
|
memset(&trule, 0, sizeof(XkbRF_RuleRec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -973,23 +967,19 @@ XkbRF_GroupRec tgroup,*group;
|
||||||
static void
|
static void
|
||||||
XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var)
|
XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
for (i=0;i<var->num_desc;i++) {
|
for (i=0;i<var->num_desc;i++) {
|
||||||
if (var->desc[i].name)
|
|
||||||
free(var->desc[i].name);
|
free(var->desc[i].name);
|
||||||
if (var->desc[i].desc)
|
|
||||||
free(var->desc[i].desc);
|
free(var->desc[i].desc);
|
||||||
var->desc[i].name= var->desc[i].desc= NULL;
|
var->desc[i].name= var->desc[i].desc= NULL;
|
||||||
}
|
}
|
||||||
if (var->desc)
|
|
||||||
free(var->desc);
|
free(var->desc);
|
||||||
var->desc= NULL;
|
var->desc= NULL;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
XkbcRF_Free(XkbRF_RulesPtr rules,Bool freeRules)
|
XkbcRF_Free(XkbRF_RulesPtr rules)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
XkbRF_RulePtr rule;
|
XkbRF_RulePtr rule;
|
||||||
|
@ -1006,38 +996,26 @@ XkbRF_GroupPtr group;
|
||||||
XkbRF_ClearVarDescriptions(&rules->extra[i]);
|
XkbRF_ClearVarDescriptions(&rules->extra[i]);
|
||||||
}
|
}
|
||||||
free(rules->extra);
|
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 && rules; i++, rule++) {
|
||||||
for (i=0,rule=rules->rules;i<rules->num_rules;i++,rule++) {
|
free(rule->model);
|
||||||
if (rule->model) free(rule->model);
|
free(rule->layout);
|
||||||
if (rule->layout) free(rule->layout);
|
free(rule->variant);
|
||||||
if (rule->variant) free(rule->variant);
|
free(rule->option);
|
||||||
if (rule->option) free(rule->option);
|
free(rule->keycodes);
|
||||||
if (rule->keycodes) free(rule->keycodes);
|
free(rule->symbols);
|
||||||
if (rule->symbols) free(rule->symbols);
|
free(rule->types);
|
||||||
if (rule->types) free(rule->types);
|
free(rule->compat);
|
||||||
if (rule->compat) free(rule->compat);
|
free(rule->geometry);
|
||||||
if (rule->geometry) free(rule->geometry);
|
free(rule->keymap);
|
||||||
if (rule->keymap) free(rule->keymap);
|
|
||||||
bzero((char *)rule,sizeof(XkbRF_RuleRec));
|
|
||||||
}
|
}
|
||||||
free(rules->rules);
|
free(rules->rules);
|
||||||
rules->num_rules= rules->sz_rules= 0;
|
|
||||||
rules->rules= NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rules->groups) {
|
for (i=0, group = rules->groups; i < rules->num_groups && group; i++, group++) {
|
||||||
for (i=0, group=rules->groups;i<rules->num_groups;i++,group++) {
|
free(group->name);
|
||||||
if (group->name) free(group->name);
|
free(group->words);
|
||||||
if (group->words) free(group->words);
|
|
||||||
}
|
}
|
||||||
free(rules->groups);
|
free(rules->groups);
|
||||||
rules->num_groups= 0;
|
|
||||||
rules->groups= NULL;
|
|
||||||
}
|
|
||||||
if (freeRules)
|
|
||||||
free(rules);
|
free(rules);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -132,7 +132,7 @@ XkbcComputeEffectiveMap(struct xkb_desc * xkb, struct xkb_key_type * type,
|
||||||
type->mods.mask = type->mods.real_mods;
|
type->mods.mask = type->mods.real_mods;
|
||||||
|
|
||||||
if (map_rtrn) {
|
if (map_rtrn) {
|
||||||
bzero(map_rtrn, type->mods.mask + 1);
|
memset(map_rtrn, 0, type->mods.mask + 1);
|
||||||
if (entry && entry->active)
|
if (entry && entry->active)
|
||||||
for (i = 0; i < type->map_count; i++)
|
for (i = 0; i < type->map_count; i++)
|
||||||
map_rtrn[type->map[i].mods.mask] = type->map[i].level;
|
map_rtrn[type->map[i].mods.mask] = type->map[i].level;
|
||||||
|
|
|
@ -48,7 +48,7 @@ extern struct xkb_desc *
|
||||||
XkbcAllocKeyboard(void);
|
XkbcAllocKeyboard(void);
|
||||||
|
|
||||||
extern 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);
|
XkbcResizeKeyActions(struct xkb_desc * xkb, xkb_keycode_t key, int needed);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
XkbcFreeClientMap(struct xkb_desc * xkb, unsigned what, Bool freeMap);
|
XkbcFreeClientMap(struct xkb_desc * xkb);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
XkbcFreeServerMap(struct xkb_desc * xkb, unsigned what, Bool freeMap);
|
XkbcFreeServerMap(struct xkb_desc * xkb);
|
||||||
|
|
||||||
#endif /* _XKBALLOC_H_ */
|
#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
|
static Bool
|
||||||
stringToAction(const char *str, unsigned *type_rtrn)
|
stringToAction(const char *str, unsigned *type_rtrn)
|
||||||
{
|
{
|
||||||
if (str == NULL)
|
return stringToValue(actionStrings, str, type_rtrn);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
stringToField(char *str, unsigned *field_rtrn)
|
stringToField(const char *str, unsigned *field_rtrn)
|
||||||
{
|
{
|
||||||
|
return stringToValue(fieldStrings, str, 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
fieldText(unsigned field)
|
fieldText(unsigned field)
|
||||||
{
|
{
|
||||||
static char buf[32];
|
return valueToString(fieldStrings, field);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
@ -609,7 +486,7 @@ HandleMovePtr(struct xkb_desc * xkb,
|
||||||
return ReportIllegal(action->type, field);
|
return ReportIllegal(action->type, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LookupEntry lockWhich[] = {
|
static const LookupEntry lockWhich[] = {
|
||||||
{"both", 0},
|
{"both", 0},
|
||||||
{"lock", XkbSA_LockNoUnlock},
|
{"lock", XkbSA_LockNoUnlock},
|
||||||
{"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)},
|
{"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)},
|
||||||
|
@ -670,7 +547,7 @@ HandlePtrBtn(struct xkb_desc * xkb,
|
||||||
return ReportIllegal(action->type, field);
|
return ReportIllegal(action->type, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LookupEntry ptrDflts[] = {
|
static const LookupEntry ptrDflts[] = {
|
||||||
{"dfltbtn", XkbSA_AffectDfltBtn},
|
{"dfltbtn", XkbSA_AffectDfltBtn},
|
||||||
{"defaultbutton", XkbSA_AffectDfltBtn},
|
{"defaultbutton", XkbSA_AffectDfltBtn},
|
||||||
{"button", XkbSA_AffectDfltBtn},
|
{"button", XkbSA_AffectDfltBtn},
|
||||||
|
@ -735,7 +612,7 @@ HandleSetPtrDflt(struct xkb_desc * xkb,
|
||||||
return ReportIllegal(action->type, field);
|
return ReportIllegal(action->type, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LookupEntry isoNames[] = {
|
static const LookupEntry isoNames[] = {
|
||||||
{"mods", XkbSA_ISONoAffectMods},
|
{"mods", XkbSA_ISONoAffectMods},
|
||||||
{"modifiers", XkbSA_ISONoAffectMods},
|
{"modifiers", XkbSA_ISONoAffectMods},
|
||||||
{"group", XkbSA_ISONoAffectGroup},
|
{"group", XkbSA_ISONoAffectGroup},
|
||||||
|
@ -850,41 +727,24 @@ HandleSwitchScreen(struct xkb_desc * xkb,
|
||||||
return ReportIllegal(action->type, field);
|
return ReportIllegal(action->type, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
LookupEntry ctrlNames[] = {
|
const LookupEntry ctrlNames[] = {
|
||||||
{"repeatkeys", XkbRepeatKeysMask}
|
{"repeatkeys", XkbRepeatKeysMask},
|
||||||
,
|
{"repeat", XkbRepeatKeysMask},
|
||||||
{"repeat", XkbRepeatKeysMask}
|
{"autorepeat", XkbRepeatKeysMask},
|
||||||
,
|
{"slowkeys", XkbSlowKeysMask},
|
||||||
{"autorepeat", XkbRepeatKeysMask}
|
{"bouncekeys", XkbBounceKeysMask},
|
||||||
,
|
{"stickykeys", XkbStickyKeysMask},
|
||||||
{"slowkeys", XkbSlowKeysMask}
|
{"mousekeys", XkbMouseKeysMask},
|
||||||
,
|
{"mousekeysaccel", XkbMouseKeysAccelMask},
|
||||||
{"bouncekeys", XkbBounceKeysMask}
|
{"accessxkeys", XkbAccessXKeysMask},
|
||||||
,
|
{"accessxtimeout", XkbAccessXTimeoutMask},
|
||||||
{"stickykeys", XkbStickyKeysMask}
|
{"accessxfeedback", XkbAccessXFeedbackMask},
|
||||||
,
|
{"audiblebell", XkbAudibleBellMask},
|
||||||
{"mousekeys", XkbMouseKeysMask}
|
{"overlay1", XkbOverlay1Mask},
|
||||||
,
|
{"overlay2", XkbOverlay2Mask},
|
||||||
{"mousekeysaccel", XkbMouseKeysAccelMask}
|
{"ignoregrouplock", XkbIgnoreGroupLockMask},
|
||||||
,
|
{"all", XkbAllBooleanCtrlsMask},
|
||||||
{"accessxkeys", XkbAccessXKeysMask}
|
{"none", 0},
|
||||||
,
|
|
||||||
{"accessxtimeout", XkbAccessXTimeoutMask}
|
|
||||||
,
|
|
||||||
{"accessxfeedback", XkbAccessXFeedbackMask}
|
|
||||||
,
|
|
||||||
{"audiblebell", XkbAudibleBellMask}
|
|
||||||
,
|
|
||||||
{"overlay1", XkbOverlay1Mask}
|
|
||||||
,
|
|
||||||
{"overlay2", XkbOverlay2Mask}
|
|
||||||
,
|
|
||||||
{"ignoregrouplock", XkbIgnoreGroupLockMask}
|
|
||||||
,
|
|
||||||
{"all", XkbAllBooleanCtrlsMask}
|
|
||||||
,
|
|
||||||
{"none", 0}
|
|
||||||
,
|
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -909,7 +769,7 @@ HandleSetLockControls(struct xkb_desc * xkb,
|
||||||
return ReportIllegal(action->type, field);
|
return ReportIllegal(action->type, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LookupEntry evNames[] = {
|
static const LookupEntry evNames[] = {
|
||||||
{"press", XkbSA_MessageOnPress},
|
{"press", XkbSA_MessageOnPress},
|
||||||
{"keypress", XkbSA_MessageOnPress},
|
{"keypress", XkbSA_MessageOnPress},
|
||||||
{"release", XkbSA_MessageOnRelease},
|
{"release", XkbSA_MessageOnRelease},
|
||||||
|
@ -1210,7 +1070,7 @@ typedef Bool(*actionHandler) (struct xkb_desc * /* xkb */ ,
|
||||||
ExprDef * /* value */
|
ExprDef * /* value */
|
||||||
);
|
);
|
||||||
|
|
||||||
static actionHandler handleAction[XkbSA_NumActions + 1] = {
|
static const actionHandler handleAction[XkbSA_NumActions + 1] = {
|
||||||
HandleNoAction /* NoAction */ ,
|
HandleNoAction /* NoAction */ ,
|
||||||
HandleSetLatchMods /* SetMods */ ,
|
HandleSetLatchMods /* SetMods */ ,
|
||||||
HandleSetLatchMods /* LatchMods */ ,
|
HandleSetLatchMods /* LatchMods */ ,
|
||||||
|
@ -1250,7 +1110,6 @@ ApplyActionFactoryDefaults(union xkb_action * action)
|
||||||
{
|
{
|
||||||
action->iso.real_mods = LockMask;
|
action->iso.real_mods = LockMask;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1422,8 +1281,8 @@ ActionsInit(void)
|
||||||
{
|
{
|
||||||
if (!actionsInitialized)
|
if (!actionsInitialized)
|
||||||
{
|
{
|
||||||
bzero((char *) &constTrue, sizeof(constTrue));
|
memset(&constTrue, 0, sizeof(constTrue));
|
||||||
bzero((char *) &constFalse, sizeof(constFalse));
|
memset(&constFalse, 0, sizeof(constFalse));
|
||||||
constTrue.common.stmtType = StmtExpr;
|
constTrue.common.stmtType = StmtExpr;
|
||||||
constTrue.common.next = NULL;
|
constTrue.common.next = NULL;
|
||||||
constTrue.op = ExprIdent;
|
constTrue.op = ExprIdent;
|
||||||
|
@ -1436,5 +1295,4 @@ ActionsInit(void)
|
||||||
constFalse.value.str = xkb_intern_atom("false");
|
constFalse.value.str = xkb_intern_atom("false");
|
||||||
actionsInitialized = 1;
|
actionsInitialized = 1;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,6 @@ extern int SetActionField(struct xkb_desc * /* xkb */ ,
|
||||||
ActionInfo ** /* info_rtrn */
|
ActionInfo ** /* info_rtrn */
|
||||||
);
|
);
|
||||||
|
|
||||||
extern LookupEntry ctrlNames[];
|
extern const LookupEntry ctrlNames[];
|
||||||
|
|
||||||
#endif /* ACTION_H */
|
#endif /* ACTION_H */
|
||||||
|
|
|
@ -71,19 +71,17 @@ HandleCollision(AliasInfo * old, AliasInfo * new)
|
||||||
}
|
}
|
||||||
old->def.fileID = new->def.fileID;
|
old->def.fileID = new->def.fileID;
|
||||||
old->def.merge = new->def.merge;
|
old->def.merge = new->def.merge;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
InitAliasInfo(AliasInfo * info,
|
InitAliasInfo(AliasInfo * info,
|
||||||
unsigned merge, unsigned file_id, char *alias, char *real)
|
unsigned merge, unsigned file_id, char *alias, char *real)
|
||||||
{
|
{
|
||||||
bzero(info, sizeof(AliasInfo));
|
memset(info, 0, sizeof(AliasInfo));
|
||||||
info->def.merge = merge;
|
info->def.merge = merge;
|
||||||
info->def.fileID = file_id;
|
info->def.fileID = file_id;
|
||||||
strncpy(info->alias, alias, XkbKeyNameLength);
|
strncpy(info->alias, alias, XkbKeyNameLength);
|
||||||
strncpy(info->real, real, XkbKeyNameLength);
|
strncpy(info->real, real, XkbKeyNameLength);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -122,7 +120,6 @@ ClearAliases(AliasInfo ** info_in)
|
||||||
{
|
{
|
||||||
if ((info_in) && (*info_in))
|
if ((info_in) && (*info_in))
|
||||||
ClearCommonInfo(&(*info_in)->def);
|
ClearCommonInfo(&(*info_in)->def);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
@ -139,7 +136,7 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge, unsigned how_merge)
|
||||||
*merge = NULL;
|
*merge = NULL;
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
bzero((char *) &def, sizeof(KeyAliasDef));
|
memset(&def, 0, sizeof(KeyAliasDef));
|
||||||
for (tmp = *merge; tmp != NULL; tmp = (AliasInfo *) tmp->def.next)
|
for (tmp = *merge; tmp != NULL; tmp = (AliasInfo *) tmp->def.next)
|
||||||
{
|
{
|
||||||
if (how_merge == MergeDefault)
|
if (how_merge == MergeDefault)
|
||||||
|
@ -157,7 +154,7 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge, unsigned how_merge)
|
||||||
int
|
int
|
||||||
ApplyAliases(struct xkb_desc * xkb, Bool toGeom, AliasInfo ** info_in)
|
ApplyAliases(struct xkb_desc * xkb, Bool toGeom, AliasInfo ** info_in)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
struct xkb_key_alias *old, *a;
|
struct xkb_key_alias *old, *a;
|
||||||
AliasInfo *info;
|
AliasInfo *info;
|
||||||
int nNew, nOld;
|
int nNew, nOld;
|
||||||
|
@ -235,7 +232,7 @@ ApplyAliases(struct xkb_desc * xkb, Bool toGeom, AliasInfo ** info_in)
|
||||||
if (!xkb->geom)
|
if (!xkb->geom)
|
||||||
{
|
{
|
||||||
struct xkb_geometry_sizes sizes;
|
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.which = XkbGeomKeyAliasesMask;
|
||||||
sizes.num_key_aliases = nOld + nNew;
|
sizes.num_key_aliases = nOld + nNew;
|
||||||
status = XkbcAllocGeometry(xkb, &sizes);
|
status = XkbcAllocGeometry(xkb, &sizes);
|
||||||
|
|
|
@ -80,7 +80,7 @@ typedef struct _CompatInfo
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
siText(SymInterpInfo * si, CompatInfo * info)
|
siText(SymInterpInfo * si, CompatInfo * info)
|
||||||
{
|
{
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
|
@ -102,7 +102,7 @@ siText(SymInterpInfo * si, CompatInfo * info)
|
||||||
static void
|
static void
|
||||||
InitCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
InitCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
info->xkb = xkb;
|
info->xkb = xkb;
|
||||||
info->name = NULL;
|
info->name = NULL;
|
||||||
|
@ -125,19 +125,18 @@ InitCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
||||||
info->ledDflt.defs.fileID = info->fileID;
|
info->ledDflt.defs.fileID = info->fileID;
|
||||||
info->ledDflt.defs.defined = 0;
|
info->ledDflt.defs.defined = 0;
|
||||||
info->ledDflt.defs.merge = MergeOverride;
|
info->ledDflt.defs.merge = MergeOverride;
|
||||||
bzero((char *) &info->groupCompat[0],
|
memset(&info->groupCompat[0], 0,
|
||||||
XkbNumKbdGroups * sizeof(GroupCompatInfo));
|
XkbNumKbdGroups * sizeof(GroupCompatInfo));
|
||||||
info->leds = NULL;
|
info->leds = NULL;
|
||||||
InitVModInfo(&info->vmods, xkb);
|
InitVModInfo(&info->vmods, xkb);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ClearCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
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->name = NULL;
|
||||||
info->dflt.defs.defined = 0;
|
info->dflt.defs.defined = 0;
|
||||||
|
@ -152,12 +151,15 @@ ClearCompatInfo(CompatInfo * info, struct xkb_desc * xkb)
|
||||||
ClearIndicatorMapInfo(&info->ledDflt);
|
ClearIndicatorMapInfo(&info->ledDflt);
|
||||||
info->nInterps = 0;
|
info->nInterps = 0;
|
||||||
info->interps = (SymInterpInfo *) ClearCommonInfo(&info->interps->defs);
|
info->interps = (SymInterpInfo *) ClearCommonInfo(&info->interps->defs);
|
||||||
bzero((char *) &info->groupCompat[0],
|
memset(&info->groupCompat[0], 0,
|
||||||
XkbNumKbdGroups * sizeof(GroupCompatInfo));
|
XkbNumKbdGroups * sizeof(GroupCompatInfo));
|
||||||
info->leds = (LEDInfo *) ClearCommonInfo(&info->leds->defs);
|
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);
|
ClearVModInfo(&info->vmods, xkb);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static SymInterpInfo *
|
static SymInterpInfo *
|
||||||
|
@ -168,7 +170,7 @@ NextInterp(CompatInfo * info)
|
||||||
si = uTypedAlloc(SymInterpInfo);
|
si = uTypedAlloc(SymInterpInfo);
|
||||||
if (si)
|
if (si)
|
||||||
{
|
{
|
||||||
bzero((char *) si, sizeof(SymInterpInfo));
|
memset(si, 0, sizeof(SymInterpInfo));
|
||||||
info->interps =
|
info->interps =
|
||||||
(SymInterpInfo *) AddCommonInfo(&info->interps->defs,
|
(SymInterpInfo *) AddCommonInfo(&info->interps->defs,
|
||||||
(CommonInfo *) si);
|
(CommonInfo *) si);
|
||||||
|
@ -351,7 +353,7 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
|
||||||
SymInterpInfo *si;
|
SymInterpInfo *si;
|
||||||
LEDInfo *led, *rtrn, *next;
|
LEDInfo *led, *rtrn, *next;
|
||||||
GroupCompatInfo *gcm;
|
GroupCompatInfo *gcm;
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
if (from->errorCount > 0)
|
if (from->errorCount > 0)
|
||||||
{
|
{
|
||||||
|
@ -388,7 +390,6 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
|
||||||
else
|
else
|
||||||
into->errorCount++;
|
into->errorCount++;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*FileHandler) (XkbFile * /* rtrn */ ,
|
typedef void (*FileHandler) (XkbFile * /* rtrn */ ,
|
||||||
|
@ -411,7 +412,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
|
||||||
{
|
{
|
||||||
haveSelf = True;
|
haveSelf = True;
|
||||||
included = *info;
|
included = *info;
|
||||||
bzero(info, sizeof(CompatInfo));
|
memset(info, 0, sizeof(CompatInfo));
|
||||||
}
|
}
|
||||||
else if (ProcessIncludeFile(stmt, XkmCompatMapIndex, &rtrn, &newMerge))
|
else if (ProcessIncludeFile(stmt, XkmCompatMapIndex, &rtrn, &newMerge))
|
||||||
{
|
{
|
||||||
|
@ -426,11 +427,13 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
|
||||||
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
||||||
if (stmt->stmt != NULL)
|
if (stmt->stmt != NULL)
|
||||||
{
|
{
|
||||||
if (included.name != NULL)
|
|
||||||
free(included.name);
|
free(included.name);
|
||||||
included.name = stmt->stmt;
|
included.name = stmt->stmt;
|
||||||
stmt->stmt = NULL;
|
stmt->stmt = NULL;
|
||||||
}
|
}
|
||||||
|
if (info->act != NULL)
|
||||||
|
included.act = NULL;
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -463,7 +466,10 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
|
||||||
next_incl.act = info->act;
|
next_incl.act = info->act;
|
||||||
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
|
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
|
||||||
MergeIncludedCompatMaps(&included, &next_incl, op);
|
MergeIncludedCompatMaps(&included, &next_incl, op);
|
||||||
|
if (info->act != NULL)
|
||||||
|
next_incl.act = NULL;
|
||||||
ClearCompatInfo(&next_incl, xkb);
|
ClearCompatInfo(&next_incl, xkb);
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -482,7 +488,7 @@ HandleIncludeCompatMap(IncludeStmt * stmt,
|
||||||
return (info->errorCount == 0);
|
return (info->errorCount == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LookupEntry useModMapValues[] = {
|
static const LookupEntry useModMapValues[] = {
|
||||||
{"levelone", 1},
|
{"levelone", 1},
|
||||||
{"level1", 1},
|
{"level1", 1},
|
||||||
{"anylevel", 0},
|
{"anylevel", 0},
|
||||||
|
@ -705,6 +711,7 @@ HandleCompatMapFile(XkbFile * file,
|
||||||
|
|
||||||
if (merge == MergeDefault)
|
if (merge == MergeDefault)
|
||||||
merge = MergeAugment;
|
merge = MergeAugment;
|
||||||
|
free(info->name);
|
||||||
info->name = _XkbDupString(file->name);
|
info->name = _XkbDupString(file->name);
|
||||||
stmt = file->defs;
|
stmt = file->defs;
|
||||||
while (stmt)
|
while (stmt)
|
||||||
|
@ -764,7 +771,6 @@ HandleCompatMapFile(XkbFile * file,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -787,7 +793,6 @@ CopyInterps(CompatInfo * info,
|
||||||
}
|
}
|
||||||
compat->sym_interpret[compat->num_si++] = si->interp;
|
compat->sym_interpret[compat->num_si++] = si->interp;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
@ -857,7 +862,6 @@ CompileCompatMap(XkbFile *file, struct xkb_desc * xkb, unsigned merge,
|
||||||
ClearCompatInfo(&info, xkb);
|
ClearCompatInfo(&info, xkb);
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
if (info.interps != NULL)
|
|
||||||
free(info.interps);
|
free(info.interps);
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
|
||||||
typedef Bool(*IdentLookupFunc) (void * /* priv */ ,
|
typedef Bool(*IdentLookupFunc) (const void * /* priv */ ,
|
||||||
uint32_t /* field */ ,
|
uint32_t /* field */ ,
|
||||||
unsigned /* type */ ,
|
unsigned /* type */ ,
|
||||||
ExprResult * /* val_rtrn */
|
ExprResult * /* val_rtrn */
|
||||||
|
@ -41,7 +41,7 @@ typedef Bool(*IdentLookupFunc) (void * /* priv */ ,
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
|
||||||
char *
|
const char *
|
||||||
exprOpText(unsigned type)
|
exprOpText(unsigned type)
|
||||||
{
|
{
|
||||||
static char buf[32];
|
static char buf[32];
|
||||||
|
@ -103,7 +103,7 @@ exprOpText(unsigned type)
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
static const char *
|
||||||
exprTypeText(unsigned type)
|
exprTypeText(unsigned type)
|
||||||
{
|
{
|
||||||
static char buf[20];
|
static char buf[20];
|
||||||
|
@ -163,10 +163,10 @@ ExprResolveLhs(ExprDef * expr,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
SimpleLookup(void * priv, uint32_t field, unsigned type,
|
SimpleLookup(const void * priv, uint32_t field, unsigned type,
|
||||||
ExprResult * val_rtrn)
|
ExprResult * val_rtrn)
|
||||||
{
|
{
|
||||||
LookupEntry *entry;
|
const LookupEntry *entry;
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
if ((priv == NULL) || (field == None) ||
|
if ((priv == NULL) || (field == None) ||
|
||||||
|
@ -189,7 +189,7 @@ SimpleLookup(void * priv, uint32_t field, unsigned type,
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
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;
|
const char *str;
|
||||||
int rg;
|
int rg;
|
||||||
|
@ -215,7 +215,7 @@ RadioLookup(void * priv, uint32_t field, unsigned type, ExprResult * val_rtrn)
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LookupEntry modIndexNames[] = {
|
static const LookupEntry modIndexNames[] = {
|
||||||
{"shift", ShiftMapIndex},
|
{"shift", ShiftMapIndex},
|
||||||
{"control", ControlMapIndex},
|
{"control", ControlMapIndex},
|
||||||
{"lock", LockMapIndex},
|
{"lock", LockMapIndex},
|
||||||
|
@ -229,14 +229,14 @@ static LookupEntry modIndexNames[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
int
|
int
|
||||||
LookupModIndex(void * priv, uint32_t field, unsigned type,
|
LookupModIndex(const void * priv, uint32_t field, unsigned type,
|
||||||
ExprResult * val_rtrn)
|
ExprResult * val_rtrn)
|
||||||
{
|
{
|
||||||
return SimpleLookup(modIndexNames, field, type, val_rtrn);
|
return SimpleLookup(modIndexNames, field, type, val_rtrn);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
LookupModMask(void * priv, uint32_t field, unsigned type,
|
LookupModMask(const void * priv, uint32_t field, unsigned type,
|
||||||
ExprResult * val_rtrn)
|
ExprResult * val_rtrn)
|
||||||
{
|
{
|
||||||
char *str;
|
char *str;
|
||||||
|
@ -518,7 +518,7 @@ ExprResolveKeyCode(ExprDef * expr,
|
||||||
static int
|
static int
|
||||||
ExprResolveIntegerLookup(ExprDef * expr,
|
ExprResolveIntegerLookup(ExprDef * expr,
|
||||||
ExprResult * val_rtrn,
|
ExprResult * val_rtrn,
|
||||||
IdentLookupFunc lookup, void * lookupPriv)
|
IdentLookupFunc lookup, const void * lookupPriv)
|
||||||
{
|
{
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
ExprResult leftRtrn, rightRtrn;
|
ExprResult leftRtrn, rightRtrn;
|
||||||
|
@ -643,7 +643,7 @@ ExprResolveGroup(ExprDef * expr,
|
||||||
ExprResult * val_rtrn)
|
ExprResult * val_rtrn)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
static LookupEntry group_names[] = {
|
static const LookupEntry group_names[] = {
|
||||||
{ "group1", 1 },
|
{ "group1", 1 },
|
||||||
{ "group2", 2 },
|
{ "group2", 2 },
|
||||||
{ "group3", 3 },
|
{ "group3", 3 },
|
||||||
|
@ -673,7 +673,7 @@ ExprResolveLevel(ExprDef * expr,
|
||||||
ExprResult * val_rtrn)
|
ExprResult * val_rtrn)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
static LookupEntry level_names[] = {
|
static const LookupEntry level_names[] = {
|
||||||
{ "level1", 1 },
|
{ "level1", 1 },
|
||||||
{ "level2", 2 },
|
{ "level2", 2 },
|
||||||
{ "level3", 3 },
|
{ "level3", 3 },
|
||||||
|
@ -702,7 +702,7 @@ int
|
||||||
ExprResolveButton(ExprDef * expr,
|
ExprResolveButton(ExprDef * expr,
|
||||||
ExprResult * val_rtrn)
|
ExprResult * val_rtrn)
|
||||||
{
|
{
|
||||||
static LookupEntry button_names[] = {
|
static const LookupEntry button_names[] = {
|
||||||
{ "button1", 1 },
|
{ "button1", 1 },
|
||||||
{ "button2", 2 },
|
{ "button2", 2 },
|
||||||
{ "button3", 3 },
|
{ "button3", 3 },
|
||||||
|
@ -756,7 +756,7 @@ ExprResolveString(ExprDef * expr,
|
||||||
int len;
|
int len;
|
||||||
char *new;
|
char *new;
|
||||||
len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
|
len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
|
||||||
new = (char *) malloc(len);
|
new = malloc(len);
|
||||||
if (new)
|
if (new)
|
||||||
{ sprintf(new, "%s%s", leftRtrn.str, rightRtrn.str);
|
{ sprintf(new, "%s%s", leftRtrn.str, rightRtrn.str);
|
||||||
free(leftRtrn.str);
|
free(leftRtrn.str);
|
||||||
|
@ -866,7 +866,7 @@ ExprResolveKeyName(ExprDef * expr,
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
|
||||||
int
|
int
|
||||||
ExprResolveEnum(ExprDef * expr, ExprResult * val_rtrn, LookupEntry * values)
|
ExprResolveEnum(ExprDef * expr, ExprResult * val_rtrn, const LookupEntry * values)
|
||||||
{
|
{
|
||||||
if (expr->op != ExprIdent)
|
if (expr->op != ExprIdent)
|
||||||
{
|
{
|
||||||
|
@ -898,7 +898,7 @@ static int
|
||||||
ExprResolveMaskLookup(ExprDef * expr,
|
ExprResolveMaskLookup(ExprDef * expr,
|
||||||
ExprResult * val_rtrn,
|
ExprResult * val_rtrn,
|
||||||
IdentLookupFunc lookup,
|
IdentLookupFunc lookup,
|
||||||
void * lookupPriv)
|
const void * lookupPriv)
|
||||||
{
|
{
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
ExprResult leftRtrn, rightRtrn;
|
ExprResult leftRtrn, rightRtrn;
|
||||||
|
@ -994,7 +994,7 @@ ExprResolveMaskLookup(ExprDef * expr,
|
||||||
int
|
int
|
||||||
ExprResolveMask(ExprDef * expr,
|
ExprResolveMask(ExprDef * expr,
|
||||||
ExprResult * val_rtrn,
|
ExprResult * val_rtrn,
|
||||||
LookupEntry * values)
|
const LookupEntry * values)
|
||||||
{
|
{
|
||||||
return ExprResolveMaskLookup(expr, val_rtrn, SimpleLookup, values);
|
return ExprResolveMaskLookup(expr, val_rtrn, SimpleLookup, values);
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,22 +48,22 @@ typedef struct _LookupEntry
|
||||||
} 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 */ ,
|
uint32_t /* field */ ,
|
||||||
unsigned /* type */ ,
|
unsigned /* type */ ,
|
||||||
ExprResult * /* val_rtrn */
|
ExprResult * /* val_rtrn */
|
||||||
);
|
);
|
||||||
|
|
||||||
extern int LookupVModMask(void * /* priv */ ,
|
extern int LookupVModMask(const void * /* priv */ ,
|
||||||
uint32_t /* field */ ,
|
uint32_t /* field */ ,
|
||||||
unsigned /* type */ ,
|
unsigned /* type */ ,
|
||||||
ExprResult * /* val_rtrn */
|
ExprResult * /* val_rtrn */
|
||||||
);
|
);
|
||||||
|
|
||||||
extern int LookupModIndex(void * /* priv */ ,
|
extern int LookupModIndex(const void * /* priv */ ,
|
||||||
uint32_t /* field */ ,
|
uint32_t /* field */ ,
|
||||||
unsigned /* type */ ,
|
unsigned /* type */ ,
|
||||||
ExprResult * /* val_rtrn */
|
ExprResult * /* val_rtrn */
|
||||||
|
@ -120,12 +120,12 @@ extern int ExprResolveKeyName(ExprDef * /* expr */ ,
|
||||||
|
|
||||||
extern int ExprResolveEnum(ExprDef * /* expr */ ,
|
extern int ExprResolveEnum(ExprDef * /* expr */ ,
|
||||||
ExprResult * /* val_rtrn */ ,
|
ExprResult * /* val_rtrn */ ,
|
||||||
LookupEntry * /* values */
|
const LookupEntry * /* values */
|
||||||
);
|
);
|
||||||
|
|
||||||
extern int ExprResolveMask(ExprDef * /* expr */ ,
|
extern int ExprResolveMask(ExprDef * /* expr */ ,
|
||||||
ExprResult * /* val_rtrn */ ,
|
ExprResult * /* val_rtrn */ ,
|
||||||
LookupEntry * /* values */
|
const LookupEntry * /* values */
|
||||||
);
|
);
|
||||||
|
|
||||||
extern int ExprResolveKeySym(ExprDef * /* expr */ ,
|
extern int ExprResolveKeySym(ExprDef * /* expr */ ,
|
||||||
|
|
|
@ -35,6 +35,7 @@
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include "keycodes.h"
|
#include "keycodes.h"
|
||||||
#include "alias.h"
|
#include "alias.h"
|
||||||
|
#include "parseutils.h"
|
||||||
|
|
||||||
#define DFLT_FONT "helvetica"
|
#define DFLT_FONT "helvetica"
|
||||||
#define DFLT_SLANT "r"
|
#define DFLT_SLANT "r"
|
||||||
|
@ -276,7 +277,6 @@ InitPropertyInfo(PropertyInfo * pi, GeometryInfo * info)
|
||||||
pi->defs.fileID = info->fileID;
|
pi->defs.fileID = info->fileID;
|
||||||
pi->defs.merge = info->merge;
|
pi->defs.merge = info->merge;
|
||||||
pi->name = pi->value = NULL;
|
pi->name = pi->value = NULL;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -292,15 +292,12 @@ FreeProperties(PropertyInfo * pi, GeometryInfo * info)
|
||||||
}
|
}
|
||||||
for (tmp = pi; tmp != NULL; tmp = next)
|
for (tmp = pi; tmp != NULL; tmp = next)
|
||||||
{
|
{
|
||||||
if (tmp->name)
|
|
||||||
free(tmp->name);
|
free(tmp->name);
|
||||||
if (tmp->value)
|
|
||||||
free(tmp->value);
|
free(tmp->value);
|
||||||
tmp->name = tmp->value = NULL;
|
tmp->name = tmp->value = NULL;
|
||||||
next = (PropertyInfo *) tmp->defs.next;
|
next = (PropertyInfo *) tmp->defs.next;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -315,7 +312,7 @@ InitKeyInfo(KeyInfo * key, RowInfo * row, GeometryInfo * info)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bzero(key, sizeof(KeyInfo));
|
memset(key, 0, sizeof(KeyInfo));
|
||||||
strcpy(key->name, "default");
|
strcpy(key->name, "default");
|
||||||
key->defs.defined = _GK_Default;
|
key->defs.defined = _GK_Default;
|
||||||
key->defs.fileID = info->fileID;
|
key->defs.fileID = info->fileID;
|
||||||
|
@ -323,7 +320,6 @@ InitKeyInfo(KeyInfo * key, RowInfo * row, GeometryInfo * info)
|
||||||
key->defs.next = NULL;
|
key->defs.next = NULL;
|
||||||
key->row = row;
|
key->row = row;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -334,7 +330,6 @@ ClearKeyInfo(KeyInfo * key)
|
||||||
key->gap = 0;
|
key->gap = 0;
|
||||||
key->shape = None;
|
key->shape = None;
|
||||||
key->color = None;
|
key->color = None;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -354,7 +349,6 @@ FreeKeys(KeyInfo * key, RowInfo * row, GeometryInfo * info)
|
||||||
next = (KeyInfo *) tmp->defs.next;
|
next = (KeyInfo *) tmp->defs.next;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -367,7 +361,7 @@ InitRowInfo(RowInfo * row, SectionInfo * section, GeometryInfo * info)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bzero(row, sizeof(RowInfo));
|
memset(row, 0, sizeof(RowInfo));
|
||||||
row->defs.defined = _GR_Default;
|
row->defs.defined = _GR_Default;
|
||||||
row->defs.fileID = info->fileID;
|
row->defs.fileID = info->fileID;
|
||||||
row->defs.merge = info->merge;
|
row->defs.merge = info->merge;
|
||||||
|
@ -377,7 +371,6 @@ InitRowInfo(RowInfo * row, SectionInfo * section, GeometryInfo * info)
|
||||||
row->keys = NULL;
|
row->keys = NULL;
|
||||||
InitKeyInfo(&row->dfltKey, row, info);
|
InitKeyInfo(&row->dfltKey, row, info);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -391,7 +384,6 @@ ClearRowInfo(RowInfo * row, GeometryInfo * info)
|
||||||
FreeKeys(row->keys, row, info);
|
FreeKeys(row->keys, row, info);
|
||||||
ClearKeyInfo(&row->dfltKey);
|
ClearKeyInfo(&row->dfltKey);
|
||||||
row->dfltKey.defs.defined |= _GK_Default;
|
row->dfltKey.defs.defined |= _GK_Default;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -411,7 +403,6 @@ FreeRows(RowInfo * row, SectionInfo * section, GeometryInfo * info)
|
||||||
next = (RowInfo *) tmp->defs.next;
|
next = (RowInfo *) tmp->defs.next;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DoodadInfo *
|
static DoodadInfo *
|
||||||
|
@ -456,7 +447,7 @@ InitDoodadInfo(DoodadInfo * di, unsigned type, SectionInfo * si,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bzero(di, sizeof(DoodadInfo));
|
memset(di, 0, sizeof(DoodadInfo));
|
||||||
di->defs.fileID = info->fileID;
|
di->defs.fileID = info->fileID;
|
||||||
di->type = type;
|
di->type = type;
|
||||||
}
|
}
|
||||||
|
@ -475,7 +466,6 @@ InitDoodadInfo(DoodadInfo * di, unsigned type, SectionInfo * si,
|
||||||
if (info->nextPriority > XkbGeomMaxPriority)
|
if (info->nextPriority > XkbGeomMaxPriority)
|
||||||
info->nextPriority = XkbGeomMaxPriority;
|
info->nextPriority = XkbGeomMaxPriority;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -484,10 +474,9 @@ ClearDoodadInfo(DoodadInfo * di)
|
||||||
CommonInfo defs;
|
CommonInfo defs;
|
||||||
|
|
||||||
defs = di->defs;
|
defs = di->defs;
|
||||||
bzero(di, sizeof(DoodadInfo));
|
memset(di, 0, sizeof(DoodadInfo));
|
||||||
di->defs = defs;
|
di->defs = defs;
|
||||||
di->defs.defined = 0;
|
di->defs.defined = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -498,7 +487,6 @@ ClearOverlayInfo(OverlayInfo * ol)
|
||||||
ol->keys = (OverlayKeyInfo *) ClearCommonInfo(&ol->keys->defs);
|
ol->keys = (OverlayKeyInfo *) ClearCommonInfo(&ol->keys->defs);
|
||||||
ol->nKeys = 0;
|
ol->nKeys = 0;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -530,7 +518,6 @@ FreeDoodads(DoodadInfo * di, SectionInfo * si, GeometryInfo * info)
|
||||||
ClearDoodadInfo(tmp);
|
ClearDoodadInfo(tmp);
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -547,7 +534,7 @@ InitSectionInfo(SectionInfo * si, GeometryInfo * info)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bzero(si, sizeof(SectionInfo));
|
memset(si, 0, sizeof(SectionInfo));
|
||||||
si->defs.fileID = info->fileID;
|
si->defs.fileID = info->fileID;
|
||||||
si->defs.merge = info->merge;
|
si->defs.merge = info->merge;
|
||||||
si->defs.next = NULL;
|
si->defs.next = NULL;
|
||||||
|
@ -555,7 +542,6 @@ InitSectionInfo(SectionInfo * si, GeometryInfo * info)
|
||||||
si->name = xkb_intern_atom("default");
|
si->name = xkb_intern_atom("default");
|
||||||
InitRowInfo(&si->dfltRow, si, info);
|
InitRowInfo(&si->dfltRow, si, info);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -574,7 +560,6 @@ DupSectionInfo(SectionInfo * into, SectionInfo * from, GeometryInfo * info)
|
||||||
into->dfltRow.dfltKey.defs.merge = defs.merge;
|
into->dfltRow.dfltKey.defs.merge = defs.merge;
|
||||||
into->dfltRow.dfltKey.defs.next = NULL;
|
into->dfltRow.dfltKey.defs.next = NULL;
|
||||||
into->dfltRow.dfltKey.row = &into->dfltRow;
|
into->dfltRow.dfltKey.row = &into->dfltRow;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -598,7 +583,6 @@ ClearSectionInfo(SectionInfo * si, GeometryInfo * info)
|
||||||
si->doodads = NULL;
|
si->doodads = NULL;
|
||||||
}
|
}
|
||||||
si->dfltRow.defs.defined = _GR_Default;
|
si->dfltRow.defs.defined = _GR_Default;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -618,7 +602,6 @@ FreeSections(SectionInfo * si, GeometryInfo * info)
|
||||||
next = (SectionInfo *) tmp->defs.next;
|
next = (SectionInfo *) tmp->defs.next;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -636,7 +619,7 @@ FreeShapes(ShapeInfo * si, GeometryInfo * info)
|
||||||
{
|
{
|
||||||
if (tmp->outlines)
|
if (tmp->outlines)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
for (i = 0; i < tmp->nOutlines; i++)
|
for (i = 0; i < tmp->nOutlines; i++)
|
||||||
{
|
{
|
||||||
if (tmp->outlines[i].points != NULL)
|
if (tmp->outlines[i].points != NULL)
|
||||||
|
@ -655,7 +638,6 @@ FreeShapes(ShapeInfo * si, GeometryInfo * info)
|
||||||
next = (ShapeInfo *) tmp->defs.next;
|
next = (ShapeInfo *) tmp->defs.next;
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
@ -663,18 +645,16 @@ FreeShapes(ShapeInfo * si, GeometryInfo * info)
|
||||||
static void
|
static void
|
||||||
InitGeometryInfo(GeometryInfo * info, unsigned fileID, unsigned merge)
|
InitGeometryInfo(GeometryInfo * info, unsigned fileID, unsigned merge)
|
||||||
{
|
{
|
||||||
bzero(info, sizeof(GeometryInfo));
|
memset(info, 0, sizeof(GeometryInfo));
|
||||||
info->fileID = fileID;
|
info->fileID = fileID;
|
||||||
info->merge = merge;
|
info->merge = merge;
|
||||||
InitSectionInfo(&info->dfltSection, info);
|
InitSectionInfo(&info->dfltSection, info);
|
||||||
info->dfltSection.defs.defined = _GS_Default;
|
info->dfltSection.defs.defined = _GS_Default;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ClearGeometryInfo(GeometryInfo * info)
|
ClearGeometryInfo(GeometryInfo * info)
|
||||||
{
|
{
|
||||||
if (info->name)
|
|
||||||
free(info->name);
|
free(info->name);
|
||||||
info->name = NULL;
|
info->name = NULL;
|
||||||
if (info->props)
|
if (info->props)
|
||||||
|
@ -683,6 +663,10 @@ ClearGeometryInfo(GeometryInfo * info)
|
||||||
FreeShapes(info->shapes, info);
|
FreeShapes(info->shapes, info);
|
||||||
if (info->sections)
|
if (info->sections)
|
||||||
FreeSections(info->sections, info);
|
FreeSections(info->sections, info);
|
||||||
|
if (info->doodads)
|
||||||
|
FreeDoodads(info->doodads, NULL, info);
|
||||||
|
if (info->dfltDoodads)
|
||||||
|
FreeDoodads(info->dfltDoodads, NULL, info);
|
||||||
info->widthMM = 0;
|
info->widthMM = 0;
|
||||||
info->heightMM = 0;
|
info->heightMM = 0;
|
||||||
info->dfltCornerRadius = 0;
|
info->dfltCornerRadius = 0;
|
||||||
|
@ -690,7 +674,6 @@ ClearGeometryInfo(GeometryInfo * info)
|
||||||
info->dfltSection.defs.defined = _GS_Default;
|
info->dfltSection.defs.defined = _GS_Default;
|
||||||
if (info->aliases)
|
if (info->aliases)
|
||||||
ClearAliases(&info->aliases);
|
ClearAliases(&info->aliases);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
@ -703,7 +686,7 @@ NextProperty(GeometryInfo * info)
|
||||||
pi = uTypedAlloc(PropertyInfo);
|
pi = uTypedAlloc(PropertyInfo);
|
||||||
if (pi)
|
if (pi)
|
||||||
{
|
{
|
||||||
bzero((char *) pi, sizeof(PropertyInfo));
|
memset(pi, 0, sizeof(PropertyInfo));
|
||||||
info->props = (PropertyInfo *) AddCommonInfo(&info->props->defs,
|
info->props = (PropertyInfo *) AddCommonInfo(&info->props->defs,
|
||||||
(CommonInfo *) pi);
|
(CommonInfo *) pi);
|
||||||
info->nProps++;
|
info->nProps++;
|
||||||
|
@ -748,7 +731,6 @@ AddProperty(GeometryInfo * info, PropertyInfo * new)
|
||||||
ACTION("Ignoring \"%s\", using \"%s\"\n", old->value,
|
ACTION("Ignoring \"%s\", using \"%s\"\n", old->value,
|
||||||
new->value);
|
new->value);
|
||||||
}
|
}
|
||||||
if (old->value)
|
|
||||||
free(old->value);
|
free(old->value);
|
||||||
old->value = _XkbDupString(new->value);
|
old->value = _XkbDupString(new->value);
|
||||||
return True;
|
return True;
|
||||||
|
@ -781,7 +763,7 @@ NextShape(GeometryInfo * info)
|
||||||
si = uTypedAlloc(ShapeInfo);
|
si = uTypedAlloc(ShapeInfo);
|
||||||
if (si)
|
if (si)
|
||||||
{
|
{
|
||||||
bzero((char *) si, sizeof(ShapeInfo));
|
memset(si, 0, sizeof(ShapeInfo));
|
||||||
info->shapes = (ShapeInfo *) AddCommonInfo(&info->shapes->defs,
|
info->shapes = (ShapeInfo *) AddCommonInfo(&info->shapes->defs,
|
||||||
(CommonInfo *) si);
|
(CommonInfo *) si);
|
||||||
info->nShapes++;
|
info->nShapes++;
|
||||||
|
@ -872,7 +854,6 @@ ReplaceDoodad(DoodadInfo * into, DoodadInfo * from)
|
||||||
next = from->defs.next;
|
next = from->defs.next;
|
||||||
ClearDoodadInfo(from);
|
ClearDoodadInfo(from);
|
||||||
from->defs.next = next;
|
from->defs.next = next;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DoodadInfo *
|
static DoodadInfo *
|
||||||
|
@ -1310,7 +1291,6 @@ MergeIncludedGeometry(GeometryInfo * into, GeometryInfo * from,
|
||||||
}
|
}
|
||||||
if (!MergeAliases(&into->aliases, &from->aliases, merge))
|
if (!MergeAliases(&into->aliases, &from->aliases, merge))
|
||||||
into->errorCount++;
|
into->errorCount++;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*FileHandler) (XkbFile * /* file */ ,
|
typedef void (*FileHandler) (XkbFile * /* file */ ,
|
||||||
|
@ -1333,7 +1313,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
|
||||||
{
|
{
|
||||||
haveSelf = True;
|
haveSelf = True;
|
||||||
included = *info;
|
included = *info;
|
||||||
bzero(info, sizeof(GeometryInfo));
|
memset(info, 0, sizeof(GeometryInfo));
|
||||||
}
|
}
|
||||||
else if (ProcessIncludeFile(stmt, XkmGeometryIndex, &rtrn, &newMerge))
|
else if (ProcessIncludeFile(stmt, XkmGeometryIndex, &rtrn, &newMerge))
|
||||||
{
|
{
|
||||||
|
@ -1344,11 +1324,11 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
|
||||||
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
||||||
if (stmt->stmt != NULL)
|
if (stmt->stmt != NULL)
|
||||||
{
|
{
|
||||||
if (included.name != NULL)
|
|
||||||
free(included.name);
|
free(included.name);
|
||||||
included.name = stmt->stmt;
|
included.name = stmt->stmt;
|
||||||
stmt->stmt = NULL;
|
stmt->stmt = NULL;
|
||||||
}
|
}
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1379,6 +1359,7 @@ HandleIncludeGeometry(IncludeStmt * stmt, struct xkb_desc * xkb, GeometryInfo *
|
||||||
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
|
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
|
||||||
MergeIncludedGeometry(&included, &next_incl, op);
|
MergeIncludedGeometry(&included, &next_incl, op);
|
||||||
ClearGeometryInfo(&next_incl);
|
ClearGeometryInfo(&next_incl);
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2080,7 +2061,7 @@ SetKeyField(KeyInfo * key,
|
||||||
return ReportBadType("key", field, keyText(key), "key name");
|
return ReportBadType("key", field, keyText(key), "key name");
|
||||||
}
|
}
|
||||||
key->defs.defined |= _GK_Name;
|
key->defs.defined |= _GK_Name;
|
||||||
bzero(key->name, XkbKeyNameLength + 1);
|
memset(key->name, 0, XkbKeyNameLength + 1);
|
||||||
strncpy(key->name, tmp.keyName.name, XkbKeyNameLength);
|
strncpy(key->name, tmp.keyName.name, XkbKeyNameLength);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2497,7 +2478,7 @@ HandleShapeDef(ShapeDef * def, struct xkb_desc * xkb, unsigned merge,
|
||||||
if (def->merge != MergeDefault)
|
if (def->merge != MergeDefault)
|
||||||
merge = def->merge;
|
merge = def->merge;
|
||||||
|
|
||||||
bzero(&si, sizeof(ShapeInfo));
|
memset(&si, 0, sizeof(ShapeInfo));
|
||||||
si.defs.merge = merge;
|
si.defs.merge = merge;
|
||||||
si.name = def->name;
|
si.name = def->name;
|
||||||
si.dfltCornerRadius = info->dfltCornerRadius;
|
si.dfltCornerRadius = info->dfltCornerRadius;
|
||||||
|
@ -2566,7 +2547,7 @@ HandleOverlayDef(OverlayDef * def,
|
||||||
ACTION("Overlay ignored\n");
|
ACTION("Overlay ignored\n");
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
bzero(&ol, sizeof(OverlayInfo));
|
memset(&ol, 0, sizeof(OverlayInfo));
|
||||||
ol.name = def->name;
|
ol.name = def->name;
|
||||||
for (keyDef = def->keys; keyDef;
|
for (keyDef = def->keys; keyDef;
|
||||||
keyDef = (OverlayKeyDef *) keyDef->common.next)
|
keyDef = (OverlayKeyDef *) keyDef->common.next)
|
||||||
|
@ -2718,7 +2699,7 @@ HandleRowBody(RowDef * def, RowInfo * row, unsigned merge,
|
||||||
ACTION("Section not compiled\n");
|
ACTION("Section not compiled\n");
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
bzero(key.name, XkbKeyNameLength + 1);
|
memset(key.name, 0, XkbKeyNameLength + 1);
|
||||||
strncpy(key.name, keyDef->name, XkbKeyNameLength);
|
strncpy(key.name, keyDef->name, XkbKeyNameLength);
|
||||||
key.defs.defined |= _GK_Name;
|
key.defs.defined |= _GK_Name;
|
||||||
}
|
}
|
||||||
|
@ -2863,6 +2844,7 @@ HandleGeometryFile(XkbFile * file,
|
||||||
|
|
||||||
if (merge == MergeDefault)
|
if (merge == MergeDefault)
|
||||||
merge = MergeAugment;
|
merge = MergeAugment;
|
||||||
|
free(info->name);
|
||||||
info->name = _XkbDupString(file->name);
|
info->name = _XkbDupString(file->name);
|
||||||
stmt = file->defs;
|
stmt = file->defs;
|
||||||
while (stmt)
|
while (stmt)
|
||||||
|
@ -2930,7 +2912,6 @@ HandleGeometryFile(XkbFile * file,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
@ -2938,7 +2919,7 @@ HandleGeometryFile(XkbFile * file,
|
||||||
static Bool
|
static Bool
|
||||||
CopyShapeDef(struct xkb_geometry * geom, ShapeInfo * si)
|
CopyShapeDef(struct xkb_geometry * geom, ShapeInfo * si)
|
||||||
{
|
{
|
||||||
register int i, n;
|
int i, n;
|
||||||
struct xkb_shape * shape;
|
struct xkb_shape * shape;
|
||||||
struct xkb_outline *old_outline, *outline;
|
struct xkb_outline *old_outline, *outline;
|
||||||
uint32_t name;
|
uint32_t name;
|
||||||
|
@ -3391,7 +3372,7 @@ VerifyOverlayInfo(struct xkb_geometry * geom,
|
||||||
OverlayInfo * oi,
|
OverlayInfo * oi,
|
||||||
GeometryInfo * info, short rowMap[256], short rowSize[256])
|
GeometryInfo * info, short rowMap[256], short rowSize[256])
|
||||||
{
|
{
|
||||||
register OverlayKeyInfo *ki, *next;
|
OverlayKeyInfo *ki, *next;
|
||||||
unsigned long oKey, uKey, sKey;
|
unsigned long oKey, uKey, sKey;
|
||||||
struct xkb_row * row;
|
struct xkb_row * row;
|
||||||
struct xkb_key * key;
|
struct xkb_key * key;
|
||||||
|
@ -3466,7 +3447,7 @@ VerifyOverlayInfo(struct xkb_geometry * geom,
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
/* now figure out how many rows are defined for the overlay */
|
/* 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++)
|
for (k = 0; k < 256; k++)
|
||||||
{
|
{
|
||||||
rowMap[k] = -1;
|
rowMap[k] = -1;
|
||||||
|
@ -3525,7 +3506,7 @@ CopyOverlayDef(struct xkb_geometry * geom,
|
||||||
{
|
{
|
||||||
row = &ol->rows[ki->overlayRow];
|
row = &ol->rows[ki->overlayRow];
|
||||||
key = &row->keys[row->num_keys++];
|
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->over.name, ki->over, XkbKeyNameLength);
|
||||||
strncpy(key->under.name, ki->under, 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 * geom;
|
||||||
struct xkb_geometry_sizes sizes;
|
struct xkb_geometry_sizes sizes;
|
||||||
bzero(&sizes, sizeof(sizes));
|
memset(&sizes, 0, sizeof(sizes));
|
||||||
sizes.which = XkbGeomAllMask;
|
sizes.which = XkbGeomAllMask;
|
||||||
sizes.num_properties = info.nProps;
|
sizes.num_properties = info.nProps;
|
||||||
sizes.num_colors = 8;
|
sizes.num_colors = 8;
|
||||||
|
|
|
@ -51,7 +51,6 @@ ClearIndicatorMapInfo(LEDInfo * info)
|
||||||
info->vmods = 0;
|
info->vmods = 0;
|
||||||
info->which_groups = info->groups = 0;
|
info->which_groups = info->groups = 0;
|
||||||
info->ctrls = 0;
|
info->ctrls = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
LEDInfo *
|
LEDInfo *
|
||||||
|
@ -162,60 +161,37 @@ AddIndicatorMap(LEDInfo * oldLEDs, LEDInfo * new)
|
||||||
return old;
|
return old;
|
||||||
}
|
}
|
||||||
|
|
||||||
static LookupEntry modComponentNames[] = {
|
static const LookupEntry modComponentNames[] = {
|
||||||
{"base", XkbIM_UseBase}
|
{"base", XkbIM_UseBase},
|
||||||
,
|
{"latched", XkbIM_UseLatched},
|
||||||
{"latched", XkbIM_UseLatched}
|
{"locked", XkbIM_UseLocked},
|
||||||
,
|
{"effective", XkbIM_UseEffective},
|
||||||
{"locked", XkbIM_UseLocked}
|
{"compat", XkbIM_UseCompat},
|
||||||
,
|
{"any", XkbIM_UseAnyMods},
|
||||||
{"effective", XkbIM_UseEffective}
|
{"none", 0},
|
||||||
,
|
|
||||||
{"compat", XkbIM_UseCompat}
|
|
||||||
,
|
|
||||||
{"any", XkbIM_UseAnyMods}
|
|
||||||
,
|
|
||||||
{"none", 0}
|
|
||||||
,
|
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
static LookupEntry groupComponentNames[] = {
|
static const LookupEntry groupComponentNames[] = {
|
||||||
{"base", XkbIM_UseBase}
|
{"base", XkbIM_UseBase},
|
||||||
,
|
{"latched", XkbIM_UseLatched},
|
||||||
{"latched", XkbIM_UseLatched}
|
{"locked", XkbIM_UseLocked},
|
||||||
,
|
{"effective", XkbIM_UseEffective},
|
||||||
{"locked", XkbIM_UseLocked}
|
{"any", XkbIM_UseAnyGroup},
|
||||||
,
|
{"none", 0},
|
||||||
{"effective", XkbIM_UseEffective}
|
|
||||||
,
|
|
||||||
{"any", XkbIM_UseAnyGroup}
|
|
||||||
,
|
|
||||||
{"none", 0}
|
|
||||||
,
|
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static LookupEntry groupNames[] = {
|
static const LookupEntry groupNames[] = {
|
||||||
{"group1", 0x01}
|
{"group1", 0x01},
|
||||||
,
|
{"group2", 0x02},
|
||||||
{"group2", 0x02}
|
{"group3", 0x04},
|
||||||
,
|
{"group4", 0x08},
|
||||||
{"group3", 0x04}
|
{"group5", 0x10},
|
||||||
,
|
{"group6", 0x20},
|
||||||
{"group4", 0x08}
|
{"group7", 0x40},
|
||||||
,
|
{"group8", 0x80},
|
||||||
{"group5", 0x10}
|
{"none", 0x00},
|
||||||
,
|
{"all", 0xff},
|
||||||
{"group6", 0x20}
|
|
||||||
,
|
|
||||||
{"group7", 0x40}
|
|
||||||
,
|
|
||||||
{"group8", 0x80}
|
|
||||||
,
|
|
||||||
{"none", 0x00}
|
|
||||||
,
|
|
||||||
{"all", 0xff}
|
|
||||||
,
|
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -434,7 +410,7 @@ CopyIndicatorMapDefs(struct xkb_desc * xkb, LEDInfo *leds, LEDInfo **unboundRtrn
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
register struct xkb_indicator_map * im;
|
struct xkb_indicator_map * im;
|
||||||
im = &xkb->indicators->maps[led->indicator - 1];
|
im = &xkb->indicators->maps[led->indicator - 1];
|
||||||
im->flags = led->flags;
|
im->flags = led->flags;
|
||||||
im->which_groups = led->which_groups;
|
im->which_groups = led->which_groups;
|
||||||
|
@ -460,8 +436,8 @@ Bool
|
||||||
BindIndicators(struct xkb_desc * xkb, Bool force, LEDInfo *unbound,
|
BindIndicators(struct xkb_desc * xkb, Bool force, LEDInfo *unbound,
|
||||||
LEDInfo **unboundRtrn)
|
LEDInfo **unboundRtrn)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register LEDInfo *led, *next, *last;
|
LEDInfo *led, *next, *last;
|
||||||
|
|
||||||
if (xkb->names != NULL)
|
if (xkb->names != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "keycodes.h"
|
#include "keycodes.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "alias.h"
|
#include "alias.h"
|
||||||
|
#include "parseutils.h"
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
longText(unsigned long val)
|
longText(unsigned long val)
|
||||||
|
@ -50,7 +51,6 @@ LongToKeyName(unsigned long val, char *name)
|
||||||
name[1] = ((val >> 16) & 0xff);
|
name[1] = ((val >> 16) & 0xff);
|
||||||
name[2] = ((val >> 8) & 0xff);
|
name[2] = ((val >> 8) & 0xff);
|
||||||
name[3] = (val & 0xff);
|
name[3] = (val & 0xff);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
@ -143,7 +143,6 @@ InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
|
||||||
ii->ndx = 0;
|
ii->ndx = 0;
|
||||||
ii->name = None;
|
ii->name = None;
|
||||||
ii->virtual = False;
|
ii->virtual = False;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -154,7 +153,6 @@ ClearIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
|
||||||
ClearCommonInfo(&ii->defs);
|
ClearCommonInfo(&ii->defs);
|
||||||
info->leds = NULL;
|
info->leds = NULL;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static IndicatorNameInfo *
|
static IndicatorNameInfo *
|
||||||
|
@ -320,7 +318,6 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
|
||||||
static void
|
static void
|
||||||
ClearKeyNamesInfo(KeyNamesInfo * info)
|
ClearKeyNamesInfo(KeyNamesInfo * info)
|
||||||
{
|
{
|
||||||
if (info->name != NULL)
|
|
||||||
free(info->name);
|
free(info->name);
|
||||||
info->name = NULL;
|
info->name = NULL;
|
||||||
info->computedMax = info->explicitMax = info->explicitMin = 0;
|
info->computedMax = info->explicitMax = info->explicitMin = 0;
|
||||||
|
@ -336,7 +333,6 @@ ClearKeyNamesInfo(KeyNamesInfo * info)
|
||||||
ClearIndicatorNameInfo(info->leds, info);
|
ClearIndicatorNameInfo(info->leds, info);
|
||||||
if (info->aliases)
|
if (info->aliases)
|
||||||
ClearAliases(&info->aliases);
|
ClearAliases(&info->aliases);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -350,13 +346,12 @@ InitKeyNamesInfo(KeyNamesInfo * info)
|
||||||
info->has_alt_forms = NULL;
|
info->has_alt_forms = NULL;
|
||||||
ClearKeyNamesInfo(info);
|
ClearKeyNamesInfo(info);
|
||||||
info->errorCount = 0;
|
info->errorCount = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
FindKeyByLong(KeyNamesInfo * info, unsigned long name)
|
FindKeyByLong(KeyNamesInfo * info, unsigned long name)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
for (i = info->computedMin; i <= info->computedMax; i++)
|
for (i = info->computedMin; i <= info->computedMax; i++)
|
||||||
{
|
{
|
||||||
|
@ -479,7 +474,7 @@ static void
|
||||||
MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
|
MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
|
||||||
unsigned merge)
|
unsigned merge)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
char buf[5];
|
char buf[5];
|
||||||
|
|
||||||
if (from->errorCount > 0)
|
if (from->errorCount > 0)
|
||||||
|
@ -540,7 +535,6 @@ MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
|
||||||
|| (into->explicitMax < from->explicitMax))
|
|| (into->explicitMax < from->explicitMax))
|
||||||
into->explicitMax = from->explicitMax;
|
into->explicitMax = from->explicitMax;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -563,7 +557,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
|
||||||
{
|
{
|
||||||
haveSelf = True;
|
haveSelf = True;
|
||||||
included = *info;
|
included = *info;
|
||||||
bzero(info, sizeof(KeyNamesInfo));
|
memset(info, 0, sizeof(KeyNamesInfo));
|
||||||
}
|
}
|
||||||
else if (stmt->file && strcmp(stmt->file, "computed") == 0)
|
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);
|
HandleKeycodesFile(rtrn, xkb, MergeOverride, &included);
|
||||||
if (stmt->stmt != NULL)
|
if (stmt->stmt != NULL)
|
||||||
{
|
{
|
||||||
if (included.name != NULL)
|
|
||||||
free(included.name);
|
free(included.name);
|
||||||
included.name = stmt->stmt;
|
included.name = stmt->stmt;
|
||||||
stmt->stmt = NULL;
|
stmt->stmt = NULL;
|
||||||
}
|
}
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -610,6 +604,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, struct xkb_desc * xkb, KeyNamesInfo *
|
||||||
HandleKeycodesFile(rtrn, xkb, MergeOverride, &next_incl);
|
HandleKeycodesFile(rtrn, xkb, MergeOverride, &next_incl);
|
||||||
MergeIncludedKeycodes(&included, &next_incl, op);
|
MergeIncludedKeycodes(&included, &next_incl, op);
|
||||||
ClearKeyNamesInfo(&next_incl);
|
ClearKeyNamesInfo(&next_incl);
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -679,7 +674,7 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
||||||
{
|
{
|
||||||
ERROR("Unknown element %s encountered\n", tmp.str);
|
ERROR("Unknown element %s encountered\n", tmp.str);
|
||||||
ACTION("Default for field %s ignored\n", field.str);
|
ACTION("Default for field %s ignored\n", field.str);
|
||||||
return 0;
|
goto err_out;
|
||||||
}
|
}
|
||||||
if (uStrCaseCmp(field.str, "minimum") == 0)
|
if (uStrCaseCmp(field.str, "minimum") == 0)
|
||||||
which = MIN_KEYCODE_DEF;
|
which = MIN_KEYCODE_DEF;
|
||||||
|
@ -689,19 +684,19 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
||||||
{
|
{
|
||||||
ERROR("Unknown field encountered\n");
|
ERROR("Unknown field encountered\n");
|
||||||
ACTION("Assigment to field %s ignored\n", field.str);
|
ACTION("Assigment to field %s ignored\n", field.str);
|
||||||
return 0;
|
goto err_out;
|
||||||
}
|
}
|
||||||
if (arrayNdx != NULL)
|
if (arrayNdx != NULL)
|
||||||
{
|
{
|
||||||
ERROR("The %s setting is not an array\n", field.str);
|
ERROR("The %s setting is not an array\n", field.str);
|
||||||
ACTION("Illegal array reference ignored\n");
|
ACTION("Illegal array reference ignored\n");
|
||||||
return 0;
|
goto err_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ExprResolveKeyCode(stmt->value, &tmp) == 0)
|
if (ExprResolveKeyCode(stmt->value, &tmp) == 0)
|
||||||
{
|
{
|
||||||
ACTION("Assignment to field %s ignored\n", field.str);
|
ACTION("Assignment to field %s ignored\n", field.str);
|
||||||
return 0;
|
goto err_out;
|
||||||
}
|
}
|
||||||
if (tmp.uval > XKB_KEYCODE_MAX)
|
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",
|
("Illegal keycode %d (must be in the range %d-%d inclusive)\n",
|
||||||
tmp.uval, 0, XKB_KEYCODE_MAX);
|
tmp.uval, 0, XKB_KEYCODE_MAX);
|
||||||
ACTION("Value of \"%s\" not changed\n", field.str);
|
ACTION("Value of \"%s\" not changed\n", field.str);
|
||||||
return 0;
|
goto err_out;
|
||||||
}
|
}
|
||||||
if (which == MIN_KEYCODE_DEF)
|
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",
|
("Minimum key code (%d) must be <= maximum key code (%d)\n",
|
||||||
tmp.uval, info->explicitMax);
|
tmp.uval, info->explicitMax);
|
||||||
ACTION("Minimum key code value not changed\n");
|
ACTION("Minimum key code value not changed\n");
|
||||||
return 0;
|
goto err_out;
|
||||||
}
|
}
|
||||||
if ((info->computedMax > 0) && (info->computedMin < tmp.uval))
|
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",
|
("Minimum key code (%d) must be <= lowest defined key (%d)\n",
|
||||||
tmp.uval, info->computedMin);
|
tmp.uval, info->computedMin);
|
||||||
ACTION("Minimum key code value not changed\n");
|
ACTION("Minimum key code value not changed\n");
|
||||||
return 0;
|
goto err_out;
|
||||||
}
|
}
|
||||||
info->explicitMin = tmp.uval;
|
info->explicitMin = tmp.uval;
|
||||||
}
|
}
|
||||||
|
@ -738,7 +733,7 @@ HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
|
||||||
ERROR("Maximum code (%d) must be >= minimum key code (%d)\n",
|
ERROR("Maximum code (%d) must be >= minimum key code (%d)\n",
|
||||||
tmp.uval, info->explicitMin);
|
tmp.uval, info->explicitMin);
|
||||||
ACTION("Maximum code value not changed\n");
|
ACTION("Maximum code value not changed\n");
|
||||||
return 0;
|
goto err_out;
|
||||||
}
|
}
|
||||||
if ((info->computedMax > 0) && (info->computedMax > tmp.uval))
|
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",
|
("Maximum code (%d) must be >= highest defined key (%d)\n",
|
||||||
tmp.uval, info->computedMax);
|
tmp.uval, info->computedMax);
|
||||||
ACTION("Maximum code value not changed\n");
|
ACTION("Maximum code value not changed\n");
|
||||||
return 0;
|
goto err_out;
|
||||||
}
|
}
|
||||||
info->explicitMax = tmp.uval;
|
info->explicitMax = tmp.uval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
free(field.str);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
err_out:
|
||||||
|
free(field.str);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -803,6 +804,7 @@ HandleKeycodesFile(XkbFile * file,
|
||||||
{
|
{
|
||||||
ParseCommon *stmt;
|
ParseCommon *stmt;
|
||||||
|
|
||||||
|
free(info->name);
|
||||||
info->name = _XkbDupString(file->name);
|
info->name = _XkbDupString(file->name);
|
||||||
stmt = file->defs;
|
stmt = file->defs;
|
||||||
while (stmt)
|
while (stmt)
|
||||||
|
@ -857,7 +859,6 @@ HandleKeycodesFile(XkbFile * file,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -893,7 +894,7 @@ CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
||||||
if (XkbcAllocNames(xkb, XkbKeyNamesMask | XkbIndicatorNamesMask, 0, 0)
|
if (XkbcAllocNames(xkb, XkbKeyNamesMask | XkbIndicatorNamesMask, 0, 0)
|
||||||
== Success)
|
== Success)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
xkb->names->keycodes = xkb_intern_atom(info.name);
|
xkb->names->keycodes = xkb_intern_atom(info.name);
|
||||||
for (i = info.computedMin; i <= info.computedMax; i++)
|
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;
|
xkb->names->indicators[ii->ndx - 1] = ii->name;
|
||||||
if (xkb->indicators != NULL)
|
if (xkb->indicators != NULL)
|
||||||
{
|
{
|
||||||
register unsigned bit;
|
unsigned bit;
|
||||||
bit = 1 << (ii->ndx - 1);
|
bit = 1 << (ii->ndx - 1);
|
||||||
if (ii->virtual)
|
if (ii->virtual)
|
||||||
xkb->indicators->phys_indicators &= ~bit;
|
xkb->indicators->phys_indicators &= ~bit;
|
||||||
|
@ -930,6 +931,7 @@ CompileKeycodes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
||||||
}
|
}
|
||||||
if (info.aliases)
|
if (info.aliases)
|
||||||
ApplyAliases(xkb, False, &info.aliases);
|
ApplyAliases(xkb, False, &info.aliases);
|
||||||
|
ClearKeyNamesInfo(&info);
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
ClearKeyNamesInfo(&info);
|
ClearKeyNamesInfo(&info);
|
||||||
|
|
|
@ -39,8 +39,6 @@
|
||||||
#define SYMBOLS 4
|
#define SYMBOLS 4
|
||||||
#define MAX_SECTIONS 5
|
#define MAX_SECTIONS 5
|
||||||
|
|
||||||
static XkbFile *sections[MAX_SECTIONS];
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile the given file and store the output in xkb.
|
* Compile the given file and store the output in xkb.
|
||||||
* @param file A list of XkbFiles, each denoting one type (e.g.
|
* @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;
|
unsigned mainType;
|
||||||
char *mainName;
|
char *mainName;
|
||||||
LEDInfo *unbound = NULL;
|
LEDInfo *unbound = NULL;
|
||||||
|
XkbFile *sections[MAX_SECTIONS];
|
||||||
|
|
||||||
bzero(sections, MAX_SECTIONS * sizeof(XkbFile *));
|
memset(sections, 0, sizeof(sections));
|
||||||
mainType = file->type;
|
mainType = file->type;
|
||||||
mainName = file->name;
|
mainName = file->name;
|
||||||
switch (mainType)
|
switch (mainType)
|
||||||
|
@ -84,7 +83,10 @@ CompileKeymap(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
||||||
/* Check for duplicate entries in the input file */
|
/* Check for duplicate entries in the input file */
|
||||||
while ((file) && (ok))
|
while ((file) && (ok))
|
||||||
{
|
{
|
||||||
file->topName = mainName;
|
if (file->topName != mainName) {
|
||||||
|
free(file->topName);
|
||||||
|
file->topName = strdup(mainName);
|
||||||
|
}
|
||||||
if ((have & (1 << file->type)) != 0)
|
if ((have & (1 << file->type)) != 0)
|
||||||
{
|
{
|
||||||
ERROR("More than one %s section in a %s file\n",
|
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;
|
xkb->defined = have;
|
||||||
if (required & (~have))
|
if (required & (~have))
|
||||||
{
|
{
|
||||||
register int i, bit;
|
int i, bit;
|
||||||
unsigned missing;
|
unsigned missing;
|
||||||
missing = required & (~have);
|
missing = required & (~have);
|
||||||
for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
|
for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include "vmod.h"
|
#include "vmod.h"
|
||||||
#include "action.h"
|
#include "action.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "parseutils.h"
|
||||||
|
|
||||||
typedef struct _PreserveInfo
|
typedef struct _PreserveInfo
|
||||||
{
|
{
|
||||||
|
@ -77,10 +78,10 @@ typedef struct _KeyTypesInfo
|
||||||
VModInfo vmods;
|
VModInfo vmods;
|
||||||
} KeyTypesInfo;
|
} KeyTypesInfo;
|
||||||
|
|
||||||
uint32_t tok_ONE_LEVEL;
|
static uint32_t tok_ONE_LEVEL;
|
||||||
uint32_t tok_TWO_LEVEL;
|
static uint32_t tok_TWO_LEVEL;
|
||||||
static uint32_t tok_ALPHABETIC;
|
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);
|
info->dflt.lvlNames = uTypedCalloc(from->dflt.szNames, uint32_t);
|
||||||
if (info->dflt.lvlNames)
|
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);
|
memcpy(info->dflt.lvlNames, from->dflt.lvlNames, sz);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,39 +174,30 @@ InitKeyTypesInfo(KeyTypesInfo * info, struct xkb_desc * xkb, KeyTypesInfo * from
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
FreeKeyTypeInfo(KeyTypeInfo * type)
|
FreeKeyTypeInfo(KeyTypeInfo * type)
|
||||||
{
|
|
||||||
if (type->entries != NULL)
|
|
||||||
{
|
{
|
||||||
free(type->entries);
|
free(type->entries);
|
||||||
type->entries = NULL;
|
type->entries = NULL;
|
||||||
}
|
|
||||||
if (type->lvlNames != NULL)
|
|
||||||
{
|
|
||||||
free(type->lvlNames);
|
free(type->lvlNames);
|
||||||
type->lvlNames = NULL;
|
type->lvlNames = NULL;
|
||||||
}
|
|
||||||
if (type->preserve != NULL)
|
if (type->preserve != NULL)
|
||||||
{
|
{
|
||||||
ClearCommonInfo(&type->preserve->defs);
|
ClearCommonInfo(&type->preserve->defs);
|
||||||
type->preserve = NULL;
|
type->preserve = NULL;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
FreeKeyTypesInfo(KeyTypesInfo * info)
|
FreeKeyTypesInfo(KeyTypesInfo * info)
|
||||||
{
|
{
|
||||||
if (info->name)
|
|
||||||
free(info->name);
|
free(info->name);
|
||||||
info->name = NULL;
|
info->name = NULL;
|
||||||
if (info->types)
|
if (info->types)
|
||||||
{
|
{
|
||||||
register KeyTypeInfo *type;
|
KeyTypeInfo *type;
|
||||||
for (type = info->types; type; type = (KeyTypeInfo *) type->defs.next)
|
for (type = info->types; type; type = (KeyTypeInfo *) type->defs.next)
|
||||||
{
|
{
|
||||||
FreeKeyTypeInfo(type);
|
FreeKeyTypeInfo(type);
|
||||||
|
@ -213,7 +205,6 @@ FreeKeyTypesInfo(KeyTypesInfo * info)
|
||||||
info->types = (KeyTypeInfo *) ClearCommonInfo(&info->types->defs);
|
info->types = (KeyTypeInfo *) ClearCommonInfo(&info->types->defs);
|
||||||
}
|
}
|
||||||
FreeKeyTypeInfo(&info->dflt);
|
FreeKeyTypeInfo(&info->dflt);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static KeyTypeInfo *
|
static KeyTypeInfo *
|
||||||
|
@ -224,7 +215,7 @@ NextKeyType(KeyTypesInfo * info)
|
||||||
type = uTypedAlloc(KeyTypeInfo);
|
type = uTypedAlloc(KeyTypeInfo);
|
||||||
if (type != NULL)
|
if (type != NULL)
|
||||||
{
|
{
|
||||||
bzero(type, sizeof(KeyTypeInfo));
|
memset(type, 0, sizeof(KeyTypeInfo));
|
||||||
type->defs.fileID = info->fileID;
|
type->defs.fileID = info->fileID;
|
||||||
info->types = (KeyTypeInfo *) AddCommonInfo(&info->types->defs,
|
info->types = (KeyTypeInfo *) AddCommonInfo(&info->types->defs,
|
||||||
(CommonInfo *) type);
|
(CommonInfo *) type);
|
||||||
|
@ -363,7 +354,6 @@ MergeIncludedKeyTypes(KeyTypesInfo * into,
|
||||||
into->errorCount++;
|
into->errorCount++;
|
||||||
}
|
}
|
||||||
into->stdPresent |= from->stdPresent;
|
into->stdPresent |= from->stdPresent;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*FileHandler) (XkbFile * /* file */ ,
|
typedef void (*FileHandler) (XkbFile * /* file */ ,
|
||||||
|
@ -386,7 +376,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
|
||||||
{
|
{
|
||||||
haveSelf = True;
|
haveSelf = True;
|
||||||
included = *info;
|
included = *info;
|
||||||
bzero(info, sizeof(KeyTypesInfo));
|
memset(info, 0, sizeof(KeyTypesInfo));
|
||||||
}
|
}
|
||||||
else if (ProcessIncludeFile(stmt, XkmTypesIndex, &rtrn, &newMerge))
|
else if (ProcessIncludeFile(stmt, XkmTypesIndex, &rtrn, &newMerge))
|
||||||
{
|
{
|
||||||
|
@ -397,11 +387,11 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
|
||||||
(*hndlr) (rtrn, xkb, newMerge, &included);
|
(*hndlr) (rtrn, xkb, newMerge, &included);
|
||||||
if (stmt->stmt != NULL)
|
if (stmt->stmt != NULL)
|
||||||
{
|
{
|
||||||
if (included.name != NULL)
|
|
||||||
free(included.name);
|
free(included.name);
|
||||||
included.name = stmt->stmt;
|
included.name = stmt->stmt;
|
||||||
stmt->stmt = NULL;
|
stmt->stmt = NULL;
|
||||||
}
|
}
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -430,6 +420,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
|
||||||
(*hndlr) (rtrn, xkb, op, &next_incl);
|
(*hndlr) (rtrn, xkb, op, &next_incl);
|
||||||
MergeIncludedKeyTypes(&included, &next_incl, op, xkb);
|
MergeIncludedKeyTypes(&included, &next_incl, op, xkb);
|
||||||
FreeKeyTypesInfo(&next_incl);
|
FreeKeyTypesInfo(&next_incl);
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -454,7 +445,7 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
|
||||||
static struct xkb_kt_map_entry *
|
static struct xkb_kt_map_entry *
|
||||||
FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
|
FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
struct xkb_kt_map_entry * entry;
|
struct xkb_kt_map_entry * entry;
|
||||||
|
|
||||||
for (i = 0, entry = type->entries; i < type->nEntries; i++, 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
|
static void
|
||||||
DeleteLevel1MapEntries(KeyTypeInfo * type)
|
DeleteLevel1MapEntries(KeyTypeInfo * type)
|
||||||
{
|
{
|
||||||
register int i, n;
|
int i, n;
|
||||||
|
|
||||||
for (i = 0; i < type->nEntries; i++)
|
for (i = 0; i < type->nEntries; i++)
|
||||||
{
|
{
|
||||||
|
@ -481,7 +472,6 @@ DeleteLevel1MapEntries(KeyTypeInfo * type)
|
||||||
type->nEntries--;
|
type->nEntries--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -939,7 +929,7 @@ static int
|
||||||
HandleKeyTypeDef(KeyTypeDef * def,
|
HandleKeyTypeDef(KeyTypeDef * def,
|
||||||
struct xkb_desc * xkb, unsigned merge, KeyTypesInfo * info)
|
struct xkb_desc * xkb, unsigned merge, KeyTypesInfo * info)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
KeyTypeInfo type;
|
KeyTypeInfo type;
|
||||||
|
|
||||||
if (def->merge != MergeDefault)
|
if (def->merge != MergeDefault)
|
||||||
|
@ -1021,6 +1011,7 @@ HandleKeyTypesFile(XkbFile * file,
|
||||||
{
|
{
|
||||||
ParseCommon *stmt;
|
ParseCommon *stmt;
|
||||||
|
|
||||||
|
free(info->name);
|
||||||
info->name = _XkbDupString(file->name);
|
info->name = _XkbDupString(file->name);
|
||||||
stmt = file->defs;
|
stmt = file->defs;
|
||||||
while (stmt)
|
while (stmt)
|
||||||
|
@ -1074,13 +1065,12 @@ HandleKeyTypesFile(XkbFile * file,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
CopyDefToKeyType(struct xkb_desc * xkb, struct xkb_key_type * type, KeyTypeInfo * def)
|
CopyDefToKeyType(struct xkb_desc * xkb, struct xkb_key_type * type, KeyTypeInfo * def)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
PreserveInfo *pre;
|
PreserveInfo *pre;
|
||||||
|
|
||||||
for (pre = def->preserve; pre != NULL;
|
for (pre = def->preserve; pre != NULL;
|
||||||
|
@ -1161,9 +1151,9 @@ CompileKeyTypes(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
||||||
|
|
||||||
if (info.errorCount == 0)
|
if (info.errorCount == 0)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
register KeyTypeInfo *def;
|
KeyTypeInfo *def;
|
||||||
register struct xkb_key_type *type, *next;
|
struct xkb_key_type *type, *next;
|
||||||
|
|
||||||
if (info.name != NULL)
|
if (info.name != NULL)
|
||||||
{
|
{
|
||||||
|
|
|
@ -355,6 +355,8 @@ AddDirectory(CompPair *cp, char *head, char *ptrn, char *rest, char *map,
|
||||||
}
|
}
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
while (FindNextFile(dirh, &file));
|
while (FindNextFile(dirh, &file));
|
||||||
|
#else
|
||||||
|
closedir(dirp);
|
||||||
#endif
|
#endif
|
||||||
return nMatch;
|
return nMatch;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,15 +53,10 @@ ProcessIncludeFile(IncludeStmt * stmt,
|
||||||
XkbFile ** file_rtrn, unsigned *merge_rtrn)
|
XkbFile ** file_rtrn, unsigned *merge_rtrn)
|
||||||
{
|
{
|
||||||
FILE *file;
|
FILE *file;
|
||||||
XkbFile *rtrn, *mapToUse;
|
XkbFile *rtrn, *mapToUse, *next;
|
||||||
char oldFile[1024] = {0};
|
char oldFile[1024] = {0};
|
||||||
int oldLine = lineNum;
|
int oldLine = lineNum;
|
||||||
|
|
||||||
rtrn = XkbFindFileInCache(stmt->file, file_type, &stmt->path);
|
|
||||||
if (rtrn == 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);
|
file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
|
@ -86,15 +81,25 @@ ProcessIncludeFile(IncludeStmt * stmt,
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
XkbAddFileToCache(stmt->file, file_type, stmt->path, rtrn);
|
|
||||||
}
|
|
||||||
mapToUse = rtrn;
|
mapToUse = rtrn;
|
||||||
if (stmt->map != NULL)
|
if (stmt->map != NULL)
|
||||||
{
|
{
|
||||||
while ((mapToUse) && ((!uStringEqual(mapToUse->name, stmt->map)) ||
|
while (mapToUse)
|
||||||
(mapToUse->type != file_type)))
|
|
||||||
{
|
{
|
||||||
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)
|
if (!mapToUse)
|
||||||
{
|
{
|
||||||
|
@ -249,7 +254,7 @@ FindNamedKey(struct xkb_desc * xkb,
|
||||||
xkb_keycode_t *kc_rtrn,
|
xkb_keycode_t *kc_rtrn,
|
||||||
Bool use_aliases, Bool create, int start_from)
|
Bool use_aliases, Bool create, int start_from)
|
||||||
{
|
{
|
||||||
register unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
if (start_from < xkb->min_key_code)
|
if (start_from < xkb->min_key_code)
|
||||||
{
|
{
|
||||||
|
@ -315,7 +320,7 @@ Bool
|
||||||
FindKeyNameForAlias(struct xkb_desc * xkb, unsigned long lname,
|
FindKeyNameForAlias(struct xkb_desc * xkb, unsigned long lname,
|
||||||
unsigned long *real_name)
|
unsigned long *real_name)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
char name[XkbKeyNameLength + 1];
|
char name[XkbKeyNameLength + 1];
|
||||||
|
|
||||||
if (xkb && xkb->geom && xkb->geom->key_aliases)
|
if (xkb && xkb->geom && xkb->geom->key_aliases)
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include "parseutils.h"
|
#include "parseutils.h"
|
||||||
#include "xkbmisc.h"
|
#include "xkbmisc.h"
|
||||||
#include "xkbpath.h"
|
#include "xkbpath.h"
|
||||||
|
#include "xkbparse.h"
|
||||||
#include <X11/keysym.h>
|
#include <X11/keysym.h>
|
||||||
#include <X11/Xalloca.h>
|
#include <X11/Xalloca.h>
|
||||||
|
|
||||||
|
@ -270,7 +271,7 @@ SymbolsCreate(char *keyName, ExprDef * symbols)
|
||||||
def->common.stmtType = StmtSymbolsDef;
|
def->common.stmtType = StmtSymbolsDef;
|
||||||
def->common.next = NULL;
|
def->common.next = NULL;
|
||||||
def->merge = MergeDefault;
|
def->merge = MergeDefault;
|
||||||
bzero(def->keyName, 5);
|
memset(def->keyName, 0, 5);
|
||||||
strncpy(def->keyName, keyName, 4);
|
strncpy(def->keyName, keyName, 4);
|
||||||
def->symbols = symbols;
|
def->symbols = symbols;
|
||||||
}
|
}
|
||||||
|
@ -420,7 +421,7 @@ ShapeDeclCreate(uint32_t name, OutlineDef * outlines)
|
||||||
shape = uTypedAlloc(ShapeDef);
|
shape = uTypedAlloc(ShapeDef);
|
||||||
if (shape != NULL)
|
if (shape != NULL)
|
||||||
{
|
{
|
||||||
bzero(shape, sizeof(ShapeDef));
|
memset(shape, 0, sizeof(ShapeDef));
|
||||||
shape->common.stmtType = StmtShapeDef;
|
shape->common.stmtType = StmtShapeDef;
|
||||||
shape->common.next = NULL;
|
shape->common.next = NULL;
|
||||||
shape->merge = MergeDefault;
|
shape->merge = MergeDefault;
|
||||||
|
@ -445,7 +446,7 @@ OutlineCreate(uint32_t field, ExprDef * points)
|
||||||
outline = uTypedAlloc(OutlineDef);
|
outline = uTypedAlloc(OutlineDef);
|
||||||
if (outline != NULL)
|
if (outline != NULL)
|
||||||
{
|
{
|
||||||
bzero(outline, sizeof(OutlineDef));
|
memset(outline, 0, sizeof(OutlineDef));
|
||||||
outline->common.stmtType = StmtOutlineDef;
|
outline->common.stmtType = StmtOutlineDef;
|
||||||
outline->common.next = NULL;
|
outline->common.next = NULL;
|
||||||
outline->field = field;
|
outline->field = field;
|
||||||
|
@ -470,7 +471,7 @@ KeyDeclCreate(char *name, ExprDef * expr)
|
||||||
key = uTypedAlloc(KeyDef);
|
key = uTypedAlloc(KeyDef);
|
||||||
if (key != NULL)
|
if (key != NULL)
|
||||||
{
|
{
|
||||||
bzero(key, sizeof(KeyDef));
|
memset(key, 0, sizeof(KeyDef));
|
||||||
key->common.stmtType = StmtKeyDef;
|
key->common.stmtType = StmtKeyDef;
|
||||||
key->common.next = NULL;
|
key->common.next = NULL;
|
||||||
if (name)
|
if (name)
|
||||||
|
@ -490,7 +491,7 @@ RowDeclCreate(KeyDef * keys)
|
||||||
row = uTypedAlloc(RowDef);
|
row = uTypedAlloc(RowDef);
|
||||||
if (row != NULL)
|
if (row != NULL)
|
||||||
{
|
{
|
||||||
bzero(row, sizeof(RowDef));
|
memset(row, 0, sizeof(RowDef));
|
||||||
row->common.stmtType = StmtRowDef;
|
row->common.stmtType = StmtRowDef;
|
||||||
row->common.next = NULL;
|
row->common.next = NULL;
|
||||||
row->nKeys = 0;
|
row->nKeys = 0;
|
||||||
|
@ -513,7 +514,7 @@ SectionDeclCreate(uint32_t name, RowDef * rows)
|
||||||
section = uTypedAlloc(SectionDef);
|
section = uTypedAlloc(SectionDef);
|
||||||
if (section != NULL)
|
if (section != NULL)
|
||||||
{
|
{
|
||||||
bzero(section, sizeof(SectionDef));
|
memset(section, 0, sizeof(SectionDef));
|
||||||
section->common.stmtType = StmtSectionDef;
|
section->common.stmtType = StmtSectionDef;
|
||||||
section->common.next = NULL;
|
section->common.next = NULL;
|
||||||
section->name = name;
|
section->name = name;
|
||||||
|
@ -536,13 +537,11 @@ OverlayKeyCreate(char *under, char *over)
|
||||||
key = uTypedAlloc(OverlayKeyDef);
|
key = uTypedAlloc(OverlayKeyDef);
|
||||||
if (key != NULL)
|
if (key != NULL)
|
||||||
{
|
{
|
||||||
bzero(key, sizeof(OverlayKeyDef));
|
memset(key, 0, sizeof(OverlayKeyDef));
|
||||||
key->common.stmtType = StmtOverlayKeyDef;
|
key->common.stmtType = StmtOverlayKeyDef;
|
||||||
strncpy(key->over, over, XkbKeyNameLength);
|
strncpy(key->over, over, XkbKeyNameLength);
|
||||||
strncpy(key->under, under, XkbKeyNameLength);
|
strncpy(key->under, under, XkbKeyNameLength);
|
||||||
if (over)
|
|
||||||
free(over);
|
free(over);
|
||||||
if (under)
|
|
||||||
free(under);
|
free(under);
|
||||||
}
|
}
|
||||||
return key;
|
return key;
|
||||||
|
@ -557,7 +556,7 @@ OverlayDeclCreate(uint32_t name, OverlayKeyDef * keys)
|
||||||
ol = uTypedAlloc(OverlayDef);
|
ol = uTypedAlloc(OverlayDef);
|
||||||
if (ol != NULL)
|
if (ol != NULL)
|
||||||
{
|
{
|
||||||
bzero(ol, sizeof(OverlayDef));
|
memset(ol, 0, sizeof(OverlayDef));
|
||||||
ol->common.stmtType = StmtOverlayDef;
|
ol->common.stmtType = StmtOverlayDef;
|
||||||
ol->name = name;
|
ol->name = name;
|
||||||
ol->keys = keys;
|
ol->keys = keys;
|
||||||
|
@ -578,7 +577,7 @@ DoodadCreate(unsigned type, uint32_t name, VarDef * body)
|
||||||
doodad = uTypedAlloc(DoodadDef);
|
doodad = uTypedAlloc(DoodadDef);
|
||||||
if (doodad != NULL)
|
if (doodad != NULL)
|
||||||
{
|
{
|
||||||
bzero(doodad, sizeof(DoodadDef));
|
memset(doodad, 0, sizeof(DoodadDef));
|
||||||
doodad->common.stmtType = StmtDoodadDef;
|
doodad->common.stmtType = StmtDoodadDef;
|
||||||
doodad->common.next = NULL;
|
doodad->common.next = NULL;
|
||||||
doodad->type = type;
|
doodad->type = type;
|
||||||
|
@ -634,6 +633,9 @@ LookupKeysym(char *str, uint32_t * sym_rtrn)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
FreeInclude(IncludeStmt *incl);
|
||||||
|
|
||||||
IncludeStmt *
|
IncludeStmt *
|
||||||
IncludeCreate(char *str, unsigned merge)
|
IncludeCreate(char *str, unsigned merge)
|
||||||
{
|
{
|
||||||
|
@ -694,28 +696,14 @@ IncludeCreate(char *str, unsigned merge)
|
||||||
}
|
}
|
||||||
if (first)
|
if (first)
|
||||||
first->stmt = stmt;
|
first->stmt = stmt;
|
||||||
else if (stmt)
|
else
|
||||||
free(stmt);
|
free(stmt);
|
||||||
return first;
|
return first;
|
||||||
|
|
||||||
BAIL:
|
BAIL:
|
||||||
ERROR("Illegal include statement \"%s\"\n", stmt);
|
ERROR("Illegal include statement \"%s\"\n", stmt);
|
||||||
ACTION("Ignored\n");
|
ACTION("Ignored\n");
|
||||||
while (first)
|
FreeInclude(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);
|
free(stmt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -765,7 +753,6 @@ CheckDefaultMap(XkbFile * maps)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
XkbFile *
|
XkbFile *
|
||||||
|
@ -778,7 +765,7 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags)
|
||||||
if (file)
|
if (file)
|
||||||
{
|
{
|
||||||
XkbcEnsureSafeMapName(name);
|
XkbcEnsureSafeMapName(name);
|
||||||
bzero(file, sizeof(XkbFile));
|
memset(file, 0, sizeof(XkbFile));
|
||||||
file->type = type;
|
file->type = type;
|
||||||
file->topName = _XkbDupString(name);
|
file->topName = _XkbDupString(name);
|
||||||
file->name = name;
|
file->name = name;
|
||||||
|
@ -800,3 +787,183 @@ StmtSetMerge(ParseCommon * stmt, unsigned merge)
|
||||||
}
|
}
|
||||||
return 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 */
|
unsigned /* flags */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
extern void FreeXKBFile(XkbFile *file);
|
||||||
|
|
||||||
extern void yyerror(const char * /* msg */
|
extern void yyerror(const char * /* msg */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,6 @@
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
#include "alias.h"
|
#include "alias.h"
|
||||||
|
|
||||||
extern uint32_t tok_ONE_LEVEL;
|
|
||||||
extern uint32_t tok_TWO_LEVEL;
|
|
||||||
extern uint32_t tok_KEYPAD;
|
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
|
||||||
#define RepeatYes 1
|
#define RepeatYes 1
|
||||||
|
@ -85,7 +81,7 @@ typedef struct _KeyInfo
|
||||||
static void
|
static void
|
||||||
InitKeyInfo(KeyInfo * info)
|
InitKeyInfo(KeyInfo * info)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
static char dflt[4] = "*";
|
static char dflt[4] = "*";
|
||||||
|
|
||||||
info->defs.defined = 0;
|
info->defs.defined = 0;
|
||||||
|
@ -109,7 +105,6 @@ InitKeyInfo(KeyInfo * info)
|
||||||
info->nameForOverlayKey = 0;
|
info->nameForOverlayKey = 0;
|
||||||
info->repeat = RepeatUndefined;
|
info->repeat = RepeatUndefined;
|
||||||
info->allowNone = 0;
|
info->allowNone = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +113,7 @@ InitKeyInfo(KeyInfo * info)
|
||||||
static void
|
static void
|
||||||
FreeKeyInfo(KeyInfo * info)
|
FreeKeyInfo(KeyInfo * info)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
info->defs.defined = 0;
|
info->defs.defined = 0;
|
||||||
info->defs.fileID = 0;
|
info->defs.fileID = 0;
|
||||||
|
@ -130,10 +125,8 @@ FreeKeyInfo(KeyInfo * info)
|
||||||
{
|
{
|
||||||
info->numLevels[i] = 0;
|
info->numLevels[i] = 0;
|
||||||
info->types[i] = None;
|
info->types[i] = None;
|
||||||
if (info->syms[i] != NULL)
|
|
||||||
free(info->syms[i]);
|
free(info->syms[i]);
|
||||||
info->syms[i] = NULL;
|
info->syms[i] = NULL;
|
||||||
if (info->acts[i] != NULL)
|
|
||||||
free(info->acts[i]);
|
free(info->acts[i]);
|
||||||
info->acts[i] = NULL;
|
info->acts[i] = NULL;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +137,6 @@ FreeKeyInfo(KeyInfo * info)
|
||||||
info->nameForOverlayKey = 0;
|
info->nameForOverlayKey = 0;
|
||||||
info->repeat = RepeatUndefined;
|
info->repeat = RepeatUndefined;
|
||||||
info->allowNone = 0;
|
info->allowNone = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -155,7 +147,7 @@ FreeKeyInfo(KeyInfo * info)
|
||||||
static Bool
|
static Bool
|
||||||
CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
|
CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
*new = *old;
|
*new = *old;
|
||||||
new->defs.next = NULL;
|
new->defs.next = NULL;
|
||||||
|
@ -183,8 +175,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
|
||||||
new->numLevels[i] = 0;
|
new->numLevels[i] = 0;
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
memcpy((char *) new->syms[i], (char *) old->syms[i],
|
memcpy(new->syms[i], old->syms[i], width * sizeof(uint32_t));
|
||||||
width * sizeof(uint32_t));
|
|
||||||
}
|
}
|
||||||
if (old->acts[i] != NULL)
|
if (old->acts[i] != NULL)
|
||||||
{
|
{
|
||||||
|
@ -194,7 +185,7 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
|
||||||
new->acts[i] = NULL;
|
new->acts[i] = NULL;
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
memcpy((char *) new->acts[i], (char *) old->acts[i],
|
memcpy(new->acts[i], old->acts[i],
|
||||||
width * sizeof(union xkb_action));
|
width * sizeof(union xkb_action));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -241,11 +232,8 @@ typedef struct _SymbolsInfo
|
||||||
static void
|
static void
|
||||||
InitSymbolsInfo(SymbolsInfo * info, struct xkb_desc * xkb)
|
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->name = NULL;
|
||||||
info->explicit_group = 0;
|
info->explicit_group = 0;
|
||||||
info->errorCount = 0;
|
info->errorCount = 0;
|
||||||
|
@ -262,38 +250,25 @@ InitSymbolsInfo(SymbolsInfo * info, struct xkb_desc * xkb)
|
||||||
InitVModInfo(&info->vmods, xkb);
|
InitVModInfo(&info->vmods, xkb);
|
||||||
info->action = NULL;
|
info->action = NULL;
|
||||||
info->aliases = NULL;
|
info->aliases = NULL;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
FreeSymbolsInfo(SymbolsInfo * info)
|
FreeSymbolsInfo(SymbolsInfo * info)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
if (info->name)
|
|
||||||
free(info->name);
|
free(info->name);
|
||||||
info->name = NULL;
|
|
||||||
if (info->keys)
|
if (info->keys)
|
||||||
{
|
{
|
||||||
for (i = 0; i < info->nKeys; i++)
|
for (i = 0; i < info->nKeys; i++)
|
||||||
{
|
|
||||||
FreeKeyInfo(&info->keys[i]);
|
FreeKeyInfo(&info->keys[i]);
|
||||||
}
|
|
||||||
free(info->keys);
|
free(info->keys);
|
||||||
info->keys = NULL;
|
|
||||||
}
|
}
|
||||||
if (info->modMap)
|
if (info->modMap)
|
||||||
{
|
|
||||||
ClearCommonInfo(&info->modMap->defs);
|
ClearCommonInfo(&info->modMap->defs);
|
||||||
info->modMap = NULL;
|
|
||||||
}
|
|
||||||
if (info->aliases)
|
if (info->aliases)
|
||||||
{
|
|
||||||
ClearAliases(&info->aliases);
|
ClearAliases(&info->aliases);
|
||||||
info->aliases = NULL;
|
memset(info, 0, sizeof(SymbolsInfo));
|
||||||
}
|
|
||||||
bzero((char *) info, sizeof(SymbolsInfo));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
|
@ -337,7 +312,7 @@ MergeKeyGroups(SymbolsInfo * info,
|
||||||
uint32_t *resultSyms;
|
uint32_t *resultSyms;
|
||||||
union xkb_action *resultActs;
|
union xkb_action *resultActs;
|
||||||
int resultWidth;
|
int resultWidth;
|
||||||
register int i;
|
int i;
|
||||||
Bool report, clobber;
|
Bool report, clobber;
|
||||||
|
|
||||||
clobber = (from->defs.merge != MergeAugment);
|
clobber = (from->defs.merge != MergeAugment);
|
||||||
|
@ -374,6 +349,9 @@ MergeKeyGroups(SymbolsInfo * info,
|
||||||
WSGO("Could not allocate actions for group merge\n");
|
WSGO("Could not allocate actions for group merge\n");
|
||||||
ACTION("Group %d of key %s not merged\n", group,
|
ACTION("Group %d of key %s not merged\n", group,
|
||||||
longText(into->name));
|
longText(into->name));
|
||||||
|
if (resultSyms != into->syms[group] &&
|
||||||
|
resultSyms != from->syms[group])
|
||||||
|
free(resultSyms);
|
||||||
return False;
|
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]);
|
free(into->syms[group]);
|
||||||
if ((from->syms[group] != NULL) && (resultSyms != from->syms[group]))
|
if (resultSyms != from->syms[group])
|
||||||
free(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]);
|
free(into->acts[group]);
|
||||||
if ((from->acts[group] != NULL) && (resultActs != from->acts[group]))
|
if (resultActs != from->acts[group])
|
||||||
free(from->acts[group]);
|
free(from->acts[group]);
|
||||||
into->numLevels[group] = resultWidth;
|
into->numLevels[group] = resultWidth;
|
||||||
into->syms[group] = resultSyms;
|
into->syms[group] = resultSyms;
|
||||||
|
@ -480,7 +458,7 @@ MergeKeyGroups(SymbolsInfo * info,
|
||||||
static Bool
|
static Bool
|
||||||
MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
|
MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
unsigned collide = 0;
|
unsigned collide = 0;
|
||||||
Bool report;
|
Bool report;
|
||||||
|
|
||||||
|
@ -490,14 +468,12 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
|
||||||
{
|
{
|
||||||
if (into->numLevels[i] != 0)
|
if (into->numLevels[i] != 0)
|
||||||
{
|
{
|
||||||
if (into->syms[i])
|
|
||||||
free(into->syms[i]);
|
free(into->syms[i]);
|
||||||
if (into->acts[i])
|
|
||||||
free(into->acts[i]);
|
free(into->acts[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*into = *from;
|
*into = *from;
|
||||||
bzero(from, sizeof(KeyInfo));
|
memset(from, 0, sizeof(KeyInfo));
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
report = ((warningLevel > 9) ||
|
report = ((warningLevel > 9) ||
|
||||||
|
@ -604,7 +580,7 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
|
||||||
static Bool
|
static Bool
|
||||||
AddKeySymbols(SymbolsInfo * info, KeyInfo * key, struct xkb_desc * xkb)
|
AddKeySymbols(SymbolsInfo * info, KeyInfo * key, struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
unsigned long real_name;
|
unsigned long real_name;
|
||||||
|
|
||||||
for (i = 0; i < info->nKeys; i++)
|
for (i = 0; i < info->nKeys; i++)
|
||||||
|
@ -716,7 +692,7 @@ static void
|
||||||
MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
|
MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
|
||||||
unsigned merge, struct xkb_desc * xkb)
|
unsigned merge, struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
KeyInfo *key;
|
KeyInfo *key;
|
||||||
|
|
||||||
if (from->errorCount > 0)
|
if (from->errorCount > 0)
|
||||||
|
@ -760,7 +736,6 @@ MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
|
||||||
}
|
}
|
||||||
if (!MergeAliases(&into->aliases, &from->aliases, merge))
|
if (!MergeAliases(&into->aliases, &from->aliases, merge))
|
||||||
into->errorCount++;
|
into->errorCount++;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef void (*FileHandler) (XkbFile * /* rtrn */ ,
|
typedef void (*FileHandler) (XkbFile * /* rtrn */ ,
|
||||||
|
@ -783,7 +758,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
|
||||||
{
|
{
|
||||||
haveSelf = True;
|
haveSelf = True;
|
||||||
included = *info;
|
included = *info;
|
||||||
bzero(info, sizeof(SymbolsInfo));
|
memset(info, 0, sizeof(SymbolsInfo));
|
||||||
}
|
}
|
||||||
else if (ProcessIncludeFile(stmt, XkmSymbolsIndex, &rtrn, &newMerge))
|
else if (ProcessIncludeFile(stmt, XkmSymbolsIndex, &rtrn, &newMerge))
|
||||||
{
|
{
|
||||||
|
@ -801,11 +776,11 @@ HandleIncludeSymbols(IncludeStmt * stmt,
|
||||||
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
(*hndlr) (rtrn, xkb, MergeOverride, &included);
|
||||||
if (stmt->stmt != NULL)
|
if (stmt->stmt != NULL)
|
||||||
{
|
{
|
||||||
if (included.name != NULL)
|
|
||||||
free(included.name);
|
free(included.name);
|
||||||
included.name = stmt->stmt;
|
included.name = stmt->stmt;
|
||||||
stmt->stmt = NULL;
|
stmt->stmt = NULL;
|
||||||
}
|
}
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -842,6 +817,7 @@ HandleIncludeSymbols(IncludeStmt * stmt,
|
||||||
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
|
(*hndlr) (rtrn, xkb, MergeOverride, &next_incl);
|
||||||
MergeIncludedSymbols(&included, &next_incl, op, xkb);
|
MergeIncludedSymbols(&included, &next_incl, op, xkb);
|
||||||
FreeSymbolsInfo(&next_incl);
|
FreeSymbolsInfo(&next_incl);
|
||||||
|
FreeXKBFile(rtrn);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -877,7 +853,7 @@ GetGroupIndex(KeyInfo * key,
|
||||||
|
|
||||||
if (arrayNdx == NULL)
|
if (arrayNdx == NULL)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
unsigned defined;
|
unsigned defined;
|
||||||
if (what == SYMBOLS)
|
if (what == SYMBOLS)
|
||||||
defined = key->symsDefined;
|
defined = key->symsDefined;
|
||||||
|
@ -968,7 +944,7 @@ AddActionsToKey(KeyInfo * key,
|
||||||
char *field,
|
char *field,
|
||||||
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
|
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
unsigned ndx, nActs;
|
unsigned ndx, nActs;
|
||||||
ExprDef *act;
|
ExprDef *act;
|
||||||
struct xkb_any_action *toAct;
|
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},
|
{"true", XkbKB_Lock},
|
||||||
{"yes", XkbKB_Lock},
|
{"yes", XkbKB_Lock},
|
||||||
{"on", XkbKB_Lock},
|
{"on", XkbKB_Lock},
|
||||||
|
@ -1082,7 +1058,7 @@ static LookupEntry lockingEntries[] = {
|
||||||
{NULL, 0}
|
{NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static LookupEntry repeatEntries[] = {
|
static const LookupEntry repeatEntries[] = {
|
||||||
{"true", RepeatYes},
|
{"true", RepeatYes},
|
||||||
{"yes", RepeatYes},
|
{"yes", RepeatYes},
|
||||||
{"on", RepeatYes},
|
{"on", RepeatYes},
|
||||||
|
@ -1507,13 +1483,11 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
|
||||||
for (i = 1; i < XkbNumKbdGroups; i++)
|
for (i = 1; i < XkbNumKbdGroups; i++)
|
||||||
{
|
{
|
||||||
key->numLevels[i] = 0;
|
key->numLevels[i] = 0;
|
||||||
if (key->syms[i] != NULL)
|
|
||||||
free(key->syms[i]);
|
free(key->syms[i]);
|
||||||
key->syms[i] = (uint32_t *) NULL;
|
key->syms[i] = NULL;
|
||||||
if (key->acts[i] != NULL)
|
|
||||||
free(key->acts[i]);
|
free(key->acts[i]);
|
||||||
key->acts[i] = (union xkb_action *) NULL;
|
key->acts[i] = NULL;
|
||||||
key->types[i] = (uint32_t) 0;
|
key->types[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
key->typesDefined = key->symsDefined = key->actsDefined = 1 << group;
|
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[group] = key->numLevels[0];
|
||||||
key->numLevels[0] = 0;
|
key->numLevels[0] = 0;
|
||||||
key->syms[group] = key->syms[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[group] = key->acts[0];
|
||||||
key->acts[0] = (union xkb_action *) NULL;
|
key->acts[0] = NULL;
|
||||||
key->types[group] = key->types[0];
|
key->types[group] = key->types[0];
|
||||||
key->types[0] = (uint32_t) 0;
|
key->types[0] = 0;
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1608,6 +1582,7 @@ HandleSymbolsFile(XkbFile * file,
|
||||||
{
|
{
|
||||||
ParseCommon *stmt;
|
ParseCommon *stmt;
|
||||||
|
|
||||||
|
free(info->name);
|
||||||
info->name = _XkbDupString(file->name);
|
info->name = _XkbDupString(file->name);
|
||||||
stmt = file->defs;
|
stmt = file->defs;
|
||||||
while (stmt)
|
while (stmt)
|
||||||
|
@ -1660,14 +1635,13 @@ HandleSymbolsFile(XkbFile * file,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
FindKeyForSymbol(struct xkb_desc * xkb, uint32_t sym, xkb_keycode_t *kc_rtrn)
|
FindKeyForSymbol(struct xkb_desc * xkb, uint32_t sym, xkb_keycode_t *kc_rtrn)
|
||||||
{
|
{
|
||||||
register int i, j;
|
int i, j;
|
||||||
register Bool gotOne;
|
Bool gotOne;
|
||||||
|
|
||||||
j = 0;
|
j = 0;
|
||||||
do
|
do
|
||||||
|
@ -1702,7 +1676,7 @@ FindKeyForSymbol(struct xkb_desc * xkb, uint32_t sym, xkb_keycode_t *kc_rtrn)
|
||||||
static Bool
|
static Bool
|
||||||
FindNamedType(struct xkb_desc * xkb, uint32_t name, unsigned *type_rtrn)
|
FindNamedType(struct xkb_desc * xkb, uint32_t name, unsigned *type_rtrn)
|
||||||
{
|
{
|
||||||
register unsigned n;
|
unsigned n;
|
||||||
|
|
||||||
if (xkb && xkb->map && xkb->map->types)
|
if (xkb && xkb->map && xkb->map->types)
|
||||||
{
|
{
|
||||||
|
@ -1822,7 +1796,7 @@ PrepareKeyDef(KeyInfo * key)
|
||||||
key->acts[i] = uTypedCalloc(width, union xkb_action);
|
key->acts[i] = uTypedCalloc(width, union xkb_action);
|
||||||
if (key->acts[i] == NULL)
|
if (key->acts[i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
memcpy((void *) key->acts[i], (void *) key->acts[0],
|
memcpy(key->acts[i], key->acts[0],
|
||||||
width * sizeof(union xkb_action));
|
width * sizeof(union xkb_action));
|
||||||
key->actsDefined |= 1 << i;
|
key->actsDefined |= 1 << i;
|
||||||
}
|
}
|
||||||
|
@ -1831,8 +1805,7 @@ PrepareKeyDef(KeyInfo * key)
|
||||||
key->syms[i] = uTypedCalloc(width, uint32_t);
|
key->syms[i] = uTypedCalloc(width, uint32_t);
|
||||||
if (key->syms[i] == NULL)
|
if (key->syms[i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
memcpy((void *) key->syms[i], (void *) key->syms[0],
|
memcpy(key->syms[i], key->syms[0], width * sizeof(uint32_t));
|
||||||
width * sizeof(uint32_t));
|
|
||||||
key->symsDefined |= 1 << i;
|
key->symsDefined |= 1 << i;
|
||||||
}
|
}
|
||||||
if (defined & 1)
|
if (defined & 1)
|
||||||
|
@ -1853,7 +1826,7 @@ PrepareKeyDef(KeyInfo * key)
|
||||||
}
|
}
|
||||||
if ((key->syms[i] != key->syms[0]) &&
|
if ((key->syms[i] != key->syms[0]) &&
|
||||||
(key->syms[i] == NULL || key->syms[0] == NULL ||
|
(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])))
|
sizeof(uint32_t) * key->numLevels[0])))
|
||||||
{
|
{
|
||||||
identical = False;
|
identical = False;
|
||||||
|
@ -1861,7 +1834,7 @@ PrepareKeyDef(KeyInfo * key)
|
||||||
}
|
}
|
||||||
if ((key->acts[i] != key->acts[0]) &&
|
if ((key->acts[i] != key->acts[0]) &&
|
||||||
(key->acts[i] == NULL || key->acts[0] == NULL ||
|
(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])))
|
sizeof(union xkb_action) * key->numLevels[0])))
|
||||||
{
|
{
|
||||||
identical = False;
|
identical = False;
|
||||||
|
@ -1873,19 +1846,16 @@ PrepareKeyDef(KeyInfo * key)
|
||||||
for (i = lastGroup; i > 0; i--)
|
for (i = lastGroup; i > 0; i--)
|
||||||
{
|
{
|
||||||
key->numLevels[i] = 0;
|
key->numLevels[i] = 0;
|
||||||
if (key->syms[i] != NULL)
|
|
||||||
free(key->syms[i]);
|
free(key->syms[i]);
|
||||||
key->syms[i] = (uint32_t *) NULL;
|
key->syms[i] = NULL;
|
||||||
if (key->acts[i] != NULL)
|
|
||||||
free(key->acts[i]);
|
free(key->acts[i]);
|
||||||
key->acts[i] = (union xkb_action *) NULL;
|
key->acts[i] = NULL;
|
||||||
key->types[i] = (uint32_t) 0;
|
key->types[i] = 0;
|
||||||
}
|
}
|
||||||
key->symsDefined &= 1;
|
key->symsDefined &= 1;
|
||||||
key->actsDefined &= 1;
|
key->actsDefined &= 1;
|
||||||
key->typesDefined &= 1;
|
key->typesDefined &= 1;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1896,7 +1866,7 @@ PrepareKeyDef(KeyInfo * key)
|
||||||
static Bool
|
static Bool
|
||||||
CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
|
CopySymbolsDef(struct xkb_desc * xkb, KeyInfo *key, int start_from)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
xkb_keycode_t okc, kc;
|
xkb_keycode_t okc, kc;
|
||||||
unsigned width, tmp, nGroups;
|
unsigned width, tmp, nGroups;
|
||||||
struct xkb_key_type * type;
|
struct xkb_key_type * type;
|
||||||
|
@ -2148,7 +2118,7 @@ CopyModMapDef(struct xkb_desc * xkb, ModMapEntry *entry)
|
||||||
Bool
|
Bool
|
||||||
CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
CompileSymbols(XkbFile *file, struct xkb_desc * xkb, unsigned merge)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
SymbolsInfo info;
|
SymbolsInfo info;
|
||||||
|
|
||||||
InitSymbolsInfo(&info, xkb);
|
InitSymbolsInfo(&info, xkb);
|
||||||
|
|
|
@ -36,16 +36,16 @@ recalloc(void * old, unsigned nOld, unsigned nNew, unsigned itemSize)
|
||||||
char *rtrn;
|
char *rtrn;
|
||||||
|
|
||||||
if (old == NULL)
|
if (old == NULL)
|
||||||
rtrn = (char *) calloc(nNew, itemSize);
|
rtrn = calloc(nNew, itemSize);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rtrn = (char *) realloc((char *) old, nNew * itemSize);
|
rtrn = realloc(old, nNew * itemSize);
|
||||||
if ((rtrn) && (nNew > nOld))
|
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;
|
static FILE *errorFile = NULL;
|
||||||
|
@ -205,7 +205,7 @@ uStrCaseCmp(const char *str1, const char *str2)
|
||||||
{
|
{
|
||||||
char buf1[512], buf2[512];
|
char buf1[512], buf2[512];
|
||||||
char c, *s;
|
char c, *s;
|
||||||
register int n;
|
int n;
|
||||||
|
|
||||||
for (n = 0, s = buf1; (c = *str1++); 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 uTypedAlloc(t) ((t *)malloc((unsigned)sizeof(t)))
|
||||||
#define uTypedCalloc(n,t) ((t *)calloc((unsigned)n,(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 uTypedRealloc(pO,n,t) ((t *)realloc(pO,((unsigned)n)*sizeof(t)))
|
||||||
#define uTypedRecalloc(pO,o,n,t) ((t *)recalloc((void *)pO,((unsigned)o),((unsigned)n),sizeof(t)))
|
#define uTypedRecalloc(pO,o,n,t) ((t *)recalloc(pO,((unsigned)o),((unsigned)n),sizeof(t)))
|
||||||
#if (defined mdHasAlloca) && (mdHasAlloca)
|
#if (defined mdHasAlloca) && (mdHasAlloca)
|
||||||
#define uTmpAlloc(n) ((void *)alloca((unsigned)n))
|
#define uTmpAlloc(n) alloca((unsigned)n)
|
||||||
#define uTmpFree(p)
|
#define uTmpFree(p)
|
||||||
#else
|
#else
|
||||||
#define uTmpAlloc(n) malloc(n)
|
#define uTmpAlloc(n) malloc(n)
|
||||||
|
|
|
@ -41,13 +41,12 @@ InitVModInfo(VModInfo * info, struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
ClearVModInfo(info, xkb);
|
ClearVModInfo(info, xkb);
|
||||||
info->errorCount = 0;
|
info->errorCount = 0;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ClearVModInfo(VModInfo * info, struct xkb_desc * xkb)
|
ClearVModInfo(VModInfo * info, struct xkb_desc * xkb)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
if (XkbcAllocNames(xkb, XkbVirtualModNamesMask, 0, 0) != Success)
|
if (XkbcAllocNames(xkb, XkbVirtualModNamesMask, 0, 0) != Success)
|
||||||
return;
|
return;
|
||||||
|
@ -57,14 +56,13 @@ ClearVModInfo(VModInfo * info, struct xkb_desc * xkb)
|
||||||
info->newlyDefined = info->defined = info->available = 0;
|
info->newlyDefined = info->defined = info->available = 0;
|
||||||
if (xkb && xkb->names)
|
if (xkb && xkb->names)
|
||||||
{
|
{
|
||||||
register int bit;
|
int bit;
|
||||||
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
|
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
|
||||||
{
|
{
|
||||||
if (xkb->names->vmods[i] != None)
|
if (xkb->names->vmods[i] != None)
|
||||||
info->defined |= bit;
|
info->defined |= bit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
@ -81,7 +79,7 @@ Bool
|
||||||
HandleVModDef(VModDef * stmt, struct xkb_desc *xkb, unsigned mergeMode,
|
HandleVModDef(VModDef * stmt, struct xkb_desc *xkb, unsigned mergeMode,
|
||||||
VModInfo * info)
|
VModInfo * info)
|
||||||
{
|
{
|
||||||
register int i, bit, nextFree;
|
int i, bit, nextFree;
|
||||||
ExprResult mod;
|
ExprResult mod;
|
||||||
struct xkb_server_map * srv;
|
struct xkb_server_map * srv;
|
||||||
struct xkb_names * names;
|
struct xkb_names * names;
|
||||||
|
@ -161,7 +159,7 @@ HandleVModDef(VModDef * stmt, struct xkb_desc *xkb, unsigned mergeMode,
|
||||||
* undefined.
|
* undefined.
|
||||||
*/
|
*/
|
||||||
static int
|
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)
|
ExprResult * val_rtrn)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
@ -197,7 +195,7 @@ LookupVModIndex(struct xkb_desc *xkb, uint32_t field, unsigned type,
|
||||||
* undefined.
|
* undefined.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
LookupVModMask(void * priv, uint32_t field, unsigned type,
|
LookupVModMask(const void * priv, uint32_t field, unsigned type,
|
||||||
ExprResult * val_rtrn)
|
ExprResult * val_rtrn)
|
||||||
{
|
{
|
||||||
if (LookupModMask(NULL, field, type, 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))
|
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));
|
val_rtrn->uval = (1 << (XkbNumModifiers + ndx));
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ authorization from the authors.
|
||||||
#include "xkballoc.h"
|
#include "xkballoc.h"
|
||||||
#include "xkbrules.h"
|
#include "xkbrules.h"
|
||||||
#include "xkbpath.h"
|
#include "xkbpath.h"
|
||||||
|
#include "xkbmisc.h"
|
||||||
#include "parseutils.h"
|
#include "parseutils.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
@ -77,23 +78,13 @@ XkbComponentsFromRules(const char *rules, const XkbRF_VarDefsPtr defs)
|
||||||
{
|
{
|
||||||
FILE *rulesFile = NULL;
|
FILE *rulesFile = NULL;
|
||||||
char *rulesPath = NULL;
|
char *rulesPath = NULL;
|
||||||
static XkbRF_RulesPtr loaded = NULL;
|
XkbRF_RulesPtr loaded = NULL;
|
||||||
static char *cached_name = NULL;
|
|
||||||
struct xkb_component_names * names = 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!loaded) {
|
|
||||||
rulesFile = XkbFindFileInPath(rules, XkmRulesFile, &rulesPath);
|
rulesFile = XkbFindFileInPath(rules, XkmRulesFile, &rulesPath);
|
||||||
if (!rulesFile) {
|
if (!rulesFile) {
|
||||||
ERROR("could not find \"%s\" rules in XKB path\n", rules);
|
ERROR("could not find \"%s\" rules in XKB path\n", rules);
|
||||||
goto out;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(loaded = _XkbTypedCalloc(1, XkbRF_RulesRec))) {
|
if (!(loaded = _XkbTypedCalloc(1, XkbRF_RulesRec))) {
|
||||||
|
@ -106,9 +97,6 @@ XkbComponentsFromRules(const char *rules, const XkbRF_VarDefsPtr defs)
|
||||||
goto unwind_file;
|
goto unwind_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
cached_name = strdup(rules);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(names = _XkbTypedCalloc(1, struct xkb_component_names))) {
|
if (!(names = _XkbTypedCalloc(1, struct xkb_component_names))) {
|
||||||
ERROR("failed to allocate XKB components\n");
|
ERROR("failed to allocate XKB components\n");
|
||||||
goto unwind_file;
|
goto unwind_file;
|
||||||
|
@ -127,10 +115,10 @@ XkbComponentsFromRules(const char *rules, const XkbRF_VarDefsPtr defs)
|
||||||
}
|
}
|
||||||
|
|
||||||
unwind_file:
|
unwind_file:
|
||||||
|
XkbcRF_Free(loaded);
|
||||||
if (rulesFile)
|
if (rulesFile)
|
||||||
fclose(rulesFile);
|
fclose(rulesFile);
|
||||||
free(rulesPath);
|
free(rulesPath);
|
||||||
out:
|
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +197,7 @@ struct xkb_desc *
|
||||||
xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
|
xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
|
||||||
{
|
{
|
||||||
XkbFile *file, *mapToUse;
|
XkbFile *file, *mapToUse;
|
||||||
struct xkb_desc * xkb;
|
struct xkb_desc * xkb = NULL;
|
||||||
|
|
||||||
uSetErrorFile(NULL);
|
uSetErrorFile(NULL);
|
||||||
|
|
||||||
|
@ -235,23 +223,23 @@ xkb_compile_keymap_from_components(const struct xkb_component_names * ktcsg)
|
||||||
|
|
||||||
if (!CompileKeymap(mapToUse, xkb, MergeReplace)) {
|
if (!CompileKeymap(mapToUse, xkb, MergeReplace)) {
|
||||||
ERROR("failed to compile keymap\n");
|
ERROR("failed to compile keymap\n");
|
||||||
goto unwind_xkb;
|
XkbcFreeKeyboard(xkb);
|
||||||
|
xkb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return xkb;
|
|
||||||
unwind_xkb:
|
|
||||||
XkbcFreeKeyboard(xkb, XkbAllComponentsMask, True);
|
|
||||||
unwind_file:
|
unwind_file:
|
||||||
/* XXX: here's where we would free the XkbFile */
|
FreeXKBFile(file);
|
||||||
|
free(scanFile);
|
||||||
|
XkbFreeIncludePath();
|
||||||
fail:
|
fail:
|
||||||
return NULL;
|
return xkb;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct xkb_desc *
|
static struct xkb_desc *
|
||||||
compile_keymap(XkbFile *file, const char *mapName)
|
compile_keymap(XkbFile *file, const char *mapName)
|
||||||
{
|
{
|
||||||
XkbFile *mapToUse;
|
XkbFile *mapToUse;
|
||||||
struct xkb_desc * xkb;
|
struct xkb_desc * xkb = NULL;
|
||||||
|
|
||||||
/* Find map to use */
|
/* Find map to use */
|
||||||
if (!(mapToUse = XkbChooseMap(file, mapName)))
|
if (!(mapToUse = XkbChooseMap(file, mapName)))
|
||||||
|
@ -275,16 +263,15 @@ compile_keymap(XkbFile *file, const char *mapName)
|
||||||
|
|
||||||
if (!CompileKeymap(mapToUse, xkb, MergeReplace)) {
|
if (!CompileKeymap(mapToUse, xkb, MergeReplace)) {
|
||||||
ERROR("failed to compile keymap\n");
|
ERROR("failed to compile keymap\n");
|
||||||
goto unwind_xkb;
|
XkbcFreeKeyboard(xkb);
|
||||||
|
xkb = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return xkb;
|
|
||||||
unwind_xkb:
|
|
||||||
XkbcFreeKeyboard(xkb, XkbAllComponentsMask, True);
|
|
||||||
unwind_file:
|
unwind_file:
|
||||||
/* XXX: here's where we would free the XkbFile */
|
FreeXKBFile(file);
|
||||||
|
free(scanFile);
|
||||||
return NULL;
|
XkbFreeIncludePath();
|
||||||
|
return xkb;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct xkb_desc *
|
struct xkb_desc *
|
||||||
|
@ -328,5 +315,6 @@ xkb_compile_keymap_from_file(FILE *inputFile, const char *mapName)
|
||||||
void
|
void
|
||||||
xkb_free_keymap(struct xkb_desc *xkb)
|
xkb_free_keymap(struct xkb_desc *xkb)
|
||||||
{
|
{
|
||||||
XkbcFreeKeyboard(xkb, 0, True);
|
XkbcFreeKeyboard(xkb);
|
||||||
|
XkbcFreeAllAtoms();
|
||||||
}
|
}
|
||||||
|
|
|
@ -332,7 +332,6 @@ KeyNameDecl : KeyName EQUALS KeyCode SEMI
|
||||||
KeycodeDef *def;
|
KeycodeDef *def;
|
||||||
|
|
||||||
def= KeycodeCreate($1,$3);
|
def= KeycodeCreate($1,$3);
|
||||||
if ($1)
|
|
||||||
free($1);
|
free($1);
|
||||||
$$= def;
|
$$= def;
|
||||||
}
|
}
|
||||||
|
@ -342,8 +341,8 @@ KeyAliasDecl : ALIAS KeyName EQUALS KeyName SEMI
|
||||||
{
|
{
|
||||||
KeyAliasDef *def;
|
KeyAliasDef *def;
|
||||||
def= KeyAliasCreate($2,$4);
|
def= KeyAliasCreate($2,$4);
|
||||||
if ($2) free($2);
|
free($2);
|
||||||
if ($4) free($4);
|
free($4);
|
||||||
$$= def;
|
$$= def;
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
@ -732,7 +731,7 @@ KeySym : IDENT { $$= strdup(scanBuf); }
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$$= malloc(17);
|
$$= malloc(17);
|
||||||
snprintf($$, 17, "%x", $1);
|
snprintf($$, 17, "0x%x", $1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#define DEBUG_VAR debugFlags
|
#define DEBUG_VAR debugFlags
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
#include <errno.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "xkbpath.h"
|
#include "xkbpath.h"
|
||||||
#include "xkbcommon/xkbcommon.h"
|
#include "xkbcommon/xkbcommon.h"
|
||||||
|
@ -170,7 +171,7 @@ XkbInitIncludePath(void)
|
||||||
return True;
|
return True;
|
||||||
|
|
||||||
szPath = PATH_CHUNK;
|
szPath = PATH_CHUNK;
|
||||||
includePath = (char **) calloc(szPath, sizeof(char *));
|
includePath = calloc(szPath, sizeof(char *));
|
||||||
if (!includePath)
|
if (!includePath)
|
||||||
return False;
|
return False;
|
||||||
|
|
||||||
|
@ -184,7 +185,7 @@ XkbInitIncludePath(void)
|
||||||
static void
|
static void
|
||||||
XkbClearIncludePath(void)
|
XkbClearIncludePath(void)
|
||||||
{
|
{
|
||||||
register int i;
|
int i;
|
||||||
|
|
||||||
if (szPath > 0)
|
if (szPath > 0)
|
||||||
{
|
{
|
||||||
|
@ -199,7 +200,14 @@ XkbClearIncludePath(void)
|
||||||
nPathEntries = 0;
|
nPathEntries = 0;
|
||||||
}
|
}
|
||||||
noDefaultPath = True;
|
noDefaultPath = True;
|
||||||
return;
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
XkbFreeIncludePath(void)
|
||||||
|
{
|
||||||
|
XkbClearIncludePath();
|
||||||
|
free(includePath);
|
||||||
|
includePath = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -232,7 +240,7 @@ XkbAddDirectoryToPath(const char *dir)
|
||||||
if (nPathEntries >= szPath)
|
if (nPathEntries >= szPath)
|
||||||
{
|
{
|
||||||
szPath += PATH_CHUNK;
|
szPath += PATH_CHUNK;
|
||||||
includePath = (char **) realloc(includePath, szPath * sizeof(char *));
|
includePath = realloc(includePath, szPath * sizeof(char *));
|
||||||
if (includePath == NULL)
|
if (includePath == NULL)
|
||||||
{
|
{
|
||||||
WSGO("Allocation failed (includePath)\n");
|
WSGO("Allocation failed (includePath)\n");
|
||||||
|
@ -263,127 +271,34 @@ XkbAddDefaultDirectoriesToPath(void)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the xkb directory based on the type.
|
* Return the xkb directory based on the type.
|
||||||
* Do not free the memory returned by this function.
|
|
||||||
*/
|
*/
|
||||||
char *
|
const char *
|
||||||
XkbDirectoryForInclude(unsigned type)
|
XkbDirectoryForInclude(unsigned type)
|
||||||
{
|
{
|
||||||
static char buf[32];
|
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case XkmSemanticsFile:
|
case XkmSemanticsFile:
|
||||||
strcpy(buf, "semantics");
|
return "semantics";
|
||||||
break;
|
|
||||||
case XkmLayoutFile:
|
case XkmLayoutFile:
|
||||||
strcpy(buf, "layout");
|
return "layout";
|
||||||
break;
|
|
||||||
case XkmKeymapFile:
|
case XkmKeymapFile:
|
||||||
strcpy(buf, "keymap");
|
return "keymap";
|
||||||
break;
|
|
||||||
case XkmKeyNamesIndex:
|
case XkmKeyNamesIndex:
|
||||||
strcpy(buf, "keycodes");
|
return "keycodes";
|
||||||
break;
|
|
||||||
case XkmTypesIndex:
|
case XkmTypesIndex:
|
||||||
strcpy(buf, "types");
|
return "types";
|
||||||
break;
|
|
||||||
case XkmSymbolsIndex:
|
case XkmSymbolsIndex:
|
||||||
strcpy(buf, "symbols");
|
return "symbols";
|
||||||
break;
|
|
||||||
case XkmCompatMapIndex:
|
case XkmCompatMapIndex:
|
||||||
strcpy(buf, "compat");
|
return "compat";
|
||||||
break;
|
|
||||||
case XkmGeometryFile:
|
case XkmGeometryFile:
|
||||||
case XkmGeometryIndex:
|
case XkmGeometryIndex:
|
||||||
strcpy(buf, "geometry");
|
return "geometry";
|
||||||
break;
|
|
||||||
case XkmRulesFile:
|
case XkmRulesFile:
|
||||||
strcpy(buf, "rules");
|
return "rules";
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
strcpy(buf, "");
|
return "";
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
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 *
|
FILE *
|
||||||
XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
|
XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
|
||||||
{
|
{
|
||||||
register int i;
|
int i, ret;
|
||||||
FILE *file = NULL;
|
FILE *file = NULL;
|
||||||
int nameLen, typeLen, pathLen;
|
char buf[PATH_MAX];
|
||||||
char buf[PATH_MAX], *typeDir;
|
const char *typeDir;
|
||||||
|
|
||||||
if (!XkbInitIncludePath())
|
if (!XkbInitIncludePath())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
typeDir = XkbDirectoryForInclude(type);
|
typeDir = XkbDirectoryForInclude(type);
|
||||||
nameLen = strlen(name);
|
|
||||||
typeLen = strlen(typeDir);
|
|
||||||
for (i = 0; i < nPathEntries; i++)
|
for (i = 0; i < nPathEntries; i++)
|
||||||
{
|
{
|
||||||
pathLen = strlen(includePath[i]);
|
if (includePath[i] == NULL || *includePath[i] == '\0')
|
||||||
if (typeLen < 1)
|
|
||||||
continue;
|
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],
|
ERROR("File name (%s/%s/%s) too long\n", includePath[i],
|
||||||
typeDir, name);
|
typeDir, name);
|
||||||
ACTION("Ignored\n");
|
ACTION("Ignored\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
snprintf(buf, sizeof(buf), "%s/%s/%s", includePath[i], typeDir, name);
|
|
||||||
file = fopen(buf, "r");
|
file = fopen(buf, "r");
|
||||||
if (file != NULL)
|
if (file == NULL) {
|
||||||
|
ERROR("Couldn't open file (%s/%s/%s): %s\n", includePath[i],
|
||||||
|
typeDir, name, strerror(-errno));
|
||||||
|
ACTION("Ignored\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((file != NULL) && (pathRtrn != NULL))
|
if ((file != NULL) && (pathRtrn != NULL))
|
||||||
{
|
*pathRtrn = strdup(buf);
|
||||||
*pathRtrn = (char *) calloc(strlen(buf) + 1, sizeof(char));
|
|
||||||
if (*pathRtrn != NULL)
|
|
||||||
strcpy(*pathRtrn, buf);
|
|
||||||
}
|
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include <X11/X.h>
|
#include <X11/X.h>
|
||||||
#include <X11/Xdefs.h>
|
#include <X11/Xdefs.h>
|
||||||
|
|
||||||
extern char *XkbDirectoryForInclude(unsigned /* type */
|
extern const char *XkbDirectoryForInclude(unsigned /* type */
|
||||||
);
|
);
|
||||||
|
|
||||||
extern FILE *XkbFindFileInPath(const char * /* name */ ,
|
extern FILE *XkbFindFileInPath(const char * /* name */ ,
|
||||||
|
@ -39,17 +39,6 @@ extern FILE *XkbFindFileInPath(const char * /* name */ ,
|
||||||
char ** /* pathRtrn */
|
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 */ ,
|
extern Bool XkbParseIncludeMap(char ** /* str_inout */ ,
|
||||||
char ** /* file_rtrn */ ,
|
char ** /* file_rtrn */ ,
|
||||||
char ** /* map_rtrn */ ,
|
char ** /* map_rtrn */ ,
|
||||||
|
@ -57,4 +46,6 @@ extern Bool XkbParseIncludeMap(char ** /* str_inout */ ,
|
||||||
char ** /* extra_data */
|
char ** /* extra_data */
|
||||||
);
|
);
|
||||||
|
|
||||||
|
extern void XkbFreeIncludePath(void);
|
||||||
|
|
||||||
#endif /* _XKBPATH_H_ */
|
#endif /* _XKBPATH_H_ */
|
||||||
|
|
|
@ -199,7 +199,6 @@ yyerror(const char *msg)
|
||||||
void setScanState(const char *file, int lineno)
|
void setScanState(const char *file, int lineno)
|
||||||
{
|
{
|
||||||
yylineno = 1;
|
yylineno = 1;
|
||||||
if (scanFile)
|
|
||||||
free(scanFile);
|
free(scanFile);
|
||||||
scanFile = strdup(file);
|
scanFile = strdup(file);
|
||||||
}
|
}
|
||||||
|
@ -230,20 +229,18 @@ XKBParseString(const char *string, XkbFile ** pRtrn)
|
||||||
int
|
int
|
||||||
XKBParseFile(FILE * file, XkbFile ** pRtrn)
|
XKBParseFile(FILE * file, XkbFile ** pRtrn)
|
||||||
{
|
{
|
||||||
if (file)
|
*pRtrn = NULL;
|
||||||
{
|
if (!file)
|
||||||
|
return 1;
|
||||||
|
|
||||||
yyin = file;
|
yyin = file;
|
||||||
rtrnValue = NULL;
|
rtrnValue = NULL;
|
||||||
if (yyparse() == 0)
|
if (yyparse() != 0)
|
||||||
{
|
return 0;
|
||||||
|
|
||||||
|
yylex_destroy();
|
||||||
*pRtrn = rtrnValue;
|
*pRtrn = rtrnValue;
|
||||||
CheckDefaultMap(rtrnValue);
|
CheckDefaultMap(rtrnValue);
|
||||||
rtrnValue = NULL;
|
rtrnValue = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
*pRtrn = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
*pRtrn = NULL;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ authorization from the authors.
|
||||||
#include "xkbcommon/xkbcommon.h"
|
#include "xkbcommon/xkbcommon.h"
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
XkbcFreeGeometry(struct xkb_geometry * geom, unsigned which, Bool freeMap);
|
XkbcFreeGeometry(struct xkb_desc * xkb);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
XkbcAllocGeomKeyAliases(struct xkb_geometry * geom, int nKeyAliases);
|
XkbcAllocGeomKeyAliases(struct xkb_geometry * geom, int nKeyAliases);
|
||||||
|
|
|
@ -70,6 +70,9 @@ XkbcNameMatchesPattern(char *name, char *ptrn);
|
||||||
extern char *
|
extern char *
|
||||||
XkbcAtomGetString(uint32_t atom);
|
XkbcAtomGetString(uint32_t atom);
|
||||||
|
|
||||||
|
extern void
|
||||||
|
XkbcFreeAllAtoms(void);
|
||||||
|
|
||||||
/***====================================================================***/
|
/***====================================================================***/
|
||||||
|
|
||||||
extern const char *
|
extern const char *
|
||||||
|
|
|
@ -156,6 +156,6 @@ extern Bool
|
||||||
XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
|
XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
XkbcRF_Free(XkbRF_RulesPtr rules, Bool freeRules);
|
XkbcRF_Free(XkbRF_RulesPtr rules);
|
||||||
|
|
||||||
#endif /* _XKBRULES_H_ */
|
#endif /* _XKBRULES_H_ */
|
||||||
|
|
Loading…
Reference in New Issue