Move AC_USE_SYSTEMS_EXTENSIONS before AM_INIT_AUTOMAKE

Otherwise it shouts.

Signed-off-by: Ran Benita <ran234@gmail.com>
Constify a global table and function arguments

Signed-off-by: Ran Benita <ran234@gmail.com>
Make temporary fix for stale xkb_atoms

When xkb_free_keymap is called the atoms are all free'd, but action.c
keeps a global copy of interned "true" and "false", which remains stale.

The correct fix is to remove the need for the ActionsInit function
entirely.

Signed-off-by: Ran Benita <ran234@gmail.com>
Fix missing initialization after freeing atoms

This was forgotten in a previous memory leak fix.

Now several xkb_desc's can coexist (relatively) peacefully in the same
process.

Signed-off-by: Ran Benita <ran234@gmail.com>
Avoid use of partly initialized VModInfo in error path

Such as:

Compiling path: ./test/data/bad.xkb  mapName:
==1300== Conditional jump or move depends on uninitialised value(s)
==1300==    at 0x4E46166: HandleVModDef (vmod.c:90)
==1300==    by 0x4E3FEC9: HandleKeyTypesFile (keytypes.c:1035)
==1300==    by 0x4E3FBE1: HandleIncludeKeyTypes.constprop.11 (keytypes.c:387)
==1300==    by 0x4E401DD: HandleKeyTypesFile (keytypes.c:1022)
==1300==    by 0x4E3FBE1: HandleIncludeKeyTypes.constprop.11 (keytypes.c:387)
==1300==    by 0x4E401DD: HandleKeyTypesFile (keytypes.c:1022)
==1300==    by 0x4E4026F: CompileKeyTypes (keytypes.c:1150)
==1300==    by 0x4E3DF9B: CompileKeymap (keymap.c:169)
==1300==    by 0x4E465E9: compile_keymap (xkbcomp.c:205)
==1300==    by 0x4E46BE4: xkb_compile_keymap_from_file (xkbcomp.c:290)
==1300==    by 0x400B37: test_file (filecomp.c:47)
==1300==    by 0x4008E3: main (filecomp.c:90)
==1300==  Uninitialised value was created by a stack allocation
==1300==    at 0x4E3FB3F: HandleIncludeKeyTypes.constprop.11 (keytypes.c:366)

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove useless check from xkb_intern_atom

The "makeit" variable is always true. Remove it and de-indent.
(Also change the type of the "len" variable to size_t to avoid some
useless casting).

Signed-off-by: Ran Benita <ran234@gmail.com>
Add a NULL check before before strcmp'ing

The names array can have NULL entries for some virtual modifier indexes.

Signed-off-by: Ran Benita <ran234@gmail.com>
makekeys: use correct format strings

The new glibc (2.15) appear to cause trouble, particularly the sscanf
call, where makekeys will output empty hash tables. Using the appropriate
macros from inttypes.h makes it work again.

Signed-off-by: Ran Benita <ran234@gmail.com>
makekeys: free strings before exiting

Just to make valgrind happy.

Signed-off-by: Ran Benita <ran234@gmail.com>
Use straight strtok_r instead of wrapper

strtok_r is POSIX-2001 and should be fine.

Signed-off-by: Ran Benita <ran234@gmail.com>
Replace remaining use of Atom instead of xkb_atom_t

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove unused struct definition

Signed-off-by: Ran Benita <ran234@gmail.com>
Do not enable yacc trace facility unconditionally

Define DEBUG and set yydebug if you want that.

Signed-off-by: Ran Benita <ran234@gmail.com>
Implement missing xkb_state_ref and add return value

xkb_state_ref was missing.

Also modify the _ref functions to return the object instead of being
void. This is a useful idiom:

    struct my_object my_object_new(struct xkb_state *state)
    {
        [...]
        my_object->state = xkb_state_ref(state);
        [...]
    }

Essentially "taking" a reference, such that you don't forget to
increment it and it's one line less.

A case could also be made for _unref to return the object or NULL, but
this is quite uncommon.

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove Xfuncproto.h from xkbcommon/xkbcommon.h

Move the _X_EXPORT's to the corresponding function definitions, and use
straight extern "C" clauses instead of _XFUNCPROTOBEGIN/END.

It also makes more sense to have the EXPORT's in the source files, as it
provides some documentation to the reader, whereas in the header it's
obvious.

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove xproto from pkg-config file

xproto is no longer needed for using the library, only building it. Most
users would still want it though, for the keysym definitions.

Signed-off-by: Ran Benita <ran234@gmail.com>
Implicitly include config.h in all files

The definitions in config.h should be available in all files an
implementation detail; it can be included through the build system
instead of having each file pull it every time.

This is especially helpful with AC_USE_SYSTEM_EXTENSIONS, as _GNU_SOURCE
and friends can have an effect by merely being defined, which can lead
to some confusion if its effective for only half the files.

And we don't really support a build _without_ config.h; so, one less
thing to worry about.

Signed-off-by: Ran Benita <ran234@gmail.com>
Reformat actionHandler dispatch table

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

Rewrite all of the current tests in the following ways:
- Instead of the current mix of C and shell, just use single-process
  pure C file per test. All of the .sh files are removed, but everything
  that was tested is ported.
- Instead of handling the test logs ourselves, use Automake's
  "parallel-test" mechanism. This will create a single log file for each
  test with it's stdout+stderr, and a top level "test-suite.log" file
  for all the failed tests.
- The "parallel-tests" directive also makes the test run in parallel,
  so "make check" runs faster.
- Also use the "color-tests" directive to have the "make check" output
  colorized. Who doesn't like to see PASS in green?
- All of the test data files are moved into the test/data subdirectory.
  That way we can just put the directory in EXTRA_DIST and forget about
  it.
- The test/Makefile.am file is consolidated into the main Makefile.am,
  for a completely non-recursive build.

Right now the tests are completely independent and just use simple
assert()'s. More sophistication can be added as needed.

It should also be noted that it's still possible to use shell, python,
etc. if a test wants more flexibility than C can provide, just do as
before.

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

Copy verbatim from libX11 and add a test.

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