diff options
Diffstat (limited to 'src/3rdparty/xkbcommon/src/xkbcomp')
20 files changed, 748 insertions, 1418 deletions
diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/action.c b/src/3rdparty/xkbcommon/src/xkbcomp/action.c index 2bd0bd1589..eb3d37fbbe 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/action.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/action.c @@ -118,6 +118,8 @@ NewActionsInfo(void) /* Increment default button. */ info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.flags = 0; info->actions[ACTION_TYPE_PTR_DEFAULT].dflt.value = 1; + info->actions[ACTION_TYPE_PTR_MOVE].ptr.flags = ACTION_ACCEL; + info->actions[ACTION_TYPE_SWITCH_VT].screen.flags = ACTION_SAME_SCREEN; return info; } @@ -186,10 +188,10 @@ fieldText(enum action_field field) /***====================================================================***/ static inline bool -ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action, +ReportMismatch(struct xkb_context *ctx, enum xkb_action_type action, enum action_field field, const char *type) { - log_err(keymap->ctx, + log_err(ctx, "Value of %s field must be of type %s; " "Action %s definition ignored\n", fieldText(field), type, ActionTypeText(action)); @@ -197,10 +199,10 @@ ReportMismatch(struct xkb_keymap *keymap, enum xkb_action_type action, } static inline bool -ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action, +ReportIllegal(struct xkb_context *ctx, enum xkb_action_type action, enum action_field field) { - log_err(keymap->ctx, + log_err(ctx, "Field %s is not defined for an action of type %s; " "Action definition ignored\n", fieldText(field), ActionTypeText(action)); @@ -208,10 +210,10 @@ ReportIllegal(struct xkb_keymap *keymap, enum xkb_action_type action, } static inline bool -ReportActionNotArray(struct xkb_keymap *keymap, enum xkb_action_type action, +ReportActionNotArray(struct xkb_context *ctx, enum xkb_action_type action, enum action_field field) { - log_err(keymap->ctx, + log_err(ctx, "The %s field in the %s action is not an array; " "Action definition ignored\n", fieldText(field), ActionTypeText(action)); @@ -228,42 +230,40 @@ HandleNoAction(struct xkb_keymap *keymap, union xkb_action *action, } static bool -CheckLatchLockFlags(struct xkb_keymap *keymap, enum xkb_action_type action, - enum action_field field, const ExprDef *value, - enum xkb_action_flags *flags_inout) +CheckBooleanFlag(struct xkb_context *ctx, enum xkb_action_type action, + enum action_field field, enum xkb_action_flags flag, + const ExprDef *array_ndx, const ExprDef *value, + enum xkb_action_flags *flags_inout) { - enum xkb_action_flags tmp; - bool result; + bool set; - if (field == ACTION_FIELD_CLEAR_LOCKS) - tmp = ACTION_LOCK_CLEAR; - else if (field == ACTION_FIELD_LATCH_TO_LOCK) - tmp = ACTION_LATCH_TO_LOCK; - else - return false; /* WSGO! */ + if (array_ndx) + return ReportActionNotArray(ctx, action, field); - if (!ExprResolveBoolean(keymap->ctx, value, &result)) - return ReportMismatch(keymap, action, field, "boolean"); + if (!ExprResolveBoolean(ctx, value, &set)) + return ReportMismatch(ctx, action, field, "boolean"); - if (result) - *flags_inout |= tmp; + if (set) + *flags_inout |= flag; else - *flags_inout &= ~tmp; + *flags_inout &= ~flag; return true; } static bool CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action, - const ExprDef *value, enum xkb_action_flags *flags_inout, - xkb_mod_mask_t *mods_rtrn) + const ExprDef *array_ndx, const ExprDef *value, + enum xkb_action_flags *flags_inout, xkb_mod_mask_t *mods_rtrn) { + if (array_ndx) + return ReportActionNotArray(keymap->ctx, action, ACTION_FIELD_MODIFIERS); + if (value->expr.op == EXPR_IDENT) { const char *valStr; valStr = xkb_atom_text(keymap->ctx, value->ident.ident); if (valStr && (istreq(valStr, "usemodmapmods") || istreq(valStr, "modmapmods"))) { - *mods_rtrn = 0; *flags_inout |= ACTION_MODS_LOOKUP_MODMAP; return true; @@ -271,184 +271,130 @@ CheckModifierField(struct xkb_keymap *keymap, enum xkb_action_type action, } if (!ExprResolveModMask(keymap, value, MOD_BOTH, mods_rtrn)) - return ReportMismatch(keymap, action, + return ReportMismatch(keymap->ctx, action, ACTION_FIELD_MODIFIERS, "modifier mask"); *flags_inout &= ~ACTION_MODS_LOOKUP_MODMAP; return true; } +static const LookupEntry lockWhich[] = { + { "both", 0 }, + { "lock", ACTION_LOCK_NO_UNLOCK }, + { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) }, + { "unlock", ACTION_LOCK_NO_LOCK }, + { NULL, 0 } +}; + static bool -HandleSetLatchMods(struct xkb_keymap *keymap, union xkb_action *action, - enum action_field field, const ExprDef *array_ndx, - const ExprDef *value) +CheckAffectField(struct xkb_context *ctx, enum xkb_action_type action, + const ExprDef *array_ndx, const ExprDef *value, + enum xkb_action_flags *flags_inout) { - struct xkb_mod_action *act = &action->mods; - enum xkb_action_flags rtrn, t1; - xkb_mod_mask_t t2; - - if (array_ndx != NULL) { - switch (field) { - case ACTION_FIELD_CLEAR_LOCKS: - case ACTION_FIELD_LATCH_TO_LOCK: - case ACTION_FIELD_MODIFIERS: - return ReportActionNotArray(keymap, action->type, field); - default: - break; - } - } - - switch (field) { - case ACTION_FIELD_CLEAR_LOCKS: - case ACTION_FIELD_LATCH_TO_LOCK: - rtrn = act->flags; - if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) { - act->flags = rtrn; - return true; - } - return false; + enum xkb_action_flags flags; - case ACTION_FIELD_MODIFIERS: - t1 = act->flags; - if (CheckModifierField(keymap, action->type, value, &t1, &t2)) { - act->flags = t1; - act->mods.mods = t2; - return true; - } - return false; + if (array_ndx) + return ReportActionNotArray(ctx, action, ACTION_FIELD_AFFECT); - default: - break; - } + if (!ExprResolveEnum(ctx, value, &flags, lockWhich)) + return ReportMismatch(ctx, action, ACTION_FIELD_AFFECT, + "lock, unlock, both, neither"); - return ReportIllegal(keymap, action->type, field); + *flags_inout &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK); + *flags_inout |= flags; + return true; } static bool -HandleLockMods(struct xkb_keymap *keymap, union xkb_action *action, - enum action_field field, const ExprDef *array_ndx, - const ExprDef *value) +HandleSetLatchLockMods(struct xkb_keymap *keymap, union xkb_action *action, + enum action_field field, const ExprDef *array_ndx, + const ExprDef *value) { struct xkb_mod_action *act = &action->mods; - enum xkb_action_flags t1; - xkb_mod_mask_t t2; - - if (array_ndx && field == ACTION_FIELD_MODIFIERS) - return ReportActionNotArray(keymap, action->type, field); - - switch (field) { - case ACTION_FIELD_MODIFIERS: - t1 = act->flags; - if (CheckModifierField(keymap, action->type, value, &t1, &t2)) { - act->flags = t1; - act->mods.mods = t2; - return true; - } - return false; - - default: - break; - } - - return ReportIllegal(keymap, action->type, field); + const enum xkb_action_type type = action->type; + + if (field == ACTION_FIELD_MODIFIERS) + return CheckModifierField(keymap, action->type, array_ndx, value, + &act->flags, &act->mods.mods); + if ((type == ACTION_TYPE_MOD_SET || type == ACTION_TYPE_MOD_LATCH) && + field == ACTION_FIELD_CLEAR_LOCKS) + return CheckBooleanFlag(keymap->ctx, action->type, field, + ACTION_LOCK_CLEAR, array_ndx, value, + &act->flags); + if (type == ACTION_TYPE_MOD_LATCH && + field == ACTION_FIELD_LATCH_TO_LOCK) + return CheckBooleanFlag(keymap->ctx, action->type, field, + ACTION_LATCH_TO_LOCK, array_ndx, value, + &act->flags); + if (type == ACTION_TYPE_MOD_LOCK && + field == ACTION_FIELD_AFFECT) + return CheckAffectField(keymap->ctx, action->type, array_ndx, value, + &act->flags); + + return ReportIllegal(keymap->ctx, action->type, field); } static bool -CheckGroupField(struct xkb_keymap *keymap, unsigned action, - const ExprDef *value, enum xkb_action_flags *flags_inout, - xkb_layout_index_t *grp_rtrn) +CheckGroupField(struct xkb_context *ctx, unsigned action, + const ExprDef *array_ndx, const ExprDef *value, + enum xkb_action_flags *flags_inout, int32_t *group_rtrn) { const ExprDef *spec; + xkb_layout_index_t idx; + enum xkb_action_flags flags = *flags_inout; + + if (array_ndx) + return ReportActionNotArray(ctx, action, ACTION_FIELD_GROUP); if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) { - *flags_inout &= ~ACTION_ABSOLUTE_SWITCH; + flags &= ~ACTION_ABSOLUTE_SWITCH; spec = value->unary.child; } else { - *flags_inout |= ACTION_ABSOLUTE_SWITCH; + flags |= ACTION_ABSOLUTE_SWITCH; spec = value; } - if (!ExprResolveGroup(keymap->ctx, spec, grp_rtrn)) - return ReportMismatch(keymap, action, ACTION_FIELD_GROUP, + if (!ExprResolveGroup(ctx, spec, &idx)) + return ReportMismatch(ctx, action, ACTION_FIELD_GROUP, "integer (range 1..8)"); - if (value->expr.op == EXPR_NEGATE) - *grp_rtrn = -*grp_rtrn; - else if (value->expr.op != EXPR_UNARY_PLUS) - (*grp_rtrn)--; - - return true; -} - -static bool -HandleSetLatchGroup(struct xkb_keymap *keymap, union xkb_action *action, - enum action_field field, const ExprDef *array_ndx, - const ExprDef *value) -{ - struct xkb_group_action *act = &action->group; - enum xkb_action_flags rtrn, t1; - xkb_layout_index_t t2; - - if (array_ndx != NULL) { - switch (field) { - case ACTION_FIELD_CLEAR_LOCKS: - case ACTION_FIELD_LATCH_TO_LOCK: - case ACTION_FIELD_GROUP: - return ReportActionNotArray(keymap, action->type, field); - - default: - break; - } + /* +n, -n are relative, n is absolute. */ + if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) { + *group_rtrn = (int32_t) idx; + if (value->expr.op == EXPR_NEGATE) + *group_rtrn = -*group_rtrn; } - - switch (field) { - case ACTION_FIELD_CLEAR_LOCKS: - case ACTION_FIELD_LATCH_TO_LOCK: - rtrn = act->flags; - if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) { - act->flags = rtrn; - return true; - } - return false; - - case ACTION_FIELD_GROUP: - t1 = act->flags; - if (CheckGroupField(keymap, action->type, value, &t1, &t2)) { - act->flags = t1; - act->group = t2; - return true; - } - return false; - - default: - break; + else { + *group_rtrn = (int32_t) (idx - 1); } - - return ReportIllegal(keymap, action->type, field); + *flags_inout = flags; + return true; } static bool -HandleLockGroup(struct xkb_keymap *keymap, union xkb_action *action, - enum action_field field, const ExprDef *array_ndx, - const ExprDef *value) +HandleSetLatchLockGroup(struct xkb_keymap *keymap, union xkb_action *action, + enum action_field field, const ExprDef *array_ndx, + const ExprDef *value) { struct xkb_group_action *act = &action->group; - enum xkb_action_flags t1; - xkb_layout_index_t t2; - - if ((array_ndx != NULL) && (field == ACTION_FIELD_GROUP)) - return ReportActionNotArray(keymap, action->type, field); - if (field == ACTION_FIELD_GROUP) { - t1 = act->flags; - if (CheckGroupField(keymap, action->type, value, &t1, &t2)) { - act->flags = t1; - act->group = t2; - return true; - } - return false; - } - return ReportIllegal(keymap, action->type, field); + const enum xkb_action_type type = action->type; + + if (field == ACTION_FIELD_GROUP) + return CheckGroupField(keymap->ctx, action->type, array_ndx, value, + &act->flags, &act->group); + if ((type == ACTION_TYPE_GROUP_SET || type == ACTION_TYPE_GROUP_LATCH) && + field == ACTION_FIELD_CLEAR_LOCKS) + return CheckBooleanFlag(keymap->ctx, action->type, field, + ACTION_LOCK_CLEAR, array_ndx, value, + &act->flags); + if (type == ACTION_TYPE_GROUP_LATCH && + field == ACTION_FIELD_LATCH_TO_LOCK) + return CheckBooleanFlag(keymap->ctx, action->type, field, + ACTION_LATCH_TO_LOCK, array_ndx, value, + &act->flags); + + return ReportIllegal(keymap->ctx, action->type, field); } static bool @@ -458,53 +404,47 @@ HandleMovePtr(struct xkb_keymap *keymap, union xkb_action *action, { struct xkb_pointer_action *act = &action->ptr; - if (array_ndx && (field == ACTION_FIELD_X || field == ACTION_FIELD_Y)) - return ReportActionNotArray(keymap, action->type, field); - if (field == ACTION_FIELD_X || field == ACTION_FIELD_Y) { int val; const bool absolute = (value->expr.op != EXPR_NEGATE && value->expr.op != EXPR_UNARY_PLUS); + if (array_ndx) + return ReportActionNotArray(keymap->ctx, action->type, field); + if (!ExprResolveInteger(keymap->ctx, value, &val)) - return ReportMismatch(keymap, action->type, field, "integer"); + return ReportMismatch(keymap->ctx, action->type, field, "integer"); + + if (val < INT16_MIN || val > INT16_MAX) { + log_err(keymap->ctx, + "The %s field in the %s action must be in range %d..%d; " + "Action definition ignored\n", + fieldText(field), ActionTypeText(action->type), + INT16_MIN, INT16_MAX); + return false; + } if (field == ACTION_FIELD_X) { if (absolute) act->flags |= ACTION_ABSOLUTE_X; - act->x = val; + act->x = (int16_t) val; } else { if (absolute) act->flags |= ACTION_ABSOLUTE_Y; - act->y = val; + act->y = (int16_t) val; } return true; } else if (field == ACTION_FIELD_ACCEL) { - bool set; - - if (!ExprResolveBoolean(keymap->ctx, value, &set)) - return ReportMismatch(keymap, action->type, field, "boolean"); - - if (set) - act->flags &= ~ACTION_NO_ACCEL; - else - act->flags |= ACTION_NO_ACCEL; + return CheckBooleanFlag(keymap->ctx, action->type, field, + ACTION_ACCEL, array_ndx, value, &act->flags); } - return ReportIllegal(keymap, action->type, field); + return ReportIllegal(keymap->ctx, action->type, field); } -static const LookupEntry lockWhich[] = { - { "both", 0 }, - { "lock", ACTION_LOCK_NO_UNLOCK }, - { "neither", (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK) }, - { "unlock", ACTION_LOCK_NO_LOCK }, - { NULL, 0 } -}; - static bool HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action, enum action_field field, const ExprDef *array_ndx, @@ -516,10 +456,10 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action, int btn; if (array_ndx) - return ReportActionNotArray(keymap, action->type, field); + return ReportActionNotArray(keymap->ctx, action->type, field); if (!ExprResolveButton(keymap->ctx, value, &btn)) - return ReportMismatch(keymap, action->type, field, + return ReportMismatch(keymap->ctx, action->type, field, "integer (range 1..5)"); if (btn < 0 || btn > 5) { @@ -534,40 +474,30 @@ HandlePtrBtn(struct xkb_keymap *keymap, union xkb_action *action, } else if (action->type == ACTION_TYPE_PTR_LOCK && field == ACTION_FIELD_AFFECT) { - enum xkb_action_flags val; - - if (array_ndx) - return ReportActionNotArray(keymap, action->type, field); - - if (!ExprResolveEnum(keymap->ctx, value, &val, lockWhich)) - return ReportMismatch(keymap, action->type, field, - "lock or unlock"); - - act->flags &= ~(ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK); - act->flags |= val; - return true; + return CheckAffectField(keymap->ctx, action->type, array_ndx, value, + &act->flags); } else if (field == ACTION_FIELD_COUNT) { - int btn; + int val; if (array_ndx) - return ReportActionNotArray(keymap, action->type, field); + return ReportActionNotArray(keymap->ctx, action->type, field); - /* XXX: Should this actually be ResolveButton? */ - if (!ExprResolveButton(keymap->ctx, value, &btn)) - return ReportMismatch(keymap, action->type, field, "integer"); + if (!ExprResolveInteger(keymap->ctx, value, &val)) + return ReportMismatch(keymap->ctx, action->type, field, "integer"); - if (btn < 0 || btn > 255) { + if (val < 0 || val > 255) { log_err(keymap->ctx, "The count field must have a value in the range 0..255; " - "Illegal count %d ignored\n", btn); + "Illegal count %d ignored\n", val); return false; } - act->count = btn; + act->count = (uint8_t) val; return true; } - return ReportIllegal(keymap, action->type, field); + + return ReportIllegal(keymap->ctx, action->type, field); } static const LookupEntry ptrDflts[] = { @@ -588,10 +518,10 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action, unsigned int val; if (array_ndx) - return ReportActionNotArray(keymap, action->type, field); + return ReportActionNotArray(keymap->ctx, action->type, field); if (!ExprResolveEnum(keymap->ctx, value, &val, ptrDflts)) - return ReportMismatch(keymap, action->type, field, + return ReportMismatch(keymap->ctx, action->type, field, "pointer component"); return true; } @@ -600,7 +530,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action, int btn; if (array_ndx) - return ReportActionNotArray(keymap, action->type, field); + return ReportActionNotArray(keymap->ctx, action->type, field); if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) { @@ -613,7 +543,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action, } if (!ExprResolveButton(keymap->ctx, button, &btn)) - return ReportMismatch(keymap, action->type, field, + return ReportMismatch(keymap->ctx, action->type, field, "integer (range 1..5)"); if (btn < 0 || btn > 5) { @@ -633,7 +563,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, union xkb_action *action, return true; } - return ReportIllegal(keymap, action->type, field); + return ReportIllegal(keymap->ctx, action->type, field); } static bool @@ -648,7 +578,7 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action, int val; if (array_ndx) - return ReportActionNotArray(keymap, action->type, field); + return ReportActionNotArray(keymap->ctx, action->type, field); if (value->expr.op == EXPR_NEGATE || value->expr.op == EXPR_UNARY_PLUS) { @@ -661,7 +591,7 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action, } if (!ExprResolveInteger(keymap->ctx, scrn, &val)) - return ReportMismatch(keymap, action->type, field, + return ReportMismatch(keymap->ctx, action->type, field, "integer (0..255)"); if (val < 0 || val > 255) { @@ -675,23 +605,12 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action, return true; } else if (field == ACTION_FIELD_SAME) { - bool set; - - if (array_ndx) - return ReportActionNotArray(keymap, action->type, field); - - if (!ExprResolveBoolean(keymap->ctx, value, &set)) - return ReportMismatch(keymap, action->type, field, "boolean"); - - if (set) - act->flags &= ~ACTION_SAME_SCREEN; - else - act->flags |= ACTION_SAME_SCREEN; - - return true; + return CheckBooleanFlag(keymap->ctx, action->type, field, + ACTION_SAME_SCREEN, array_ndx, value, + &act->flags); } - return ReportIllegal(keymap, action->type, field); + return ReportIllegal(keymap->ctx, action->type, field); } static bool @@ -705,17 +624,21 @@ HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action, unsigned int mask; if (array_ndx) - return ReportActionNotArray(keymap, action->type, field); + return ReportActionNotArray(keymap->ctx, action->type, field); if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames)) - return ReportMismatch(keymap, action->type, field, + return ReportMismatch(keymap->ctx, action->type, field, "controls mask"); act->ctrls = mask; return true; } + else if (field == ACTION_FIELD_AFFECT) { + return CheckAffectField(keymap->ctx, action->type, array_ndx, value, + &act->flags); + } - return ReportIllegal(keymap, action->type, field); + return ReportIllegal(keymap->ctx, action->type, field); } static bool @@ -728,8 +651,11 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action, if (field == ACTION_FIELD_TYPE) { int type; + if (array_ndx) + return ReportActionNotArray(keymap->ctx, action->type, field); + if (!ExprResolveInteger(keymap->ctx, value, &type)) - return ReportMismatch(keymap, ACTION_TYPE_PRIVATE, field, "integer"); + return ReportMismatch(keymap->ctx, ACTION_TYPE_PRIVATE, field, "integer"); if (type < 0 || type > 255) { log_err(keymap->ctx, @@ -764,17 +690,17 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action, if (array_ndx == NULL) { xkb_atom_t val; const char *str; - int len; + size_t len; if (!ExprResolveString(keymap->ctx, value, &val)) - return ReportMismatch(keymap, action->type, field, "string"); + return ReportMismatch(keymap->ctx, action->type, field, "string"); str = xkb_atom_text(keymap->ctx, val); len = strlen(str); if (len < 1 || len > 7) { log_warn(keymap->ctx, "A private action has 7 data bytes; " - "Extra %d bytes ignored\n", len - 6); + "Illegal data ignored\n"); return false; } @@ -791,7 +717,7 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action, return false; } - if (ndx < 0 || ndx >= sizeof(act->data)) { + if (ndx < 0 || (size_t) ndx >= sizeof(act->data)) { log_err(keymap->ctx, "The data for a private action is %lu bytes long; " "Attempt to use data[%d] ignored\n", @@ -800,7 +726,7 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action, } if (!ExprResolveInteger(keymap->ctx, value, &datum)) - return ReportMismatch(keymap, act->type, field, "integer"); + return ReportMismatch(keymap->ctx, act->type, field, "integer"); if (datum < 0 || datum > 255) { log_err(keymap->ctx, @@ -814,7 +740,7 @@ HandlePrivate(struct xkb_keymap *keymap, union xkb_action *action, } } - return ReportIllegal(keymap, ACTION_TYPE_NONE, field); + return ReportIllegal(keymap->ctx, ACTION_TYPE_NONE, field); } typedef bool (*actionHandler)(struct xkb_keymap *keymap, @@ -825,12 +751,12 @@ typedef bool (*actionHandler)(struct xkb_keymap *keymap, static const actionHandler handleAction[_ACTION_TYPE_NUM_ENTRIES] = { [ACTION_TYPE_NONE] = HandleNoAction, - [ACTION_TYPE_MOD_SET] = HandleSetLatchMods, - [ACTION_TYPE_MOD_LATCH] = HandleSetLatchMods, - [ACTION_TYPE_MOD_LOCK] = HandleLockMods, - [ACTION_TYPE_GROUP_SET] = HandleSetLatchGroup, - [ACTION_TYPE_GROUP_LATCH] = HandleSetLatchGroup, - [ACTION_TYPE_GROUP_LOCK] = HandleLockGroup, + [ACTION_TYPE_MOD_SET] = HandleSetLatchLockMods, + [ACTION_TYPE_MOD_LATCH] = HandleSetLatchLockMods, + [ACTION_TYPE_MOD_LOCK] = HandleSetLatchLockMods, + [ACTION_TYPE_GROUP_SET] = HandleSetLatchLockGroup, + [ACTION_TYPE_GROUP_LATCH] = HandleSetLatchLockGroup, + [ACTION_TYPE_GROUP_LOCK] = HandleSetLatchLockGroup, [ACTION_TYPE_PTR_MOVE] = HandleMovePtr, [ACTION_TYPE_PTR_BUTTON] = HandlePtrBtn, [ACTION_TYPE_PTR_LOCK] = HandlePtrBtn, @@ -921,7 +847,6 @@ HandleActionDef(ExprDef *def, struct xkb_keymap *keymap, return true; } - bool SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field, ExprDef *array_ndx, ExprDef *value, ActionsInfo *info) diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/ast-build.c b/src/3rdparty/xkbcommon/src/xkbcomp/ast-build.c index d470884e78..11bc0912d1 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/ast-build.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/ast-build.c @@ -53,7 +53,6 @@ #include "xkbcomp-priv.h" #include "ast-build.h" -#include "parser-priv.h" #include "include.h" ParseCommon * @@ -202,7 +201,7 @@ ExprCreateKeysymList(xkb_keysym_t sym) ExprDef * ExprCreateMultiKeysymList(ExprDef *expr) { - size_t nLevels = darray_size(expr->keysym_list.symsMapIndex); + unsigned nLevels = darray_size(expr->keysym_list.symsMapIndex); darray_resize(expr->keysym_list.symsMapIndex, 1); darray_resize(expr->keysym_list.symsNumEntries, 1); @@ -215,7 +214,7 @@ ExprCreateMultiKeysymList(ExprDef *expr) ExprDef * ExprAppendKeysymList(ExprDef *expr, xkb_keysym_t sym) { - size_t nSyms = darray_size(expr->keysym_list.syms); + unsigned nSyms = darray_size(expr->keysym_list.syms); darray_append(expr->keysym_list.symsMapIndex, nSyms); darray_append(expr->keysym_list.symsNumEntries, 1); @@ -227,8 +226,8 @@ ExprAppendKeysymList(ExprDef *expr, xkb_keysym_t sym) ExprDef * ExprAppendMultiKeysymList(ExprDef *expr, ExprDef *append) { - size_t nSyms = darray_size(expr->keysym_list.syms); - size_t numEntries = darray_size(append->keysym_list.syms); + unsigned nSyms = darray_size(expr->keysym_list.syms); + unsigned numEntries = darray_size(append->keysym_list.syms); darray_append(expr->keysym_list.symsMapIndex, nSyms); darray_append(expr->keysym_list.symsNumEntries, numEntries); @@ -356,7 +355,7 @@ SymbolsCreate(xkb_atom_t keyName, VarDef *symbols) } GroupCompatDef * -GroupCompatCreate(int group, ExprDef *val) +GroupCompatCreate(unsigned group, ExprDef *val) { GroupCompatDef *def = malloc(sizeof(*def)); if (!def) @@ -372,7 +371,7 @@ GroupCompatCreate(int group, ExprDef *val) } ModMapDef * -ModMapCreate(uint32_t modifier, ExprDef *keys) +ModMapCreate(xkb_atom_t modifier, ExprDef *keys) { ModMapDef *def = malloc(sizeof(*def)); if (!def) @@ -404,7 +403,7 @@ LedMapCreate(xkb_atom_t name, VarDef *body) } LedNameDef * -LedNameCreate(int ndx, ExprDef *name, bool virtual) +LedNameCreate(unsigned ndx, ExprDef *name, bool virtual) { LedNameDef *def = malloc(sizeof(*def)); if (!def) @@ -496,8 +495,8 @@ err: } XkbFile * -XkbFileCreate(struct xkb_context *ctx, enum xkb_file_type type, char *name, - ParseCommon *defs, enum xkb_map_flags flags) +XkbFileCreate(enum xkb_file_type type, char *name, ParseCommon *defs, + enum xkb_map_flags flags) { XkbFile *file; @@ -533,7 +532,7 @@ XkbFileFromComponents(struct xkb_context *ctx, if (!include) goto err; - file = XkbFileCreate(ctx, type, NULL, &include->common, 0); + file = XkbFileCreate(type, NULL, (ParseCommon *) include, 0); if (!file) { FreeInclude(include); goto err; @@ -542,7 +541,7 @@ XkbFileFromComponents(struct xkb_context *ctx, defs = AppendStmt(defs, &file->common); } - file = XkbFileCreate(ctx, FILE_TYPE_KEYMAP, NULL, defs, 0); + file = XkbFileCreate(FILE_TYPE_KEYMAP, NULL, defs, 0); if (!file) goto err; @@ -565,7 +564,7 @@ FreeExpr(ExprDef *expr) case EXPR_UNARY_PLUS: case EXPR_NOT: case EXPR_INVERT: - FreeStmt(&expr->unary.child->common); + FreeStmt((ParseCommon *) expr->unary.child); break; case EXPR_DIVIDE: @@ -573,16 +572,16 @@ FreeExpr(ExprDef *expr) case EXPR_SUBTRACT: case EXPR_MULTIPLY: case EXPR_ASSIGN: - FreeStmt(&expr->binary.left->common); - FreeStmt(&expr->binary.right->common); + FreeStmt((ParseCommon *) expr->binary.left); + FreeStmt((ParseCommon *) expr->binary.right); break; case EXPR_ACTION_DECL: - FreeStmt(&expr->action.args->common); + FreeStmt((ParseCommon *) expr->action.args); break; case EXPR_ARRAY_REF: - FreeStmt(&expr->array_ref.entry->common); + FreeStmt((ParseCommon *) expr->array_ref.entry); break; case EXPR_KEYSYM_LIST: @@ -619,12 +618,10 @@ void FreeStmt(ParseCommon *stmt) { ParseCommon *next; - YYSTYPE u; while (stmt) { next = stmt->next; - u.any = stmt; switch (stmt->type) { case STMT_INCLUDE: @@ -633,36 +630,36 @@ FreeStmt(ParseCommon *stmt) stmt = NULL; break; case STMT_EXPR: - FreeExpr(u.expr); + FreeExpr((ExprDef *) stmt); break; case STMT_VAR: - FreeStmt(&u.var->name->common); - FreeStmt(&u.var->value->common); + FreeStmt((ParseCommon *) ((VarDef *) stmt)->name); + FreeStmt((ParseCommon *) ((VarDef *) stmt)->value); break; case STMT_TYPE: - FreeStmt(&u.keyType->body->common); + FreeStmt((ParseCommon *) ((KeyTypeDef *) stmt)->body); break; case STMT_INTERP: - FreeStmt(&u.interp->match->common); - FreeStmt(&u.interp->def->common); + FreeStmt((ParseCommon *) ((InterpDef *) stmt)->match); + FreeStmt((ParseCommon *) ((InterpDef *) stmt)->def); break; case STMT_VMOD: - FreeStmt(&u.vmod->value->common); + FreeStmt((ParseCommon *) ((VModDef *) stmt)->value); break; case STMT_SYMBOLS: - FreeStmt(&u.syms->symbols->common); + FreeStmt((ParseCommon *) ((SymbolsDef *) stmt)->symbols); break; case STMT_MODMAP: - FreeStmt(&u.modMask->keys->common); + FreeStmt((ParseCommon *) ((ModMapDef *) stmt)->keys); break; case STMT_GROUP_COMPAT: - FreeStmt(&u.groupCompat->def->common); + FreeStmt((ParseCommon *) ((GroupCompatDef *) stmt)->def); break; case STMT_LED_MAP: - FreeStmt(&u.ledMap->body->common); + FreeStmt((ParseCommon *) ((LedMapDef *) stmt)->body); break; case STMT_LED_NAME: - FreeStmt(&u.ledName->name->common); + FreeStmt((ParseCommon *) ((LedNameDef *) stmt)->name); break; default: break; diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/ast-build.h b/src/3rdparty/xkbcommon/src/xkbcomp/ast-build.h index 8146b066d1..b57e4cdce1 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/ast-build.h +++ b/src/3rdparty/xkbcommon/src/xkbcomp/ast-build.h @@ -98,23 +98,23 @@ SymbolsDef * SymbolsCreate(xkb_atom_t keyName, VarDef *symbols); GroupCompatDef * -GroupCompatCreate(int group, ExprDef *def); +GroupCompatCreate(unsigned group, ExprDef *def); ModMapDef * -ModMapCreate(uint32_t modifier, ExprDef *keys); +ModMapCreate(xkb_atom_t modifier, ExprDef *keys); LedMapDef * LedMapCreate(xkb_atom_t name, VarDef *body); LedNameDef * -LedNameCreate(int ndx, ExprDef *name, bool virtual); +LedNameCreate(unsigned ndx, ExprDef *name, bool virtual); IncludeStmt * IncludeCreate(struct xkb_context *ctx, char *str, enum merge_mode merge); XkbFile * -XkbFileCreate(struct xkb_context *ctx, enum xkb_file_type type, char *name, - ParseCommon *defs, enum xkb_map_flags flags); +XkbFileCreate(enum xkb_file_type type, char *name, ParseCommon *defs, + enum xkb_map_flags flags); void FreeStmt(ParseCommon *stmt); diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/ast.h b/src/3rdparty/xkbcommon/src/xkbcomp/ast.h index 489b33193c..26cbb3a3e4 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/ast.h +++ b/src/3rdparty/xkbcommon/src/xkbcomp/ast.h @@ -143,9 +143,7 @@ expr_op_type_to_string(enum expr_op_type type); const char * expr_value_type_to_string(enum expr_value_type type); -/* This struct contains fields common to all other AST nodes. It is only - * ever embedded in other structs, so save some memory by packing it. */ -typedef struct ATTR_PACKED _ParseCommon { +typedef struct _ParseCommon { struct _ParseCommon *next; enum stmt_type type; } ParseCommon; @@ -226,7 +224,7 @@ typedef struct { typedef struct { ExprCommon expr; darray(xkb_keysym_t) syms; - darray(int) symsMapIndex; + darray(unsigned int) symsMapIndex; darray(unsigned int) symsNumEntries; } ExprKeysymList; @@ -299,7 +297,7 @@ typedef struct { typedef struct { ParseCommon common; enum merge_mode merge; - int group; + unsigned group; ExprDef *def; } GroupCompatDef; @@ -314,7 +312,7 @@ typedef struct { typedef struct { ParseCommon common; enum merge_mode merge; - int ndx; + unsigned ndx; ExprDef *name; bool virtual; } LedNameDef; diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/compat.c b/src/3rdparty/xkbcommon/src/xkbcomp/compat.c index fffb2d34b2..475895c6c1 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/compat.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/compat.c @@ -54,179 +54,6 @@ #include "vmod.h" #include "include.h" -/* - * The xkb_compat section - * ===================== - * This section is the third to be processed, after xkb_keycodes and - * xkb_types. - * - * Interpret statements - * -------------------- - * Statements of the form: - * interpret Num_Lock+Any { ... } - * interpret Shift_Lock+AnyOf(Shift+Lock) { ... } - * - * The xkb_symbols section (see symbols.c) allows the keymap author to do, - * among other things, the following for each key: - * - Bind an action, like SetMods or LockGroup, to the key. Actions, like - * symbols, are specified for each level of each group in the key - * separately. - * - Add a virtual modifier to the key's virtual modifier mapping (vmodmap). - * - Specify whether the key should repeat or not. - * - * However, doing this for each key (or level) is tedious and inflexible. - * Interpret's are a mechanism to apply these settings to a bunch of - * keys/levels at once. - * - * Each interpret specifies a condition by which it attaches to certain - * levels. The condition consists of two parts: - * - A keysym. If the level has a different (or more than one) keysym, the - * match failes. Leaving out the keysym is equivalent to using the - * NoSymbol keysym, which always matches successfully. - * - A modifier predicate. The predicate consists of a matching operation - * and a mask of (real) modifiers. The modifers are matched against the - * key's modifier map (modmap). The matching operation can be one of the - * following: - * + AnyOfOrNone - The modmap must either be empty or include at least - * one of the specified modifiers. - * + AnyOf - The modmap must include at least one of the specified - * modifiers. - * + NoneOf - The modmap must not include any of the specified modifiers. - * + AllOf - The modmap must include all of the specified modifiers (but - * may include others as well). - * + Exactly - The modmap must be exactly the same as the specified - * modifiers. - * Leaving out the predicate is equivalent to usign AnyOfOrNone while - * specifying all modifiers. Leaving out just the matching condtition - * is equivalent to using Exactly. - * An interpret may also include "useModMapMods = level1;" - see below. - * - * If a level fulfils the conditions of several interpret's, only the - * most specific one is used: - * - A specific keysym will always match before a generic NoSymbol - * condition. - * - If the keysyms are the same, the interpret with the more specific - * matching operation is used. The above list is sorted from least to - * most specific. - * - If both the keysyms and the matching operations are the same (but the - * modifiers are different), the first interpret is used. - * - * As described above, once an interpret "attaches" to a level, it can bind - * an action to that level, add one virtual modifier to the key's vmodmap, - * or set the key's repeat setting. You should note the following: - * - The key repeat is a property of the entire key; it is not level-specific. - * In order to avoid confusion, it is only inspected for the first level of - * the first group; the interpret's repeat setting is ignored when applied - * to other levels. - * - If one of the above fields was set directly for a key in xkb_symbols, - * the explicit setting takes precedence over the interpret. - * - * The body of the statment may include statements of the following - * forms (all of which are optional): - * - * - useModMapMods statement: - * useModMapMods = level1; - * - * When set to 'level1', the interpret will only match levels which are - * the first level of the first group of the keys. This can be useful in - * conjunction with e.g. a virtualModifier statement. - * - * - action statement: - * action = LockMods(modifiers=NumLock); - * - * Bind this action to the matching levels. - * - * - virtual modifier statement: - * virtualModifier = NumLock; - * - * Add this virtual modifier to the key's vmodmap. The given virtual - * modifier must be declared at the top level of the file with a - * virtual_modifiers statement, e.g.: - * virtual_modifiers NumLock; - * - * - repeat statement: - * repeat = True; - * - * Set whether the key should repeat or not. Must be a boolean value. - * - * Led map statements - * ------------------------ - * Statements of the form: - * indicator "Shift Lock" { ... } - * - * This statement specifies the behavior and binding of the LED (a.k.a - * indicator) with the given name ("Shift Lock" above). The name should - * have been declared previously in the xkb_keycodes section (see Led - * name statement), and given an index there. If it wasn't, it is created - * with the next free index. - * The body of the statement describes the conditions of the keyboard - * state which will cause the LED to be lit. It may include the following - * statements: - * - * - modifiers statment: - * modifiers = ScrollLock; - * - * If the given modifiers are in the required state (see below), the - * led is lit. - * - * - whichModifierState statment: - * whichModState = Latched + Locked; - * - * Can be any combination of: - * base, latched, locked, effective - * any (i.e. all of the above) - * none (i.e. none of the above) - * compat (legacy value, treated as effective) - * This will cause the respective portion of the modifer state (see - * struct xkb_state) to be matched against the modifiers given in the - * "modifiers" statement. - * - * Here's a simple example: - * indicator "Num Lock" { - * modifiers = NumLock; - * whichModState = Locked; - * }; - * Whenever the NumLock modifier is locked, the Num Lock LED will light - * up. - * - * - groups statment: - * groups = All - group1; - * - * If the given groups are in the required state (see below), the led - * is lit. - * - * - whichGroupState statment: - * whichGroupState = Effective; - * - * Can be any combination of: - * base, latched, locked, effective - * any (i.e. all of the above) - * none (i.e. none of the above) - * This will cause the respective portion of the group state (see - * struct xkb_state) to be matched against the groups given in the - * "groups" statement. - * - * Note: the above conditions are disjunctive, i.e. if any of them are - * satisfied the led is lit. - * - * Virtual modifier statements - * --------------------------- - * Statements of the form: - * virtual_modifiers LControl; - * - * Can appear in the xkb_types, xkb_compat, xkb_symbols sections. - * TODO - * - * Effect on keymap - * ---------------- - * After all of the xkb_compat sections have been compiled, the following - * members of struct xkb_keymap are finalized: - * darray(struct xkb_sym_interpret) sym_interprets; - * darray(struct xkb_led) leds; - * char *compat_section_name; - * TODO: virtual modifiers. - */ - enum si_field { SI_FIELD_VIRTUAL_MOD = (1 << 0), SI_FIELD_ACTION = (1 << 1), @@ -555,16 +382,28 @@ MergeIncludedCompatMaps(CompatInfo *into, CompatInfo *from, from->name = NULL; } - darray_foreach(si, from->interps) { - si->merge = (merge == MERGE_DEFAULT ? si->merge : merge); - if (!AddInterp(into, si, false)) - into->errorCount++; + if (darray_empty(into->interps)) { + into->interps = from->interps; + darray_init(from->interps); + } + else { + darray_foreach(si, from->interps) { + si->merge = (merge == MERGE_DEFAULT ? si->merge : merge); + if (!AddInterp(into, si, false)) + into->errorCount++; + } } - darray_foreach(ledi, from->leds) { - ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge); - if (!AddLedMap(into, ledi, false)) - into->errorCount++; + if (darray_empty(into->leds)) { + into->leds = from->leds; + darray_init(from->leds); + } + else { + darray_foreach(ledi, from->leds) { + ledi->merge = (merge == MERGE_DEFAULT ? ledi->merge : merge); + if (!AddLedMap(into, ledi, false)) + into->errorCount++; + } } } @@ -929,7 +768,7 @@ HandleCompatMapFile(CompatInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleGlobalVar(info, (VarDef *) stmt); break; case STMT_VMOD: - ok = HandleVModDef(info->keymap, (VModDef *) stmt); + ok = HandleVModDef(info->keymap, (VModDef *) stmt, merge); break; default: log_err(info->keymap->ctx, diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/expr.c b/src/3rdparty/xkbcommon/src/xkbcomp/expr.c index ba71208f7e..c514f8d54c 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/expr.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/expr.c @@ -116,7 +116,7 @@ LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field, if (ndx == XKB_MOD_INVALID) return false; - *val_rtrn = (1 << ndx); + *val_rtrn = (1u << ndx); return true; } @@ -427,14 +427,8 @@ ExprResolveLevel(struct xkb_context *ctx, const ExprDef *expr, bool ExprResolveButton(struct xkb_context *ctx, const ExprDef *expr, int *btn_rtrn) { - int result; - - if (!ExprResolveIntegerLookup(ctx, expr, &result, SimpleLookup, - buttonNames)) - return false; - - *btn_rtrn = result; - return true; + return ExprResolveIntegerLookup(ctx, expr, btn_rtrn, SimpleLookup, + buttonNames); } bool diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/keycodes.c b/src/3rdparty/xkbcommon/src/xkbcomp/keycodes.c index 59916b7266..d90f6a4465 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/keycodes.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/keycodes.c @@ -29,79 +29,6 @@ #include "expr.h" #include "include.h" -/* - * The xkb_keycodes section - * ======================== - * - * This is the simplest section type, and is the first one to be - * compiled. The purpose of this is mostly to map between the - * hardware/evdev scancodes and xkb keycodes. Each key is given a name - * by which it can be referred to later, e.g. in the symbols section. - * - * Keycode statements - * ------------------ - * Statements of the form: - * <TLDE> = 49; - * <AE01> = 10; - * - * The above would let 49 and 10 be valid keycodes in the keymap, and - * assign them the names TLDE and AE01 respectively. The format <WXYZ> is - * always used to refer to a key by name. - * - * [ The naming convention <AE01> just denoted the position of the key - * in the main alphanumric section of the keyboard, with the two letters - * specifying the row and the two digits specifying the column, from - * the bottom left.] - * - * In the common case this just maps to the evdev scancodes from - * /usr/include/linux/input.h, e.g. the following definitions: - * #define KEY_GRAVE 41 - * #define KEY_1 2 - * Similar definitions appear in the xf86-input-keyboard driver. Note - * that in all current keymaps there's a constant offset of 8 (for - * historical reasons). - * - * If there's a conflict, like the same name given to different keycodes, - * or same keycode given different names, it is resolved according to the - * merge mode which applies to the definitions. - * - * Alias statements - * ---------------- - * Statements of the form: - * alias <MENU> = <COMP>; - * - * Allows to refer to a previously defined key (here <COMP>) by another - * name (here <MENU>). Conflicts are handled similarly. - * - * LED name statements - * ------------------------- - * Statements of the form: - * indicator 1 = "Caps Lock"; - * indicator 2 = "Num Lock"; - * indicator 3 = "Scroll Lock"; - * - * Assigns a name to the keyboard LED (a.k.a indicator) with the given index. - * The led may be referred by this name later in the compat section - * and by the user. - * - * Effect on the keymap - * -------------------- - * After all of the xkb_keycodes sections have been compiled, the - * following members of struct xkb_keymap are finalized: - * xkb_keycode_t min_key_code; - * xkb_keycode_t max_key_code; - * unsigned int num_aliases; - * struct xkb_key_alias *key_aliases; - * char *keycodes_section_name; - * The 'name' field of leds declared in xkb_keycodes: - * darray(struct xkb_led) leds; - * Further, the array of keys: - * struct xkb_key *keys; - * had been resized to its final size (i.e. all of the xkb_key objects are - * referable by their keycode). However the objects themselves do not - * contain any useful information besides the key name at this point. - */ - typedef struct { enum merge_mode merge; @@ -322,7 +249,7 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, xkb_atom_t name, /***====================================================================***/ -static int +static bool HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge); static void @@ -459,7 +386,7 @@ HandleKeycodeDef(KeyNamesInfo *info, KeycodeDef *stmt, enum merge_mode merge) return AddKeyName(info, stmt->value, stmt->name, merge, false, true); } -static int +static bool HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge) { AliasInfo *old, new; @@ -499,7 +426,7 @@ HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge) return true; } -static int +static bool HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt) { const char *elem, *field; @@ -524,7 +451,7 @@ HandleKeyNameVar(KeyNamesInfo *info, VarDef *stmt) return true; } -static int +static bool HandleLedNameDef(KeyNamesInfo *info, LedNameDef *def, enum merge_mode merge) { diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/keymap-dump.c b/src/3rdparty/xkbcommon/src/xkbcomp/keymap-dump.c index 6b4c266ec0..7f70ca3481 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/keymap-dump.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/keymap-dump.c @@ -92,7 +92,7 @@ check_write_buf(struct buf *buf, const char *fmt, ...) if (printed < 0) goto err; - if (printed >= available) + if ((size_t) printed >= available) if (!do_realloc(buf, printed)) goto err; @@ -103,7 +103,7 @@ check_write_buf(struct buf *buf, const char *fmt, ...) printed = vsnprintf(buf->buf + buf->size, available, fmt, args); va_end(args); - if (printed >= available || printed < 0) + if (printed < 0 || (size_t) printed >= available) goto err; buf->size += printed; @@ -273,6 +273,20 @@ write_led_map(struct xkb_keymap *keymap, struct buf *buf, return true; } +static const char * +affect_lock_text(enum xkb_action_flags flags) +{ + switch (flags & (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK)) { + case ACTION_LOCK_NO_UNLOCK: + return ",affect=lock"; + case ACTION_LOCK_NO_LOCK: + return ",affect=unlock"; + case ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK: + return ",affect=neither"; + } + return ""; +} + static bool write_action(struct xkb_keymap *keymap, struct buf *buf, const union xkb_action *action, @@ -289,20 +303,17 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, type = ActionTypeText(action->type); switch (action->type) { + case ACTION_TYPE_MOD_LOCK: case ACTION_TYPE_MOD_SET: case ACTION_TYPE_MOD_LATCH: - case ACTION_TYPE_MOD_LOCK: if (action->mods.flags & ACTION_MODS_LOOKUP_MODMAP) args = "modMapMods"; else args = ModMaskText(keymap, action->mods.mods.mods); - write_buf(buf, "%s%s(modifiers=%s%s%s)%s", prefix, type, args, - (action->type != ACTION_TYPE_MOD_LOCK && - (action->mods.flags & ACTION_LOCK_CLEAR)) ? - ",clearLocks" : "", - (action->type != ACTION_TYPE_MOD_LOCK && - (action->mods.flags & ACTION_LATCH_TO_LOCK)) ? - ",latchToLock" : "", + write_buf(buf, "%s%s(modifiers=%s%s%s%s)%s", prefix, type, args, + (action->type != ACTION_TYPE_MOD_LOCK && (action->mods.flags & ACTION_LOCK_CLEAR)) ? ",clearLocks" : "", + (action->type != ACTION_TYPE_MOD_LOCK && (action->mods.flags & ACTION_LATCH_TO_LOCK)) ? ",latchToLock" : "", + (action->type == ACTION_TYPE_MOD_LOCK) ? affect_lock_text(action->mods.flags) : "", suffix); break; @@ -310,16 +321,10 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, case ACTION_TYPE_GROUP_LATCH: case ACTION_TYPE_GROUP_LOCK: write_buf(buf, "%s%s(group=%s%d%s%s)%s", prefix, type, - (!(action->group.flags & ACTION_ABSOLUTE_SWITCH) && - action->group.group > 0) ? "+" : "", - (action->group.flags & ACTION_ABSOLUTE_SWITCH) ? - action->group.group + 1 : action->group.group, - (action->type != ACTION_TYPE_GROUP_LOCK && - (action->group.flags & ACTION_LOCK_CLEAR)) ? - ",clearLocks" : "", - (action->type != ACTION_TYPE_GROUP_LOCK && - (action->group.flags & ACTION_LATCH_TO_LOCK)) ? - ",latchToLock" : "", + (!(action->group.flags & ACTION_ABSOLUTE_SWITCH) && action->group.group > 0) ? "+" : "", + (action->group.flags & ACTION_ABSOLUTE_SWITCH) ? action->group.group + 1 : action->group.group, + (action->type != ACTION_TYPE_GROUP_LOCK && (action->group.flags & ACTION_LOCK_CLEAR)) ? ",clearLocks" : "", + (action->type != ACTION_TYPE_GROUP_LOCK && (action->group.flags & ACTION_LATCH_TO_LOCK)) ? ",latchToLock" : "", suffix); break; @@ -329,35 +334,17 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, case ACTION_TYPE_PTR_MOVE: write_buf(buf, "%s%s(x=%s%d,y=%s%d%s)%s", prefix, type, - (!(action->ptr.flags & ACTION_ABSOLUTE_X) && - action->ptr.x >= 0) ? "+" : "", + (!(action->ptr.flags & ACTION_ABSOLUTE_X) && action->ptr.x >= 0) ? "+" : "", action->ptr.x, - (!(action->ptr.flags & ACTION_ABSOLUTE_Y) && - action->ptr.y >= 0) ? "+" : "", + (!(action->ptr.flags & ACTION_ABSOLUTE_Y) && action->ptr.y >= 0) ? "+" : "", action->ptr.y, - (action->ptr.flags & ACTION_NO_ACCEL) ? ",!accel" : "", + (action->ptr.flags & ACTION_ACCEL) ? "" : ",!accel", suffix); break; case ACTION_TYPE_PTR_LOCK: - switch (action->btn.flags & - (ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK)) { - case ACTION_LOCK_NO_UNLOCK: - args = ",affect=lock"; - break; - - case ACTION_LOCK_NO_LOCK: - args = ",affect=unlock"; - break; - - case ACTION_LOCK_NO_LOCK | ACTION_LOCK_NO_UNLOCK: - args = ",affect=neither"; - break; - - default: - args = ",affect=both"; - break; - } + args = affect_lock_text(action->btn.flags); + /* fallthrough */ case ACTION_TYPE_PTR_BUTTON: write_buf(buf, "%s%s(button=", prefix, type); if (action->btn.button > 0 && action->btn.button <= 5) @@ -374,25 +361,25 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, case ACTION_TYPE_PTR_DEFAULT: write_buf(buf, "%s%s(", prefix, type); write_buf(buf, "affect=button,button=%s%d", - (!(action->dflt.flags & ACTION_ABSOLUTE_SWITCH) && - action->dflt.value >= 0) ? "+" : "", + (!(action->dflt.flags & ACTION_ABSOLUTE_SWITCH) && action->dflt.value >= 0) ? "+" : "", action->dflt.value); write_buf(buf, ")%s", suffix); break; case ACTION_TYPE_SWITCH_VT: write_buf(buf, "%s%s(screen=%s%d,%ssame)%s", prefix, type, - (!(action->screen.flags & ACTION_ABSOLUTE_SWITCH) && - action->screen.screen >= 0) ? "+" : "", + (!(action->screen.flags & ACTION_ABSOLUTE_SWITCH) && action->screen.screen >= 0) ? "+" : "", action->screen.screen, - (action->screen.flags & ACTION_SAME_SCREEN) ? "!" : "", + (action->screen.flags & ACTION_SAME_SCREEN) ? "" : "!", suffix); break; case ACTION_TYPE_CTRL_SET: case ACTION_TYPE_CTRL_LOCK: - write_buf(buf, "%s%s(controls=%s)%s", prefix, type, - ControlMaskText(keymap->ctx, action->ctrls.ctrls), suffix); + write_buf(buf, "%s%s(controls=%s%s)%s", prefix, type, + ControlMaskText(keymap->ctx, action->ctrls.ctrls), + (action->type == ACTION_TYPE_CTRL_LOCK) ? affect_lock_text(action->ctrls.flags) : "", + suffix); break; case ACTION_TYPE_NONE: @@ -429,7 +416,7 @@ write_compat(struct xkb_keymap *keymap, struct buf *buf) write_buf(buf, "\tinterpret.useModMapMods= AnyLevel;\n"); write_buf(buf, "\tinterpret.repeat= False;\n"); - for (int i = 0; i < keymap->num_sym_interprets; i++) { + for (unsigned i = 0; i < keymap->num_sym_interprets; i++) { const struct xkb_sym_interpret *si = &keymap->sym_interprets[i]; write_buf(buf, "\tinterpret %s+%s(%s) {\n", @@ -635,7 +622,7 @@ write_symbols(struct xkb_keymap *keymap, struct buf *buf) continue; darray_enumerate(i, mod, keymap->mods) - if (key->modmap & (1 << i)) + if (key->modmap & (1u << i)) write_buf(buf, "\tmodifier_map %s { %s };\n", xkb_atom_text(keymap->ctx, mod->name), KeyNameText(keymap->ctx, key->name)); diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/keymap.c b/src/3rdparty/xkbcommon/src/xkbcomp/keymap.c index 549cf05da6..8a70577faf 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/keymap.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/keymap.c @@ -39,7 +39,7 @@ ComputeEffectiveMask(struct xkb_keymap *keymap, struct xkb_mods *mods) mods->mask = mods->mods & MOD_REAL_MASK_ALL; darray_enumerate(i, mod, keymap->mods) - if (mods->mods & (1 << i)) + if (mods->mods & (1u << i)) mods->mask |= mod->mapping; } @@ -92,7 +92,7 @@ FindInterpForKey(struct xkb_keymap *keymap, const struct xkb_key *key, * sym_interprets array from the most specific to the least specific, * such that when we find a match we return immediately. */ - for (int i = 0; i < keymap->num_sym_interprets; i++) { + for (unsigned i = 0; i < keymap->num_sym_interprets; i++) { const struct xkb_sym_interpret *interp = &keymap->sym_interprets[i]; xkb_mod_mask_t mods; @@ -158,7 +158,7 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, struct xkb_key *key) if ((group == 0 && level == 0) || !interp->level_one_only) if (interp->virtual_mod != XKB_MOD_INVALID) - vmodmap |= (1 << interp->virtual_mod); + vmodmap |= (1u << interp->virtual_mod); if (interp->action.type != ACTION_TYPE_NONE) key->groups[group].levels[level].action = interp->action; @@ -194,7 +194,7 @@ UpdateDerivedKeymapFields(struct xkb_keymap *keymap) /* Update keymap->mods, the virtual -> real mod mapping. */ xkb_foreach_key(key, keymap) darray_enumerate(i, mod, keymap->mods) - if (key->vmodmap & (1 << i)) + if (key->vmodmap & (1u << i)) mod->mapping |= key->modmap; /* Now update the level masks for all the types to reflect the vmods. */ diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/keywords.c b/src/3rdparty/xkbcommon/src/xkbcomp/keywords.c index c19d66ffde..abab7fe266 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/keywords.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/keywords.c @@ -339,10 +339,9 @@ keyword_gperf_lookup (register const char *str, register unsigned int len) int -keyword_to_token(const char *string) +keyword_to_token(const char *string, unsigned int len) { - const struct keyword_tok *kt; - kt = keyword_gperf_lookup(string, strlen(string)); + const struct keyword_tok *kt = keyword_gperf_lookup(string, len); if (!kt) return -1; return kt->tok; diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/parser-priv.h b/src/3rdparty/xkbcommon/src/xkbcomp/parser-priv.h index 05e725eb00..0675e55a8f 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/parser-priv.h +++ b/src/3rdparty/xkbcommon/src/xkbcomp/parser-priv.h @@ -27,24 +27,18 @@ #ifndef XKBCOMP_PARSER_PRIV_H #define XKBCOMP_PARSER_PRIV_H -struct scanner; struct parser_param; +#include "scanner-utils.h" #include "parser.h" int -scanner_error(struct scanner *scanner, const char *msg); - -void -scanner_warn(struct scanner *s, const char *msg); - -int _xkbcommon_lex(YYSTYPE *yylval, struct scanner *scanner); XkbFile * -parse(struct xkb_context *ctx, void *scanner, const char *map); +parse(struct xkb_context *ctx, struct scanner *scanner, const char *map); int -keyword_to_token(const char *string); +keyword_to_token(const char *string, unsigned int len); #endif diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/parser.c b/src/3rdparty/xkbcommon/src/xkbcomp/parser.c index 26bbf30be8..eaa7384369 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/parser.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/parser.c @@ -82,27 +82,21 @@ struct parser_param { struct xkb_context *ctx; - void *scanner; + struct scanner *scanner; XkbFile *rtrn; bool more_maps; }; -static void -parser_error(struct parser_param *param, const char *msg) -{ - scanner_error(param->scanner, msg); -} +#define parser_err(param, fmt, ...) \ + scanner_err((param)->scanner, fmt, ##__VA_ARGS__) -static void -parser_warn(struct parser_param *param, const char *msg) -{ - scanner_warn(param->scanner, msg); -} +#define parser_warn(param, fmt, ...) \ + scanner_warn((param)->scanner, fmt, ##__VA_ARGS__) static void _xkbcommon_error(struct parser_param *param, const char *msg) { - parser_error(param, msg); + parser_err(param, "%s", msg); } static bool @@ -129,11 +123,11 @@ resolve_keysym(const char *str, xkb_keysym_t *sym_rtrn) return false; } -#define scanner param->scanner +#define param_scanner param->scanner /* Line 268 of yacc.c */ -#line 137 "src/xkbcomp/parser.c" +#line 131 "src/xkbcomp/parser.c" /* Enabling traces. */ #ifndef YYDEBUG @@ -298,7 +292,7 @@ typedef union YYSTYPE { /* Line 293 of yacc.c */ -#line 167 "parser.y" +#line 161 "parser.y" int ival; int64_t num; @@ -327,7 +321,7 @@ typedef union YYSTYPE /* Line 293 of yacc.c */ -#line 331 "src/xkbcomp/parser.c" +#line 325 "src/xkbcomp/parser.c" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -339,7 +333,7 @@ typedef union YYSTYPE /* Line 343 of yacc.c */ -#line 343 "src/xkbcomp/parser.c" +#line 337 "src/xkbcomp/parser.c" #ifdef short # undef short @@ -698,25 +692,25 @@ static const yytype_int16 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 238, 238, 240, 242, 246, 252, 253, 254, 257, - 264, 268, 283, 284, 285, 286, 287, 290, 291, 294, - 295, 298, 299, 300, 301, 302, 303, 304, 305, 308, - 310, 313, 318, 323, 328, 333, 338, 343, 348, 353, - 358, 363, 368, 369, 370, 371, 378, 380, 382, 386, - 390, 394, 398, 400, 404, 406, 410, 416, 418, 422, - 424, 428, 434, 440, 442, 444, 447, 448, 449, 450, - 451, 454, 456, 460, 464, 468, 472, 474, 478, 480, - 484, 488, 489, 492, 494, 496, 498, 500, 504, 505, - 508, 509, 513, 514, 517, 519, 523, 527, 528, 531, - 534, 536, 540, 542, 544, 548, 550, 554, 558, 562, - 563, 564, 565, 568, 569, 572, 574, 576, 578, 580, - 582, 584, 586, 588, 590, 592, 596, 597, 600, 601, - 602, 603, 604, 614, 615, 618, 620, 624, 626, 628, - 630, 632, 634, 638, 640, 642, 644, 646, 648, 650, - 652, 656, 658, 662, 666, 668, 670, 672, 676, 678, + 0, 232, 232, 234, 236, 240, 246, 247, 248, 251, + 259, 263, 278, 279, 280, 281, 282, 285, 286, 289, + 290, 293, 294, 295, 296, 297, 298, 299, 300, 303, + 305, 308, 313, 318, 323, 328, 333, 338, 343, 348, + 353, 358, 363, 364, 365, 366, 373, 375, 377, 381, + 385, 389, 393, 396, 400, 402, 406, 412, 414, 418, + 421, 425, 431, 437, 440, 442, 445, 446, 447, 448, + 449, 452, 454, 458, 462, 466, 470, 472, 476, 478, + 482, 486, 487, 490, 492, 494, 496, 498, 502, 503, + 506, 507, 511, 512, 515, 517, 521, 525, 526, 529, + 532, 534, 538, 540, 542, 546, 548, 552, 556, 560, + 561, 562, 563, 566, 567, 570, 572, 574, 576, 578, + 580, 582, 584, 586, 588, 590, 594, 595, 598, 599, + 600, 601, 602, 612, 613, 616, 619, 623, 625, 627, + 629, 631, 633, 637, 639, 641, 643, 645, 647, 649, + 651, 655, 658, 662, 666, 668, 670, 672, 676, 678, 680, 682, 686, 687, 690, 692, 694, 696, 700, 704, - 710, 711, 725, 726, 729, 730, 733, 736, 739, 742, - 743, 746, 749, 750, 753 + 710, 711, 731, 732, 735, 736, 739, 742, 745, 748, + 749, 752, 755, 756, 759 }; #endif @@ -1217,7 +1211,7 @@ while (YYID (0)) #ifdef YYLEX_PARAM # define YYLEX yylex (&yylval, YYLEX_PARAM) #else -# define YYLEX yylex (&yylval, scanner) +# define YYLEX yylex (&yylval, param_scanner) #endif /* Enable debugging if requested. */ @@ -1970,75 +1964,76 @@ yyreduce: case 2: /* Line 1806 of yacc.c */ -#line 239 "parser.y" +#line 233 "parser.y" { (yyval.file) = param->rtrn = (yyvsp[(1) - (1)].file); param->more_maps = true; } break; case 3: /* Line 1806 of yacc.c */ -#line 241 "parser.y" +#line 235 "parser.y" { (yyval.file) = param->rtrn = (yyvsp[(1) - (1)].file); param->more_maps = true; YYACCEPT; } break; case 4: /* Line 1806 of yacc.c */ -#line 243 "parser.y" +#line 237 "parser.y" { (yyval.file) = param->rtrn = NULL; param->more_maps = false; } break; case 5: /* Line 1806 of yacc.c */ -#line 249 "parser.y" - { (yyval.file) = XkbFileCreate(param->ctx, (yyvsp[(2) - (7)].file_type), (yyvsp[(3) - (7)].str), &(yyvsp[(5) - (7)].file)->common, (yyvsp[(1) - (7)].mapFlags)); } +#line 243 "parser.y" + { (yyval.file) = XkbFileCreate((yyvsp[(2) - (7)].file_type), (yyvsp[(3) - (7)].str), (ParseCommon *) (yyvsp[(5) - (7)].file), (yyvsp[(1) - (7)].mapFlags)); } break; case 6: /* Line 1806 of yacc.c */ -#line 252 "parser.y" +#line 246 "parser.y" { (yyval.file_type) = FILE_TYPE_KEYMAP; } break; case 7: /* Line 1806 of yacc.c */ -#line 253 "parser.y" +#line 247 "parser.y" { (yyval.file_type) = FILE_TYPE_KEYMAP; } break; case 8: /* Line 1806 of yacc.c */ -#line 254 "parser.y" +#line 248 "parser.y" { (yyval.file_type) = FILE_TYPE_KEYMAP; } break; case 9: /* Line 1806 of yacc.c */ -#line 258 "parser.y" +#line 252 "parser.y" { if (!(yyvsp[(2) - (2)].file)) (yyval.file) = (yyvsp[(1) - (2)].file); else - (yyval.file) = (XkbFile *)AppendStmt(&(yyvsp[(1) - (2)].file)->common, &(yyvsp[(2) - (2)].file)->common); + (yyval.file) = (XkbFile *) AppendStmt((ParseCommon *) (yyvsp[(1) - (2)].file), + (ParseCommon *) (yyvsp[(2) - (2)].file)); } break; case 10: /* Line 1806 of yacc.c */ -#line 265 "parser.y" +#line 260 "parser.y" { (yyval.file) = (yyvsp[(1) - (1)].file); } break; case 11: /* Line 1806 of yacc.c */ -#line 271 "parser.y" +#line 266 "parser.y" { if ((yyvsp[(2) - (7)].file_type) == FILE_TYPE_GEOMETRY) { free((yyvsp[(3) - (7)].str)); @@ -2046,7 +2041,7 @@ yyreduce: (yyval.file) = NULL; } else { - (yyval.file) = XkbFileCreate(param->ctx, (yyvsp[(2) - (7)].file_type), (yyvsp[(3) - (7)].str), (yyvsp[(5) - (7)].any), (yyvsp[(1) - (7)].mapFlags)); + (yyval.file) = XkbFileCreate((yyvsp[(2) - (7)].file_type), (yyvsp[(3) - (7)].str), (yyvsp[(5) - (7)].any), (yyvsp[(1) - (7)].mapFlags)); } } break; @@ -2054,273 +2049,273 @@ yyreduce: case 12: /* Line 1806 of yacc.c */ -#line 283 "parser.y" +#line 278 "parser.y" { (yyval.file_type) = FILE_TYPE_KEYCODES; } break; case 13: /* Line 1806 of yacc.c */ -#line 284 "parser.y" +#line 279 "parser.y" { (yyval.file_type) = FILE_TYPE_TYPES; } break; case 14: /* Line 1806 of yacc.c */ -#line 285 "parser.y" +#line 280 "parser.y" { (yyval.file_type) = FILE_TYPE_COMPAT; } break; case 15: /* Line 1806 of yacc.c */ -#line 286 "parser.y" +#line 281 "parser.y" { (yyval.file_type) = FILE_TYPE_SYMBOLS; } break; case 16: /* Line 1806 of yacc.c */ -#line 287 "parser.y" +#line 282 "parser.y" { (yyval.file_type) = FILE_TYPE_GEOMETRY; } break; case 17: /* Line 1806 of yacc.c */ -#line 290 "parser.y" +#line 285 "parser.y" { (yyval.mapFlags) = (yyvsp[(1) - (1)].mapFlags); } break; case 18: /* Line 1806 of yacc.c */ -#line 291 "parser.y" +#line 286 "parser.y" { (yyval.mapFlags) = 0; } break; case 19: /* Line 1806 of yacc.c */ -#line 294 "parser.y" +#line 289 "parser.y" { (yyval.mapFlags) = ((yyvsp[(1) - (2)].mapFlags) | (yyvsp[(2) - (2)].mapFlags)); } break; case 20: /* Line 1806 of yacc.c */ -#line 295 "parser.y" +#line 290 "parser.y" { (yyval.mapFlags) = (yyvsp[(1) - (1)].mapFlags); } break; case 21: /* Line 1806 of yacc.c */ -#line 298 "parser.y" +#line 293 "parser.y" { (yyval.mapFlags) = MAP_IS_PARTIAL; } break; case 22: /* Line 1806 of yacc.c */ -#line 299 "parser.y" +#line 294 "parser.y" { (yyval.mapFlags) = MAP_IS_DEFAULT; } break; case 23: /* Line 1806 of yacc.c */ -#line 300 "parser.y" +#line 295 "parser.y" { (yyval.mapFlags) = MAP_IS_HIDDEN; } break; case 24: /* Line 1806 of yacc.c */ -#line 301 "parser.y" +#line 296 "parser.y" { (yyval.mapFlags) = MAP_HAS_ALPHANUMERIC; } break; case 25: /* Line 1806 of yacc.c */ -#line 302 "parser.y" +#line 297 "parser.y" { (yyval.mapFlags) = MAP_HAS_MODIFIER; } break; case 26: /* Line 1806 of yacc.c */ -#line 303 "parser.y" +#line 298 "parser.y" { (yyval.mapFlags) = MAP_HAS_KEYPAD; } break; case 27: /* Line 1806 of yacc.c */ -#line 304 "parser.y" +#line 299 "parser.y" { (yyval.mapFlags) = MAP_HAS_FN; } break; case 28: /* Line 1806 of yacc.c */ -#line 305 "parser.y" +#line 300 "parser.y" { (yyval.mapFlags) = MAP_IS_ALTGR; } break; case 29: /* Line 1806 of yacc.c */ -#line 309 "parser.y" +#line 304 "parser.y" { (yyval.any) = AppendStmt((yyvsp[(1) - (2)].any), (yyvsp[(2) - (2)].any)); } break; case 30: /* Line 1806 of yacc.c */ -#line 310 "parser.y" +#line 305 "parser.y" { (yyval.any) = NULL; } break; case 31: /* Line 1806 of yacc.c */ -#line 314 "parser.y" +#line 309 "parser.y" { (yyvsp[(2) - (2)].var)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].var)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].var); } break; case 32: /* Line 1806 of yacc.c */ -#line 319 "parser.y" +#line 314 "parser.y" { (yyvsp[(2) - (2)].vmod)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].vmod)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].vmod); } break; case 33: /* Line 1806 of yacc.c */ -#line 324 "parser.y" +#line 319 "parser.y" { (yyvsp[(2) - (2)].interp)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].interp)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].interp); } break; case 34: /* Line 1806 of yacc.c */ -#line 329 "parser.y" +#line 324 "parser.y" { (yyvsp[(2) - (2)].keyCode)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].keyCode)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].keyCode); } break; case 35: /* Line 1806 of yacc.c */ -#line 334 "parser.y" +#line 329 "parser.y" { (yyvsp[(2) - (2)].keyAlias)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].keyAlias)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].keyAlias); } break; case 36: /* Line 1806 of yacc.c */ -#line 339 "parser.y" +#line 334 "parser.y" { (yyvsp[(2) - (2)].keyType)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].keyType)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].keyType); } break; case 37: /* Line 1806 of yacc.c */ -#line 344 "parser.y" +#line 339 "parser.y" { (yyvsp[(2) - (2)].syms)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].syms)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].syms); } break; case 38: /* Line 1806 of yacc.c */ -#line 349 "parser.y" +#line 344 "parser.y" { (yyvsp[(2) - (2)].modMask)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].modMask)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].modMask); } break; case 39: /* Line 1806 of yacc.c */ -#line 354 "parser.y" +#line 349 "parser.y" { (yyvsp[(2) - (2)].groupCompat)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].groupCompat)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].groupCompat); } break; case 40: /* Line 1806 of yacc.c */ -#line 359 "parser.y" +#line 354 "parser.y" { (yyvsp[(2) - (2)].ledMap)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].ledMap)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].ledMap); } break; case 41: /* Line 1806 of yacc.c */ -#line 364 "parser.y" +#line 359 "parser.y" { (yyvsp[(2) - (2)].ledName)->merge = (yyvsp[(1) - (2)].merge); - (yyval.any) = &(yyvsp[(2) - (2)].ledName)->common; + (yyval.any) = (ParseCommon *) (yyvsp[(2) - (2)].ledName); } break; case 42: /* Line 1806 of yacc.c */ -#line 368 "parser.y" +#line 363 "parser.y" { (yyval.any) = NULL; } break; case 43: /* Line 1806 of yacc.c */ -#line 369 "parser.y" +#line 364 "parser.y" { (yyval.any) = NULL; } break; case 44: /* Line 1806 of yacc.c */ -#line 370 "parser.y" +#line 365 "parser.y" { (yyval.any) = NULL; } break; case 45: /* Line 1806 of yacc.c */ -#line 372 "parser.y" +#line 367 "parser.y" { - (yyval.any) = &IncludeCreate(param->ctx, (yyvsp[(2) - (2)].str), (yyvsp[(1) - (2)].merge))->common; + (yyval.any) = (ParseCommon *) IncludeCreate(param->ctx, (yyvsp[(2) - (2)].str), (yyvsp[(1) - (2)].merge)); free((yyvsp[(2) - (2)].str)); } break; @@ -2328,609 +2323,612 @@ yyreduce: case 46: /* Line 1806 of yacc.c */ -#line 379 "parser.y" +#line 374 "parser.y" { (yyval.var) = VarCreate((yyvsp[(1) - (4)].expr), (yyvsp[(3) - (4)].expr)); } break; case 47: /* Line 1806 of yacc.c */ -#line 381 "parser.y" +#line 376 "parser.y" { (yyval.var) = BoolVarCreate((yyvsp[(1) - (2)].sval), true); } break; case 48: /* Line 1806 of yacc.c */ -#line 383 "parser.y" +#line 378 "parser.y" { (yyval.var) = BoolVarCreate((yyvsp[(2) - (3)].sval), false); } break; case 49: /* Line 1806 of yacc.c */ -#line 387 "parser.y" +#line 382 "parser.y" { (yyval.keyCode) = KeycodeCreate((yyvsp[(1) - (4)].sval), (yyvsp[(3) - (4)].num)); } break; case 50: /* Line 1806 of yacc.c */ -#line 391 "parser.y" +#line 386 "parser.y" { (yyval.keyAlias) = KeyAliasCreate((yyvsp[(2) - (5)].sval), (yyvsp[(4) - (5)].sval)); } break; case 51: /* Line 1806 of yacc.c */ -#line 395 "parser.y" +#line 390 "parser.y" { (yyval.vmod) = (yyvsp[(2) - (3)].vmod); } break; case 52: /* Line 1806 of yacc.c */ -#line 399 "parser.y" - { (yyval.vmod) = (VModDef *)AppendStmt(&(yyvsp[(1) - (3)].vmod)->common, &(yyvsp[(3) - (3)].vmod)->common); } +#line 394 "parser.y" + { (yyval.vmod) = (VModDef *) AppendStmt((ParseCommon *) (yyvsp[(1) - (3)].vmod), + (ParseCommon *) (yyvsp[(3) - (3)].vmod)); } break; case 53: /* Line 1806 of yacc.c */ -#line 401 "parser.y" +#line 397 "parser.y" { (yyval.vmod) = (yyvsp[(1) - (1)].vmod); } break; case 54: /* Line 1806 of yacc.c */ -#line 405 "parser.y" +#line 401 "parser.y" { (yyval.vmod) = VModCreate((yyvsp[(1) - (1)].sval), NULL); } break; case 55: /* Line 1806 of yacc.c */ -#line 407 "parser.y" +#line 403 "parser.y" { (yyval.vmod) = VModCreate((yyvsp[(1) - (3)].sval), (yyvsp[(3) - (3)].expr)); } break; case 56: /* Line 1806 of yacc.c */ -#line 413 "parser.y" +#line 409 "parser.y" { (yyvsp[(2) - (6)].interp)->def = (yyvsp[(4) - (6)].var); (yyval.interp) = (yyvsp[(2) - (6)].interp); } break; case 57: /* Line 1806 of yacc.c */ -#line 417 "parser.y" +#line 413 "parser.y" { (yyval.interp) = InterpCreate((yyvsp[(1) - (3)].keysym), (yyvsp[(3) - (3)].expr)); } break; case 58: /* Line 1806 of yacc.c */ -#line 419 "parser.y" +#line 415 "parser.y" { (yyval.interp) = InterpCreate((yyvsp[(1) - (1)].keysym), NULL); } break; case 59: /* Line 1806 of yacc.c */ -#line 423 "parser.y" - { (yyval.var) = (VarDef *)AppendStmt(&(yyvsp[(1) - (2)].var)->common, &(yyvsp[(2) - (2)].var)->common); } +#line 419 "parser.y" + { (yyval.var) = (VarDef *) AppendStmt((ParseCommon *) (yyvsp[(1) - (2)].var), + (ParseCommon *) (yyvsp[(2) - (2)].var)); } break; case 60: /* Line 1806 of yacc.c */ -#line 425 "parser.y" +#line 422 "parser.y" { (yyval.var) = (yyvsp[(1) - (1)].var); } break; case 61: /* Line 1806 of yacc.c */ -#line 431 "parser.y" +#line 428 "parser.y" { (yyval.keyType) = KeyTypeCreate((yyvsp[(2) - (6)].sval), (yyvsp[(4) - (6)].var)); } break; case 62: /* Line 1806 of yacc.c */ -#line 437 "parser.y" +#line 434 "parser.y" { (yyval.syms) = SymbolsCreate((yyvsp[(2) - (6)].sval), (yyvsp[(4) - (6)].var)); } break; case 63: /* Line 1806 of yacc.c */ -#line 441 "parser.y" - { (yyval.var) = (VarDef *)AppendStmt(&(yyvsp[(1) - (3)].var)->common, &(yyvsp[(3) - (3)].var)->common); } +#line 438 "parser.y" + { (yyval.var) = (VarDef *) AppendStmt((ParseCommon *) (yyvsp[(1) - (3)].var), + (ParseCommon *) (yyvsp[(3) - (3)].var)); } break; case 64: /* Line 1806 of yacc.c */ -#line 443 "parser.y" +#line 441 "parser.y" { (yyval.var) = (yyvsp[(1) - (1)].var); } break; case 65: /* Line 1806 of yacc.c */ -#line 444 "parser.y" +#line 442 "parser.y" { (yyval.var) = NULL; } break; case 66: /* Line 1806 of yacc.c */ -#line 447 "parser.y" +#line 445 "parser.y" { (yyval.var) = VarCreate((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 67: /* Line 1806 of yacc.c */ -#line 448 "parser.y" +#line 446 "parser.y" { (yyval.var) = VarCreate((yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 68: /* Line 1806 of yacc.c */ -#line 449 "parser.y" +#line 447 "parser.y" { (yyval.var) = BoolVarCreate((yyvsp[(1) - (1)].sval), true); } break; case 69: /* Line 1806 of yacc.c */ -#line 450 "parser.y" +#line 448 "parser.y" { (yyval.var) = BoolVarCreate((yyvsp[(2) - (2)].sval), false); } break; case 70: /* Line 1806 of yacc.c */ -#line 451 "parser.y" +#line 449 "parser.y" { (yyval.var) = VarCreate(NULL, (yyvsp[(1) - (1)].expr)); } break; case 71: /* Line 1806 of yacc.c */ -#line 455 "parser.y" +#line 453 "parser.y" { (yyval.expr) = (yyvsp[(2) - (3)].expr); } break; case 72: /* Line 1806 of yacc.c */ -#line 457 "parser.y" +#line 455 "parser.y" { (yyval.expr) = ExprCreateUnary(EXPR_ACTION_LIST, EXPR_TYPE_ACTION, (yyvsp[(2) - (3)].expr)); } break; case 73: /* Line 1806 of yacc.c */ -#line 461 "parser.y" +#line 459 "parser.y" { (yyval.groupCompat) = GroupCompatCreate((yyvsp[(2) - (5)].ival), (yyvsp[(4) - (5)].expr)); } break; case 74: /* Line 1806 of yacc.c */ -#line 465 "parser.y" +#line 463 "parser.y" { (yyval.modMask) = ModMapCreate((yyvsp[(2) - (6)].sval), (yyvsp[(4) - (6)].expr)); } break; case 75: /* Line 1806 of yacc.c */ -#line 469 "parser.y" +#line 467 "parser.y" { (yyval.ledMap) = LedMapCreate((yyvsp[(2) - (6)].sval), (yyvsp[(4) - (6)].var)); } break; case 76: /* Line 1806 of yacc.c */ -#line 473 "parser.y" +#line 471 "parser.y" { (yyval.ledName) = LedNameCreate((yyvsp[(2) - (5)].ival), (yyvsp[(4) - (5)].expr), false); } break; case 77: /* Line 1806 of yacc.c */ -#line 475 "parser.y" +#line 473 "parser.y" { (yyval.ledName) = LedNameCreate((yyvsp[(3) - (6)].ival), (yyvsp[(5) - (6)].expr), true); } break; case 78: /* Line 1806 of yacc.c */ -#line 479 "parser.y" +#line 477 "parser.y" { (yyval.geom) = NULL; } break; case 79: /* Line 1806 of yacc.c */ -#line 481 "parser.y" +#line 479 "parser.y" { (yyval.geom) = NULL; } break; case 80: /* Line 1806 of yacc.c */ -#line 485 "parser.y" +#line 483 "parser.y" { (yyval.geom) = NULL; } break; case 81: /* Line 1806 of yacc.c */ -#line 488 "parser.y" +#line 486 "parser.y" { (yyval.geom) = NULL;} break; case 82: /* Line 1806 of yacc.c */ -#line 489 "parser.y" +#line 487 "parser.y" { (yyval.geom) = NULL; } break; case 83: /* Line 1806 of yacc.c */ -#line 493 "parser.y" +#line 491 "parser.y" { (yyval.geom) = NULL; } break; case 84: /* Line 1806 of yacc.c */ -#line 495 "parser.y" - { FreeStmt(&(yyvsp[(1) - (1)].var)->common); (yyval.geom) = NULL; } +#line 493 "parser.y" + { FreeStmt((ParseCommon *) (yyvsp[(1) - (1)].var)); (yyval.geom) = NULL; } break; case 85: /* Line 1806 of yacc.c */ -#line 497 "parser.y" +#line 495 "parser.y" { (yyval.geom) = NULL; } break; case 86: /* Line 1806 of yacc.c */ -#line 499 "parser.y" - { FreeStmt(&(yyvsp[(1) - (1)].ledMap)->common); (yyval.geom) = NULL; } +#line 497 "parser.y" + { FreeStmt((ParseCommon *) (yyvsp[(1) - (1)].ledMap)); (yyval.geom) = NULL; } break; case 87: /* Line 1806 of yacc.c */ -#line 501 "parser.y" +#line 499 "parser.y" { (yyval.geom) = NULL; } break; case 88: /* Line 1806 of yacc.c */ -#line 504 "parser.y" +#line 502 "parser.y" { (yyval.geom) = NULL;} break; case 89: /* Line 1806 of yacc.c */ -#line 505 "parser.y" +#line 503 "parser.y" { (yyval.geom) = NULL; } break; case 90: /* Line 1806 of yacc.c */ -#line 508 "parser.y" +#line 506 "parser.y" { (yyval.geom) = NULL; } break; case 91: /* Line 1806 of yacc.c */ -#line 510 "parser.y" - { FreeStmt(&(yyvsp[(1) - (1)].var)->common); (yyval.geom) = NULL; } +#line 508 "parser.y" + { FreeStmt((ParseCommon *) (yyvsp[(1) - (1)].var)); (yyval.geom) = NULL; } break; case 92: /* Line 1806 of yacc.c */ -#line 513 "parser.y" +#line 511 "parser.y" { (yyval.geom) = NULL; } break; case 93: /* Line 1806 of yacc.c */ -#line 514 "parser.y" +#line 512 "parser.y" { (yyval.geom) = NULL; } break; case 94: /* Line 1806 of yacc.c */ -#line 518 "parser.y" +#line 516 "parser.y" { (yyval.geom) = NULL; } break; case 95: /* Line 1806 of yacc.c */ -#line 520 "parser.y" - { FreeStmt(&(yyvsp[(2) - (3)].expr)->common); (yyval.geom) = NULL; } +#line 518 "parser.y" + { FreeStmt((ParseCommon *) (yyvsp[(2) - (3)].expr)); (yyval.geom) = NULL; } break; case 96: /* Line 1806 of yacc.c */ -#line 524 "parser.y" +#line 522 "parser.y" { (yyval.geom) = NULL; } break; case 97: /* Line 1806 of yacc.c */ -#line 527 "parser.y" +#line 525 "parser.y" { (yyval.geom) = NULL; } break; case 98: /* Line 1806 of yacc.c */ -#line 528 "parser.y" +#line 526 "parser.y" { (yyval.geom) = NULL; } break; case 99: /* Line 1806 of yacc.c */ -#line 531 "parser.y" +#line 529 "parser.y" { (yyval.geom) = NULL; } break; case 100: /* Line 1806 of yacc.c */ -#line 535 "parser.y" +#line 533 "parser.y" { (yyval.geom) = NULL;} break; case 101: /* Line 1806 of yacc.c */ -#line 537 "parser.y" +#line 535 "parser.y" { (yyval.geom) = NULL; } break; case 102: /* Line 1806 of yacc.c */ -#line 541 "parser.y" +#line 539 "parser.y" { (yyval.geom) = NULL; } break; case 103: /* Line 1806 of yacc.c */ -#line 543 "parser.y" +#line 541 "parser.y" { (yyval.geom) = NULL; } break; case 104: /* Line 1806 of yacc.c */ -#line 545 "parser.y" - { FreeStmt(&(yyvsp[(3) - (3)].expr)->common); (yyval.geom) = NULL; } +#line 543 "parser.y" + { FreeStmt((ParseCommon *) (yyvsp[(3) - (3)].expr)); (yyval.geom) = NULL; } break; case 105: /* Line 1806 of yacc.c */ -#line 549 "parser.y" +#line 547 "parser.y" { (yyval.expr) = NULL; } break; case 106: /* Line 1806 of yacc.c */ -#line 551 "parser.y" +#line 549 "parser.y" { (yyval.expr) = NULL; } break; case 107: /* Line 1806 of yacc.c */ -#line 555 "parser.y" +#line 553 "parser.y" { (yyval.expr) = NULL; } break; case 108: /* Line 1806 of yacc.c */ -#line 559 "parser.y" - { FreeStmt(&(yyvsp[(4) - (6)].var)->common); (yyval.geom) = NULL; } +#line 557 "parser.y" + { FreeStmt((ParseCommon *) (yyvsp[(4) - (6)].var)); (yyval.geom) = NULL; } break; case 109: /* Line 1806 of yacc.c */ -#line 562 "parser.y" +#line 560 "parser.y" { (yyval.ival) = 0; } break; case 110: /* Line 1806 of yacc.c */ -#line 563 "parser.y" +#line 561 "parser.y" { (yyval.ival) = 0; } break; case 111: /* Line 1806 of yacc.c */ -#line 564 "parser.y" +#line 562 "parser.y" { (yyval.ival) = 0; } break; case 112: /* Line 1806 of yacc.c */ -#line 565 "parser.y" +#line 563 "parser.y" { (yyval.ival) = 0; } break; case 113: /* Line 1806 of yacc.c */ -#line 568 "parser.y" +#line 566 "parser.y" { (yyval.sval) = (yyvsp[(1) - (1)].sval); } break; case 114: /* Line 1806 of yacc.c */ -#line 569 "parser.y" +#line 567 "parser.y" { (yyval.sval) = (yyvsp[(1) - (1)].sval); } break; case 115: /* Line 1806 of yacc.c */ -#line 573 "parser.y" +#line 571 "parser.y" { (yyval.sval) = xkb_atom_intern_literal(param->ctx, "action"); } break; case 116: /* Line 1806 of yacc.c */ -#line 575 "parser.y" +#line 573 "parser.y" { (yyval.sval) = xkb_atom_intern_literal(param->ctx, "interpret"); } break; case 117: /* Line 1806 of yacc.c */ -#line 577 "parser.y" +#line 575 "parser.y" { (yyval.sval) = xkb_atom_intern_literal(param->ctx, "type"); } break; case 118: /* Line 1806 of yacc.c */ -#line 579 "parser.y" +#line 577 "parser.y" { (yyval.sval) = xkb_atom_intern_literal(param->ctx, "key"); } break; case 119: /* Line 1806 of yacc.c */ -#line 581 "parser.y" +#line 579 "parser.y" { (yyval.sval) = xkb_atom_intern_literal(param->ctx, "group"); } break; case 120: /* Line 1806 of yacc.c */ -#line 583 "parser.y" +#line 581 "parser.y" {(yyval.sval) = xkb_atom_intern_literal(param->ctx, "modifier_map");} break; case 121: /* Line 1806 of yacc.c */ -#line 585 "parser.y" +#line 583 "parser.y" { (yyval.sval) = xkb_atom_intern_literal(param->ctx, "indicator"); } break; case 122: /* Line 1806 of yacc.c */ -#line 587 "parser.y" +#line 585 "parser.y" { (yyval.sval) = XKB_ATOM_NONE; } break; case 123: /* Line 1806 of yacc.c */ -#line 589 "parser.y" +#line 587 "parser.y" { (yyval.sval) = XKB_ATOM_NONE; } break; case 124: /* Line 1806 of yacc.c */ -#line 591 "parser.y" +#line 589 "parser.y" { (yyval.sval) = XKB_ATOM_NONE; } break; case 125: /* Line 1806 of yacc.c */ -#line 593 "parser.y" +#line 591 "parser.y" { (yyval.sval) = XKB_ATOM_NONE; } break; case 126: /* Line 1806 of yacc.c */ -#line 596 "parser.y" +#line 594 "parser.y" { (yyval.merge) = (yyvsp[(1) - (1)].merge); } break; case 127: /* Line 1806 of yacc.c */ -#line 597 "parser.y" +#line 595 "parser.y" { (yyval.merge) = MERGE_DEFAULT; } break; case 128: /* Line 1806 of yacc.c */ -#line 600 "parser.y" +#line 598 "parser.y" { (yyval.merge) = MERGE_DEFAULT; } break; case 129: /* Line 1806 of yacc.c */ -#line 601 "parser.y" +#line 599 "parser.y" { (yyval.merge) = MERGE_AUGMENT; } break; case 130: /* Line 1806 of yacc.c */ -#line 602 "parser.y" +#line 600 "parser.y" { (yyval.merge) = MERGE_OVERRIDE; } break; case 131: /* Line 1806 of yacc.c */ -#line 603 "parser.y" +#line 601 "parser.y" { (yyval.merge) = MERGE_REPLACE; } break; case 132: /* Line 1806 of yacc.c */ -#line 605 "parser.y" +#line 603 "parser.y" { /* * This used to be MERGE_ALT_FORM. This functionality was @@ -2943,134 +2941,136 @@ yyreduce: case 133: /* Line 1806 of yacc.c */ -#line 614 "parser.y" +#line 612 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); } break; case 134: /* Line 1806 of yacc.c */ -#line 615 "parser.y" +#line 613 "parser.y" { (yyval.expr) = NULL; } break; case 135: /* Line 1806 of yacc.c */ -#line 619 "parser.y" - { (yyval.expr) = (ExprDef *)AppendStmt(&(yyvsp[(1) - (3)].expr)->common, &(yyvsp[(3) - (3)].expr)->common); } +#line 617 "parser.y" + { (yyval.expr) = (ExprDef *) AppendStmt((ParseCommon *) (yyvsp[(1) - (3)].expr), + (ParseCommon *) (yyvsp[(3) - (3)].expr)); } break; case 136: /* Line 1806 of yacc.c */ -#line 621 "parser.y" +#line 620 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); } break; case 137: /* Line 1806 of yacc.c */ -#line 625 "parser.y" +#line 624 "parser.y" { (yyval.expr) = ExprCreateBinary(EXPR_DIVIDE, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 138: /* Line 1806 of yacc.c */ -#line 627 "parser.y" +#line 626 "parser.y" { (yyval.expr) = ExprCreateBinary(EXPR_ADD, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 139: /* Line 1806 of yacc.c */ -#line 629 "parser.y" +#line 628 "parser.y" { (yyval.expr) = ExprCreateBinary(EXPR_SUBTRACT, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 140: /* Line 1806 of yacc.c */ -#line 631 "parser.y" +#line 630 "parser.y" { (yyval.expr) = ExprCreateBinary(EXPR_MULTIPLY, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 141: /* Line 1806 of yacc.c */ -#line 633 "parser.y" +#line 632 "parser.y" { (yyval.expr) = ExprCreateBinary(EXPR_ASSIGN, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); } break; case 142: /* Line 1806 of yacc.c */ -#line 635 "parser.y" +#line 634 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); } break; case 143: /* Line 1806 of yacc.c */ -#line 639 "parser.y" +#line 638 "parser.y" { (yyval.expr) = ExprCreateUnary(EXPR_NEGATE, (yyvsp[(2) - (2)].expr)->expr.value_type, (yyvsp[(2) - (2)].expr)); } break; case 144: /* Line 1806 of yacc.c */ -#line 641 "parser.y" +#line 640 "parser.y" { (yyval.expr) = ExprCreateUnary(EXPR_UNARY_PLUS, (yyvsp[(2) - (2)].expr)->expr.value_type, (yyvsp[(2) - (2)].expr)); } break; case 145: /* Line 1806 of yacc.c */ -#line 643 "parser.y" +#line 642 "parser.y" { (yyval.expr) = ExprCreateUnary(EXPR_NOT, EXPR_TYPE_BOOLEAN, (yyvsp[(2) - (2)].expr)); } break; case 146: /* Line 1806 of yacc.c */ -#line 645 "parser.y" +#line 644 "parser.y" { (yyval.expr) = ExprCreateUnary(EXPR_INVERT, (yyvsp[(2) - (2)].expr)->expr.value_type, (yyvsp[(2) - (2)].expr)); } break; case 147: /* Line 1806 of yacc.c */ -#line 647 "parser.y" +#line 646 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); } break; case 148: /* Line 1806 of yacc.c */ -#line 649 "parser.y" +#line 648 "parser.y" { (yyval.expr) = ExprCreateAction((yyvsp[(1) - (4)].sval), (yyvsp[(3) - (4)].expr)); } break; case 149: /* Line 1806 of yacc.c */ -#line 651 "parser.y" +#line 650 "parser.y" { (yyval.expr) = (yyvsp[(1) - (1)].expr); } break; case 150: /* Line 1806 of yacc.c */ -#line 653 "parser.y" +#line 652 "parser.y" { (yyval.expr) = (yyvsp[(2) - (3)].expr); } break; case 151: /* Line 1806 of yacc.c */ -#line 657 "parser.y" - { (yyval.expr) = (ExprDef *)AppendStmt(&(yyvsp[(1) - (3)].expr)->common, &(yyvsp[(3) - (3)].expr)->common); } +#line 656 "parser.y" + { (yyval.expr) = (ExprDef *) AppendStmt((ParseCommon *) (yyvsp[(1) - (3)].expr), + (ParseCommon *) (yyvsp[(3) - (3)].expr)); } break; case 152: @@ -3215,14 +3215,20 @@ yyreduce: /* Line 1806 of yacc.c */ #line 712 "parser.y" { - if ((yyvsp[(1) - (1)].ival) < 10) { /* XKB_KEY_0 .. XKB_KEY_9 */ - (yyval.keysym) = XKB_KEY_0 + (yyvsp[(1) - (1)].ival); + if ((yyvsp[(1) - (1)].ival) < 0) { + parser_warn(param, "unrecognized keysym"); + (yyval.keysym) = XKB_KEY_NoSymbol; + } + else if ((yyvsp[(1) - (1)].ival) < 10) { /* XKB_KEY_0 .. XKB_KEY_9 */ + (yyval.keysym) = XKB_KEY_0 + (xkb_keysym_t) (yyvsp[(1) - (1)].ival); } else { char buf[17]; snprintf(buf, sizeof(buf), "0x%x", (yyvsp[(1) - (1)].ival)); - if (!resolve_keysym(buf, &(yyval.keysym))) + if (!resolve_keysym(buf, &(yyval.keysym))) { parser_warn(param, "unrecognized keysym"); + (yyval.keysym) = XKB_KEY_NoSymbol; + } } } break; @@ -3230,98 +3236,98 @@ yyreduce: case 172: /* Line 1806 of yacc.c */ -#line 725 "parser.y" +#line 731 "parser.y" { (yyval.ival) = -(yyvsp[(2) - (2)].ival); } break; case 173: /* Line 1806 of yacc.c */ -#line 726 "parser.y" +#line 732 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].ival); } break; case 174: /* Line 1806 of yacc.c */ -#line 729 "parser.y" +#line 735 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].num); } break; case 175: /* Line 1806 of yacc.c */ -#line 730 "parser.y" +#line 736 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].num); } break; case 176: /* Line 1806 of yacc.c */ -#line 733 "parser.y" +#line 739 "parser.y" { (yyval.ival) = 0; } break; case 177: /* Line 1806 of yacc.c */ -#line 736 "parser.y" +#line 742 "parser.y" { (yyval.ival) = (yyvsp[(1) - (1)].num); } break; case 178: /* Line 1806 of yacc.c */ -#line 739 "parser.y" +#line 745 "parser.y" { (yyval.num) = (yyvsp[(1) - (1)].num); } break; case 179: /* Line 1806 of yacc.c */ -#line 742 "parser.y" +#line 748 "parser.y" { (yyval.sval) = xkb_atom_steal(param->ctx, (yyvsp[(1) - (1)].str)); } break; case 180: /* Line 1806 of yacc.c */ -#line 743 "parser.y" +#line 749 "parser.y" { (yyval.sval) = xkb_atom_intern_literal(param->ctx, "default"); } break; case 181: /* Line 1806 of yacc.c */ -#line 746 "parser.y" +#line 752 "parser.y" { (yyval.sval) = xkb_atom_steal(param->ctx, (yyvsp[(1) - (1)].str)); } break; case 182: /* Line 1806 of yacc.c */ -#line 749 "parser.y" +#line 755 "parser.y" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; case 183: /* Line 1806 of yacc.c */ -#line 750 "parser.y" +#line 756 "parser.y" { (yyval.str) = NULL; } break; case 184: /* Line 1806 of yacc.c */ -#line 753 "parser.y" +#line 759 "parser.y" { (yyval.str) = (yyvsp[(1) - (1)].str); } break; /* Line 1806 of yacc.c */ -#line 3325 "src/xkbcomp/parser.c" +#line 3331 "src/xkbcomp/parser.c" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -3552,13 +3558,11 @@ yyreturn: /* Line 2067 of yacc.c */ -#line 756 "parser.y" +#line 762 "parser.y" -#undef scanner - XkbFile * -parse(struct xkb_context *ctx, void *scanner, const char *map) +parse(struct xkb_context *ctx, struct scanner *scanner, const char *map) { int ret; XkbFile *first = NULL; @@ -3604,5 +3608,3 @@ parse(struct xkb_context *ctx, void *scanner, const char *map) return first; } -#define scanner param->scanner - diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/parser.h b/src/3rdparty/xkbcommon/src/xkbcomp/parser.h index f85a2bad85..ee9b4468b5 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/parser.h +++ b/src/3rdparty/xkbcommon/src/xkbcomp/parser.h @@ -175,7 +175,7 @@ typedef union YYSTYPE { /* Line 2068 of yacc.c */ -#line 167 "parser.y" +#line 161 "parser.y" int ival; int64_t num; diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/rules.c b/src/3rdparty/xkbcommon/src/xkbcomp/rules.c index de82d96119..61799e7059 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/rules.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/rules.c @@ -52,84 +52,6 @@ #include "include.h" #include "scanner-utils.h" -/* - * The rules file - * ============== - * The purpose of this file is to map between configuration values that - * are easy for a user to specify and understand, and the configuration - * values xkbcomp uses and understands. - * xkbcomp uses the xkb_component_names struct, which maps directly to - * include statements of the appropriate sections, called for short - * KcCGST (see keycodes.c, types.c, compat.c, symbols.c; geometry.c was - * removed). These are not really intuitive or straight-forward for - * the uninitiated. - * Instead, the user passes in a xkb_rule_names struct, which consists - * of the name of a rules file (in Linux this is usually "evdev"), a - * keyboard model (e.g. "pc105"), a set of layouts (which will end up - * in different groups, e.g. "us,fr"), variants (used to alter/augment - * the respective layout, e.g. "intl,dvorak"), and a set of options - * (used to tweak some general behavior of the keyboard, e.g. - * "ctrl:nocaps,compose:menu" to make the Caps Lock key act like Ctrl - * and the Menu key like Compose). We call these RMLVO. - * - * Format of the file - * ------------------ - * The file consists of rule sets, each consisting of rules (one per - * line), which match the MLVO values on the left hand side, and, if - * the values match to the values the user passed in, results in the - * values on the right hand side being added to the resulting KcCGST. - * Since some values are related and repeated often, it is possible - * to group them together and refer to them by a group name in the - * rules. - * Along with matching values by simple string equality, and for - * membership in a group defined previously, rules may also contain - * "wildcard" values - "*" - which always match. These usually appear - * near the end. - * - * Grammer - * ------- - * (It might be helpful to look at a file like rules/evdev along with - * this grammer. Comments, whitespace, etc. are not shown.) - * - * File ::= { "!" (Group | RuleSet) } - * - * Group ::= GroupName "=" { GroupElement } "\n" - * GroupName ::= "$"<ident> - * GroupElement ::= <ident> - * - * RuleSet ::= Mapping { Rule } - * - * Mapping ::= { Mlvo } "=" { Kccgst } "\n" - * Mlvo ::= "model" | "option" | ("layout" | "variant") [ Index ] - * Index ::= "[" 1..XKB_NUM_GROUPS "]" - * Kccgst ::= "keycodes" | "symbols" | "types" | "compat" | "geometry" - * - * Rule ::= { MlvoValue } "=" { KccgstValue } "\n" - * MlvoValue ::= "*" | GroupName | <ident> - * KccgstValue ::= <ident> - * - * Notes: - * - The order of values in a Rule must be the same as the Mapping it - * follows. The mapping line determines the meaning of the values in - * the rules which follow in the RuleSet. - * - If a Rule is matched, %-expansion is performed on the KccgstValue, - * as follows: - * %m, %l, %v: - * The model, layout or variant, if only one was given (e.g. - * %l for "us,il" is invalid). - * %l[1], %v[1]: - * Layout or variant for the specified group Index, if more than - * one was given (e.g. %l[1] for "us" is invalid). - * %+m, %+l, %+v, %+l[1], %+v[1] - * As above, but prefixed with '+'. Similarly, '|', '-', '_' may be - * used instead of '+'. - * %(m), %(l), %(l[1]), %(v), %(v[1]): - * As above, but prefixed by '(' and suffixed by ')'. - * In case the expansion is invalid, as described above, it is - * skipped (the rest of the string is still processed); this includes - * the prefix and suffix (that's why you shouldn't use e.g. "(%v[1])"). - */ - /* Scanner / Lexer */ /* Values returned with some tokens, like yylval. */ @@ -137,14 +59,6 @@ union lvalue { struct sval string; }; -/* - * Holds the location in the file of the last processed token, - * like yylloc. - */ -struct location { - int line, column; -}; - enum rules_token { TOK_END_OF_FILE = 0, TOK_END_OF_LINE, @@ -156,14 +70,6 @@ enum rules_token { TOK_ERROR }; -/* C99 is stupid. Just use the 1 variant when there are no args. */ -#define scanner_error1(scanner, loc, msg) \ - log_warn((scanner)->ctx, "rules/%s:%d:%d: %s\n", \ - (scanner)->file_name, (loc)->line, (loc)->column, msg) -#define scanner_error(scanner, loc, fmt, ...) \ - log_warn((scanner)->ctx, "rules/%s:%d:%d: " fmt "\n", \ - (scanner)->file_name, (loc)->line, (loc)->column, __VA_ARGS__) - static inline bool is_ident(char ch) { @@ -171,7 +77,7 @@ is_ident(char ch) } static enum rules_token -lex(struct scanner *s, union lvalue *val, struct location *loc) +lex(struct scanner *s, union lvalue *val) { skip_more_whitespace_and_comments: /* Skip spaces. */ @@ -191,8 +97,7 @@ skip_more_whitespace_and_comments: /* Escaped line continuation. */ if (chr(s, '\\')) { if (!eol(s)) { - scanner_error1(s, loc, - "illegal new line escape; must appear at end of line"); + scanner_err(s, "illegal new line escape; must appear at end of line"); return TOK_ERROR; } next(s); @@ -203,8 +108,8 @@ skip_more_whitespace_and_comments: if (eof(s)) return TOK_END_OF_FILE; /* New token. */ - loc->line = s->line; - loc->column = s->column; + s->token_line = s->line; + s->token_column = s->column; /* Operators and punctuation. */ if (chr(s, '!')) return TOK_BANG; @@ -220,8 +125,7 @@ skip_more_whitespace_and_comments: val->string.len++; } if (val->string.len == 0) { - scanner_error1(s, loc, - "unexpected character after \'$\'; expected name"); + scanner_err(s, "unexpected character after \'$\'; expected name"); return TOK_ERROR; } return TOK_GROUP_NAME; @@ -238,7 +142,7 @@ skip_more_whitespace_and_comments: return TOK_IDENTIFIER; } - scanner_error1(s, loc, "unrecognized token"); + scanner_err(s, "unrecognized token"); return TOK_ERROR; } @@ -330,7 +234,6 @@ struct matcher { struct xkb_context *ctx; /* Input.*/ struct rule_names rmlvo; - struct location loc; union lvalue val; struct scanner scanner; darray(struct group) groups; @@ -410,10 +313,8 @@ matcher_free(struct matcher *m) free(m); } -#define matcher_error1(matcher, msg) \ - scanner_error1(&(matcher)->scanner, &(matcher)->loc, msg) -#define matcher_error(matcher, fmt, ...) \ - scanner_error(&(matcher)->scanner, &(matcher)->loc, fmt, __VA_ARGS__) +#define matcher_err(matcher, fmt, ...) \ + scanner_err(&(matcher)->scanner, fmt, ## __VA_ARGS__) static void matcher_group_start_new(struct matcher *m, struct sval name) @@ -474,19 +375,15 @@ matcher_mapping_set_mlvo(struct matcher *m, struct sval ident) /* Not found. */ if (mlvo >= _MLVO_NUM_ENTRIES) { - matcher_error(m, - "invalid mapping: %.*s is not a valid value here; " - "ignoring rule set", - ident.len, ident.start); + matcher_err(m, "invalid mapping: %.*s is not a valid value here; ignoring rule set", + ident.len, ident.start); m->mapping.skip = true; return; } - if (m->mapping.defined_mlvo_mask & (1 << mlvo)) { - matcher_error(m, - "invalid mapping: %.*s appears twice on the same line; " - "ignoring rule set", - mlvo_sval.len, mlvo_sval.start); + if (m->mapping.defined_mlvo_mask & (1u << mlvo)) { + matcher_err(m, "invalid mapping: %.*s appears twice on the same line; ignoring rule set", + mlvo_sval.len, mlvo_sval.start); m->mapping.skip = true; return; } @@ -497,10 +394,8 @@ matcher_mapping_set_mlvo(struct matcher *m, struct sval ident) int consumed = extract_layout_index(ident.start + mlvo_sval.len, ident.len - mlvo_sval.len, &idx); if ((int) (ident.len - mlvo_sval.len) != consumed) { - matcher_error(m, - "invalid mapping:\" %.*s\" may only be followed by a valid group index; " - "ignoring rule set", - mlvo_sval.len, mlvo_sval.start); + matcher_err(m, "invalid mapping: \"%.*s\" may only be followed by a valid group index; ignoring rule set", + mlvo_sval.len, mlvo_sval.start); m->mapping.skip = true; return; } @@ -512,17 +407,15 @@ matcher_mapping_set_mlvo(struct matcher *m, struct sval ident) m->mapping.variant_idx = idx; } else { - matcher_error(m, - "invalid mapping: \"%.*s\" cannot be followed by a group index; " - "ignoring rule set", - mlvo_sval.len, mlvo_sval.start); + matcher_err(m, "invalid mapping: \"%.*s\" cannot be followed by a group index; ignoring rule set", + mlvo_sval.len, mlvo_sval.start); m->mapping.skip = true; return; } } m->mapping.mlvo_at_pos[m->mapping.num_mlvo] = mlvo; - m->mapping.defined_mlvo_mask |= 1 << mlvo; + m->mapping.defined_mlvo_mask |= 1u << mlvo; m->mapping.num_mlvo++; } @@ -541,25 +434,21 @@ matcher_mapping_set_kccgst(struct matcher *m, struct sval ident) /* Not found. */ if (kccgst >= _KCCGST_NUM_ENTRIES) { - matcher_error(m, - "invalid mapping: %.*s is not a valid value here; " - "ignoring rule set", - ident.len, ident.start); + matcher_err(m, "invalid mapping: %.*s is not a valid value here; ignoring rule set", + ident.len, ident.start); m->mapping.skip = true; return; } - if (m->mapping.defined_kccgst_mask & (1 << kccgst)) { - matcher_error(m, - "invalid mapping: %.*s appears twice on the same line; " - "ignoring rule set", - kccgst_sval.len, kccgst_sval.start); + if (m->mapping.defined_kccgst_mask & (1u << kccgst)) { + matcher_err(m, "invalid mapping: %.*s appears twice on the same line; ignoring rule set", + kccgst_sval.len, kccgst_sval.start); m->mapping.skip = true; return; } m->mapping.kccgst_at_pos[m->mapping.num_kccgst] = kccgst; - m->mapping.defined_kccgst_mask |= 1 << kccgst; + m->mapping.defined_kccgst_mask |= 1u << kccgst; m->mapping.num_kccgst++; } @@ -567,16 +456,12 @@ static void matcher_mapping_verify(struct matcher *m) { if (m->mapping.num_mlvo == 0) { - matcher_error1(m, - "invalid mapping: must have at least one value on the left hand side; " - "ignoring rule set"); + matcher_err(m, "invalid mapping: must have at least one value on the left hand side; ignoring rule set"); goto skip; } if (m->mapping.num_kccgst == 0) { - matcher_error1(m, - "invalid mapping: must have at least one value on the right hand side; " - "ignoring rule set"); + matcher_err(m, "invalid mapping: must have at least one value on the right hand side; ignoring rule set"); goto skip; } @@ -585,7 +470,7 @@ matcher_mapping_verify(struct matcher *m) * See the "Notes" section in the overview above. */ - if (m->mapping.defined_mlvo_mask & (1 << MLVO_LAYOUT)) { + if (m->mapping.defined_mlvo_mask & (1u << MLVO_LAYOUT)) { if (m->mapping.layout_idx == XKB_LAYOUT_INVALID) { if (darray_size(m->rmlvo.layouts) > 1) goto skip; @@ -597,7 +482,7 @@ matcher_mapping_verify(struct matcher *m) } } - if (m->mapping.defined_mlvo_mask & (1 << MLVO_VARIANT)) { + if (m->mapping.defined_mlvo_mask & (1u << MLVO_VARIANT)) { if (m->mapping.variant_idx == XKB_LAYOUT_INVALID) { if (darray_size(m->rmlvo.variants) > 1) goto skip; @@ -627,9 +512,7 @@ matcher_rule_set_mlvo_common(struct matcher *m, struct sval ident, enum mlvo_match_type match_type) { if (m->rule.num_mlvo_values + 1 > m->mapping.num_mlvo) { - matcher_error1(m, - "invalid rule: has more values than the mapping line; " - "ignoring rule"); + matcher_err(m, "invalid rule: has more values than the mapping line; ignoring rule"); m->rule.skip = true; return; } @@ -661,9 +544,7 @@ static void matcher_rule_set_kccgst(struct matcher *m, struct sval ident) { if (m->rule.num_kccgst_values + 1 > m->mapping.num_kccgst) { - matcher_error1(m, - "invalid rule: has more values than the mapping line; " - "ignoring rule"); + matcher_err(m, "invalid rule: has more values than the mapping line; ignoring rule"); m->rule.skip = true; return; } @@ -720,20 +601,10 @@ static bool append_expanded_kccgst_value(struct matcher *m, darray_char *to, struct sval value) { - const size_t original_size = darray_size(*to); const char *s = value.start; - - /* - * Appending bar to foo -> foo (not an error if this happens) - * Appending +bar to foo -> foo+bar - * Appending bar to +foo -> bar+foo - * Appending +bar to +foo -> +foo+bar - */ - if (!darray_empty(*to) && s[0] != '+' && s[0] != '|') { - if (darray_item(*to, 0) == '+' || darray_item(*to, 0) == '|') - darray_prepend_items_nullterminate(*to, value.start, value.len); - return true; - } + darray_char expanded = darray_new(); + char ch; + bool expanded_plus, to_plus; /* * Some ugly hand-lexing here, but going through the scanner is more @@ -743,12 +614,12 @@ append_expanded_kccgst_value(struct matcher *m, darray_char *to, enum rules_mlvo mlv; xkb_layout_index_t idx; char pfx, sfx; - struct sval expanded; + struct sval expanded_value; /* Check if that's a start of an expansion. */ if (s[i] != '%') { /* Just a normal character. */ - darray_append_items_nullterminate(*to, &s[i++], 1); + darray_appends_nullterminate(expanded, &s[i++], 1); continue; } if (++i >= value.len) goto error; @@ -777,9 +648,7 @@ append_expanded_kccgst_value(struct matcher *m, darray_char *to, int consumed; if (mlv != MLVO_LAYOUT && mlv != MLVO_VARIANT) { - matcher_error1(m, - "invalid index in %%-expansion; " - "may only index layout or variant"); + matcher_err(m, "invalid index in %%-expansion; may only index layout or variant"); goto error; } @@ -795,46 +664,65 @@ append_expanded_kccgst_value(struct matcher *m, darray_char *to, } /* Get the expanded value. */ - expanded.len = 0; + expanded_value.len = 0; if (mlv == MLVO_LAYOUT) { if (idx != XKB_LAYOUT_INVALID && idx < darray_size(m->rmlvo.layouts) && darray_size(m->rmlvo.layouts) > 1) - expanded = darray_item(m->rmlvo.layouts, idx); + expanded_value = darray_item(m->rmlvo.layouts, idx); else if (idx == XKB_LAYOUT_INVALID && darray_size(m->rmlvo.layouts) == 1) - expanded = darray_item(m->rmlvo.layouts, 0); + expanded_value = darray_item(m->rmlvo.layouts, 0); } else if (mlv == MLVO_VARIANT) { if (idx != XKB_LAYOUT_INVALID && idx < darray_size(m->rmlvo.variants) && darray_size(m->rmlvo.variants) > 1) - expanded = darray_item(m->rmlvo.variants, idx); + expanded_value = darray_item(m->rmlvo.variants, idx); else if (idx == XKB_LAYOUT_INVALID && darray_size(m->rmlvo.variants) == 1) - expanded = darray_item(m->rmlvo.variants, 0); + expanded_value = darray_item(m->rmlvo.variants, 0); } else if (mlv == MLVO_MODEL) { - expanded = m->rmlvo.model; + expanded_value = m->rmlvo.model; } /* If we didn't get one, skip silently. */ - if (expanded.len <= 0) + if (expanded_value.len <= 0) continue; if (pfx != 0) - darray_append_items_nullterminate(*to, &pfx, 1); - darray_append_items_nullterminate(*to, expanded.start, expanded.len); + darray_appends_nullterminate(expanded, &pfx, 1); + darray_appends_nullterminate(expanded, + expanded_value.start, expanded_value.len); if (sfx != 0) - darray_append_items_nullterminate(*to, &sfx, 1); + darray_appends_nullterminate(expanded, &sfx, 1); } + /* + * Appending bar to foo -> foo (not an error if this happens) + * Appending +bar to foo -> foo+bar + * Appending bar to +foo -> bar+foo + * Appending +bar to +foo -> +foo+bar + */ + + ch = (darray_empty(expanded) ? '\0' : darray_item(expanded, 0)); + expanded_plus = (ch == '+' || ch == '|'); + ch = (darray_empty(*to) ? '\0' : darray_item(*to, 0)); + to_plus = (ch == '+' || ch == '|'); + + if (expanded_plus || darray_empty(*to)) + darray_appends_nullterminate(*to, expanded.item, expanded.size); + else if (to_plus) + darray_prepends_nullterminate(*to, expanded.item, expanded.size); + + darray_free(expanded); return true; error: - matcher_error1(m, "invalid %%-expansion in value; not used"); - darray_resize(*to, original_size); + darray_free(expanded); + matcher_err(m, "invalid %%-expansion in value; not used"); return false; } @@ -843,9 +731,7 @@ matcher_rule_verify(struct matcher *m) { if (m->rule.num_mlvo_values != m->mapping.num_mlvo || m->rule.num_kccgst_values != m->mapping.num_kccgst) { - matcher_error1(m, - "invalid rule: must have same number of values as mapping line;" - "ignoring rule"); + matcher_err(m, "invalid rule: must have same number of values as mapping line; ignoring rule"); m->rule.skip = true; } } @@ -907,7 +793,7 @@ matcher_rule_apply_if_matches(struct matcher *m) static enum rules_token gettok(struct matcher *m) { - return lex(&m->scanner, &m->val, &m->loc); + return lex(&m->scanner, &m->val); } static bool @@ -1068,7 +954,7 @@ finish: return true; state_error: - matcher_error1(m, "unexpected token"); + matcher_err(m, "unexpected token"); error: return false; } @@ -1091,12 +977,13 @@ xkb_components_from_rules(struct xkb_context *ctx, ret = map_file(file, &string, &size); if (!ret) { - log_err(ctx, "Couldn't read rules file: %s\n", strerror(errno)); + log_err(ctx, "Couldn't read rules file \"%s\": %s\n", + path, strerror(errno)); goto err_file; } matcher = matcher_new(ctx, rmlvo); - ret = matcher_match(matcher, string, size, rmlvo->rules, out); + ret = matcher_match(matcher, string, size, path, out); if (!ret) log_err(ctx, "No components returned from XKB rules \"%s\"\n", path); matcher_free(matcher); diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/scanner-utils.h b/src/3rdparty/xkbcommon/src/xkbcomp/scanner-utils.h deleted file mode 100644 index 7e21b00662..0000000000 --- a/src/3rdparty/xkbcommon/src/xkbcomp/scanner-utils.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * 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. - */ - -#ifndef XKBCOMP_SCANNER_UTILS_H -#define XKBCOMP_SCANNER_UTILS_H - -/* Point to some substring in the file; used to avoid copying. */ -struct sval { - const char *start; - unsigned int len; -}; -typedef darray(struct sval) darray_sval; - -static inline bool -svaleq(struct sval s1, struct sval s2) -{ - return s1.len == s2.len && strncmp(s1.start, s2.start, s1.len) == 0; -} - -static inline bool -svaleq_prefix(struct sval s1, struct sval s2) -{ - return s1.len <= s2.len && strncmp(s1.start, s2.start, s1.len) == 0; -} - -struct scanner { - const char *s; - size_t pos; - size_t len; - char buf[1024]; - size_t buf_pos; - int line, column; - /* The line/column of the start of the current token. */ - int token_line, token_column; - const char *file_name; - struct xkb_context *ctx; -}; - -static inline void -scanner_init(struct scanner *s, struct xkb_context *ctx, - const char *string, size_t len, const char *file_name) -{ - s->s = string; - s->len = len; - s->pos = 0; - s->line = s->column = 1; - s->token_line = s->token_column = 1; - s->file_name = file_name; - s->ctx = ctx; -} - -static inline char -peek(struct scanner *s) -{ - return s->pos < s->len ? s->s[s->pos] : '\0'; -} - -static inline bool -eof(struct scanner *s) -{ - return s->pos >= s->len; -} - -static inline bool -eol(struct scanner *s) -{ - return peek(s) == '\n'; -} - -static inline char -next(struct scanner *s) -{ - if (eof(s)) - return '\0'; - if (eol(s)) { - s->line++; - s->column = 1; - } - else { - s->column++; - } - return s->s[s->pos++]; -} - -static inline bool -chr(struct scanner *s, char ch) -{ - if (peek(s) != ch) - return false; - s->pos++; s->column++; - return true; -} - -static inline bool -str(struct scanner *s, const char *string, size_t len) -{ - if (s->len - s->pos < len) - return false; - if (strncasecmp(s->s + s->pos, string, len) != 0) - return false; - s->pos += len; s->column += len; - return true; -} - -#define lit(s, literal) str(s, literal, sizeof(literal) - 1) - -static inline bool -buf_append(struct scanner *s, char ch) -{ - if (s->buf_pos + 1 >= sizeof(s->buf)) - return false; - s->buf[s->buf_pos++] = ch; - return true; -} - -static inline bool -oct(struct scanner *s, uint8_t *out) -{ - int i; - for (i = 0, *out = 0; peek(s) >= '0' && peek(s) <= '7' && i < 3; i++) - *out = *out * 8 + next(s) - '0'; - return i > 0; -} - -#endif diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/scanner.c b/src/3rdparty/xkbcommon/src/xkbcomp/scanner.c index 48df488547..9f200bbec4 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/scanner.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/scanner.c @@ -23,27 +23,6 @@ #include "xkbcomp-priv.h" #include "parser-priv.h" -#include "scanner-utils.h" - -static void -scanner_log(enum xkb_log_level level, struct scanner *s, const char *msg) -{ - xkb_log(s->ctx, level, 0, "%s:%d:%d: %s\n", s->file_name, - s->token_line, s->token_column, msg); -} - -int -scanner_error(struct scanner *s, const char *msg) -{ - scanner_log(XKB_LOG_LEVEL_ERROR, s, msg); - return ERROR_TOK; -} - -void -scanner_warn(struct scanner *s, const char *msg) -{ - scanner_log(XKB_LOG_LEVEL_WARNING, s, msg); -} static bool number(struct scanner *s, int64_t *out, int *out_tok) @@ -123,11 +102,13 @@ skip_more_whitespace_and_comments: buf_append(s, next(s)); } } - if (!buf_append(s, '\0') || !chr(s, '\"')) - return scanner_error(s, "unterminated string literal"); + if (!buf_append(s, '\0') || !chr(s, '\"')) { + scanner_err(s, "unterminated string literal"); + return ERROR_TOK; + } yylval->str = strdup(s->buf); if (!yylval->str) - return scanner_error(s, "scanner out of memory"); + return ERROR_TOK; return STRING; } @@ -135,8 +116,10 @@ skip_more_whitespace_and_comments: if (chr(s, '<')) { while (is_graph(peek(s)) && peek(s) != '>') buf_append(s, next(s)); - if (!buf_append(s, '\0') || !chr(s, '>')) - return scanner_error(s, "unterminated key name literal"); + if (!buf_append(s, '\0') || !chr(s, '>')) { + scanner_err(s, "unterminated key name literal"); + return ERROR_TOK; + } /* Empty key name literals are allowed. */ yylval->sval = xkb_atom_intern(s->ctx, s->buf, s->buf_pos - 1); return KEYNAME; @@ -165,27 +148,32 @@ skip_more_whitespace_and_comments: s->buf_pos = 0; while (is_alnum(peek(s)) || peek(s) == '_') buf_append(s, next(s)); - if (!buf_append(s, '\0')) - return scanner_error(s, "identifier too long"); + if (!buf_append(s, '\0')) { + scanner_err(s, "identifier too long"); + return ERROR_TOK; + } /* Keyword. */ - tok = keyword_to_token(s->buf); + tok = keyword_to_token(s->buf, s->buf_pos - 1); if (tok != -1) return tok; yylval->str = strdup(s->buf); if (!yylval->str) - return scanner_error(s, "scanner out of memory"); + return ERROR_TOK; return IDENT; } /* Number literal (hexadecimal / decimal / float). */ if (number(s, &yylval->num, &tok)) { - if (tok == ERROR_TOK) - return scanner_error(s, "malformed number literal"); + if (tok == ERROR_TOK) { + scanner_err(s, "malformed number literal"); + return ERROR_TOK; + } return tok; } - return scanner_error(s, "unrecognized token"); + scanner_err(s, "unrecognized token"); + return ERROR_TOK; } XkbFile * diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/symbols.c b/src/3rdparty/xkbcommon/src/xkbcomp/symbols.c index 56cce431da..bd7f73d4f1 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/symbols.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/symbols.c @@ -125,12 +125,11 @@ ClearGroupInfo(GroupInfo *groupi) static void CopyGroupInfo(GroupInfo *to, const GroupInfo *from) { - xkb_level_index_t j; to->defined = from->defined; to->type = from->type; darray_init(to->levels); darray_copy(to->levels, from->levels); - for (j = 0; j < darray_size(to->levels); j++) + for (xkb_level_index_t j = 0; j < darray_size(to->levels); j++) if (darray_item(from->levels, j).num_syms > 1) darray_item(to->levels, j).u.syms = memdup(darray_item(from->levels, j).u.syms, @@ -480,7 +479,6 @@ static void MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from, enum merge_mode merge) { - unsigned int i; KeyInfo *keyi; ModMapEntry *mm; xkb_atom_t *group_name; @@ -498,7 +496,7 @@ MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from, group_names_in_both = MIN(darray_size(into->group_names), darray_size(from->group_names)); - for (i = 0; i < group_names_in_both; i++) { + for (xkb_layout_index_t i = 0; i < group_names_in_both; i++) { if (!darray_item(from->group_names, i)) continue; @@ -511,16 +509,28 @@ MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from, darray_foreach_from(group_name, from->group_names, group_names_in_both) darray_append(into->group_names, *group_name); - darray_foreach(keyi, from->keys) { - keyi->merge = (merge == MERGE_DEFAULT ? keyi->merge : merge); - if (!AddKeySymbols(into, keyi, false)) - into->errorCount++; + if (darray_empty(into->keys)) { + into->keys = from->keys; + darray_init(from->keys); + } + else { + darray_foreach(keyi, from->keys) { + keyi->merge = (merge == MERGE_DEFAULT ? keyi->merge : merge); + if (!AddKeySymbols(into, keyi, false)) + into->errorCount++; + } } - darray_foreach(mm, from->modmaps) { - mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge); - if (!AddModMapEntry(into, mm)) - into->errorCount++; + if (darray_empty(into->modmaps)) { + into->modmaps = from->modmaps; + darray_init(from->modmaps); + } + else { + darray_foreach(mm, from->modmaps) { + mm->merge = (merge == MERGE_DEFAULT ? mm->merge : merge); + if (!AddModMapEntry(into, mm)) + into->errorCount++; + } } } @@ -633,8 +643,6 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, xkb_layout_index_t ndx; GroupInfo *groupi; xkb_level_index_t nLevels; - xkb_level_index_t i; - int j; if (!GetGroupIndex(info, keyi, arrayNdx, SYMBOLS, &ndx)) return false; @@ -669,7 +677,7 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, groupi->defined |= GROUP_FIELD_SYMS; - for (i = 0; i < nLevels; i++) { + for (xkb_level_index_t i = 0; i < nLevels; i++) { unsigned int sym_index; struct xkb_level *leveli = &darray_item(groupi->levels, i); @@ -678,7 +686,7 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, if (leveli->num_syms > 1) leveli->u.syms = calloc(leveli->num_syms, sizeof(*leveli->u.syms)); - for (j = 0; j < leveli->num_syms; j++) { + for (unsigned j = 0; j < leveli->num_syms; j++) { xkb_keysym_t keysym = darray_item(value->keysym_list.syms, sym_index + j); @@ -701,7 +709,6 @@ static bool AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, ExprDef *value) { - unsigned int i; xkb_layout_index_t ndx; GroupInfo *groupi; unsigned int nActs; @@ -742,7 +749,7 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx, groupi->defined |= GROUP_FIELD_ACTS; act = value->unary.child; - for (i = 0; i < nActs; i++) { + for (unsigned i = 0; i < nActs; i++) { union xkb_action *toAct = &darray_item(groupi->levels, i).action; if (!HandleActionDef(act, info->keymap, toAct, info->actions)) @@ -772,19 +779,20 @@ static bool SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, ExprDef *arrayNdx, ExprDef *value) { - bool ok = true; struct xkb_context *ctx = info->keymap->ctx; if (istreq(field, "type")) { xkb_layout_index_t ndx; xkb_atom_t val; - if (!ExprResolveString(ctx, value, &val)) - log_vrb(ctx, 1, + if (!ExprResolveString(ctx, value, &val)) { + log_err(ctx, "The type field of a key symbol map must be a string; " "Ignoring illegal type definition\n"); + return false; + } - if (arrayNdx == NULL) { + if (!arrayNdx) { keyi->default_type = val; keyi->defined |= KEY_FIELD_DEFAULT_TYPE; } @@ -803,32 +811,33 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, darray_item(keyi->groups, ndx).defined |= GROUP_FIELD_TYPE; } } - else if (istreq(field, "symbols")) + else if (istreq(field, "symbols")) { return AddSymbolsToKey(info, keyi, arrayNdx, value); - else if (istreq(field, "actions")) + } + else if (istreq(field, "actions")) { return AddActionsToKey(info, keyi, arrayNdx, value); + } else if (istreq(field, "vmods") || istreq(field, "virtualmods") || istreq(field, "virtualmodifiers")) { xkb_mod_mask_t mask; - ok = ExprResolveModMask(info->keymap, value, MOD_VIRT, &mask); - if (ok) { - keyi->vmodmap = mask; - keyi->defined |= KEY_FIELD_VMODMAP; - } - else { - log_err(info->keymap->ctx, + if (!ExprResolveModMask(info->keymap, value, MOD_VIRT, &mask)) { + log_err(ctx, "Expected a virtual modifier mask, found %s; " "Ignoring virtual modifiers definition for key %s\n", expr_op_type_to_string(value->expr.op), KeyInfoText(info, keyi)); + return false; } + + keyi->vmodmap = mask; + keyi->defined |= KEY_FIELD_VMODMAP; } else if (istreq(field, "locking") || istreq(field, "lock") || istreq(field, "locks")) { - log_err(info->keymap->ctx, + log_vrb(ctx, 1, "Key behaviors not supported; " "Ignoring locking specification for key %s\n", KeyInfoText(info, keyi)); @@ -836,14 +845,14 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, else if (istreq(field, "radiogroup") || istreq(field, "permanentradiogroup") || istreq(field, "allownone")) { - log_err(info->keymap->ctx, + log_vrb(ctx, 1, "Radio groups not supported; " "Ignoring radio group specification for key %s\n", KeyInfoText(info, keyi)); } else if (istreq_prefix("overlay", field) || istreq_prefix("permanentoverlay", field)) { - log_err(info->keymap->ctx, + log_vrb(ctx, 1, "Overlays not supported; " "Ignoring overlay specification for key %s\n", KeyInfoText(info, keyi)); @@ -853,14 +862,14 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, istreq(field, "repeat")) { unsigned int val; - ok = ExprResolveEnum(ctx, value, &val, repeatEntries); - if (!ok) { - log_err(info->keymap->ctx, + if (!ExprResolveEnum(ctx, value, &val, repeatEntries)) { + log_err(ctx, "Illegal repeat setting for %s; " "Non-boolean repeat setting ignored\n", KeyInfoText(info, keyi)); return false; } + keyi->repeat = val; keyi->defined |= KEY_FIELD_REPEAT; } @@ -869,18 +878,14 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, bool set; if (!ExprResolveBoolean(ctx, value, &set)) { - log_err(info->keymap->ctx, + log_err(ctx, "Illegal groupsWrap setting for %s; " "Non-boolean value ignored\n", KeyInfoText(info, keyi)); return false; } - if (set) - keyi->out_of_range_group_action = RANGE_WRAP; - else - keyi->out_of_range_group_action = RANGE_SATURATE; - + keyi->out_of_range_group_action = (set ? RANGE_WRAP : RANGE_SATURATE); keyi->defined |= KEY_FIELD_GROUPINFO; } else if (istreq(field, "groupsclamp") || @@ -888,18 +893,14 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, bool set; if (!ExprResolveBoolean(ctx, value, &set)) { - log_err(info->keymap->ctx, + log_err(ctx, "Illegal groupsClamp setting for %s; " "Non-boolean value ignored\n", KeyInfoText(info, keyi)); return false; } - if (set) - keyi->out_of_range_group_action = RANGE_SATURATE; - else - keyi->out_of_range_group_action = RANGE_WRAP; - + keyi->out_of_range_group_action = (set ? RANGE_SATURATE : RANGE_WRAP); keyi->defined |= KEY_FIELD_GROUPINFO; } else if (istreq(field, "groupsredirect") || @@ -907,7 +908,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, xkb_layout_index_t grp; if (!ExprResolveGroup(ctx, value, &grp)) { - log_err(info->keymap->ctx, + log_err(ctx, "Illegal group index for redirect of key %s; " "Definition with non-integer group ignored\n", KeyInfoText(info, keyi)); @@ -919,17 +920,17 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field, keyi->defined |= KEY_FIELD_GROUPINFO; } else { - log_err(info->keymap->ctx, + log_err(ctx, "Unknown field %s in a symbol interpretation; " "Definition ignored\n", field); - ok = false; + return false; } - return ok; + return true; } -static int +static bool SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value) { xkb_layout_index_t group, group_to_use; @@ -979,16 +980,16 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value) return true; } -static int +static bool HandleGlobalVar(SymbolsInfo *info, VarDef *stmt) { const char *elem, *field; ExprDef *arrayNdx; bool ret; - if (ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field, - &arrayNdx) == 0) - return 0; /* internal error, already reported */ + if (!ExprResolveLhs(info->keymap->ctx, stmt->name, &elem, &field, &arrayNdx)) + return false; + if (elem && istreq(elem, "key")) { ret = SetSymbolsField(info, &info->default_key, field, arrayNdx, stmt->value); @@ -1098,16 +1099,15 @@ SetExplicitGroup(SymbolsInfo *info, KeyInfo *keyi) return true; } -static int +static bool HandleSymbolsDef(SymbolsInfo *info, SymbolsDef *stmt) { KeyInfo keyi; - xkb_layout_index_t i; keyi = info->default_key; darray_init(keyi.groups); darray_copy(keyi.groups, info->default_key.groups); - for (i = 0; i < darray_size(keyi.groups); i++) + for (xkb_layout_index_t i = 0; i < darray_size(keyi.groups); i++) CopyGroupInfo(&darray_item(keyi.groups, i), &darray_item(info->default_key.groups, i)); keyi.merge = stmt->merge; @@ -1134,7 +1134,6 @@ HandleSymbolsDef(SymbolsInfo *info, SymbolsDef *stmt) static bool HandleModMapDef(SymbolsInfo *info, ModMapDef *def) { - ExprDef *key; ModMapEntry tmp; xkb_mod_index_t ndx; bool ok; @@ -1153,7 +1152,7 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def) tmp.modifier = ndx; tmp.merge = def->merge; - for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next) { + for (ExprDef *key = def->keys; key; key = (ExprDef *) key->common.next) { xkb_keysym_t sym; if (key->expr.op == EXPR_VALUE && @@ -1198,7 +1197,7 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge) ok = HandleGlobalVar(info, (VarDef *) stmt); break; case STMT_VMOD: - ok = HandleVModDef(info->keymap, (VModDef *) stmt); + ok = HandleVModDef(info->keymap, (VModDef *) stmt, merge); break; case STMT_MODMAP: ok = HandleModMapDef(info, (ModMapDef *) stmt); @@ -1518,7 +1517,7 @@ CopyModMapDef(SymbolsInfo *info, ModMapEntry *entry) } } - key->modmap |= (1 << entry->modifier); + key->modmap |= (1u << entry->modifier); return true; } diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/types.c b/src/3rdparty/xkbcommon/src/xkbcomp/types.c index 5b7ccbb4db..7708da3882 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/types.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/types.c @@ -30,111 +30,6 @@ #include "expr.h" #include "include.h" -/* - * The xkb_types section - * ===================== - * This section is the second to be processesed, after xkb_keycodes. - * However, it is completely independent and could have been the first - * to be processed (it does not refer to specific keys as specified in - * the xkb_keycodes section). - * - * This section defines key types, which, given a key and a keyboard - * state (i.e. modifier state and group), determine the shift level to - * be used in translating the key to keysyms. These types are assigned - * to each group in each key, in the xkb_symbols section. - * - * Key types are called this way because, in a way, they really describe - * the "type" of the key (or more correctly, a specific group of the - * key). For example, an ordinary keymap will provide a type called - * "KEYPAD", which consists of two levels, with the second level being - * chosen according to the state of the Num Lock (or Shift) modifiers. - * Another example is a type called "ONE_LEVEL", which is usually - * assigned to keys such as Escape; these have just one level and are - * not affected by the modifier state. Yet more common examples are - * "TWO_LEVEL" (with Shift choosing the second level), "ALPHABETIC" - * (where Caps Lock may also choose the second level), etc. - * - * Type definitions - * ---------------- - * Statements of the form: - * type "FOUR_LEVEL" { ... } - * - * The above would create a new type named "FOUR_LEVEL". - * The body of the definition may include statements of the following - * forms: - * - * - level_name statements (mandatory for each level in the type): - * level_name[Level1] = "Base"; - * - * Gives each level in this type a descriptive name. It isn't used - * for any thing. - * Note: A level may be specified as Level[1-8] or just a number (can - * be more than 8). - * - * - modifiers statement (mandatory, should be specified only once): - * modifiers = Shift+Lock+LevelThree; - * - * A mask of real and virtual modifiers. These are the only modifiers - * being considered when matching the modifier state against the type. - * The other modifiers, whether active or not, are masked out in the - * calculation. - * - * - map entry statements (should have at least as many mappings as there - * are levels in the type): - * map[Shift+LevelThree] = Level4; - * - * If the active modifiers, masked with the type's modifiers (as stated - * above), match (i.e. equal) the modifiers inside the map[] statement, - * then the level in the right hand side is chosen. For example, in the - * above, if in the current keyboard state the Shift and LevelThree - * modifiers are active, while the Lock modifier is not, then the - * keysym(s) in the 4th level of the group will be returned to the - * user. - * - * - preserve statements: - * map[Shift+Lock+LevelThree] = Level5; - * preserve[Shift+Lock+LevelThree] = Lock; - * - * When a map entry matches the active modifiers and the level it - * specified is chosen, then these modifiers are said to be "consumed"; - * for example, in a simple US keymap where the "g" key is assigned an - * ordinary ALPHABETIC key type, if the Lock (Caps Lock) modifier is - * active and the key is pressed, then a "G" keysym is produced (as - * opposed to lower-case "g"). This is because the type definition has - * a map entry like the following: - * map[Lock] = Level2; - * And as such the Lock modifier is consumed. This information is - * relevant for applications which further process the modifiers, - * since by then the consumed modifiers have already "done their part" - * and should be masked out. - * - * However, sometimes even if a modifier is actually used to choose - * the shift level (as Lock above), it should *not* be reported as - * consumed, for various reasons. In this case, a preserve[] statement - * can be used to augment the map entry. The modifiers inside the square - * brackets should match one of the map[] statements in the type. The - * right hand side should consists of modifiers from the left hand - * side; these modifiers are then "preserved" and not reported as - * consumed. - * - * Virtual modifier statements - * --------------------------- - * Statements of the form: - * virtual_modifiers LControl; - * - * Can appear in the xkb_types, xkb_compat, xkb_symbols sections. - * TODO - * - * Effect on keymap - * ---------------- - * After all of the xkb_types sections have been compiled, the following - * members of struct xkb_keymap are finalized: - * struct xkb_key_type *types; - * unsigned int num_types; - * char *types_section_name; - * TODO: virtual modifiers. - */ - enum type_field { TYPE_FIELD_MASK = (1 << 0), TYPE_FIELD_MAP = (1 << 1), @@ -287,10 +182,16 @@ MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from, from->name = NULL; } - darray_foreach(type, from->types) { - type->merge = (merge == MERGE_DEFAULT ? type->merge : merge); - if (!AddKeyType(into, type, false)) - into->errorCount++; + if (darray_empty(into->types)) { + into->types = from->types; + darray_init(from->types); + } + else { + darray_foreach(type, from->types) { + type->merge = (merge == MERGE_DEFAULT ? type->merge : merge); + if (!AddKeyType(into, type, false)) + into->errorCount++; + } } } @@ -738,7 +639,7 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge) ok = true; break; case STMT_VMOD: - ok = HandleVModDef(info->keymap, (VModDef *) stmt); + ok = HandleVModDef(info->keymap, (VModDef *) stmt, merge); break; default: log_err(info->keymap->ctx, diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/vmod.c b/src/3rdparty/xkbcommon/src/xkbcomp/vmod.c index 206e1624e6..86e7bec786 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/vmod.c +++ b/src/3rdparty/xkbcommon/src/xkbcomp/vmod.c @@ -30,27 +30,64 @@ #include "vmod.h" bool -HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt) +HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt, + enum merge_mode merge) { xkb_mod_index_t i; - const struct xkb_mod *mod; + struct xkb_mod *mod; + xkb_mod_mask_t mapping; struct xkb_mod new; - if (stmt->value) - log_err(keymap->ctx, - "Support for setting a value in a virtual_modifiers statement has been removed; " - "Value ignored\n"); + merge = (merge == MERGE_DEFAULT ? stmt->merge : merge); + + if (stmt->value) { + /* + * This is a statement such as 'virtualModifiers NumLock = Mod1'; + * it sets the vmod-to-real-mod[s] mapping directly instead of going + * through modifier_map or some such. + */ + if (!ExprResolveModMask(keymap, stmt->value, MOD_REAL, &mapping)) { + log_err(keymap->ctx, + "Declaration of %s ignored\n", + xkb_atom_text(keymap->ctx, stmt->name)); + return false; + } + } + else { + mapping = 0; + } darray_enumerate(i, mod, keymap->mods) { if (mod->name == stmt->name) { - if (mod->type == MOD_VIRT) + if (mod->type != MOD_VIRT) { + log_err(keymap->ctx, + "Can't add a virtual modifier named \"%s\"; " + "there is already a non-virtual modifier with this name! Ignored\n", + xkb_atom_text(keymap->ctx, mod->name)); + return false; + } + + if (mod->mapping == mapping) return true; - log_err(keymap->ctx, - "Can't add a virtual modifier named \"%s\"; " - "there is already a non-virtual modifier with this name! Ignored\n", - xkb_atom_text(keymap->ctx, mod->name)); - return false; + if (mod->mapping != 0) { + xkb_mod_mask_t use, ignore; + + use = (merge == MERGE_OVERRIDE ? mapping : mod->mapping); + ignore = (merge == MERGE_OVERRIDE ? mod->mapping : mapping); + + log_warn(keymap->ctx, + "Virtual modifier %s defined multiple times; " + "Using %s, ignoring %s\n", + xkb_atom_text(keymap->ctx, stmt->name), + ModMaskText(keymap, use), + ModMaskText(keymap, ignore)); + + mapping = use; + } + + mod->mapping = mapping; + return true; } } @@ -62,7 +99,7 @@ HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt) } new.name = stmt->name; - new.mapping = 0; + new.mapping = mapping; new.type = MOD_VIRT; darray_append(keymap->mods, new); return true; diff --git a/src/3rdparty/xkbcommon/src/xkbcomp/vmod.h b/src/3rdparty/xkbcommon/src/xkbcomp/vmod.h index 991550735f..1ba59f73cd 100644 --- a/src/3rdparty/xkbcommon/src/xkbcomp/vmod.h +++ b/src/3rdparty/xkbcommon/src/xkbcomp/vmod.h @@ -28,6 +28,7 @@ #define XKBCOMP_VMOD_H bool -HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt); +HandleVModDef(struct xkb_keymap *keymap, VModDef *stmt, + enum merge_mode merge); #endif |