Fix possible overflow in scanner

Also reduce the size of scanBuf given that it's allocated on the stack,
and 1024 is enough.

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>
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>
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>
Constify a global table and function arguments

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 (see example in our own code).

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>
Constify the syms_out argument to xkb_key_get_syms()

The caller should not mess around with these as they come directly from
our internal structs.

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

The kbproto header is not needed here anymore.

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 and kbproto from pkg-config file

These are no longer needed for using the library, only building it. Most
users would still want xproto 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>
Pass DFLT_XKB_CONFIG_ROOT through config.h

Instead of -D preprocessor flag. That's why it's there for.

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>
Fix formatting in xkbcomp headers

Signed-off-by: Ran Benita <ran234@gmail.com>
Add xkb_state_get_map()

This is very useful because it avoids redundent pointers in structs
and/or parameter passing in the application.

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