Add a non-extensive test to check that some basic things (e.g. rule
matching, var substitution, indexes and groups) work as expected.
Signed-off-by: Ran Benita <ran234@gmail.com>
Currently, if you pass in an rmlvo with an empty string for layout or
variant, it would not match layout and variant rules even with
wildcards. But if the rules file had set an appropriate default, and someone
passes in the empty string, than he should get the default.
NULL in this case signifies not wanting to match against the layout or
variant at all, and so the rule should still fail to match NULLs.
Signed-off-by: Ran Benita <ran234@gmail.com>
Really all we need from this file is a way to get xkb_component_names
from an xkb_rule_names, which is now the only thing being exposed. This
should allow for some much needed refactoring of this code.
Since this is only used by xkbcomp.c and uses xkbcomp functions, also
move rules.{c,h} under the xkbcomp dir.
Signed-off-by: Ran Benita <ran234@gmail.com>
i.e. xkb_map_new_from_file. The reason is that flex only works with
FILE's, so we must use fdopen on the file descriptor; but to avoid a
memory leak, we must also fclose() it, which, in turn, closes the file
descriptor itself.
Either way is not acceptable, so we can either:
* dup() the fd and use fdopen on that, or
* have the user call fdopen on his own, and accept a FILE* instead of an
fd.
The second one seems better, and is standard C, so why not. We must add
stdio.h to xkbcommon.h though, which is regrettable, but not a big deal.
Signed-off-by: Ran Benita <ran234@gmail.com>
This partly reverts commit 8feba630fa.
This seems to fix valgrind errors:
==9581== Invalid read of size 4
==9581== at 0x4E50928: MergeKeyGroups (symbols.c:544)
==9581== by 0x4E510F3: MergeKeys (symbols.c:644)
==9581== by 0x4E514C6: AddKeySymbols (symbols.c:722)
==9581== by 0x4E51A3F: MergeIncludedSymbols (symbols.c:854)
==9581== by 0x4E51E97: HandleIncludeSymbols (symbols.c:952)
==9581== by 0x4E53D75: HandleSymbolsFile (symbols.c:1619)
==9581== by 0x4E55A0B: CompileSymbols (symbols.c:2187)
==9581== by 0x4E4056C: CompileKeymap (keymap.c:160)
==9581== by 0x4E56953: compile_keymap (xkbcomp.c:149)
==9581== by 0x4E56AC5: xkb_map_new_from_kccgst (xkbcomp.c:195)
==9581== by 0x4009D7: test_names (namescomp.c:56)
==9581== by 0x400A55: main (namescomp.c:75)
==9581== Address 0x5729b04 is 0 bytes after a block of size 4 alloc'd
==9581== at 0x4C29024: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9581== by 0x4E5C37B: recalloc (utils.c:41)
==9581== by 0x4E4FF50: ResizeKeyGroup (symbols.c:356)
==9581== by 0x4E5229E: AddSymbolsToKey (symbols.c:1058)
==9581== by 0x4E52ABB: SetSymbolsField (symbols.c:1214)
==9581== by 0x4E536C7: HandleSymbolsBody (symbols.c:1481)
==9581== by 0x4E53A63: HandleSymbolsDef (symbols.c:1543)
==9581== by 0x4E53DAD: HandleSymbolsFile (symbols.c:1623)
==9581== by 0x4E51CA4: HandleIncludeSymbols (symbols.c:909)
==9581== by 0x4E53D75: HandleSymbolsFile (symbols.c:1619)
==9581== by 0x4E51E74: HandleIncludeSymbols (symbols.c:951)
==9581== by 0x4E53D75: HandleSymbolsFile (symbols.c:1619)
Signed-off-by: Ran Benita <ran234@gmail.com>
Still keep things as 'ctx' internally so we don't have to worry about
typing it too often, but rename the user-visible API back as it was
kinda ugly.
This partially reverts e7bb1e5f.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
It was a pretty pointless check. Also sanitise the _x11 variant to
actually do what it says on the box.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>