rules: fix parsing of multiple options

This was broken by commit 18d331b86b4942ba54fe087ca07e47c9383d768b
(where only the first option out of a comma-separated string was
matched). Do it correctly this time and add a test.

Signed-off-by: Ran Benita <ran234@gmail.com>
keyseq: add a failing group-switching test

For some reason, with the grp:alt_shift_toggle option, the following
sequence switches a group:
< Left Shift down, Left Alt down >
While the reverse doesn't:
< Left Alt down, Left Shift down >
And it should.

Signed-off-by: Ran Benita <ran234@gmail.com>
symbols: fix bug in symbol merging

When we merge two KeyInfo's (belonging to the same keycode), we may take
a shortcut from copying if we see that the merged keys will be exactly
like those in one of the two KeyInfo's. In the case where we take the
symbols from the KeyInfo we are *not* merging into, we need to copy
the three arrays:
    syms[group], symsMapNumEntries[group], symsMapIndex[group]
The code currently only copies the first one, so if there's a merge
conflict some levels may seem to disappear (i.e. have a NoSymbol
keysym).

This fixes the failing test added in c8d6bba.

Signed-off-by: Ran Benita <ran234@gmail.com>
test/dump: output commentary to stderr

Signed-off-by: Ran Benita <ran234@gmail.com>
Enlarge keysym name buffers and mention in comment

The longest keysym is 27 chars long.

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove 'force' argument from BindIndicators

It was always true in the one callsite, so just remove the other
branches.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Remove 'unboundRtrn' argument from BindIndicators

It was only ever passed as NULL from its single callsite, so just remove
it and be done with it.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Change BindIndicators return to void

Since it could only ever return true, which avoids a totally unnecessary
cleanup path.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Make BindIndicators static

Since BindIndicators was only ever called immediately after
CopyIndicatorMapDefs, move it up in the file and turn it into a static
function, which avoids the need to ever pass the unbound LEDs around.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Move test data files to test/data/keymaps

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Add a library of common test functions

Including creating a context (will come in useful soon), opening and
reading files, and compiling keymaps.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Import dataset into test/data/

Use a self-contained dataset instead of relying on a globally-installed
set.  Data taken from xkeyboard-config 2.5.1.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
dump: use KeyNameText instead of copying

Signed-off-by: Ran Benita <ran234@gmail.com>
symbols: fix bug in modifier_map handling

The code used to match a keysym to a keycode (see added comment)
differed in behavior from xkbcomp, always taking the first key it found.
This caused some incorrect interpretation of the xkeyboard-config data,
for example the one corrected in dump.data (see the diff): since the
de-neo layout sets the both_capslock option, the Left Shift key (LFSH)
has the Caps_Lock keysym in group 4 level 2; now since
    keycode(Left Shift) = 50 < keycode(Caps Lock) = 64
the Left Shift one was picked, instead of the Caps Lock one which is
group 1 level 1. The correct behavior is to pick according to group,
level, keycode.

Signed-off-by: Ran Benita <ran234@gmail.com>
!fixup symbols: fix bug in modifier_map handling

[ these were wrong as well - don't think backslash was supposed to be a
modifier :) ]

Signed-off-by: Ran Benita <ran234@gmail.com>
!fixup test/dump: output commentary to stderr

[ this is for easy redirection - they should both show up in
test-suite.log ]

Signed-off-by: Ran Benita <ran234@gmail.com>
dump: add back kccgst names

Readd the component names to the keymap->names struct. This is used when
printing the component, e.g.

xkb_keymap {
	xkb_keycodes "evdev+aliases(qwerty)" {

instead of

xkb_keymap {
	xkb_keycodes {

This makes diffing against xkbcomp $DISPLAY a bit easier and is kind of
useful anyway.

Signed-off-by: Ran Benita <ran234@gmail.com>