enum si_field defined;
unsigned file_id;
enum merge_mode merge;
- struct list entry;
struct xkb_sym_interpret interp;
} SymInterpInfo;
char *name;
unsigned file_id;
int errorCount;
- int nInterps;
- struct list interps;
SymInterpInfo dflt;
+ darray(SymInterpInfo) interps;
LEDInfo ledDflt;
darray(LEDInfo) leds;
VModInfo vmods;
info->name = NULL;
info->file_id = file_id;
info->errorCount = 0;
- info->nInterps = 0;
- list_init(&info->interps);
+ darray_init(info->interps);
info->act = NULL;
info->dflt.file_id = file_id;
info->dflt.defined = 0;
static void
ClearCompatInfo(CompatInfo *info)
{
- SymInterpInfo *si, *next_si;
struct xkb_keymap *keymap = info->keymap;
free(info->name);
memset(&info->dflt.interp.act, 0, sizeof(info->dflt.interp.act));
info->dflt.interp.act.type = XkbSA_NoAction;
ClearIndicatorMapInfo(keymap->ctx, &info->ledDflt);
- info->nInterps = 0;
- list_foreach_safe(si, next_si, &info->interps, entry)
- free(si);
+ darray_free(info->interps);
darray_free(info->leds);
FreeActionInfo(info->act);
info->act = NULL;
}
static SymInterpInfo *
-NextInterp(CompatInfo *info)
-{
- SymInterpInfo *si;
-
- si = calloc(1, sizeof(*si));
- if (!si)
- return NULL;
-
- list_append(&si->entry, &info->interps);
- info->nInterps++;
-
- return si;
-}
-
-static SymInterpInfo *
FindMatchingInterp(CompatInfo *info, SymInterpInfo *new)
{
SymInterpInfo *old;
- list_foreach(old, &info->interps, entry)
+ darray_foreach(old, info->interps)
if (old->interp.sym == new->interp.sym &&
old->interp.mods == new->interp.mods &&
old->interp.match == new->interp.match)
{
enum si_field collide;
SymInterpInfo *old;
- struct list entry;
int verbosity = xkb_get_log_verbosity(info->keymap->ctx);
collide = 0;
old = FindMatchingInterp(info, new);
if (old != NULL) {
if (new->merge == MERGE_REPLACE) {
- entry = old->entry;
if ((old->file_id == new->file_id && verbosity > 0) ||
verbosity > 9)
log_warn(info->keymap->ctx,
"Earlier interpretation ignored\n",
siText(new, info));
*old = *new;
- old->entry = entry;
return true;
}
return true;
}
- old = new;
- new = NextInterp(info);
- if (!new)
- return false;
- entry = new->entry;
- *new = *old;
- new->entry = entry;
+ darray_append(info->interps, *new);
return true;
}
MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from,
enum merge_mode merge)
{
- SymInterpInfo *si, *next_si;
+ SymInterpInfo *si;
LEDInfo *led;
if (from->errorCount > 0) {
from->name = NULL;
}
- list_foreach_safe(si, next_si, &from->interps, entry) {
+ darray_foreach(si, from->interps) {
si->merge = (merge == MERGE_DEFAULT ? si->merge : merge);
if (!AddInterp(into, si))
into->errorCount++;
{
SymInterpInfo *si;
- list_foreach(si, &info->interps, entry) {
+ darray_foreach(si, info->interps) {
if (((si->interp.match & XkbSI_OpMask) != pred) ||
(needSymbol && si->interp.sym == XKB_KEY_NoSymbol) ||
(!needSymbol && si->interp.sym != XKB_KEY_NoSymbol))
if (info.name)
keymap->compat_section_name = strdup(info.name);
- darray_init(keymap->sym_interpret);
- if (info.nInterps > 0) {
- darray_growalloc(keymap->sym_interpret, info.nInterps);
+ if (!darray_empty(info.interps)) {
CopyInterps(&info, true, XkbSI_Exactly);
CopyInterps(&info, true, XkbSI_AllOf | XkbSI_NoneOf);
CopyInterps(&info, true, XkbSI_AnyOf);