diff options
-rw-r--r-- | src/keymap-dump.c | 40 | ||||
-rw-r--r-- | src/text.c | 245 | ||||
-rw-r--r-- | src/text.h | 23 | ||||
-rw-r--r-- | src/xkb-priv.h | 3 | ||||
-rw-r--r-- | src/xkbcomp/action.c | 107 | ||||
-rw-r--r-- | src/xkbcomp/action.h | 2 | ||||
-rw-r--r-- | src/xkbcomp/compat.c | 67 | ||||
-rw-r--r-- | src/xkbcomp/expr.c | 37 | ||||
-rw-r--r-- | src/xkbcomp/expr.h | 5 | ||||
-rw-r--r-- | src/xkbcomp/vmod.c | 1 |
10 files changed, 247 insertions, 283 deletions
diff --git a/src/keymap-dump.c b/src/keymap-dump.c index 6d00851..addeeba 100644 --- a/src/keymap-dump.c +++ b/src/keymap-dump.c @@ -166,14 +166,6 @@ get_indicator_state_text(uint8_t which) { int i; static char ret[GET_TEXT_BUF_SIZE]; - /* FIXME: Merge with ... something ... in xkbcomp? */ - static const char *state_names[] = { - "base", - "latched", - "locked", - "effective", - "compat" - }; memset(ret, 0, GET_TEXT_BUF_SIZE); @@ -185,14 +177,18 @@ get_indicator_state_text(uint8_t which) } for (i = 0; which != 0; i++) { + const char *name; + if (!(which & (1 << i))) continue; + which &= ~(1 << i); + name = LookupValue(modComponentMaskNames, (1 << i)); if (ret[0] != '\0') - append_get_text("%s+%s", ret, state_names[i]); + append_get_text("%s+%s", ret, name); else - append_get_text("%s", state_names[i]); + append_get_text("%s", name); } return ret; @@ -203,22 +199,7 @@ get_control_mask_text(uint32_t control_mask) { int i; static char ret[GET_TEXT_BUF_SIZE]; - /* FIXME: Merge with ... something ... in xkbcomp. */ - static const char *ctrl_names[] = { - "RepeatKeys", - "SlowKeys", - "BounceKeys", - "StickyKeys", - "MouseKeys", - "MouseKeysAccel", - "AccessXKeys", - "AccessXTimeout", - "AccessXFeedback", - "AudibleBell", - "Overlay1", - "Overlay2", - "IgnoreGroupLock" - }; + const char *control_name; memset(ret, 0, GET_TEXT_BUF_SIZE); @@ -236,12 +217,14 @@ get_control_mask_text(uint32_t control_mask) for (i = 0; control_mask; i++) { if (!(control_mask & (1 << i))) continue; + control_mask &= ~(1 << i); + control_name = LookupValue(ctrlMaskNames, (1 << i)); if (ret[0] != '\0') - append_get_text("%s+%s", ret, ctrl_names[i]); + append_get_text("%s+%s", ret, control_name); else - append_get_text("%s", ctrl_names[i]); + append_get_text("%s", control_name); } return ret; @@ -518,7 +501,6 @@ write_action(struct xkb_keymap *keymap, struct buf *buf, write_buf(buf, "%sNoAction()%s", prefix, suffix); break; - case XkbSA_XFree86Private: default: write_buf(buf, "%s%s(type=0x%02x,data[0]=0x%02x,data[1]=0x%02x,data[2]=0x%02x,data[3]=0x%02x,data[4]=0x%02x,data[5]=0x%02x,data[6]=0x%02x)%s", @@ -26,6 +26,188 @@ #include "text.h" +bool +LookupString(const LookupEntry tab[], const char *string, + unsigned int *value_rtrn) +{ + const LookupEntry *entry; + + if (!string) + return false; + + for (entry = tab; entry->name; entry++) { + if (istreq(entry->name, string)) { + *value_rtrn = entry->value; + return true; + } + } + + return false; +} + +const char * +LookupValue(const LookupEntry tab[], unsigned int value) +{ + const LookupEntry *entry; + + for (entry = tab; entry->name; entry++) + if (entry->value == value) + return entry->name; + + return NULL; +} + +const LookupEntry ctrlMaskNames[] = { + { "RepeatKeys", XkbRepeatKeysMask }, + { "Repeat", XkbRepeatKeysMask }, + { "AutoRepeat", XkbRepeatKeysMask }, + { "SlowKeys", XkbSlowKeysMask }, + { "BounceKeys", XkbBounceKeysMask }, + { "StickyKeys", XkbStickyKeysMask }, + { "MouseKeys", XkbMouseKeysMask }, + { "MouseKeysAccel", XkbMouseKeysAccelMask }, + { "AccessXKeys", XkbAccessXKeysMask }, + { "AccessXTimeout", XkbAccessXTimeoutMask }, + { "AccessXFeedback", XkbAccessXFeedbackMask }, + { "AudibleBell", XkbAudibleBellMask }, + { "IgnoreGroupLock", XkbIgnoreGroupLockMask }, + { "all", XkbAllBooleanCtrlsMask }, + { "none", 0 }, + { "Overlay1", 0 }, + { "Overlay2", 0 }, + { NULL, 0 } +}; + +const LookupEntry modComponentMaskNames[] = { + {"base", XkbIM_UseBase}, + {"latched", XkbIM_UseLatched}, + {"locked", XkbIM_UseLocked}, + {"effective", XkbIM_UseEffective}, + {"compat", XkbIM_UseCompat}, + {"any", XkbIM_UseAnyMods}, + {"none", 0}, + {NULL, 0} +}; + +const LookupEntry groupComponentMaskNames[] = { + {"base", XkbIM_UseBase}, + {"latched", XkbIM_UseLatched}, + {"locked", XkbIM_UseLocked}, + {"effective", XkbIM_UseEffective}, + {"any", XkbIM_UseAnyGroup}, + {"none", 0}, + {NULL, 0} +}; + +const LookupEntry groupMaskNames[] = { + {"group1", 0x01}, + {"group2", 0x02}, + {"group3", 0x04}, + {"group4", 0x08}, + {"group5", 0x10}, + {"group6", 0x20}, + {"group7", 0x40}, + {"group8", 0x80}, + {"none", 0x00}, + {"all", 0xff}, + {NULL, 0} +}; + +const LookupEntry groupNames[] = { + {"group1", 1}, + {"group2", 2}, + {"group3", 3}, + {"group4", 4}, + {"group5", 5}, + {"group6", 6}, + {"group7", 7}, + {"group8", 8}, + {NULL, 0} +}; + +const LookupEntry levelNames[] = { + { "level1", 1 }, + { "level2", 2 }, + { "level3", 3 }, + { "level4", 4 }, + { "level5", 5 }, + { "level6", 6 }, + { "level7", 7 }, + { "level8", 8 }, + { NULL, 0 } +}; + +const LookupEntry buttonNames[] = { + { "button1", 1 }, + { "button2", 2 }, + { "button3", 3 }, + { "button4", 4 }, + { "button5", 5 }, + { "default", 0 }, + { NULL, 0 } +}; + +const LookupEntry useModMapValueNames[] = { + { "levelone", 1 }, + { "level1", 1 }, + { "anylevel", 0 }, + { "any", 0 }, + { NULL, 0 } +}; + +const LookupEntry actionTypeNames[] = { + { "NoAction", XkbSA_NoAction }, + { "SetMods", XkbSA_SetMods }, + { "LatchMods", XkbSA_LatchMods }, + { "LockMods", XkbSA_LockMods }, + { "SetGroup", XkbSA_SetGroup }, + { "LatchGroup", XkbSA_LatchGroup }, + { "LockGroup", XkbSA_LockGroup }, + { "MovePtr", XkbSA_MovePtr }, + { "MovePointer", XkbSA_MovePtr }, + { "PtrBtn", XkbSA_PtrBtn }, + { "PointerButton", XkbSA_PtrBtn }, + { "LockPtrBtn", XkbSA_LockPtrBtn }, + { "LockPtrButton", XkbSA_LockPtrBtn }, + { "LockPointerButton", XkbSA_LockPtrBtn }, + { "LockPointerBtn", XkbSA_LockPtrBtn }, + { "SetPtrDflt", XkbSA_SetPtrDflt }, + { "SetPointerDefault", XkbSA_SetPtrDflt }, + { "ISOLock", XkbSA_ISOLock }, + { "Terminate", XkbSA_Terminate }, + { "TerminateServer", XkbSA_Terminate }, + { "SwitchScreen", XkbSA_SwitchScreen }, + { "SetControls", XkbSA_SetControls }, + { "LockControls", XkbSA_LockControls }, + { "ActionMessage", XkbSA_ActionMessage }, + { "MessageAction", XkbSA_ActionMessage }, + { "Message", XkbSA_ActionMessage }, + { "RedirectKey", XkbSA_RedirectKey }, + { "Redirect", XkbSA_RedirectKey }, + { "DeviceBtn", XkbSA_DeviceBtn }, + { "DevBtn", XkbSA_DeviceBtn }, + { "DevButton", XkbSA_DeviceBtn }, + { "DeviceButton", XkbSA_DeviceBtn }, + { "LockDeviceBtn", XkbSA_LockDeviceBtn }, + { "LockDevBtn", XkbSA_LockDeviceBtn }, + { "LockDevButton", XkbSA_LockDeviceBtn }, + { "LockDeviceButton", XkbSA_LockDeviceBtn }, + { "DeviceValuator", XkbSA_DeviceValuator }, + { "DevVal", XkbSA_DeviceValuator }, + { "DeviceVal", XkbSA_DeviceValuator }, + { "DevValuator", XkbSA_DeviceValuator }, + { "Private", PrivateAction }, + { NULL, 0 }, +}; + +const LookupEntry symInterpretMatchMaskNames[] = { + { "NoneOf", XkbSI_NoneOf }, + { "AnyOfOrNone", XkbSI_AnyOfOrNone }, + { "AnyOf", XkbSI_AnyOf }, + { "AllOf", XkbSI_AllOf }, + { "Exactly", XkbSI_Exactly }, +}; + #define BUFFER_SIZE 1024 static char * @@ -226,36 +408,11 @@ ModMaskText(xkb_mod_mask_t mask) return buf; } -static const char *actionTypeNames[XkbSA_NumActions] = { - [XkbSA_NoAction] = "NoAction", - [XkbSA_SetMods] = "SetMods", - [XkbSA_LatchMods] = "LatchMods", - [XkbSA_LockMods] = "LockMods", - [XkbSA_SetGroup] = "SetGroup", - [XkbSA_LatchGroup] = "LatchGroup", - [XkbSA_LockGroup] = "LockGroup", - [XkbSA_MovePtr] = "MovePtr", - [XkbSA_PtrBtn] = "PtrBtn", - [XkbSA_LockPtrBtn] = "LockPtrBtn", - [XkbSA_SetPtrDflt] = "SetPtrDflt", - [XkbSA_ISOLock] = "ISOLock", - [XkbSA_Terminate] = "Terminate", - [XkbSA_SwitchScreen] = "SwitchScreen", - [XkbSA_SetControls] = "SetControls", - [XkbSA_LockControls] = "LockControls", - [XkbSA_ActionMessage] = "ActionMessage", - [XkbSA_RedirectKey] = "RedirectKey", - [XkbSA_DeviceBtn] = "DeviceBtn", - [XkbSA_LockDeviceBtn] = "LockDeviceBtn", - [XkbSA_DeviceValuator] = "DeviceValuator" -}; - const char * ActionTypeText(unsigned type) { - if (type <= XkbSA_LastAction) - return actionTypeNames[type]; - return "Private"; + const char *name = LookupValue(actionTypeNames, type); + return name ? name : "Private"; } const char * @@ -285,33 +442,19 @@ KeyNameText(const char name[XkbKeyNameLength]) return buf; } -static const char *siMatchText[5] = { - "NoneOf", /* XkbSI_NoneOf */ - "AnyOfOrNone", /* XkbSI_AnyOfOrNone */ - "AnyOf", /* XkbSI_AnyOf */ - "AllOf", /* XkbSI_AllOf */ - "Exactly" /* XkbSI_Exactly */ -}; - const char * SIMatchText(unsigned type) { + const char *name; char *buf; - switch (type & XkbSI_OpMask) { - case XkbSI_NoneOf: - return siMatchText[0]; - case XkbSI_AnyOfOrNone: - return siMatchText[1]; - case XkbSI_AnyOf: - return siMatchText[2]; - case XkbSI_AllOf: - return siMatchText[3]; - case XkbSI_Exactly: - return siMatchText[4]; - default: - buf = GetBuffer(40); - snprintf(buf, 40, "0x%x", type & XkbSI_OpMask); - return buf; - } + type &= XkbSI_OpMask; + + name = LookupValue(symInterpretMatchMaskNames, type); + if (name) + return name; + + buf = GetBuffer(40); + snprintf(buf, 40, "0x%x", type & XkbSI_OpMask); + return buf; } @@ -29,6 +29,29 @@ #include "xkb-priv.h" +typedef struct { + const char *name; + unsigned int value; +} LookupEntry; + +bool +LookupString(const LookupEntry tab[], const char *string, + unsigned int *value_rtrn); + +const char * +LookupValue(const LookupEntry tab[], unsigned int value); + +extern const LookupEntry ctrlMaskNames[]; +extern const LookupEntry modComponentMaskNames[]; +extern const LookupEntry groupComponentMaskNames[]; +extern const LookupEntry groupMaskNames[]; +extern const LookupEntry groupNames[]; +extern const LookupEntry levelNames[]; +extern const LookupEntry buttonNames[]; +extern const LookupEntry useModMapValueNames[]; +extern const LookupEntry actionTypeNames[]; +extern const LookupEntry symInterpretMatchMaskNames[]; + const char * VModMaskText(struct xkb_keymap *keymap, xkb_mod_mask_t cmask); diff --git a/src/xkb-priv.h b/src/xkb-priv.h index a598e3c..a06e90f 100644 --- a/src/xkb-priv.h +++ b/src/xkb-priv.h @@ -216,6 +216,9 @@ struct xkb_pointer_button_action { int8_t button; }; +/* Instead of non-sequential XkbSA_XFree86Private. */ +#define PrivateAction (XkbSA_LastAction + 1) + struct xkb_private_action { uint8_t type; uint8_t data[7]; diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c index ad8f42a..4e903bd 100644 --- a/src/xkbcomp/action.c +++ b/src/xkbcomp/action.c @@ -30,8 +30,6 @@ #include "action.h" #include "keycodes.h" -#define PrivateAction (XkbSA_LastAction + 1) - static const ExprDef constTrue = { .common = { .type = STMT_EXPR, .next = NULL }, .op = EXPR_VALUE, @@ -105,51 +103,6 @@ FreeActionsInfo(ActionsInfo *info) free(info); } -static const LookupEntry actionStrings[] = { - { "noaction", XkbSA_NoAction }, - { "setmods", XkbSA_SetMods }, - { "latchmods", XkbSA_LatchMods }, - { "lockmods", XkbSA_LockMods }, - { "setgroup", XkbSA_SetGroup }, - { "latchgroup", XkbSA_LatchGroup }, - { "lockgroup", XkbSA_LockGroup }, - { "moveptr", XkbSA_MovePtr }, - { "movepointer", XkbSA_MovePtr }, - { "ptrbtn", XkbSA_PtrBtn }, - { "pointerbutton", XkbSA_PtrBtn }, - { "lockptrbtn", XkbSA_LockPtrBtn }, - { "lockpointerbutton", XkbSA_LockPtrBtn }, - { "lockptrbutton", XkbSA_LockPtrBtn }, - { "lockpointerbtn", XkbSA_LockPtrBtn }, - { "setptrdflt", XkbSA_SetPtrDflt }, - { "setpointerdefault", XkbSA_SetPtrDflt }, - { "isolock", XkbSA_ISOLock }, - { "terminate", XkbSA_Terminate }, - { "terminateserver", XkbSA_Terminate }, - { "switchscreen", XkbSA_SwitchScreen }, - { "setcontrols", XkbSA_SetControls }, - { "lockcontrols", XkbSA_LockControls }, - { "actionmessage", XkbSA_ActionMessage }, - { "messageaction", XkbSA_ActionMessage }, - { "message", XkbSA_ActionMessage }, - { "redirect", XkbSA_RedirectKey }, - { "redirectkey", XkbSA_RedirectKey }, - { "devbtn", XkbSA_DeviceBtn }, - { "devicebtn", XkbSA_DeviceBtn }, - { "devbutton", XkbSA_DeviceBtn }, - { "devicebutton", XkbSA_DeviceBtn }, - { "lockdevbtn", XkbSA_LockDeviceBtn }, - { "lockdevicebtn", XkbSA_LockDeviceBtn }, - { "lockdevbutton", XkbSA_LockDeviceBtn }, - { "lockdevicebutton", XkbSA_LockDeviceBtn }, - { "devval", XkbSA_DeviceValuator }, - { "deviceval", XkbSA_DeviceValuator }, - { "devvaluator", XkbSA_DeviceValuator }, - { "devicevaluator", XkbSA_DeviceValuator }, - { "private", PrivateAction }, - { NULL, 0 } -}; - static const LookupEntry fieldStrings[] = { { "clearLocks", ACTION_FIELD_CLEAR_LOCKS }, { "latchToLock", ACTION_FIELD_LATCH_TO_LOCK }, @@ -188,52 +141,21 @@ static const LookupEntry fieldStrings[] = { }; static bool -stringToValue(const LookupEntry tab[], const char *string, - unsigned int *value_rtrn) -{ - const LookupEntry *entry; - - if (!string) - return false; - - for (entry = tab; entry->name; entry++) { - if (istreq(entry->name, string)) { - *value_rtrn = entry->value; - return true; - } - } - - return false; -} - -static const char * -valueToString(const LookupEntry tab[], unsigned int value) -{ - const LookupEntry *entry; - - for (entry = tab; entry->name; entry++) - if (entry->value == value) - return entry->name; - - return "unknown"; -} - -static bool stringToAction(const char *str, unsigned *type_rtrn) { - return stringToValue(actionStrings, str, type_rtrn); + return LookupString(actionTypeNames, str, type_rtrn); } static bool stringToField(const char *str, enum action_field *field_rtrn) { - return stringToValue(fieldStrings, str, field_rtrn); + return LookupString(fieldStrings, str, field_rtrn); } static const char * fieldText(enum action_field field) { - return valueToString(fieldStrings, field); + return LookupValue(fieldStrings, field); } /***====================================================================***/ @@ -830,27 +752,6 @@ HandleSwitchScreen(struct xkb_keymap *keymap, union xkb_action *action, return ReportIllegal(keymap, action->type, field); } -const LookupEntry ctrlNames[] = { - { "repeatkeys", XkbRepeatKeysMask }, - { "repeat", XkbRepeatKeysMask }, - { "autorepeat", XkbRepeatKeysMask }, - { "slowkeys", XkbSlowKeysMask }, - { "bouncekeys", XkbBounceKeysMask }, - { "stickykeys", XkbStickyKeysMask }, - { "mousekeys", XkbMouseKeysMask }, - { "mousekeysaccel", XkbMouseKeysAccelMask }, - { "accessxkeys", XkbAccessXKeysMask }, - { "accessxtimeout", XkbAccessXTimeoutMask }, - { "accessxfeedback", XkbAccessXFeedbackMask }, - { "audiblebell", XkbAudibleBellMask }, - { "ignoregrouplock", XkbIgnoreGroupLockMask }, - { "all", XkbAllBooleanCtrlsMask }, - { "overlay1", 0 }, - { "overlay2", 0 }, - { "none", 0 }, - { NULL, 0 } -}; - static bool HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action, enum action_field field, const ExprDef *array_ndx, @@ -864,7 +765,7 @@ HandleSetLockControls(struct xkb_keymap *keymap, union xkb_action *action, if (array_ndx) return ReportActionNotArray(keymap, action->type, field); - if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlNames)) + if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames)) return ReportMismatch(keymap, action->type, field, "controls mask"); diff --git a/src/xkbcomp/action.h b/src/xkbcomp/action.h index 8ec8386..cbfb261 100644 --- a/src/xkbcomp/action.h +++ b/src/xkbcomp/action.h @@ -50,6 +50,4 @@ bool SetActionField(struct xkb_keymap *keymap, const char *elem, const char *field, ExprDef *array_ndx, ExprDef *value, ActionsInfo *info); -extern const LookupEntry ctrlNames[]; - #endif diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c index dda930e..4059572 100644 --- a/src/xkbcomp/compat.c +++ b/src/xkbcomp/compat.c @@ -394,17 +394,7 @@ ResolveStateAndPredicate(ExprDef *expr, unsigned *pred_rtrn, if (expr->op == EXPR_ACTION_DECL) { const char *pred_txt = xkb_atom_text(info->keymap->ctx, expr->value.action.name); - if (istreq(pred_txt, "noneof")) - *pred_rtrn = XkbSI_NoneOf; - else if (istreq(pred_txt, "anyofornone")) - *pred_rtrn = XkbSI_AnyOfOrNone; - else if (istreq(pred_txt, "anyof")) - *pred_rtrn = XkbSI_AnyOf; - else if (istreq(pred_txt, "allof")) - *pred_rtrn = XkbSI_AllOf; - else if (istreq(pred_txt, "exactly")) - *pred_rtrn = XkbSI_Exactly; - else { + if (!LookupString(symInterpretMatchMaskNames, pred_txt, pred_rtrn)) { log_err(info->keymap->ctx, "Illegal modifier predicate \"%s\"; Ignored\n", pred_txt); return false; @@ -588,14 +578,6 @@ HandleIncludeCompatMap(CompatInfo *info, IncludeStmt *stmt) return (info->errorCount == 0); } -static const LookupEntry useModMapValues[] = { - { "levelone", 1 }, - { "level1", 1 }, - { "anylevel", 0 }, - { "any", 0 }, - { NULL, 0 } -}; - static bool SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field, ExprDef *arrayNdx, ExprDef *value) @@ -651,7 +633,7 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field, if (arrayNdx) return ReportSINotArray(info, si, field); - if (!ExprResolveEnum(keymap->ctx, value, &val, useModMapValues)) + if (!ExprResolveEnum(keymap->ctx, value, &val, useModMapValueNames)) return ReportSIBadType(info, si, field, "level specification"); if (val) @@ -669,41 +651,6 @@ SetInterpField(CompatInfo *info, SymInterpInfo *si, const char *field, return true; } -static const LookupEntry modComponentNames[] = { - {"base", XkbIM_UseBase}, - {"latched", XkbIM_UseLatched}, - {"locked", XkbIM_UseLocked}, - {"effective", XkbIM_UseEffective}, - {"compat", XkbIM_UseCompat}, - {"any", XkbIM_UseAnyMods}, - {"none", 0}, - {NULL, 0} -}; - -static const LookupEntry groupComponentNames[] = { - {"base", XkbIM_UseBase}, - {"latched", XkbIM_UseLatched}, - {"locked", XkbIM_UseLocked}, - {"effective", XkbIM_UseEffective}, - {"any", XkbIM_UseAnyGroup}, - {"none", 0}, - {NULL, 0} -}; - -static const LookupEntry groupNames[] = { - {"group1", 0x01}, - {"group2", 0x02}, - {"group3", 0x04}, - {"group4", 0x08}, - {"group5", 0x10}, - {"group6", 0x20}, - {"group7", 0x40}, - {"group8", 0x80}, - {"none", 0x00}, - {"all", 0xff}, - {NULL, 0} -}; - static bool SetIndicatorMapField(CompatInfo *info, LEDInfo *led, const char *field, ExprDef *arrayNdx, ExprDef *value) @@ -726,7 +673,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led, if (arrayNdx) return ReportIndicatorNotArray(info, led, field); - if (!ExprResolveMask(keymap->ctx, value, &mask, groupNames)) + if (!ExprResolveMask(keymap->ctx, value, &mask, groupMaskNames)) return ReportIndicatorBadType(info, led, field, "group mask"); led->groups = mask; @@ -738,7 +685,7 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led, if (arrayNdx) return ReportIndicatorNotArray(info, led, field); - if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlNames)) + if (!ExprResolveMask(keymap->ctx, value, &mask, ctrlMaskNames)) return ReportIndicatorBadType(info, led, field, "controls mask"); @@ -757,7 +704,8 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led, if (arrayNdx) return ReportIndicatorNotArray(info, led, field); - if (!ExprResolveMask(keymap->ctx, value, &mask, modComponentNames)) + if (!ExprResolveMask(keymap->ctx, value, &mask, + modComponentMaskNames)) return ReportIndicatorBadType(info, led, field, "mask of modifier state components"); @@ -769,7 +717,8 @@ SetIndicatorMapField(CompatInfo *info, LEDInfo *led, if (arrayNdx) return ReportIndicatorNotArray(info, led, field); - if (!ExprResolveMask(keymap->ctx, value, &mask, groupComponentNames)) + if (!ExprResolveMask(keymap->ctx, value, &mask, + groupComponentMaskNames)) return ReportIndicatorBadType(info, led, field, "mask of group state components"); diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c index 0ad6c60..6fe4029 100644 --- a/src/xkbcomp/expr.c +++ b/src/xkbcomp/expr.c @@ -390,20 +390,9 @@ ExprResolveGroup(struct xkb_context *ctx, const ExprDef *expr, { bool ok; int result; - static const LookupEntry group_names[] = { - { "group1", 1 }, - { "group2", 2 }, - { "group3", 3 }, - { "group4", 4 }, - { "group5", 5 }, - { "group6", 6 }, - { "group7", 7 }, - { "group8", 8 }, - { NULL, 0 } - }; ok = ExprResolveIntegerLookup(ctx, expr, &result, SimpleLookup, - group_names); + groupNames); if (!ok) return false; @@ -423,20 +412,9 @@ ExprResolveLevel(struct xkb_context *ctx, const ExprDef *expr, { bool ok; int result; - static const LookupEntry level_names[] = { - { "level1", 1 }, - { "level2", 2 }, - { "level3", 3 }, - { "level4", 4 }, - { "level5", 5 }, - { "level6", 6 }, - { "level7", 7 }, - { "level8", 8 }, - { NULL, 0 } - }; ok = ExprResolveIntegerLookup(ctx, expr, &result, SimpleLookup, - level_names); + levelNames); if (!ok) return false; @@ -455,18 +433,9 @@ bool ExprResolveButton(struct xkb_context *ctx, const ExprDef *expr, int *btn_rtrn) { int result; - static const LookupEntry button_names[] = { - { "button1", 1 }, - { "button2", 2 }, - { "button3", 3 }, - { "button4", 4 }, - { "button5", 5 }, - { "default", 0 }, - { NULL, 0 } - }; if (!ExprResolveIntegerLookup(ctx, expr, &result, SimpleLookup, - button_names)) + buttonNames)) return false; *btn_rtrn = result; diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h index 3d8f5c1..e30f43e 100644 --- a/src/xkbcomp/expr.h +++ b/src/xkbcomp/expr.h @@ -27,11 +27,6 @@ #ifndef XKBCOMP_EXPR_H #define XKBCOMP_EXPR_H -typedef struct _LookupEntry { - const char *name; - unsigned int value; -} LookupEntry; - bool ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr, const char **elem_rtrn, const char **field_rtrn, diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c index 59c3b6d..56e840c 100644 --- a/src/xkbcomp/vmod.c +++ b/src/xkbcomp/vmod.c @@ -25,6 +25,7 @@ ********************************************************/ #include "xkbcomp-priv.h" +#include "text.h" #include "expr.h" #include "vmod.h" |