Fix configure check for xkbparse.c instead of parser.c

This obscure test is easy to miss.

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

Introduced in 38cb639082ec4b31725d4ce4e35af63938691631.

Signed-off-by: Ran Benita <ran234@gmail.com>
Various static analyzer fixes

Signed-off-by: Ran Benita <ran234@gmail.com>
Revert "Fix KeyInfo's syms array size calculation"

This partly reverts commit 8feba630fa7a4b720c42a9b5b4e4280b0e17a500.

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>
Remove unused allowNone from KeyInfo

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove FileHandler callback argument

It's unneeded; the same function is always passed.

Signed-off-by: Ran Benita <ran234@gmail.com>
Change xkb_map_new_from_fd to use FILE*

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>
Create path.h for the path.c functions

No need to stash them in xkbcomp-priv.h; files which need the functions
should explicitly include them.

Signed-off-by: Ran Benita <ran234@gmail.com>
Don't run the benchmark by default

For people running 'make check' on every compilation, this can be
a nuisance.

Signed-off-by: Ran Benita <ran234@gmail.com>
rules: remove unused struct fields and use size_t

Signed-off-by: Ran Benita <ran234@gmail.com>
rules: only export a single function

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>
rules: don't use custom logging functions

Signed-off-by: Ran Benita <ran234@gmail.com>
rules: reformat input line handling

Signed-off-by: Ran Benita <ran234@gmail.com>
rules: don't typedef the structs and rename them

The long prefix is unnecessary now that they are all private.

Signed-off-by: Ran Benita <ran234@gmail.com>
rules: rewrite get_index to use sscanf

Signed-off-by: Ran Benita <ran234@gmail.com>
rules: reformat SetUpRemap and struct remap_spec

Rename to more descriptive names and reformat.

Signed-off-by: Ran Benita <ran234@gmail.com>
rules: reformat CheckLine and break into several functions

And remove struct file_spec which is really unneeded. Should be
slightly more clear now.

Signed-off-by: Ran Benita <ran234@gmail.com>
rules: use asprintf instead of _Concat function

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

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

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