summaryrefslogtreecommitdiff
path: root/src/xkbcomp/action.c
Commit message (Collapse)AuthorAgeFilesLines
* build: include config.h manuallyRan Benita2019-12-271-0/+2
| | | | | | | | | Previously we included it with an `-include` compiler directive. But that's not portable. And it's better to be explicit anyway. Every .c file should have `include "config.h"` first thing. Signed-off-by: Ran Benita <ran@unusedvar.com>
* action: make a note that we may not null-terminate private stringsPeter Hutterer2018-08-011-0/+1
| | | | | | | | | | | | | | Coverity complains that a 7-byte string may not be null-terminated when copied into act->data (size 7). This is fine, make a note of it. All the strings in xkeyboard-config only use 6 bytes + null terminator so this won't be an issue. The server (the only user of these) uses an 8-byte array and forcibly null-terminates the string, see XkbDDXPrivate(). Everything else treats it as byte-array size 7 anyway so whether it's null-terminated doesn't matter. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
* action: take xkb_mod_set instead of the entire keymapRan Benita2014-04-191-113/+115
| | | | | | | A couple of modiifer actions need this information, but not the entire keymap. Signed-off-by: Ran Benita <ran234@gmail.com>
* expr: take xkb_mod_set instead of the entire keymapRan Benita2014-04-191-1/+2
| | | | | | The modifier-resolving functions only need the modifier information. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: convert a few missed unsigned -> enum xkb_action_typeRan Benita2014-04-161-5/+5
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* action: unify SetLatch and Lock handler functionsRan Benita2014-02-161-54/+33
| | | | | | | | This is a little shorter and follows easier from the spec flag description table. Also a few were too permissive (like allowing LatchToLock in SetMods). Signed-off-by: Ran Benita <ran234@gmail.com>
* action: add a common CheckBooleanFlag functionRan Benita2014-02-161-52/+32
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* keymap: change action flag NO_ACCEL -> ACCELRan Benita2014-02-161-2/+3
| | | | | | It's easier to deal with, but we need to set it as "factory default". Signed-off-by: Ran Benita <ran234@gmail.com>
* action: fix SwitchScreen "same" field handlingRan Benita2014-02-161-2/+3
| | | | | | | This used to *unset* a flag called "SwitchApplication"; we changed the flag to "same" but forgot to switch the cases. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: don't pass a keymap where a ctx is sufficientRan Benita2014-02-151-59/+59
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* action: add missing array_ndx checksRan Benita2014-02-151-4/+9
| | | | | | | Only the "data" field can have them, and every other field needs to error out if it appears. But some didn't check. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: move array_ndx errors into the Check functionsRan Benita2014-02-151-75/+44
| | | | | | Makes more sense and flows more nicely this way. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: fix missing support for "affect" fieldRan Benita2014-02-151-18/+34
| | | | | | | | | Support for setting this field was missing from the LockMods and LockControls actions. Based on a xkbcomp patch by Andreas Wettstein. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: simplify Check* functionsRan Benita2014-02-141-68/+34
| | | | | | | | | | Instead of using those t1 t2 variables, pass the final destinations directly (while making sure they are not modified in case of error). This also ensures the types are right, e.g. in CheckGroupField it should be int32_t, not xkb_layout_index_t (and indeed it takes a negation!). Signed-off-by: Ran Benita <ran234@gmail.com>
* action: fix misleading castRan Benita2014-02-081-1/+1
| | | | | | The type is uint8_t and so is the checked range. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: fix printing of underflowed value in error messageRan Benita2014-02-081-2/+2
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Fix sign-compare warningsRan Benita2014-02-081-1/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* action: Use ResolveInteger for PtrBtn.count, not ResolveButtonRan Benita2014-02-071-6/+5
| | | | | | It's not a button. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: check range of MovePtr X,Y valuesRan Benita2014-02-071-2/+11
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* action, types: remove unused Report functionsRan Benita2014-01-121-11/+0
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Fix some cppcheck warningsRan Benita2014-01-111-6/+2
| | | | | | | | | | | | | | | | | | | | | | | Someone was nice enough to run this for us: ftp://ftp.sunet.se/pub/Linux/distributions/Debian/debian/pool/main/libx/libxkbcommon/libxkbcommon_0.3.1.orig.tar.gz [libxkbcommon-0.3.1/src/keymap.c:86]: (style) The scope of the variable 'j' can be reduced. [libxkbcommon-0.3.1/src/keymap.c:87]: (style) The scope of the variable 'key' can be reduced. [libxkbcommon-0.3.1/src/keysym-utf.c:843]: (style) The scope of the variable 'mid' can be reduced. [libxkbcommon-0.3.1/src/state.c:992]: (style) The scope of the variable 'str' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/action.c:467]: (style) The scope of the variable 'absolute' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/rules.c:468]: (style) The scope of the variable 'consumed' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/rules.c:862]: (style) The scope of the variable 'mlvo' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/rules.c:863]: (style) The scope of the variable 'kccgst' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/rules.c:865]: (style) The scope of the variable 'match_type' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/symbols.c:753]: (style) The scope of the variable 'toAct' can be reduced. [libxkbcommon-0.3.1/src/xkbcomp/symbols.c:1573]: (style) The scope of the variable 'key' can be reduced. [libxkbcommon-0.3.1/test/common.c:80]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'unsigned int'. [libxkbcommon-0.3.1/test/interactive.c:358]: (style) The scope of the variable 'nevs' can be reduced. [libxkbcommon-0.3.1/test/interactive.c:236]: (style) Checking if unsigned variable 'nsyms' is less than zero. [libxkbcommon-0.3.1/test/interactive.c:226]: (style) Unused variable: unicode Signed-off-by: Ran Benita <ran234@gmail.com>
* expr: split expression types and allocate them separatelyRan Benita2013-12-011-34/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, we have one ExprDef type, which contains a tagged union with the value of all expression types. Turns out, this union is quite wasteful memory-wise. Instead, create separate types for all expressions (e.g ExprBinary, ExprInteger) which embed the common fields (ExprCommon), and malloc them per their size; ExprDef then becomes a union of all these types, but is just used as a generic pointer. [Instead of making ExprDef a union, another option is to use ExprCommon as the generic pointer type and then do up-castings, like we do with ParseCommon. But this makes the code much uglier.] The diff is mostly straightforward mechanical adaptations. It could have been much smaller with the help of C11 anonymous structs (which were previously a gnu extension). This will have saved all of the 'op' -> 'expr->op', etc changes. But if we can be a bit more portable for a little effort, we should. Before (./test/rulescomp, x86 32 bit, -O2): ==12974== total heap usage: 145,217 allocs, 145,217 frees, 10,476,238 bytes allocated After: ==11145== total heap usage: 145,217 allocs, 145,217 frees, 8,270,358 bytes allocated Signed-off-by: Ran Benita <ran234@gmail.com>
* expr: add constructor for boolean expressionsRan Benita2013-12-011-2/+2
| | | | | | | Also add a 'bool set' to the ExprDef union, instead of using 'ival' as a bool. Signed-off-by: Ran Benita <ran234@gmail.com>
* expr: add 'ident' value to ExprDef unionRan Benita2013-11-301-1/+1
| | | | | | | This distinguishes between an identifier expression and a string expression in the union. Signed-off-by: Ran Benita <ran234@gmail.com>
* Fix pointer style nitRan Benita2013-03-181-1/+1
| | | | | | (I really dislike this one for some reason..) Signed-off-by: Ran Benita <ran234@gmail.com>
* Move a couple of general keymap functions from keycodes.cRan Benita2013-03-181-1/+0
| | | | | | | To get a key by name and resolve an alias - this makes sense for everyone. Signed-off-by: Ran Benita <ran234@gmail.com>
* More spelling errorsRan Benita2013-03-181-1/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* action: s/hndlrType/handler_typeRan Benita2013-03-181-5/+5
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* action: don't allow private actions with a known typeRan Benita2012-10-301-1/+20
| | | | | | | | Some obscure bug having to do with Private actions; see the comments. This was prompted by: https://bugs.freedesktop.org/show_bug.cgi?id=56491 Signed-off-by: Ran Benita <ran234@gmail.com>
* expr: unify the real and virtual modifier functionsRan Benita2012-10-061-1/+1
| | | | | | | | This again pushes the mod type annotation to the original call site, to make it easier to grep to see where the real/virtual distinction matters. Signed-off-by: Ran Benita <ran234@gmail.com>
* Use our types instead of int/uint32_t in a few placesRan Benita2012-10-061-1/+1
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Don't use %z printf formatRan Benita2012-09-301-2/+2
| | | | | | Some libc's don't support it. Signed-off-by: Ran Benita <ran234@gmail.com>
* Don't use xkbcommon-compat names in internal codeRan Benita2012-09-241-3/+3
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>
* Rename ACTION_TYPE_LAST to _ACTION_TYPE_NUM_ENTRIESRan Benita2012-09-141-3/+2
| | | | | | | It's not really "last" per-se, and we use this other format in some other enums. Signed-off-by: Ran Benita <ran234@gmail.com>
* Copyright updatesDaniel Stone2012-09-121-0/+27
| | | | | | | | | | | | With Dan Nicholson's permission (via email), update his copyright and license statements to the standard X.Org boilerplate MIT license, as both myself and Ran have been using. Clean up my copyright declarations (in some cases to correct ownership), and add copyright/license statements from myself and/or Ran where appropriate. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* actions: Remove PointerDefault affect fieldDaniel Stone2012-09-101-5/+3
| | | | | | This was always set to affect the default button, so no need for it. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* kbproto unentanglement: action flagsDaniel Stone2012-09-101-31/+29
| | | | Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* kbproto unentanglement: action typesDaniel Stone2012-09-101-30/+30
| | | | Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* Remove deprecated actionsDaniel Stone2012-09-101-331/+1
| | | | | | | We didn't do anything with ISO_Lock, ActionMessage, RedirectKey, and the device-specifying variants of the pointer actions, so remove those. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* kbproto unentanglement: XkbNumVirtualModsDaniel Stone2012-09-101-1/+1
| | | | Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* kbproto untanglement: XkbKeyNameLengthDaniel Stone2012-09-101-1/+1
| | | | | | | Define it ourselves as XKB_KEY_NAME_LENGTH and use that, instead of the one from XKB.h. Signed-off-by: Daniel Stone <daniel@fooishbar.org>
* Unify some string tables from xkbcomp, text and keymap-dumpRan Benita2012-09-031-103/+4
| | | | | | | | | | | We move the LookupEntry struct from expr.h to text.h, along with most of the lookup tables. This makes them available everywhere. Looking up a value in the LookupEntry format is slower than direct index mapping, but it allows multiple names per value (with the canonical one being first) and "all"- and "none"-type masks. These functions are not used anywhere efficiency matters. Signed-off-by: Ran Benita <ran234@gmail.com>
* expr: make ResolveString return an atomRan Benita2012-09-031-2/+6
| | | | | | | | Almost all callers do xkb_atom_intern on the currently returned string, while ResolveString converts the atom to the string to begin with... uselss double work. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: fix LookupEntry for "lockdevbtn"Ran Benita2012-09-031-1/+1
| | | | | | xkbcomp has that bug as well, guess no one uses it. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: remove redundant checkRan Benita2012-09-031-7/+0
| | | | | | The NoAction handler always errors out with the same message. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: keep array of default actions, instead of list of changesRan Benita2012-09-031-78/+44
| | | | | | | | | | | | | | | | | | | | The implementation of changing the default properties of actions, e.g. a statements such as (from test/data/compat/basic): setMods.clearLocks= True; latchMods.clearLocks= True; latchMods.latchToLock= True; works by keeping a list of ActionInfo's, each containing the neccesary info from each statement, and then when some action comes up (e.g. in an interpret statment) it goes through the list, and applies the relevent ActionInfo's to the newly-constructed xkb_action. Instead of doing this, we add a struct ActionsInfo, which contains an array of xkb_actions, one for each type. When a default changing statement appears, we change the action in the array; when a new action comes up, we just copy from the array. This is simpler to figure out, and pretty straightforward. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: disallow setting an action_field default for all typesRan Benita2012-09-031-13/+8
| | | | | | | | | | | | | | | | | | Currently where it is possible to write: setMods.clearLocks = True; It's also possible to write: action.clearLocks = True; This will set the default value for the clearLocks action field for *all* action types, as opposed to just setMods in this case. If subsequently an action is used for which this field does not make sense, it will error out. This doesn't make any sense, because any given field is only possible by at most 3 or 4 action types... which you might as well write explicitly and avoid the side effect mentioned above. Needless to say this is one of xkbcomp's "hidden features" and is not used anywhere; remove it. Signed-off-by: Ran Benita <ran234@gmail.com>
* action: clean up formatting of extern functionsRan Benita2012-09-031-48/+62
| | | | | | Make it a bit easier to understand what they do. Signed-off-by: Ran Benita <ran234@gmail.com>
* expr: move op_type/value_type_to_string functions to astRan Benita2012-09-021-1/+1
| | | | | | | Generally the enum-to-string function should appear where the enum is defined. Signed-off-by: Ran Benita <ran234@gmail.com>
* compat: small changesRan Benita2012-09-011-2/+2
| | | | Signed-off-by: Ran Benita <ran234@gmail.com>