*
********************************************************/
-#include <limits.h>
+/*
+ * Copyright © 2012 Intel Corporation
+ * Copyright © 2012 Ran Benita <ran234@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * Author: Daniel Stone <daniel@fooishbar.org>
+ * Ran Benita <ran234@gmail.com>
+ */
#include "xkbcomp-priv.h"
-#include "parseutils.h"
+#include "text.h"
+#include "expr.h"
#include "action.h"
#include "vmod.h"
+#include "keycodes.h"
+#include "include.h"
+#include "keysym.h"
+
+enum key_repeat {
+ KEY_REPEAT_UNDEFINED = 0,
+ KEY_REPEAT_YES = 1,
+ KEY_REPEAT_NO = 2,
+};
-/***====================================================================***/
+enum group_field {
+ GROUP_FIELD_SYMS = (1 << 0),
+ GROUP_FIELD_ACTS = (1 << 1),
+ GROUP_FIELD_TYPE = (1 << 2),
+};
+
+enum key_field {
+ KEY_FIELD_REPEAT = (1 << 0),
+ KEY_FIELD_TYPE_DFLT = (1 << 1),
+ KEY_FIELD_GROUPINFO = (1 << 2),
+ KEY_FIELD_VMODMAP = (1 << 3),
+};
+
+typedef struct {
+ unsigned int num_syms;
+ unsigned int sym_index;
+ union xkb_action act;
+} LevelInfo;
-/* Needed to work with the typechecker. */
typedef darray(xkb_keysym_t) darray_xkb_keysym_t;
-typedef darray(union xkb_action) darray_xkb_action;
-
-#define RepeatYes 1
-#define RepeatNo 0
-#define RepeatUndefined ~((unsigned) 0)
-
-#define _Key_Syms (1 << 0)
-#define _Key_Acts (1 << 1)
-#define _Key_Repeat (1 << 2)
-#define _Key_Behavior (1 << 3)
-#define _Key_Type_Dflt (1 << 4)
-#define _Key_Types (1 << 5)
-#define _Key_GroupInfo (1 << 6)
-#define _Key_VModMap (1 << 7)
-
-static inline const char *
-longText(unsigned long val)
-{
- char buf[4];
- LongToKeyName(val, buf);
- return XkbcKeyNameText(buf);
-}
+typedef struct {
+ enum group_field defined;
+ darray_xkb_keysym_t syms;
+ darray(LevelInfo) levels;
+ xkb_atom_t type;
+} GroupInfo;
typedef struct _KeyInfo {
- unsigned short defined;
+ enum key_field defined;
unsigned file_id;
enum merge_mode merge;
unsigned long name; /* the 4 chars of the key name, as long */
- unsigned char typesDefined;
- unsigned char symsDefined;
- unsigned char actsDefined;
- unsigned int numLevels[XkbNumKbdGroups];
- /* syms[group] -> Single array for all the keysyms in the group. */
- darray_xkb_keysym_t syms[XkbNumKbdGroups];
- /*
- * symsMapIndex[group][level] -> The index from which the syms for
- * the level begin in the syms[group] array. Remember each keycode
- * can have multiple keysyms in each level (that is, each key press
- * can result in multiple keysyms).
- */
- darray(int) symsMapIndex[XkbNumKbdGroups];
- /*
- * symsMapNumEntries[group][level] -> How many syms are in
- * syms[group][symsMapIndex[group][level]].
- */
- darray(size_t) symsMapNumEntries[XkbNumKbdGroups];
+ darray(GroupInfo) groups;
- darray_xkb_action acts[XkbNumKbdGroups];
-
- xkb_atom_t types[XkbNumKbdGroups];
- unsigned repeat;
- struct xkb_behavior behavior;
- unsigned short vmodmap;
+ enum key_repeat repeat;
+ xkb_mod_mask_t vmodmap;
xkb_atom_t dfltType;
- uint8_t out_of_range_group_action;
- xkb_group_index_t out_of_range_group_number;
+ enum xkb_range_exceed_type out_of_range_group_action;
+ xkb_layout_index_t out_of_range_group_number;
} KeyInfo;
-/**
- * Init the given key info to sane values.
- */
static void
-InitKeyInfo(KeyInfo *keyi, unsigned file_id)
+InitGroupInfo(GroupInfo *groupi)
{
- xkb_group_index_t i;
- static const char dflt[4] = "*";
-
- keyi->defined = 0;
- keyi->file_id = file_id;
- keyi->merge = MERGE_OVERRIDE;
- keyi->name = KeyNameToLong(dflt);
- keyi->typesDefined = keyi->symsDefined = keyi->actsDefined = 0;
-
- for (i = 0; i < XkbNumKbdGroups; i++) {
- keyi->numLevels[i] = 0;
- keyi->types[i] = XKB_ATOM_NONE;
- darray_init(keyi->syms[i]);
- darray_init(keyi->symsMapIndex[i]);
- darray_init(keyi->symsMapNumEntries[i]);
- darray_init(keyi->acts[i]);
- }
-
- keyi->dfltType = XKB_ATOM_NONE;
- keyi->behavior.type = XkbKB_Default;
- keyi->behavior.data = 0;
- keyi->vmodmap = 0;
- keyi->repeat = RepeatUndefined;
- keyi->out_of_range_group_action = 0;
- keyi->out_of_range_group_number = 0;
+ memset(groupi, 0, sizeof(*groupi));
}
static void
-FreeKeyInfo(KeyInfo *keyi)
+ClearGroupInfo(GroupInfo *groupi)
{
- xkb_group_index_t i;
-
- for (i = 0; i < XkbNumKbdGroups; i++) {
- darray_free(keyi->syms[i]);
- darray_free(keyi->symsMapIndex[i]);
- darray_free(keyi->symsMapNumEntries[i]);
- darray_free(keyi->acts[i]);
- }
+ darray_free(groupi->syms);
+ darray_free(groupi->levels);
}
-/**
- * Copy old into new, optionally reset old to 0.
- * If old is reset, new simply re-uses old's memory. Otherwise, the memory is
- * newly allocated and new points to the new memory areas.
- */
-static bool
-CopyKeyInfo(KeyInfo * old, KeyInfo * new, bool clearOld)
+static void
+InitKeyInfo(KeyInfo *keyi, unsigned file_id)
{
- xkb_group_index_t i;
-
- *new = *old;
+ static const char dflt_key_name[XKB_KEY_NAME_LENGTH] = "*";
- if (clearOld) {
- for (i = 0; i < XkbNumKbdGroups; i++) {
- old->numLevels[i] = 0;
- darray_init(old->symsMapIndex[i]);
- darray_init(old->symsMapNumEntries[i]);
- darray_init(old->syms[i]);
- darray_init(old->acts[i]);
- }
- }
- else {
- for (i = 0; i < XkbNumKbdGroups; i++) {
- darray_copy(new->syms[i], old->syms[i]);
- darray_copy(new->symsMapIndex[i], old->symsMapIndex[i]);
- darray_copy(new->symsMapNumEntries[i], old->symsMapNumEntries[i]);
- darray_copy(new->acts[i], old->acts[i]);
- }
- }
+ memset(keyi, 0, sizeof(*keyi));
+ keyi->file_id = file_id;
+ keyi->merge = MERGE_OVERRIDE;
+ keyi->name = KeyNameToLong(dflt_key_name);
+ keyi->out_of_range_group_action = RANGE_WRAP;
+}
- return true;
+static void
+ClearKeyInfo(KeyInfo *keyi)
+{
+ GroupInfo *groupi;
+ darray_foreach(groupi, keyi->groups)
+ ClearGroupInfo(groupi);
+ darray_free(keyi->groups);
}
/***====================================================================***/
typedef struct _ModMapEntry {
- struct list entry;
enum merge_mode merge;
bool haveSymbol;
int modifier;
int errorCount;
unsigned file_id;
enum merge_mode merge;
- xkb_group_index_t explicit_group;
+ xkb_layout_index_t explicit_group;
darray(KeyInfo) keys;
KeyInfo dflt;
VModInfo vmods;
- ActionInfo *action;
- xkb_atom_t groupNames[XkbNumKbdGroups];
-
- struct list modMaps;
+ ActionsInfo *actions;
+ xkb_atom_t group_names[XKB_NUM_GROUPS];
+ darray(ModMapEntry) modMaps;
struct xkb_keymap *keymap;
} SymbolsInfo;
static void
-InitSymbolsInfo(SymbolsInfo * info, struct xkb_keymap *keymap,
- unsigned file_id)
+InitSymbolsInfo(SymbolsInfo *info, struct xkb_keymap *keymap,
+ unsigned file_id, ActionsInfo *actions)
{
- xkb_group_index_t i;
-
- info->name = NULL;
- info->explicit_group = 0;
- info->errorCount = 0;
+ memset(info, 0, sizeof(*info));
+ info->keymap = keymap;
info->file_id = file_id;
info->merge = MERGE_OVERRIDE;
- darray_init(info->keys);
- darray_growalloc(info->keys, 110);
- list_init(&info->modMaps);
- for (i = 0; i < XkbNumKbdGroups; i++)
- info->groupNames[i] = XKB_ATOM_NONE;
InitKeyInfo(&info->dflt, file_id);
InitVModInfo(&info->vmods, keymap);
- info->action = NULL;
- info->keymap = keymap;
+ info->actions = actions;
}
static void
-FreeSymbolsInfo(SymbolsInfo * info)
+ClearSymbolsInfo(SymbolsInfo * info)
{
KeyInfo *keyi;
- ModMapEntry *mm, *next;
-
free(info->name);
- darray_foreach(keyi, info->keys) {
- FreeKeyInfo(keyi);
- }
+ darray_foreach(keyi, info->keys)
+ ClearKeyInfo(keyi);
darray_free(info->keys);
- list_foreach_safe(mm, next, &info->modMaps, entry)
- free(mm);
- memset(info, 0, sizeof(SymbolsInfo));
+ darray_free(info->modMaps);
+ ClearKeyInfo(&info->dflt);
}
static bool
-ResizeKeyGroup(KeyInfo *keyi, xkb_group_index_t group, unsigned int numLevels,
- unsigned sizeSyms, bool forceActions)
+MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
+ bool report, xkb_layout_index_t group, unsigned long key_name)
{
- int i;
-
- if (darray_size(keyi->syms[group]) < sizeSyms)
- darray_resize0(keyi->syms[group], sizeSyms);
-
- if (darray_empty(keyi->symsMapIndex[group]) ||
- keyi->numLevels[group] < numLevels) {
- darray_resize(keyi->symsMapIndex[group], numLevels);
- for (i = keyi->numLevels[group]; i < numLevels; i++)
- darray_item(keyi->symsMapIndex[group], i) = -1;
- }
-
- if (darray_empty(keyi->symsMapNumEntries[group]) ||
- keyi->numLevels[group] < numLevels)
- darray_resize0(keyi->symsMapNumEntries[group], numLevels);
-
- if ((forceActions && (keyi->numLevels[group] < numLevels ||
- darray_empty(keyi->acts[group]))) ||
- (keyi->numLevels[group] < numLevels && !darray_empty(keyi->acts[group])))
- darray_resize0(keyi->acts[group], numLevels);
-
- if (keyi->numLevels[group] < numLevels)
- keyi->numLevels[group] = numLevels;
-
- return true;
-}
+ xkb_level_index_t i, numLevels;
+ enum { INTO = (1 << 0), FROM = (1 << 1) } using;
-enum key_group_selector {
- NONE = 0,
- FROM = (1 << 0),
- TO = (1 << 1),
-};
-
-static bool
-MergeKeyGroups(SymbolsInfo * info,
- KeyInfo * into, KeyInfo * from, xkb_group_index_t group)
-{
- darray_xkb_keysym_t resultSyms;
- enum key_group_selector using = NONE;
- darray_xkb_action resultActs;
- unsigned int resultWidth;
- unsigned int resultSize = 0;
- int cur_idx = 0;
- int i;
- bool report, clobber;
- int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
+ /* First find the type of the merged group. */
+ if (into->type != from->type) {
+ if (from->type == XKB_ATOM_NONE) {
+ }
+ else if (into->type == XKB_ATOM_NONE) {
+ into->type = from->type;
+ }
+ else {
+ xkb_atom_t use = (clobber ? from->type : into->type);
+ xkb_atom_t ignore = (clobber ? into->type : from->type);
- clobber = (from->merge != MERGE_AUGMENT);
+ if (report)
+ log_warn(info->keymap->ctx,
+ "Multiple definitions for group %d type of key %s; "
+ "Using %s, ignoring %s\n",
+ group + 1, LongKeyNameText(key_name),
+ xkb_atom_text(info->keymap->ctx, use),
+ xkb_atom_text(info->keymap->ctx, ignore));
- report = (verbosity > 9) ||
- (into->file_id == from->file_id && verbosity > 0);
+ into->type = use;
+ }
+ }
+ into->defined |= (from->defined & GROUP_FIELD_TYPE);
- darray_init(resultSyms);
+ /* Now look at the levels. */
- if (into->numLevels[group] >= from->numLevels[group]) {
- resultActs = into->acts[group];
- resultWidth = into->numLevels[group];
+ if (darray_empty(from->levels)) {
+ InitGroupInfo(from);
+ return true;
}
- else {
- resultActs = from->acts[group];
- resultWidth = from->numLevels[group];
- darray_resize(into->symsMapIndex[group],
- from->numLevels[group]);
- darray_resize0(into->symsMapNumEntries[group],
- from->numLevels[group]);
- for (i = into->numLevels[group]; i < from->numLevels[group]; i++)
- darray_item(into->symsMapIndex[group], i) = -1;
+ if (darray_empty(into->levels)) {
+ from->type = into->type;
+ *into = *from;
+ InitGroupInfo(from);
+ return true;
}
- if (darray_empty(resultActs) && (!darray_empty(into->acts[group]) ||
- !darray_empty(from->acts[group]))) {
- darray_resize0(resultActs, resultWidth);
- for (i = 0; i < resultWidth; i++) {
- union xkb_action *fromAct = NULL, *toAct = NULL;
+ /* First we merge the actions and ensure @into has all the levels. */
+ numLevels = MAX(darray_size(into->levels), darray_size(from->levels));
+ for (i = 0; i < numLevels; i++) {
+ union xkb_action *intoAct, *fromAct;
- if (!darray_empty(from->acts[group]))
- fromAct = &darray_item(from->acts[group], i);
-
- if (!darray_empty(into->acts[group]))
- toAct = &darray_item(into->acts[group], i);
+ if (i >= darray_size(from->levels))
+ continue;
- if (((fromAct == NULL) || (fromAct->type == XkbSA_NoAction))
- && (toAct != NULL)) {
- darray_item(resultActs, i) = *toAct;
- }
- else if (((toAct == NULL) || (toAct->type == XkbSA_NoAction))
- && (fromAct != NULL)) {
- darray_item(resultActs, i) = *fromAct;
- }
- else {
- union xkb_action *use, *ignore;
- if (clobber) {
- use = fromAct;
- ignore = toAct;
- }
- else {
- use = toAct;
- ignore = fromAct;
- }
- if (report)
- log_warn(info->keymap->ctx,
- "Multiple actions for level %d/group %u on key %s; "
- "Using %s, ignoring %s\n",
- i + 1, group + 1, longText(into->name),
- XkbcActionTypeText(use->type),
- XkbcActionTypeText(ignore->type));
- if (use)
- darray_item(resultActs, i) = *use;
- }
+ if (i >= darray_size(into->levels)) {
+ darray_append(into->levels, darray_item(from->levels, i));
+ darray_item(into->levels, i).num_syms = 0;
+ darray_item(into->levels, i).sym_index = 0;
+ continue;
}
- }
-
- for (i = 0; i < resultWidth; i++) {
- unsigned int fromSize = 0;
- unsigned toSize = 0;
-
- if (!darray_empty(from->symsMapNumEntries[group]) &&
- i < from->numLevels[group])
- fromSize = darray_item(from->symsMapNumEntries[group], i);
- if (!darray_empty(into->symsMapNumEntries[group]) &&
- i < into->numLevels[group])
- toSize = darray_item(into->symsMapNumEntries[group], i);
+ intoAct = &darray_item(into->levels, i).act;
+ fromAct = &darray_item(from->levels, i).act;
- if (fromSize == 0) {
- resultSize += toSize;
- using |= TO;
+ if (fromAct->type == ACTION_TYPE_NONE) {
}
- else if (toSize == 0 || clobber) {
- resultSize += fromSize;
- using |= FROM;
+ else if (intoAct->type == ACTION_TYPE_NONE) {
+ *intoAct = *fromAct;
}
else {
- resultSize += toSize;
- using |= TO;
- }
- }
+ union xkb_action *use = (clobber ? fromAct : intoAct);
+ union xkb_action *ignore = (clobber ? intoAct : fromAct);
- if (resultSize == 0)
- goto out;
+ if (report)
+ log_warn(info->keymap->ctx,
+ "Multiple actions for level %d/group %u on key %s; "
+ "Using %s, ignoring %s\n",
+ i + 1, group + 1, LongKeyNameText(key_name),
+ ActionTypeText(use->type),
+ ActionTypeText(ignore->type));
- if (using == FROM) {
- resultSyms = from->syms[group];
- darray_free(into->symsMapNumEntries[group]);
- darray_free(into->symsMapIndex[group]);
- into->symsMapNumEntries[group] = from->symsMapNumEntries[group];
- into->symsMapIndex[group] = from->symsMapIndex[group];
- darray_init(from->symsMapNumEntries[group]);
- darray_init(from->symsMapIndex[group]);
- goto out;
- }
- else if (using == TO) {
- resultSyms = into->syms[group];
- goto out;
+ *intoAct = *use;
+ }
}
+ into->defined |= (from->defined & GROUP_FIELD_ACTS);
- darray_resize0(resultSyms, resultSize);
+ /* Then merge the keysyms. */
- for (i = 0; i < resultWidth; i++) {
- enum key_group_selector use = NONE;
- unsigned int fromSize = 0;
- unsigned int toSize = 0;
+ /*
+ * We want to avoid copying and allocating if not necessary. So
+ * here we do a pre-scan of the levels to check if we'll only use
+ * @into's or @from's keysyms, and if so we'll just assign them.
+ * However if one level uses @into's and another uses @from's, we
+ * will need to construct a new syms array.
+ */
+ using = 0;
+ for (i = 0; i < numLevels; i++) {
+ unsigned int intoSize, fromSize;
- if (i < from->numLevels[group])
- fromSize = darray_item(from->symsMapNumEntries[group], i);
+ intoSize = darray_item(into->levels, i).num_syms;
+ if (i < darray_size(from->levels))
+ fromSize = darray_item(from->levels, i).num_syms;
+ else
+ fromSize = 0;
- if (i < into->numLevels[group])
- toSize = darray_item(into->symsMapNumEntries[group], i);
+ if (intoSize == 0 && fromSize == 0)
+ using |= 0;
+ else if (intoSize == 0)
+ using |= FROM;
+ else if (fromSize == 0)
+ using |= INTO;
+ else
+ using |= (clobber ? FROM : INTO);
+ }
- if (fromSize == 0 && toSize == 0) {
- darray_item(into->symsMapIndex[group], i) = -1;
- darray_item(into->symsMapNumEntries[group], i) = 0;
- continue;
+ if (using == 0 || using == INTO) {
+ }
+ else if (using == FROM) {
+ darray_free(into->syms);
+ into->syms = from->syms;
+ darray_init(from->syms);
+ for (i = 0; i < darray_size(from->levels); i++) {
+ darray_item(into->levels, i).num_syms =
+ darray_item(from->levels, i).num_syms;
+ darray_item(into->levels, i).sym_index =
+ darray_item(from->levels, i).sym_index;
}
+ }
+ else {
+ darray_xkb_keysym_t syms = darray_new();
- if (fromSize == 0)
- use = TO;
- else if (toSize == 0 || clobber)
- use = FROM;
- else
- use = TO;
-
- if (toSize && fromSize && report) {
- log_info(info->keymap->ctx,
- "Multiple symbols for group %u, level %d on key %s; "
- "Using %s, ignoring %s\n",
- group + 1, i + 1, longText(into->name),
- (use == FROM ? "from" : "to"),
- (use == FROM ? "to" : "from"));
- }
+ for (i = 0; i < numLevels; i++) {
+ unsigned int intoSize, fromSize;
- if (use == FROM) {
- memcpy(darray_mem(resultSyms, cur_idx),
- darray_mem(from->syms[group],
- darray_item(from->symsMapIndex[group], i)),
- darray_item(from->symsMapNumEntries[group],
- i) * sizeof(xkb_keysym_t));
- darray_item(into->symsMapIndex[group], i) = cur_idx;
- darray_item(into->symsMapNumEntries[group], i) =
- darray_item(from->symsMapNumEntries[group], i);
- }
- else {
- memcpy(darray_mem(resultSyms, cur_idx),
- darray_mem(into->syms[group],
- darray_item(into->symsMapIndex[group], i)),
- darray_item(into->symsMapNumEntries[group],
- i) * sizeof(xkb_keysym_t));
- darray_item(into->symsMapIndex[group], i) = cur_idx;
+ intoSize = darray_item(into->levels, i).num_syms;
+ if (i < darray_size(from->levels))
+ fromSize = darray_item(from->levels, i).num_syms;
+ else
+ fromSize = 0;
+
+ /* Empty level. */
+ if (intoSize == 0 && fromSize == 0)
+ continue;
+
+ if (intoSize != 0 && fromSize != 0 && report)
+ log_info(info->keymap->ctx,
+ "Multiple symbols for group %u, level %d on key %s; "
+ "Using %s, ignoring %s\n",
+ group + 1, i + 1, LongKeyNameText(key_name),
+ (clobber ? "from" : "to"),
+ (clobber ? "to" : "from"));
+
+ if (intoSize == 0 || (fromSize != 0 && clobber)) {
+ unsigned sym_index = darray_item(from->levels, i).sym_index;
+ darray_item(into->levels, i).sym_index = darray_size(syms);
+ darray_item(into->levels, i).num_syms = fromSize;
+ darray_append_items(syms, &darray_item(from->syms, sym_index),
+ fromSize);
+ }
+ else
+ {
+ unsigned sym_index = darray_item(into->levels, i).sym_index;
+ darray_item(into->levels, i).sym_index = darray_size(syms);
+ darray_item(into->levels, i).num_syms = intoSize;
+ darray_append_items(syms, &darray_item(into->syms, sym_index),
+ intoSize);
+ }
}
- cur_idx += darray_item(into->symsMapNumEntries[group], i);
- }
-
-out:
- if (!darray_same(resultActs, into->acts[group]))
- darray_free(into->acts[group]);
- if (!darray_same(resultActs, from->acts[group]))
- darray_free(from->acts[group]);
- into->numLevels[group] = resultWidth;
- if (!darray_same(resultSyms, into->syms[group]))
- darray_free(into->syms[group]);
- into->syms[group] = resultSyms;
- if (!darray_same(resultSyms, from->syms[group]))
- darray_free(from->syms[group]);
- darray_init(from->syms[group]);
- darray_free(from->symsMapIndex[group]);
- darray_free(from->symsMapNumEntries[group]);
- into->acts[group] = resultActs;
- darray_init(from->acts[group]);
- if (!darray_empty(into->syms[group]))
- into->symsDefined |= (1 << group);
- from->symsDefined &= ~(1 << group);
- into->actsDefined |= (1 << group);
- from->actsDefined &= ~(1 << group);
+ darray_free(into->syms);
+ into->syms = syms;
+ }
+ into->defined |= (from->defined & GROUP_FIELD_SYMS);
return true;
}
static bool
-UseNewKeyField(unsigned field, KeyInfo *old, KeyInfo *new, int verbosity,
- unsigned *collide)
+UseNewKeyField(enum key_field field, enum key_field old, enum key_field new,
+ bool clobber, bool report, enum key_field *collide)
{
- if (!(old->defined & field))
- return true;
+ if (!(old & field))
+ return (new & field);
- if (new->defined & field) {
- if ((old->file_id == new->file_id && verbosity > 0) || verbosity > 9)
+ if (new & field) {
+ if (report)
*collide |= field;
- if (new->merge != MERGE_AUGMENT)
+ if (clobber)
return true;
}
static bool
MergeKeys(SymbolsInfo *info, KeyInfo *into, KeyInfo *from)
{
- xkb_group_index_t i;
- unsigned collide = 0;
- bool report;
- int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
+ xkb_layout_index_t i;
+ xkb_layout_index_t groups_in_both;
+ enum key_field collide = 0;
+ bool clobber, report;
+ int verbosity = xkb_context_get_log_verbosity(info->keymap->ctx);
if (from->merge == MERGE_REPLACE) {
- for (i = 0; i < XkbNumKbdGroups; i++) {
- if (into->numLevels[i] != 0) {
- darray_free(into->syms[i]);
- darray_free(into->acts[i]);
- }
- }
+ ClearKeyInfo(into);
*into = *from;
- memset(from, 0, sizeof(KeyInfo));
+ InitKeyInfo(from, info->file_id);
return true;
}
+ clobber = (from->merge != MERGE_AUGMENT);
report = (verbosity > 9 ||
(into->file_id == from->file_id && verbosity > 0));
- for (i = 0; i < XkbNumKbdGroups; i++) {
- if (from->numLevels[i] > 0) {
- if (into->numLevels[i] == 0) {
- into->numLevels[i] = from->numLevels[i];
- into->syms[i] = from->syms[i];
- into->symsMapIndex[i] = from->symsMapIndex[i];
- into->symsMapNumEntries[i] = from->symsMapNumEntries[i];
- into->acts[i] = from->acts[i];
- into->symsDefined |= (1 << i);
- darray_init(from->syms[i]);
- darray_init(from->symsMapIndex[i]);
- darray_init(from->symsMapNumEntries[i]);
- darray_init(from->acts[i]);
- from->numLevels[i] = 0;
- from->symsDefined &= ~(1 << i);
- if (!darray_empty(into->syms[i]))
- into->defined |= _Key_Syms;
- if (!darray_empty(into->acts[i]))
- into->defined |= _Key_Acts;
- }
- else {
- if (report) {
- if (!darray_empty(into->syms[i]))
- collide |= _Key_Syms;
- if (!darray_empty(into->acts[i]))
- collide |= _Key_Acts;
- }
- MergeKeyGroups(info, into, from, (unsigned) i);
- }
- }
- if (from->types[i] != XKB_ATOM_NONE) {
- if ((into->types[i] != XKB_ATOM_NONE) && report &&
- (into->types[i] != from->types[i])) {
- xkb_atom_t use, ignore;
- collide |= _Key_Types;
- if (from->merge != MERGE_AUGMENT) {
- use = from->types[i];
- ignore = into->types[i];
- }
- else {
- use = into->types[i];
- ignore = from->types[i];
- }
-
- log_warn(info->keymap->ctx,
- "Multiple definitions for group %d type of key %s; "
- "Using %s, ignoring %s\n",
- i, longText(into->name),
- xkb_atom_text(info->keymap->ctx, use),
- xkb_atom_text(info->keymap->ctx, ignore));
- }
-
- if (from->merge != MERGE_AUGMENT ||
- into->types[i] == XKB_ATOM_NONE) {
- into->types[i] = from->types[i];
- }
- }
- }
-
- if (UseNewKeyField(_Key_Behavior, into, from, verbosity, &collide)) {
- into->behavior = from->behavior;
- into->defined |= _Key_Behavior;
- }
- if (UseNewKeyField(_Key_VModMap, into, from, verbosity, &collide)) {
+ groups_in_both = MIN(darray_size(into->groups),
+ darray_size(from->groups));
+ for (i = 0; i < groups_in_both; i++)
+ MergeGroups(info,
+ &darray_item(into->groups, i),
+ &darray_item(from->groups, i),
+ clobber, report, i, into->name);
+ /* If @from has extra groups, just move them to @into. */
+ for (i = groups_in_both; i < darray_size(from->groups); i++) {
+ darray_append(into->groups, darray_item(from->groups, i));
+ InitGroupInfo(&darray_item(from->groups, i));
+ }
+
+ if (UseNewKeyField(KEY_FIELD_VMODMAP, into->defined, from->defined,
+ clobber, report, &collide)) {
into->vmodmap = from->vmodmap;
- into->defined |= _Key_VModMap;
+ into->defined |= KEY_FIELD_VMODMAP;
}
- if (UseNewKeyField(_Key_Repeat, into, from, verbosity, &collide)) {
+ if (UseNewKeyField(KEY_FIELD_REPEAT, into->defined, from->defined,
+ clobber, report, &collide)) {
into->repeat = from->repeat;
- into->defined |= _Key_Repeat;
+ into->defined |= KEY_FIELD_REPEAT;
}
- if (UseNewKeyField(_Key_Type_Dflt, into, from, verbosity, &collide)) {
+ if (UseNewKeyField(KEY_FIELD_TYPE_DFLT, into->defined, from->defined,
+ clobber, report, &collide)) {
into->dfltType = from->dfltType;
- into->defined |= _Key_Type_Dflt;
+ into->defined |= KEY_FIELD_TYPE_DFLT;
}
- if (UseNewKeyField(_Key_GroupInfo, into, from, verbosity, &collide)) {
+ if (UseNewKeyField(KEY_FIELD_GROUPINFO, into->defined, from->defined,
+ clobber, report, &collide)) {
into->out_of_range_group_action = from->out_of_range_group_action;
into->out_of_range_group_number = from->out_of_range_group_number;
- into->defined |= _Key_GroupInfo;
+ into->defined |= KEY_FIELD_GROUPINFO;
}
if (collide)
log_warn(info->keymap->ctx,
"Symbol map for key %s redefined; "
"Using %s definition for conflicting fields\n",
- longText(into->name),
- (from->merge == MERGE_AUGMENT ? "first" : "last"));
+ LongKeyNameText(into->name),
+ (clobber ? "first" : "last"));
+ ClearKeyInfo(from);
+ InitKeyInfo(from, info->file_id);
return true;
}
AddKeySymbols(SymbolsInfo *info, KeyInfo *keyi)
{
unsigned long real_name;
- KeyInfo *iter, *new;
+ KeyInfo *iter;
+
+ /*
+ * Don't keep aliases in the keys array; this guarantees that
+ * searching for keys to merge with by straight comparison (see the
+ * following loop) is enough, and we won't get multiple KeyInfo's
+ * for the same key because of aliases.
+ */
+ if (FindKeyNameForAlias(info->keymap, keyi->name, &real_name))
+ keyi->name = real_name;
darray_foreach(iter, info->keys)
if (iter->name == keyi->name)
return MergeKeys(info, iter, keyi);
- if (FindKeyNameForAlias(info->keymap, keyi->name, &real_name))
- darray_foreach(iter, info->keys)
- if (iter->name == real_name)
- return MergeKeys(info, iter, keyi);
-
- darray_resize0(info->keys, darray_size(info->keys) + 1);
- new = &darray_item(info->keys, darray_size(info->keys) - 1);
- return CopyKeyInfo(keyi, new, true);
+ darray_append(info->keys, *keyi);
+ InitKeyInfo(keyi, info->file_id);
+ return true;
}
static bool
bool clobber;
clobber = (new->merge != MERGE_AUGMENT);
- list_foreach(mm, &info->modMaps, entry) {
+ darray_foreach(mm, info->modMaps) {
if (new->haveSymbol && mm->haveSymbol
&& (new->u.keySym == mm->u.keySym)) {
unsigned use, ignore;
log_err(info->keymap->ctx,
"%s added to symbol map for multiple modifiers; "
"Using %s, ignoring %s.\n",
- XkbcKeysymText(new->u.keySym),
- XkbcModIndexText(use),
- XkbcModIndexText(ignore));
+ KeysymText(new->u.keySym), ModIndexText(use),
+ ModIndexText(ignore));
mm->modifier = use;
}
return true;
log_err(info->keymap->ctx,
"Key %s added to map for multiple modifiers; "
"Using %s, ignoring %s.\n",
- longText(new->u.keyName),
- XkbcModIndexText(use),
- XkbcModIndexText(ignore));
+ LongKeyNameText(new->u.keyName), ModIndexText(use),
+ ModIndexText(ignore));
mm->modifier = use;
}
return true;
}
}
- mm = malloc(sizeof(*mm));
- if (!mm) {
- log_wsgo(info->keymap->ctx,
- "Could not allocate modifier map entry; "
- "Modifier map for %s will be incomplete\n",
- XkbcModIndexText(new->modifier));
- return false;
- }
-
- *mm = *new;
- list_add(&mm->entry, &info->modMaps);
+ darray_append(info->modMaps, *new);
return true;
}
{
unsigned int i;
KeyInfo *keyi;
- ModMapEntry *mm, *next;
+ ModMapEntry *mm;
if (from->errorCount > 0) {
into->errorCount += from->errorCount;
into->name = from->name;
from->name = NULL;
}
- for (i = 0; i < XkbNumKbdGroups; i++) {
- if (from->groupNames[i] != XKB_ATOM_NONE) {
+ for (i = 0; i < XKB_NUM_GROUPS; i++) {
+ if (from->group_names[i] != XKB_ATOM_NONE) {
if ((merge != MERGE_AUGMENT) ||
- (into->groupNames[i] == XKB_ATOM_NONE))
- into->groupNames[i] = from->groupNames[i];
+ (into->group_names[i] == XKB_ATOM_NONE))
+ into->group_names[i] = from->group_names[i];
}
}
darray_foreach(keyi, from->keys) {
- if (merge != MERGE_DEFAULT)
- keyi->merge = merge;
-
+ merge = (merge == MERGE_DEFAULT ? keyi->merge : merge);
if (!AddKeySymbols(into, keyi))
into->errorCount++;
}
- list_foreach_safe(mm, next, &from->modMaps, entry) {
- if (merge != MERGE_DEFAULT)
- mm->merge = merge;
+ darray_foreach(mm, from->modMaps) {
+ mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge);
if (!AddModMapEntry(into, mm))
into->errorCount++;
- free(mm);
}
- list_init(&from->modMaps);
}
static void
XkbFile *rtrn;
SymbolsInfo included, next_incl;
- InitSymbolsInfo(&included, info->keymap, info->file_id);
+ InitSymbolsInfo(&included, info->keymap, info->file_id, info->actions);
if (stmt->stmt) {
free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
- for (; stmt; stmt = stmt->next) {
+ for (; stmt; stmt = stmt->next_incl) {
if (!ProcessIncludeFile(info->keymap->ctx, stmt, FILE_TYPE_SYMBOLS,
&rtrn, &merge)) {
info->errorCount += 10;
- FreeSymbolsInfo(&included);
+ ClearSymbolsInfo(&included);
return false;
}
- InitSymbolsInfo(&next_incl, info->keymap, rtrn->id);
+ InitSymbolsInfo(&next_incl, info->keymap, rtrn->id, info->actions);
next_incl.merge = next_incl.dflt.merge = MERGE_OVERRIDE;
- if (stmt->modifier)
+ if (stmt->modifier) {
next_incl.explicit_group = atoi(stmt->modifier) - 1;
- else
+ if (next_incl.explicit_group >= XKB_NUM_GROUPS) {
+ log_err(info->keymap->ctx,
+ "Cannot set explicit group to %d - must be between 1..%d; "
+ "Ignoring group number\n",
+ next_incl.explicit_group + 1, XKB_NUM_GROUPS);
+ next_incl.explicit_group = info->explicit_group;
+ }
+ }
+ else {
next_incl.explicit_group = info->explicit_group;
+ }
HandleSymbolsFile(&next_incl, rtrn, MERGE_OVERRIDE);
MergeIncludedSymbols(&included, &next_incl, merge);
- FreeSymbolsInfo(&next_incl);
- FreeXKBFile(rtrn);
+ ClearSymbolsInfo(&next_incl);
+ FreeXkbFile(rtrn);
}
MergeIncludedSymbols(info, &included, merge);
- FreeSymbolsInfo(&included);
+ ClearSymbolsInfo(&included);
return (info->errorCount == 0);
}
static bool
GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
- unsigned what, xkb_group_index_t *ndx_rtrn)
+ unsigned what, xkb_layout_index_t *ndx_rtrn)
{
- const char *name;
- ExprResult tmp;
-
- if (what == SYMBOLS)
- name = "symbols";
- else
- name = "actions";
+ const char *name = (what == SYMBOLS ? "symbols" : "actions");
if (arrayNdx == NULL) {
- xkb_group_index_t i;
- unsigned defined;
- if (what == SYMBOLS)
- defined = keyi->symsDefined;
- else
- defined = keyi->actsDefined;
+ xkb_layout_index_t i;
+ GroupInfo *groupi;
+ enum group_field field = (what == SYMBOLS ?
+ GROUP_FIELD_SYMS : GROUP_FIELD_ACTS);
- for (i = 0; i < XkbNumKbdGroups; i++) {
- if ((defined & (1 << i)) == 0) {
+ darray_enumerate(i, groupi, keyi->groups) {
+ if (!(groupi->defined & field)) {
*ndx_rtrn = i;
return true;
}
}
- log_err(info->keymap->ctx,
- "Too many groups of %s for key %s (max %u); "
- "Ignoring %s defined for extra groups\n",
- name, longText(keyi->name), XkbNumKbdGroups + 1, name);
- return false;
+
+ if (i >= XKB_NUM_GROUPS) {
+ log_err(info->keymap->ctx,
+ "Too many groups of %s for key %s (max %u); "
+ "Ignoring %s defined for extra groups\n",
+ name, LongKeyNameText(keyi->name), XKB_NUM_GROUPS + 1, name);
+ return false;
+ }
+
+ darray_resize0(keyi->groups, darray_size(keyi->groups) + 1);
+ *ndx_rtrn = darray_size(keyi->groups) - 1;
+ return true;
}
- if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, &tmp)) {
+
+ if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, ndx_rtrn)) {
log_err(info->keymap->ctx,
"Illegal group index for %s of key %s\n"
"Definition with non-integer array index ignored\n",
- name, longText(keyi->name));
+ name, LongKeyNameText(keyi->name));
return false;
}
- *ndx_rtrn = tmp.uval - 1;
+
+ (*ndx_rtrn)--;
+ if (*ndx_rtrn >= darray_size(keyi->groups))
+ darray_resize0(keyi->groups, *ndx_rtrn + 1);
+
return true;
}
+bool
+LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
+{
+ xkb_keysym_t sym;
+
+ if (!str || istreq(str, "any") || istreq(str, "nosymbol")) {
+ *sym_rtrn = XKB_KEY_NoSymbol;
+ return 1;
+ }
+
+ if (istreq(str, "none") || istreq(str, "voidsymbol")) {
+ *sym_rtrn = XKB_KEY_VoidSymbol;
+ return 1;
+ }
+
+ sym = xkb_keysym_from_name(str);
+ if (sym != XKB_KEY_NoSymbol) {
+ *sym_rtrn = sym;
+ return 1;
+ }
+
+ return 0;
+}
+
static bool
AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
ExprDef *value)
{
- xkb_group_index_t ndx;
- size_t nSyms, nLevels;
- size_t i;
+ xkb_layout_index_t ndx;
+ GroupInfo *groupi;
+ unsigned int nSyms;
+ xkb_level_index_t nLevels;
+ xkb_level_index_t i;
int j;
if (!GetGroupIndex(info, keyi, arrayNdx, SYMBOLS, &ndx))
return false;
+
+ groupi = &darray_item(keyi->groups, ndx);
+
if (value == NULL) {
- keyi->symsDefined |= (1 << ndx);
+ groupi->defined |= GROUP_FIELD_SYMS;
return true;
}
- if (value->op != ExprKeysymList) {
+
+ if (value->op != EXPR_KEYSYM_LIST) {
log_err(info->keymap->ctx,
"Expected a list of symbols, found %s; "
"Ignoring symbols for group %u of %s\n",
- exprOpText(value->op), ndx + 1, longText(keyi->name));
+ expr_op_type_to_string(value->op), ndx + 1,
+ LongKeyNameText(keyi->name));
return false;
}
- if (!darray_empty(keyi->syms[ndx])) {
+
+ if (groupi->defined & GROUP_FIELD_SYMS) {
log_err(info->keymap->ctx,
"Symbols for key %s, group %u already defined; "
"Ignoring duplicate definition\n",
- longText(keyi->name), ndx + 1);
+ LongKeyNameText(keyi->name), ndx + 1);
return false;
}
+
nSyms = darray_size(value->value.list.syms);
nLevels = darray_size(value->value.list.symsMapIndex);
- if ((keyi->numLevels[ndx] < nSyms || darray_empty(keyi->syms[ndx])) &&
- (!ResizeKeyGroup(keyi, ndx, nLevels, nSyms, false))) {
- log_wsgo(info->keymap->ctx,
- "Could not resize group %u of key %s to contain %zu levels; "
- "Symbols lost\n",
- ndx + 1, longText(keyi->name), nSyms);
- return false;
- }
- keyi->symsDefined |= (1 << ndx);
+
+ if (darray_size(groupi->syms) < nSyms)
+ darray_resize0(groupi->syms, nSyms);
+
+ if (darray_size(groupi->levels) < nLevels)
+ darray_resize0(groupi->levels, nLevels);
+
+ groupi->defined |= GROUP_FIELD_SYMS;
+
for (i = 0; i < nLevels; i++) {
- darray_item(keyi->symsMapIndex[ndx], i) =
- darray_item(value->value.list.symsMapIndex, i);
- darray_item(keyi->symsMapNumEntries[ndx], i) =
- darray_item(value->value.list.symsNumEntries, i);
-
- for (j = 0; j < darray_item(keyi->symsMapNumEntries[ndx], i); j++) {
- /* FIXME: What's abort() doing here? */
- if (darray_item(keyi->symsMapIndex[ndx], i) + j >= nSyms)
- abort();
+ LevelInfo *leveli = &darray_item(groupi->levels, i);
+
+ leveli->sym_index = darray_item(value->value.list.symsMapIndex, i);
+ leveli->num_syms = darray_item(value->value.list.symsNumEntries, i);
+
+ for (j = 0; j < leveli->num_syms; j++) {
if (!LookupKeysym(darray_item(value->value.list.syms,
- darray_item(value->value.list.symsMapIndex,
- i) + j),
- &darray_item(keyi->syms[ndx],
- darray_item(keyi->symsMapIndex[ndx],
- i) + j))) {
+ leveli->sym_index + j),
+ &darray_item(groupi->syms,
+ leveli->sym_index + j))) {
log_warn(info->keymap->ctx,
- "Could not resolve keysym %s for key %s, group %u (%s), level %zu\n",
+ "Could not resolve keysym %s for key %s, group %u (%s), level %u\n",
darray_item(value->value.list.syms, i),
- longText(keyi->name),
+ LongKeyNameText(keyi->name),
ndx + 1,
xkb_atom_text(info->keymap->ctx,
- info->groupNames[ndx]),
+ info->group_names[ndx]),
nSyms);
- while (--j >= 0)
- darray_item(keyi->syms[ndx],
- darray_item(keyi->symsMapIndex[ndx],
- i) + j) = XKB_KEY_NoSymbol;
- darray_item(keyi->symsMapIndex[ndx], i) = -1;
- darray_item(keyi->symsMapNumEntries[ndx], i) = 0;
+ leveli->sym_index = 0;
+ leveli->num_syms = 0;
break;
}
- if (darray_item(keyi->symsMapNumEntries[ndx], i) == 1 &&
- darray_item(keyi->syms[ndx],
- darray_item(keyi->symsMapIndex[ndx],
- i) + j) == XKB_KEY_NoSymbol) {
- darray_item(keyi->symsMapIndex[ndx], i) = -1;
- darray_item(keyi->symsMapNumEntries[ndx], i) = 0;
+
+ if (leveli->num_syms == 1 &&
+ darray_item(groupi->syms,
+ leveli->sym_index + j) == XKB_KEY_NoSymbol) {
+ leveli->sym_index = 0;
+ leveli->num_syms = 0;
}
}
}
- for (j = keyi->numLevels[ndx] - 1;
- j >= 0 && darray_item(keyi->symsMapNumEntries[ndx], j) == 0; j--)
- keyi->numLevels[ndx]--;
+
+ for (j = darray_size(groupi->levels) - 1;
+ j >= 0 && darray_item(groupi->levels, j).num_syms == 0; j--)
+ (void) darray_pop(groupi->levels);
+
return true;
}
AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
ExprDef *value)
{
- size_t i;
- xkb_group_index_t ndx;
- size_t nActs;
+ unsigned int i;
+ xkb_layout_index_t ndx;
+ GroupInfo *groupi;
+ unsigned int nActs;
ExprDef *act;
- struct xkb_any_action *toAct;
+ union xkb_action *toAct;
if (!GetGroupIndex(info, keyi, arrayNdx, ACTIONS, &ndx))
return false;
+ groupi = &darray_item(keyi->groups, ndx);
+
if (value == NULL) {
- keyi->actsDefined |= (1 << ndx);
+ groupi->defined |= GROUP_FIELD_ACTS;
return true;
}
- if (value->op != ExprActionList) {
+ if (value->op != EXPR_ACTION_LIST) {
log_wsgo(info->keymap->ctx,
"Bad expression type (%d) for action list value; "
"Ignoring actions for group %u of %s\n",
- value->op, ndx, longText(keyi->name));
+ value->op, ndx, LongKeyNameText(keyi->name));
return false;
}
- if (!darray_empty(keyi->acts[ndx])) {
+ if (groupi->defined & GROUP_FIELD_ACTS) {
log_wsgo(info->keymap->ctx,
"Actions for key %s, group %u already defined\n",
- longText(keyi->name), ndx);
+ LongKeyNameText(keyi->name), ndx);
return false;
}
- for (nActs = 0, act = value->value.child; act != NULL; nActs++) {
- act = (ExprDef *) act->common.next;
- }
+ nActs = 0;
+ for (act = value->value.child; act; act = (ExprDef *) act->common.next)
+ nActs++;
- if (nActs < 1) {
- log_wsgo(info->keymap->ctx,
- "Action list but not actions in AddActionsToKey\n");
- return false;
- }
+ if (darray_size(groupi->levels) < nActs)
+ darray_resize0(groupi->levels, nActs);
- if ((keyi->numLevels[ndx] < nActs || darray_empty(keyi->acts[ndx])) &&
- !ResizeKeyGroup(keyi, ndx, nActs, nActs, true)) {
- log_wsgo(info->keymap->ctx,
- "Could not resize group %u of key %s; "
- "Actions lost\n",
- ndx, longText(keyi->name));
- return false;
- }
- keyi->actsDefined |= (1 << ndx);
+ groupi->defined |= GROUP_FIELD_ACTS;
- toAct = (struct xkb_any_action *) darray_mem(keyi->acts[ndx], 0);
act = value->value.child;
- for (i = 0; i < nActs; i++, toAct++) {
- if (!HandleActionDef(act, info->keymap, toAct, info->action)) {
+ for (i = 0; i < nActs; i++) {
+ toAct = &darray_item(groupi->levels, i).act;
+
+ if (!HandleActionDef(act, info->keymap, toAct, info->actions))
log_err(info->keymap->ctx,
"Illegal action definition for %s; "
- "Action for group %u/level %zu ignored\n",
- longText(keyi->name), ndx + 1, i + 1);
- }
+ "Action for group %u/level %u ignored\n",
+ LongKeyNameText(keyi->name), ndx + 1, i + 1);
+
act = (ExprDef *) act->common.next;
}
return true;
}
-static const LookupEntry lockingEntries[] = {
- { "true", XkbKB_Lock },
- { "yes", XkbKB_Lock },
- { "on", XkbKB_Lock },
- { "false", XkbKB_Default },
- { "no", XkbKB_Default },
- { "off", XkbKB_Default },
- { "permanent", XkbKB_Lock | XkbKB_Permanent },
- { NULL, 0 }
-};
-
static const LookupEntry repeatEntries[] = {
- { "true", RepeatYes },
- { "yes", RepeatYes },
- { "on", RepeatYes },
- { "false", RepeatNo },
- { "no", RepeatNo },
- { "off", RepeatNo },
- { "default", RepeatUndefined },
+ { "true", KEY_REPEAT_YES },
+ { "yes", KEY_REPEAT_YES },
+ { "on", KEY_REPEAT_YES },
+ { "false", KEY_REPEAT_NO },
+ { "no", KEY_REPEAT_NO },
+ { "off", KEY_REPEAT_NO },
+ { "default", KEY_REPEAT_UNDEFINED },
{ NULL, 0 }
};
static bool
-SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, char *field,
+SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
ExprDef *arrayNdx, ExprDef *value)
{
bool ok = true;
- ExprResult tmp;
struct xkb_context *ctx = info->keymap->ctx;
- if (strcasecmp(field, "type") == 0) {
- ExprResult ndx;
- if (!ExprResolveString(ctx, value, &tmp))
- log_lvl(info->keymap->ctx, 1,
+ if (istreq(field, "type")) {
+ xkb_layout_index_t ndx;
+ xkb_atom_t val;
+
+ if (!ExprResolveString(ctx, value, &val))
+ log_vrb(ctx, 1,
"The type field of a key symbol map must be a string; "
"Ignoring illegal type definition\n");
+
if (arrayNdx == NULL) {
- keyi->dfltType = xkb_atom_intern(ctx, tmp.str);
- keyi->defined |= _Key_Type_Dflt;
+ keyi->dfltType = val;
+ keyi->defined |= KEY_FIELD_TYPE_DFLT;
}
else if (!ExprResolveGroup(ctx, arrayNdx, &ndx)) {
- log_err(info->keymap->ctx,
+ log_err(ctx,
"Illegal group index for type of key %s; "
"Definition with non-integer array index ignored\n",
- longText(keyi->name));
- free(tmp.str);
+ LongKeyNameText(keyi->name));
return false;
}
else {
- keyi->types[ndx.uval - 1] = xkb_atom_intern(ctx, tmp.str);
- keyi->typesDefined |= (1 << (ndx.uval - 1));
+ ndx--;
+ if (ndx >= darray_size(keyi->groups))
+ darray_resize0(keyi->groups, ndx + 1);
+ darray_item(keyi->groups, ndx).type = val;
+ darray_item(keyi->groups, ndx).defined |= GROUP_FIELD_TYPE;
}
- free(tmp.str);
}
- else if (strcasecmp(field, "symbols") == 0)
+ else if (istreq(field, "symbols"))
return AddSymbolsToKey(info, keyi, arrayNdx, value);
- else if (strcasecmp(field, "actions") == 0)
+ else if (istreq(field, "actions"))
return AddActionsToKey(info, keyi, arrayNdx, value);
- else if ((strcasecmp(field, "vmods") == 0) ||
- (strcasecmp(field, "virtualmods") == 0) ||
- (strcasecmp(field, "virtualmodifiers") == 0)) {
- ok = ExprResolveVModMask(value, &tmp, info->keymap);
+ else if (istreq(field, "vmods") ||
+ istreq(field, "virtualmods") ||
+ istreq(field, "virtualmodifiers")) {
+ xkb_mod_mask_t mask;
+
+ ok = ExprResolveVModMask(info->keymap, value, &mask);
if (ok) {
- keyi->vmodmap = (tmp.uval >> 8);
- keyi->defined |= _Key_VModMap;
+ keyi->vmodmap = (mask >> XKB_NUM_CORE_MODS) & 0xffff;
+ keyi->defined |= KEY_FIELD_VMODMAP;
}
else {
log_err(info->keymap->ctx,
"Expected a virtual modifier mask, found %s; "
"Ignoring virtual modifiers definition for key %s\n",
- exprOpText(value->op), longText(keyi->name));
+ expr_op_type_to_string(value->op),
+ LongKeyNameText(keyi->name));
}
}
- else if ((strcasecmp(field, "locking") == 0) ||
- (strcasecmp(field, "lock") == 0) ||
- (strcasecmp(field, "locks") == 0)) {
- ok = ExprResolveEnum(ctx, value, &tmp, lockingEntries);
- if (ok)
- keyi->behavior.type = tmp.uval;
- keyi->defined |= _Key_Behavior;
+ else if (istreq(field, "locking") ||
+ istreq(field, "lock") ||
+ istreq(field, "locks")) {
+ log_err(info->keymap->ctx,
+ "Key behaviors not supported; "
+ "Ignoring locking specification for key %s\n",
+ LongKeyNameText(keyi->name));
}
- else if ((strcasecmp(field, "radiogroup") == 0) ||
- (strcasecmp(field, "permanentradiogroup") == 0) ||
- (strcasecmp(field, "allownone") == 0)) {
+ else if (istreq(field, "radiogroup") ||
+ istreq(field, "permanentradiogroup") ||
+ istreq(field, "allownone")) {
log_err(info->keymap->ctx,
"Radio groups not supported; "
"Ignoring radio group specification for key %s\n",
- longText(keyi->name));
- return false;
+ LongKeyNameText(keyi->name));
}
- else if (uStrCasePrefix("overlay", field) ||
- uStrCasePrefix("permanentoverlay", field)) {
+ else if (istreq_prefix("overlay", field) ||
+ istreq_prefix("permanentoverlay", field)) {
log_err(info->keymap->ctx,
"Overlays not supported; "
"Ignoring overlay specification for key %s\n",
- longText(keyi->name));
+ LongKeyNameText(keyi->name));
}
- else if ((strcasecmp(field, "repeating") == 0) ||
- (strcasecmp(field, "repeats") == 0) ||
- (strcasecmp(field, "repeat") == 0)) {
- ok = ExprResolveEnum(ctx, value, &tmp, repeatEntries);
+ else if (istreq(field, "repeating") ||
+ istreq(field, "repeats") ||
+ istreq(field, "repeat")) {
+ unsigned int val;
+
+ ok = ExprResolveEnum(ctx, value, &val, repeatEntries);
if (!ok) {
log_err(info->keymap->ctx,
"Illegal repeat setting for %s; "
"Non-boolean repeat setting ignored\n",
- longText(keyi->name));
+ LongKeyNameText(keyi->name));
return false;
}
- keyi->repeat = tmp.uval;
- keyi->defined |= _Key_Repeat;
+ keyi->repeat = val;
+ keyi->defined |= KEY_FIELD_REPEAT;
}
- else if ((strcasecmp(field, "groupswrap") == 0) ||
- (strcasecmp(field, "wrapgroups") == 0)) {
- ok = ExprResolveBoolean(ctx, value, &tmp);
- if (!ok) {
+ else if (istreq(field, "groupswrap") ||
+ istreq(field, "wrapgroups")) {
+ bool set;
+
+ if (!ExprResolveBoolean(ctx, value, &set)) {
log_err(info->keymap->ctx,
"Illegal groupsWrap setting for %s; "
"Non-boolean value ignored\n",
- longText(keyi->name));
+ LongKeyNameText(keyi->name));
return false;
}
- if (tmp.uval)
- keyi->out_of_range_group_action = XkbWrapIntoRange;
+
+ if (set)
+ keyi->out_of_range_group_action = RANGE_WRAP;
else
- keyi->out_of_range_group_action = XkbClampIntoRange;
- keyi->defined |= _Key_GroupInfo;
+ keyi->out_of_range_group_action = RANGE_SATURATE;
+
+ keyi->defined |= KEY_FIELD_GROUPINFO;
}
- else if ((strcasecmp(field, "groupsclamp") == 0) ||
- (strcasecmp(field, "clampgroups") == 0)) {
- ok = ExprResolveBoolean(ctx, value, &tmp);
- if (!ok) {
+ else if (istreq(field, "groupsclamp") ||
+ istreq(field, "clampgroups")) {
+ bool set;
+
+ if (!ExprResolveBoolean(ctx, value, &set)) {
log_err(info->keymap->ctx,
"Illegal groupsClamp setting for %s; "
"Non-boolean value ignored\n",
- longText(keyi->name));
+ LongKeyNameText(keyi->name));
return false;
}
- if (tmp.uval)
- keyi->out_of_range_group_action = XkbClampIntoRange;
+
+ if (set)
+ keyi->out_of_range_group_action = RANGE_SATURATE;
else
- keyi->out_of_range_group_action = XkbWrapIntoRange;
- keyi->defined |= _Key_GroupInfo;
+ keyi->out_of_range_group_action = RANGE_WRAP;
+
+ keyi->defined |= KEY_FIELD_GROUPINFO;
}
- else if ((strcasecmp(field, "groupsredirect") == 0) ||
- (strcasecmp(field, "redirectgroups") == 0)) {
- if (!ExprResolveGroup(ctx, value, &tmp)) {
+ else if (istreq(field, "groupsredirect") ||
+ istreq(field, "redirectgroups")) {
+ xkb_layout_index_t grp;
+
+ if (!ExprResolveGroup(ctx, value, &grp)) {
log_err(info->keymap->ctx,
"Illegal group index for redirect of key %s; "
"Definition with non-integer group ignored\n",
- longText(keyi->name));
+ LongKeyNameText(keyi->name));
return false;
}
- keyi->out_of_range_group_action = XkbRedirectIntoRange;
- keyi->out_of_range_group_number = tmp.uval - 1;
- keyi->defined |= _Key_GroupInfo;
+
+ keyi->out_of_range_group_action = RANGE_REDIRECT;
+ keyi->out_of_range_group_number = grp - 1;
+ keyi->defined |= KEY_FIELD_GROUPINFO;
}
else {
log_err(info->keymap->ctx,
field);
ok = false;
}
+
return ok;
}
static int
SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
{
- ExprResult tmp, name;
+ xkb_layout_index_t grp;
+ xkb_atom_t name;
if (!arrayNdx) {
- log_lvl(info->keymap->ctx, 1,
+ log_vrb(info->keymap->ctx, 1,
"You must specify an index when specifying a group name; "
"Group name definition without array subscript ignored\n");
return false;
}
- if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, &tmp)) {
+ if (!ExprResolveGroup(info->keymap->ctx, arrayNdx, &grp)) {
log_err(info->keymap->ctx,
"Illegal index in group name definition; "
"Definition with non-integer array index ignored\n");
if (!ExprResolveString(info->keymap->ctx, value, &name)) {
log_err(info->keymap->ctx,
"Group name must be a string; "
- "Illegal name for group %d ignored\n", tmp.uval);
+ "Illegal name for group %d ignored\n", grp);
return false;
}
- info->groupNames[tmp.uval - 1 + info->explicit_group] =
- xkb_atom_intern(info->keymap->ctx, name.str);
- free(name.str);
-
+ info->group_names[grp - 1 + info->explicit_group] = name;
return true;
}
static int
-HandleSymbolsVar(SymbolsInfo *info, VarDef *stmt)
+HandleGlobalVar(SymbolsInfo *info, VarDef *stmt)
{
- ExprResult elem, field;
+ const char *elem, *field;
ExprDef *arrayNdx;
bool ret;
- if (ExprResolveLhs(info->keymap, stmt->name, &elem, &field,
+ if (ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field,
&arrayNdx) == 0)
return 0; /* internal error, already reported */
- if (elem.str && (strcasecmp(elem.str, "key") == 0)) {
- ret = SetSymbolsField(info, &info->dflt, field.str, arrayNdx,
+ if (elem && istreq(elem, "key")) {
+ ret = SetSymbolsField(info, &info->dflt, field, arrayNdx,
stmt->value);
}
- else if ((elem.str == NULL) && ((strcasecmp(field.str, "name") == 0) ||
- (strcasecmp(field.str, "groupname") ==
- 0))) {
+ else if (!elem && (istreq(field, "name") ||
+ istreq(field, "groupname"))) {
ret = SetGroupName(info, arrayNdx, stmt->value);
}
- else if ((elem.str == NULL)
- && ((strcasecmp(field.str, "groupswrap") == 0) ||
- (strcasecmp(field.str, "wrapgroups") == 0))) {
+ else if (!elem && (istreq(field, "groupswrap") ||
+ istreq(field, "wrapgroups"))) {
log_err(info->keymap->ctx,
"Global \"groupswrap\" not supported; Ignored\n");
ret = true;
}
- else if ((elem.str == NULL)
- && ((strcasecmp(field.str, "groupsclamp") == 0) ||
- (strcasecmp(field.str, "clampgroups") == 0))) {
+ else if (!elem && (istreq(field, "groupsclamp") ||
+ istreq(field, "clampgroups"))) {
log_err(info->keymap->ctx,
"Global \"groupsclamp\" not supported; Ignored\n");
ret = true;
}
- else if ((elem.str == NULL)
- && ((strcasecmp(field.str, "groupsredirect") == 0) ||
- (strcasecmp(field.str, "redirectgroups") == 0))) {
+ else if (!elem && (istreq(field, "groupsredirect") ||
+ istreq(field, "redirectgroups"))) {
log_err(info->keymap->ctx,
"Global \"groupsredirect\" not supported; Ignored\n");
ret = true;
}
- else if ((elem.str == NULL) &&
- (strcasecmp(field.str, "allownone") == 0)) {
+ else if (!elem && istreq(field, "allownone")) {
log_err(info->keymap->ctx,
"Radio groups not supported; "
"Ignoring \"allownone\" specification\n");
ret = true;
}
else {
- ret = SetActionField(info->keymap, elem.str, field.str, arrayNdx,
- stmt->value, &info->action);
+ ret = SetActionField(info->keymap, elem, field, arrayNdx, stmt->value,
+ info->actions);
}
- free(elem.str);
- free(field.str);
return ret;
}
HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi)
{
bool ok = true;
- ExprResult tmp, field;
+ const char *elem, *field;
ExprDef *arrayNdx;
- for (; def != NULL; def = (VarDef *) def->common.next) {
- if ((def->name) && (def->name->type == ExprFieldRef)) {
- ok = HandleSymbolsVar(info, def);
+ for (; def; def = (VarDef *) def->common.next) {
+ if (def->name && def->name->op == EXPR_FIELD_REF) {
+ log_err(info->keymap->ctx,
+ "Cannot set a global default value from within a key statement; "
+ "Move statements to the global file scope\n");
continue;
}
+
+ if (!def->name) {
+ if (!def->value || def->value->op == EXPR_KEYSYM_LIST)
+ field = "symbols";
+ else
+ field = "actions";
+ arrayNdx = NULL;
+ }
else {
- if (def->name == NULL) {
- if ((def->value == NULL)
- || (def->value->op == ExprKeysymList))
- field.str = strdup("symbols");
- else
- field.str = strdup("actions");
- arrayNdx = NULL;
- }
- else {
- ok = ExprResolveLhs(info->keymap, def->name, &tmp, &field,
- &arrayNdx);
- }
- if (ok)
- ok = SetSymbolsField(info, keyi, field.str, arrayNdx,
- def->value);
- free(field.str);
+ ok = ExprResolveLhs(info->keymap->ctx, def->name, &elem, &field,
+ &arrayNdx);
}
+
+ if (ok)
+ ok = SetSymbolsField(info, keyi, field, arrayNdx, def->value);
}
+
return ok;
}
static bool
SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi)
{
- xkb_group_index_t group = info->explicit_group;
+ xkb_layout_index_t i;
+ GroupInfo *groupi;
+ bool warn = false;
- if (group == 0)
+ if (info->explicit_group == 0)
return true;
- if ((keyi->typesDefined | keyi->symsDefined | keyi->actsDefined) & ~1) {
- xkb_group_index_t i;
- log_warn(info->keymap->ctx,
- "For the map %s an explicit group specified\n",
- info->name);
+ darray_enumerate_from(i, groupi, keyi->groups, 1) {
+ if (groupi->defined) {
+ warn = true;
+ ClearGroupInfo(groupi);
+ }
+ }
+
+ if (warn)
log_warn(info->keymap->ctx,
+ "For the map %s an explicit group specified, "
"but key %s has more than one group defined; "
"All groups except first one will be ignored\n",
- longText(keyi->name));
- for (i = 1; i < XkbNumKbdGroups; i++) {
- keyi->numLevels[i] = 0;
- darray_free(keyi->syms[i]);
- darray_free(keyi->acts[i]);
- keyi->types[i] = 0;
- }
- }
- keyi->typesDefined = keyi->symsDefined = keyi->actsDefined = 1 << group;
-
- keyi->numLevels[group] = keyi->numLevels[0];
- keyi->numLevels[0] = 0;
- keyi->syms[group] = keyi->syms[0];
- darray_init(keyi->syms[0]);
- keyi->symsMapIndex[group] = keyi->symsMapIndex[0];
- darray_init(keyi->symsMapIndex[0]);
- keyi->symsMapNumEntries[group] = keyi->symsMapNumEntries[0];
- darray_init(keyi->symsMapNumEntries[0]);
- keyi->acts[group] = keyi->acts[0];
- darray_init(keyi->acts[0]);
- keyi->types[group] = keyi->types[0];
- keyi->types[0] = 0;
+ info->name, LongKeyNameText(keyi->name));
+
+ darray_resize0(keyi->groups, info->explicit_group + 1);
+ darray_item(keyi->groups, info->explicit_group) =
+ darray_item(keyi->groups, 0);
+ InitGroupInfo(&darray_item(keyi->groups, 0));
return true;
}
HandleSymbolsDef(SymbolsInfo *info, SymbolsDef *stmt)
{
KeyInfo keyi;
-
- InitKeyInfo(&keyi, info->file_id);
- CopyKeyInfo(&info->dflt, &keyi, false);
+ xkb_layout_index_t i;
+
+ keyi = info->dflt;
+ darray_init(keyi.groups);
+ darray_copy(keyi.groups, info->dflt.groups);
+ for (i = 0; i < darray_size(keyi.groups); i++) {
+ darray_init(darray_item(keyi.groups, i).syms);
+ darray_copy(darray_item(keyi.groups, i).syms,
+ darray_item(info->dflt.groups, i).syms);
+ darray_init(darray_item(keyi.groups, i).levels);
+ darray_copy(darray_item(keyi.groups, i).levels,
+ darray_item(info->dflt.groups, i).levels);
+ }
keyi.merge = stmt->merge;
keyi.name = KeyNameToLong(stmt->keyName);
+
if (!HandleSymbolsBody(info, (VarDef *) stmt->symbols, &keyi)) {
info->errorCount++;
return false;
info->errorCount++;
return false;
}
+
return true;
}
{
ExprDef *key;
ModMapEntry tmp;
- ExprResult rtrn;
+ xkb_mod_index_t ndx;
bool ok;
struct xkb_context *ctx = info->keymap->ctx;
- if (!LookupModIndex(ctx, NULL, def->modifier, TypeInt, &rtrn)) {
+ if (!LookupModIndex(ctx, NULL, def->modifier, EXPR_TYPE_INT, &ndx)) {
log_err(info->keymap->ctx,
"Illegal modifier map definition; "
"Ignoring map for non-modifier \"%s\"\n",
xkb_atom_text(ctx, def->modifier));
return false;
}
+
ok = true;
- tmp.modifier = rtrn.uval;
+ tmp.modifier = ndx;
+
for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next) {
- if ((key->op == ExprValue) && (key->type == TypeKeyName)) {
+ xkb_keysym_t sym;
+
+ if (key->op == EXPR_VALUE && key->value_type == EXPR_TYPE_KEYNAME) {
tmp.haveSymbol = false;
tmp.u.keyName = KeyNameToLong(key->value.keyName);
}
- else if (ExprResolveKeySym(ctx, key, &rtrn)) {
+ else if (ExprResolveKeySym(ctx, key, &sym)) {
tmp.haveSymbol = true;
- tmp.u.keySym = rtrn.uval;
+ tmp.u.keySym = sym;
}
else {
log_err(info->keymap->ctx,
"Modmap entries may contain only key names or keysyms; "
"Illegal definition for %s modifier ignored\n",
- XkbcModIndexText(tmp.modifier));
+ ModIndexText(tmp.modifier));
continue;
}
static void
HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
{
+ bool ok;
ParseCommon *stmt;
free(info->name);
- info->name = uDupString(file->name);
+ info->name = strdup_safe(file->name);
+
stmt = file->defs;
- while (stmt)
- {
- switch (stmt->stmtType) {
- case StmtInclude:
- if (!HandleIncludeSymbols(info, (IncludeStmt *) stmt))
- info->errorCount++;
+ for (stmt = file->defs; stmt; stmt = stmt->next) {
+ switch (stmt->type) {
+ case STMT_INCLUDE:
+ ok = HandleIncludeSymbols(info, (IncludeStmt *) stmt);
break;
- case StmtSymbolsDef:
- if (!HandleSymbolsDef(info, (SymbolsDef *) stmt))
- info->errorCount++;
+ case STMT_SYMBOLS:
+ ok = HandleSymbolsDef(info, (SymbolsDef *) stmt);
break;
- case StmtVarDef:
- if (!HandleSymbolsVar(info, (VarDef *) stmt))
- info->errorCount++;
+ case STMT_VAR:
+ ok = HandleGlobalVar(info, (VarDef *) stmt);
break;
- case StmtVModDef:
- if (!HandleVModDef((VModDef *) stmt, info->keymap, merge,
- &info->vmods))
- info->errorCount++;
+ case STMT_VMOD:
+ ok = HandleVModDef((VModDef *) stmt, info->keymap, merge,
+ &info->vmods);
break;
- case StmtInterpDef:
- log_err(info->keymap->ctx,
- "Interpretation files may not include other types; "
- "Ignoring definition of symbol interpretation\n");
- info->errorCount++;
+ case STMT_MODMAP:
+ ok = HandleModMapDef(info, (ModMapDef *) stmt);
break;
- case StmtKeycodeDef:
+ default:
log_err(info->keymap->ctx,
"Interpretation files may not include other types; "
- "Ignoring definition of key name\n");
- info->errorCount++;
- break;
- case StmtModMapDef:
- if (!HandleModMapDef(info, (ModMapDef *) stmt))
- info->errorCount++;
- break;
- default:
- log_wsgo(info->keymap->ctx,
- "Unexpected statement type %d in HandleSymbolsFile\n",
- stmt->stmtType);
+ "Ignoring %s\n", stmt_type_to_string(stmt->type));
+ ok = false;
break;
}
- stmt = stmt->next;
+
+ if (!ok)
+ info->errorCount++;
+
if (info->errorCount > 10) {
log_err(info->keymap->ctx, "Abandoning symbols file \"%s\"\n",
file->topName);
FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym)
{
struct xkb_key *key, *ret = NULL;
- xkb_group_index_t group, min_group = UINT_MAX;
- unsigned int level, min_level = UINT_MAX;
+ xkb_layout_index_t group, min_group = UINT32_MAX;
+ xkb_level_index_t level, min_level = UINT16_MAX;
xkb_foreach_key(key, keymap) {
for (group = 0; group < key->num_groups; group++) {
return ret;
}
-/**
- * Find the given name in the keymap->map->types and return its index.
- *
- * @param atom The atom to search for.
- * @param type_rtrn Set to the index of the name if found.
- *
- * @return true if found, false otherwise.
- */
static bool
-FindNamedType(struct xkb_keymap *keymap, xkb_atom_t atom, unsigned *type_rtrn)
+FindNamedType(struct xkb_keymap *keymap, xkb_atom_t name, unsigned *type_rtrn)
{
- unsigned n = 0;
- const char *name = xkb_atom_text(keymap->ctx, atom);
- struct xkb_key_type *type;
-
- if (keymap) {
- darray_foreach(type, keymap->types) {
- if (strcmp(type->name, name) == 0) {
- *type_rtrn = n;
- return true;
- }
- n++;
+ unsigned int i;
+
+ for (i = 0; i < keymap->num_types; i++) {
+ if (keymap->types[i].name == name) {
+ *type_rtrn = i;
+ return true;
}
}
+
return false;
}
* symbol per level.
*/
static bool
-FindAutomaticType(struct xkb_keymap *keymap, int width,
+FindAutomaticType(struct xkb_context *ctx, xkb_level_index_t width,
const xkb_keysym_t *syms, xkb_atom_t *typeNameRtrn,
bool *autoType)
{
*autoType = false;
if ((width == 1) || (width == 0)) {
- *typeNameRtrn = xkb_atom_intern(keymap->ctx, "ONE_LEVEL");
+ *typeNameRtrn = xkb_atom_intern(ctx, "ONE_LEVEL");
*autoType = true;
}
else if (width == 2) {
if (syms && xkb_keysym_is_lower(syms[0]) &&
xkb_keysym_is_upper(syms[1])) {
- *typeNameRtrn = xkb_atom_intern(keymap->ctx, "ALPHABETIC");
+ *typeNameRtrn = xkb_atom_intern(ctx, "ALPHABETIC");
}
else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
xkb_keysym_is_keypad(syms[1]))) {
- *typeNameRtrn = xkb_atom_intern(keymap->ctx, "KEYPAD");
+ *typeNameRtrn = xkb_atom_intern(ctx, "KEYPAD");
*autoType = true;
}
else {
- *typeNameRtrn = xkb_atom_intern(keymap->ctx, "TWO_LEVEL");
+ *typeNameRtrn = xkb_atom_intern(ctx, "TWO_LEVEL");
*autoType = true;
}
}
xkb_keysym_is_upper(syms[1]))
if (xkb_keysym_is_lower(syms[2]) && xkb_keysym_is_upper(syms[3]))
*typeNameRtrn =
- xkb_atom_intern(keymap->ctx, "FOUR_LEVEL_ALPHABETIC");
+ xkb_atom_intern(ctx, "FOUR_LEVEL_ALPHABETIC");
else
- *typeNameRtrn = xkb_atom_intern(keymap->ctx,
+ *typeNameRtrn = xkb_atom_intern(ctx,
"FOUR_LEVEL_SEMIALPHABETIC");
else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
xkb_keysym_is_keypad(syms[1])))
- *typeNameRtrn = xkb_atom_intern(keymap->ctx, "FOUR_LEVEL_KEYPAD");
+ *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL_KEYPAD");
else
- *typeNameRtrn = xkb_atom_intern(keymap->ctx, "FOUR_LEVEL");
+ *typeNameRtrn = xkb_atom_intern(ctx, "FOUR_LEVEL");
/* XXX: why not set autoType here? */
}
- return ((width >= 0) && (width <= 4));
-}
-
-/**
- * Ensure the given KeyInfo is in a coherent state, i.e. no gaps between the
- * groups, and reduce to one group if all groups are identical anyway.
- */
-static void
-PrepareKeyDef(KeyInfo *keyi)
-{
- xkb_group_index_t i, lastGroup;
- int j, width, defined;
- bool identical;
-
- defined = keyi->symsDefined | keyi->actsDefined | keyi->typesDefined;
- /* get highest group number */
- for (i = XkbNumKbdGroups - 1; i > 0; i--) {
- if (defined & (1 << i))
- break;
- }
- lastGroup = i;
-
- if (lastGroup == 0)
- return;
-
- /* If there are empty groups between non-empty ones fill them with data */
- /* from the first group. */
- /* We can make a wrong assumption here. But leaving gaps is worse. */
- for (i = lastGroup; i > 0; i--) {
- if (defined & (1 << i))
- continue;
- width = keyi->numLevels[0];
- if (keyi->typesDefined & 1) {
- for (j = 0; j < width; j++) {
- keyi->types[i] = keyi->types[0];
- }
- keyi->typesDefined |= 1 << i;
- }
- if ((keyi->actsDefined & 1) && !darray_empty(keyi->acts[0])) {
- darray_copy(keyi->acts[i], keyi->acts[0]);
- keyi->actsDefined |= 1 << i;
- }
- if ((keyi->symsDefined & 1) && !darray_empty(keyi->syms[0])) {
- darray_copy(keyi->syms[i], keyi->syms[0]);
- darray_copy(keyi->symsMapIndex[i], keyi->symsMapIndex[0]);
- darray_copy(keyi->symsMapNumEntries[i],
- keyi->symsMapNumEntries[0]);
- keyi->symsDefined |= 1 << i;
- }
- if (defined & 1) {
- keyi->numLevels[i] = keyi->numLevels[0];
- }
- }
- /* If all groups are completely identical remove them all */
- /* exept the first one. */
- identical = true;
- for (i = lastGroup; i > 0; i--) {
- if ((keyi->numLevels[i] != keyi->numLevels[0]) ||
- (keyi->types[i] != keyi->types[0])) {
- identical = false;
- break;
- }
- if (!darray_same(keyi->syms[i], keyi->syms[0]) &&
- (darray_empty(keyi->syms[i]) || darray_empty(keyi->syms[0]) ||
- darray_size(keyi->syms[i]) != darray_size(keyi->syms[0]) ||
- memcmp(darray_mem(keyi->syms[i], 0),
- darray_mem(keyi->syms[0], 0),
- sizeof(xkb_keysym_t) * darray_size(keyi->syms[0])))) {
- identical = false;
- break;
- }
- if (!darray_same(keyi->symsMapIndex[i], keyi->symsMapIndex[0]) &&
- (darray_empty(keyi->symsMapIndex[i]) ||
- darray_empty(keyi->symsMapIndex[0]) ||
- memcmp(darray_mem(keyi->symsMapIndex[i], 0),
- darray_mem(keyi->symsMapIndex[0], 0),
- keyi->numLevels[0] * sizeof(int)))) {
- identical = false;
- continue;
- }
- if (!darray_same(keyi->symsMapNumEntries[i],
- keyi->symsMapNumEntries[0]) &&
- (darray_empty(keyi->symsMapNumEntries[i]) ||
- darray_empty(keyi->symsMapNumEntries[0]) ||
- memcmp(darray_mem(keyi->symsMapNumEntries[i], 0),
- darray_mem(keyi->symsMapNumEntries[0], 0),
- keyi->numLevels[0] * sizeof(size_t)))) {
- identical = false;
- continue;
- }
- if (!darray_same(keyi->acts[i], keyi->acts[0]) &&
- (darray_empty(keyi->acts[i]) || darray_empty(keyi->acts[0]) ||
- memcmp(darray_mem(keyi->acts[i], 0),
- darray_mem(keyi->acts[0], 0),
- keyi->numLevels[0] * sizeof(union xkb_action)))) {
- identical = false;
- break;
- }
- }
- if (identical) {
- for (i = lastGroup; i > 0; i--) {
- keyi->numLevels[i] = 0;
- darray_free(keyi->syms[i]);
- darray_free(keyi->symsMapIndex[i]);
- darray_free(keyi->symsMapNumEntries[i]);
- darray_free(keyi->acts[i]);
- keyi->types[i] = 0;
- }
- keyi->symsDefined &= 1;
- keyi->actsDefined &= 1;
- keyi->typesDefined &= 1;
- }
+ return width <= 4;
}
-/**
- * Copy the KeyInfo into the keyboard description.
- *
- * This function recurses.
- */
static bool
-CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi,
- xkb_keycode_t start_from)
+CopySymbolsDef(SymbolsInfo *info, KeyInfo *keyi)
{
struct xkb_keymap *keymap = info->keymap;
- xkb_keycode_t kc;
struct xkb_key *key;
- size_t sizeSyms = 0;
- xkb_group_index_t i, nGroups;
- unsigned width, tmp;
- struct xkb_key_type * type;
- bool haveActions, autoType, useAlias;
- unsigned types[XkbNumKbdGroups];
- union xkb_action *outActs;
- unsigned int symIndex = 0;
-
- useAlias = (start_from == 0);
-
- key = FindNamedKey(keymap, keyi->name, useAlias,
- CreateKeyNames(keymap), start_from);
+ GroupInfo *groupi;
+ const GroupInfo *group0;
+ xkb_layout_index_t i;
+ bool haveActions;
+ unsigned int sizeSyms;
+ unsigned int symIndex;
+
+ /*
+ * The name is guaranteed to be real and not an alias (see
+ * AddKeySymbols), so 'false' is safe here.
+ */
+ key = FindNamedKey(keymap, keyi->name, false);
if (!key) {
- if (start_from == 0)
- log_lvl(info->keymap->ctx, 5,
- "Key %s not found in keycodes; Symbols ignored\n",
- longText(keyi->name));
+ log_vrb(info->keymap->ctx, 5,
+ "Key %s not found in keycodes; Symbols ignored\n",
+ LongKeyNameText(keyi->name));
return false;
}
- kc = XkbKeyGetKeycode(keymap, key);
+ /* Find the range of groups we need. */
+ key->num_groups = 0;
+ darray_enumerate(i, groupi, keyi->groups)
+ if (groupi->defined)
+ key->num_groups = i + 1;
+
+ if (key->num_groups <= 0)
+ return false; /* WSGO */
+
+ darray_resize(keyi->groups, key->num_groups);
+
+ /*
+ * If there are empty groups between non-empty ones, fill them with data
+ * from the first group.
+ * We can make a wrong assumption here. But leaving gaps is worse.
+ */
+ group0 = &darray_item(keyi->groups, 0);
+ darray_foreach_from(groupi, keyi->groups, 1) {
+ if (groupi->defined)
+ continue;
+
+ groupi->type = group0->type;
+ darray_copy(groupi->syms, group0->syms);
+ darray_copy(groupi->levels, group0->levels);
+ groupi->defined = group0->defined;
+ }
+
+ /* See if we need to allocate an actions array. */
haveActions = false;
- width = 0;
- for (i = nGroups = 0; i < XkbNumKbdGroups; i++) {
- if (((i + 1) > nGroups)
- && (((keyi->symsDefined | keyi->actsDefined) & (1 << i))
- || (keyi->typesDefined) & (1 << i)))
- nGroups = i + 1;
- if (!darray_empty(keyi->acts[i]))
- haveActions = true;
- autoType = false;
- /* Assign the type to the key, if it is missing. */
- if (keyi->types[i] == XKB_ATOM_NONE) {
+ darray_foreach(groupi, keyi->groups) {
+ LevelInfo *leveli;
+ darray_foreach(leveli, groupi->levels) {
+ if (leveli->act.type != ACTION_TYPE_NONE) {
+ haveActions = true;
+ goto out_of_loops;
+ }
+ }
+ }
+out_of_loops:
+
+ /*
+ * Find and assign the groups' types in the keymap. Also find the
+ * key width according to the largest type.
+ */
+ key->kt_index = calloc(key->num_groups, sizeof(*key->kt_index));
+ key->width = 0;
+ darray_enumerate(i, groupi, keyi->groups) {
+ struct xkb_key_type *type;
+ bool autoType = false;
+
+ /* Find the type of the group, if it is missing. */
+ if (groupi->type == XKB_ATOM_NONE) {
if (keyi->dfltType != XKB_ATOM_NONE)
- keyi->types[i] = keyi->dfltType;
- else if (FindAutomaticType(keymap, keyi->numLevels[i],
- darray_mem(keyi->syms[i], 0),
- &keyi->types[i], &autoType)) { }
+ groupi->type = keyi->dfltType;
+ else if (FindAutomaticType(keymap->ctx,
+ darray_size(groupi->levels),
+ darray_mem(groupi->syms, 0),
+ &groupi->type, &autoType)) { }
else
- log_lvl(info->keymap->ctx, 5,
- "No automatic type for %d symbols; "
- "Using %s for the %s key (keycode %d)\n",
- keyi->numLevels[i],
- xkb_atom_text(keymap->ctx, keyi->types[i]),
- longText(keyi->name), kc);
+ log_vrb(info->keymap->ctx, 5,
+ "No automatic type for %d levels; "
+ "Using %s for the %s key\n",
+ (int) darray_size(groupi->levels),
+ xkb_atom_text(keymap->ctx, groupi->type),
+ LongKeyNameText(keyi->name));
}
- if (FindNamedType(keymap, keyi->types[i], &types[i])) {
- if (!autoType || keyi->numLevels[i] > 2)
- key->explicit |= (1 << i);
+
+ /* Find the type in the keymap, if it was defined in xkb_types. */
+ if (FindNamedType(keymap, groupi->type, &key->kt_index[i])) {
+ if (!autoType || darray_size(groupi->levels) > 2)
+ key->explicit_groups |= (1 << i);
}
else {
- log_lvl(info->keymap->ctx, 3,
+ log_vrb(info->keymap->ctx, 3,
"Type \"%s\" is not defined; "
- "Using TWO_LEVEL for the %s key (keycode %d)\n",
- xkb_atom_text(keymap->ctx, keyi->types[i]),
- longText(keyi->name), kc);
- types[i] = XkbTwoLevelIndex;
+ "Using default type for the %s key\n",
+ xkb_atom_text(keymap->ctx, groupi->type),
+ LongKeyNameText(keyi->name));
+ /*
+ * Index 0 is guaranteed to contain something, usually
+ * ONE_LEVEL or at least some default one-level type.
+ */
+ key->kt_index[i] = 0;
}
- /* if the type specifies fewer levels than the key has, shrink the key */
- type = &darray_item(keymap->types, types[i]);
- if (type->num_levels < keyi->numLevels[i]) {
- log_lvl(info->keymap->ctx, 1,
- "Type \"%s\" has %d levels, but %s has %d symbols; "
+ /* If the type specifies fewer levels than the key has, shrink the key. */
+ type = &keymap->types[key->kt_index[i]];
+ if (type->num_levels < darray_size(groupi->levels)) {
+ log_vrb(info->keymap->ctx, 1,
+ "Type \"%s\" has %d levels, but %s has %d levels; "
"Ignoring extra symbols\n",
- type->name, type->num_levels,
- longText(keyi->name),
- keyi->numLevels[i]);
- keyi->numLevels[i] = type->num_levels;
+ xkb_atom_text(keymap->ctx, type->name),
+ type->num_levels,
+ LongKeyNameText(keyi->name),
+ (int) darray_size(groupi->levels));
+ darray_resize(groupi->levels, type->num_levels);
}
- if (keyi->numLevels[i] > width)
- width = keyi->numLevels[i];
- if (type->num_levels > width)
- width = type->num_levels;
- sizeSyms += darray_size(keyi->syms[i]);
- }
-
- darray_resize0(key->syms, sizeSyms);
- if (haveActions) {
- outActs = XkbcResizeKeyActions(keymap, key, width * nGroups);
- if (outActs == NULL) {
- log_wsgo(info->keymap->ctx,
- "Could not enlarge actions for %s (key %d)\n",
- longText(keyi->name), kc);
- return false;
- }
- key->explicit |= XkbExplicitInterpretMask;
- }
- else
- outActs = NULL;
-
- key->num_groups = nGroups;
- if (keyi->defined & _Key_GroupInfo) {
- key->out_of_range_group_number = keyi->out_of_range_group_number;
- key->out_of_range_group_action = keyi->out_of_range_group_action;
- }
- key->width = width;
- key->sym_index = calloc(nGroups * width, sizeof(*key->sym_index));
- key->num_syms = calloc(nGroups * width, sizeof(*key->num_syms));
-
- for (i = 0; i < nGroups; i++) {
- /* assign kt_index[i] to the index of the type in map->types.
- * kt_index[i] may have been set by a previous run (if we have two
- * layouts specified). Let's not overwrite it with the ONE_LEVEL
- * default group if we dont even have keys for this group anyway.
- *
- * FIXME: There should be a better fix for this.
+ /*
+ * Why type->num_levels and not darray_size(groupi->levels)?
+ * Because the type may have more levels, and each group must
+ * have at least as many levels as its type. Because the
+ * key->syms array is indexed by (group * width + level), we
+ * must take the largest one.
+ * Maybe we can change it to save some space.
*/
- if (keyi->numLevels[i])
- key->kt_index[i] = types[i];
- if (!darray_empty(keyi->syms[i])) {
- /* fill key to "width" symbols*/
- for (tmp = 0; tmp < width; tmp++) {
- if (tmp < keyi->numLevels[i] &&
- darray_item(keyi->symsMapNumEntries[i], tmp) != 0) {
- memcpy(darray_mem(key->syms, symIndex),
- darray_mem(keyi->syms[i],
- darray_item(keyi->symsMapIndex[i], tmp)),
- darray_item(keyi->symsMapNumEntries[i],
- tmp) * sizeof(xkb_keysym_t));
- key->sym_index[(i * width) + tmp] = symIndex;
- key->num_syms[(i * width) + tmp] =
- darray_item(keyi->symsMapNumEntries[i], tmp);
- symIndex += key->num_syms[(i * width) + tmp];
- }
- else {
- key->sym_index[(i * width) + tmp] = -1;
- key->num_syms[(i * width) + tmp] = 0;
- }
- if (outActs != NULL && !darray_empty(keyi->acts[i])) {
- if (tmp < keyi->numLevels[i])
- outActs[tmp] = darray_item(keyi->acts[i], tmp);
- else
- outActs[tmp].type = XkbSA_NoAction;
- }
- }
- }
- }
- switch (keyi->behavior.type & XkbKB_OpMask) {
- case XkbKB_Default:
- break;
-
- default:
- key->behavior = keyi->behavior;
- key->explicit |= XkbExplicitBehaviorMask;
- break;
+ key->width = MAX(key->width, type->num_levels);
+ }
+
+ /* Find the size of the syms array. */
+ sizeSyms = 0;
+ darray_foreach(groupi, keyi->groups)
+ sizeSyms += darray_size(groupi->syms);
+
+ /* Initialize the xkb_key, now that we know the sizes. */
+ key->syms = calloc(sizeSyms, sizeof(*key->syms));
+ key->sym_index = calloc(key->num_groups * key->width,
+ sizeof(*key->sym_index));
+ key->num_syms = calloc(key->num_groups * key->width,
+ sizeof(*key->num_syms));
+ key->out_of_range_group_number = keyi->out_of_range_group_number;
+ key->out_of_range_group_action = keyi->out_of_range_group_action;
+ if (haveActions) {
+ key->actions = calloc(key->num_groups * key->width,
+ sizeof(*key->actions));
+ key->explicit |= EXPLICIT_INTERP;
}
- if (keyi->defined & _Key_VModMap) {
+ if (keyi->defined & KEY_FIELD_VMODMAP) {
key->vmodmap = keyi->vmodmap;
- key->explicit |= XkbExplicitVModMapMask;
+ key->explicit |= EXPLICIT_VMODMAP;
+ }
+
+ if (keyi->repeat != KEY_REPEAT_UNDEFINED) {
+ key->repeats = (keyi->repeat == KEY_REPEAT_YES);
+ key->explicit |= EXPLICIT_REPEAT;
}
- if (keyi->repeat != RepeatUndefined) {
- key->repeats = keyi->repeat == RepeatYes;
- key->explicit |= XkbExplicitAutoRepeatMask;
+
+ /* Copy keysyms and actions. */
+ symIndex = 0;
+ darray_enumerate(i, groupi, keyi->groups) {
+ xkb_level_index_t j;
+ LevelInfo *leveli;
+
+ /* We rely on calloc having zeroized the arrays up to key->width. */
+ darray_enumerate(j, leveli, groupi->levels) {
+ if (leveli->act.type != ACTION_TYPE_NONE)
+ key->actions[i * key->width + j] = leveli->act;
+
+ if (leveli->num_syms <= 0)
+ continue;
+
+ memcpy(&key->syms[symIndex],
+ &darray_item(groupi->syms, leveli->sym_index),
+ leveli->num_syms * sizeof(*key->syms));
+ key->sym_index[i * key->width + j] = symIndex;
+ key->num_syms[i * key->width + j] = leveli->num_syms;
+ symIndex += key->num_syms[i * key->width + j];
+ }
}
- /* do the same thing for the next key */
- CopySymbolsDef(info, keyi, kc + 1);
return true;
}
struct xkb_keymap *keymap = info->keymap;
if (!entry->haveSymbol) {
- key = FindNamedKey(keymap, entry->u.keyName, true,
- CreateKeyNames(keymap), 0);
+ key = FindNamedKey(keymap, entry->u.keyName, true);
if (!key) {
- log_lvl(info->keymap->ctx, 5,
+ log_vrb(info->keymap->ctx, 5,
"Key %s not found in keycodes; "
"Modifier map entry for %s not updated\n",
- longText(entry->u.keyName),
- XkbcModIndexText(entry->modifier));
+ LongKeyNameText(entry->u.keyName),
+ ModIndexText(entry->modifier));
return false;
}
}
else {
key = FindKeyForSymbol(keymap, entry->u.keySym);
if (!key) {
- log_lvl(info->keymap->ctx, 5,
+ log_vrb(info->keymap->ctx, 5,
"Key \"%s\" not found in symbol map; "
"Modifier map entry for %s not updated\n",
- XkbcKeysymText(entry->u.keySym),
- XkbcModIndexText(entry->modifier));
+ KeysymText(entry->u.keySym),
+ ModIndexText(entry->modifier));
return false;
}
}
return true;
}
-/**
- * Handle the xkb_symbols section of an xkb file.
- *
- * @param file The parsed xkb_symbols section of the xkb file.
- * @param keymap Handle to the keyboard description to store the symbols in.
- * @param merge Merge strategy (e.g. MERGE_OVERRIDE).
- */
+static bool
+CopySymbolsToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info)
+{
+ KeyInfo *keyi;
+ ModMapEntry *mm;
+ xkb_layout_index_t i;
+ struct xkb_key *key;
+
+ keymap->symbols_section_name = strdup_safe(info->name);
+
+ for (i = 0; i < XKB_NUM_GROUPS; i++)
+ if (info->group_names[i] != XKB_ATOM_NONE)
+ keymap->group_names[i] = info->group_names[i];
+
+ darray_foreach(keyi, info->keys)
+ if (!CopySymbolsDef(info, keyi))
+ info->errorCount++;
+
+ if (xkb_context_get_log_verbosity(keymap->ctx) > 3) {
+ xkb_foreach_key(key, keymap) {
+ if (key->name[0] == '\0')
+ continue;
+
+ if (key->num_groups < 1)
+ log_info(keymap->ctx,
+ "No symbols defined for %s\n",
+ KeyNameText(key->name));
+ }
+ }
+
+ darray_foreach(mm, info->modMaps)
+ if (!CopyModMapDef(info, mm))
+ info->errorCount++;
+
+ /* XXX: If we don't ignore errorCount, things break. */
+ return true;
+}
+
bool
CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge)
{
- xkb_group_index_t i;
- struct xkb_key *key;
SymbolsInfo info;
- KeyInfo *keyi;
- ModMapEntry *mm;
+ ActionsInfo *actions;
- InitSymbolsInfo(&info, keymap, file->id);
+ actions = NewActionsInfo();
+ if (!actions)
+ return false;
+
+ InitSymbolsInfo(&info, keymap, file->id, actions);
info.dflt.merge = merge;
HandleSymbolsFile(&info, file, merge);
if (info.errorCount != 0)
goto err_info;
- darray_resize0(keymap->acts, darray_size(keymap->acts) + 32 + 1);
-
- if (info.name)
- keymap->symbols_section_name = strdup(info.name);
-
- for (i = 0; i < XkbNumKbdGroups; i++) {
- if (info.groupNames[i] != XKB_ATOM_NONE) {
- free(keymap->group_names[i]);
- keymap->group_names[i] = xkb_atom_strdup(keymap->ctx,
- info.groupNames[i]);
- }
- }
-
- /* sanitize keys */
- darray_foreach(keyi, info.keys)
- PrepareKeyDef(keyi);
-
- /* copy! */
- darray_foreach(keyi, info.keys)
- if (!CopySymbolsDef(&info, keyi, 0))
- info.errorCount++;
-
- if (xkb_get_log_verbosity(keymap->ctx) > 3) {
- xkb_foreach_key(key, keymap) {
- if (key->name[0] == '\0')
- continue;
-
- if (key->num_groups < 1)
- log_warn(info.keymap->ctx,
- "No symbols defined for <%.4s> (keycode %d)\n",
- key->name, XkbKeyGetKeycode(keymap, key));
- }
- }
-
- list_foreach(mm, &info.modMaps, entry)
- if (!CopyModMapDef(&info, mm))
- info.errorCount++;
+ if (!CopySymbolsToKeymap(keymap, &info))
+ goto err_info;
- FreeSymbolsInfo(&info);
+ ClearSymbolsInfo(&info);
+ FreeActionsInfo(actions);
return true;
err_info:
- FreeSymbolsInfo(&info);
+ FreeActionsInfo(actions);
+ ClearSymbolsInfo(&info);
return false;
}