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>
Use straight strtok_r instead of wrapper

strtok_r is POSIX-2001 and should be fine.

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>
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>
Avoid leak in CompileKeymap error path

The NULL check is unneeded, and prevented the atoms from being free'd.

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

[daniels: Updated for xkb_map_unref.]
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>
Fix bugs to allow multiple keymaps in one process

These were several initializations that were forgotten in the previous
memory leak fixes.

Now several xkb_desc's can coexist (relatively) peacefully.

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

[daniels: Only the atom.c is relevant with the new context API.]
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>
Constify a global table

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

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Add cscope output to .gitignore

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
include resets group compatibility modifiers #43091

This change makes sure that include does not overwrite previous
compatibility modifier settings when the included files does not
explicitly specify them.

Signed-off-by: Andreas Wettstein <wettstein509@solnet.ch>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>

[Cross-picked from xkbcomp commit 14470719.]
Remove unused device_spec

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Don't parse nonsense Unicode/hex keycodes

If a keysym was specified as "U1039andsomeextrastuffontheend", return
NoSymbol rather than 0x10001039; similarly, return NoSymbol for
"0xdeadbeefhitherehowsyourdaybeen" rather than 0xdeadbeef.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Eliminate remaining gcc warnings

Various one-liners (mostly removing unused variables) to make the code
safe for the full set of warnings used by the xorg macros.

On Debian-based systems, flex generates incorrect code resulting in two
warnings about yy_getcolumn and yy_setcolumn having no previous
declaration despite being non-static.  Fedora carries a patch to fix
this, and a bug has been filed on Debian's flex to add the patch:
http://bugs.debian.org/667027

Aside from this, it's now safe for --enable-strict-compilation.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Use xorg CFLAGS and fix AC_USE_SYSTEM_EXTENSIONS

autotools was warning that AC_USE_SYSTEM_EXTENSIONS was being called too
late, so move it earlier.  Also shove BASE_CFLAGS into CFLAGS so we get
all the added warning flags from xorg.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Rename xkb_desc to xkb_keymap

struct xkb_desc was just a hangover from the old XkbDescRec, which isn't
a very descriptive name.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Unconstify xkb_rules_names

Since we never return an xkb_rules_names and it's all user-provided
strings, seems a bit harsh to have it const.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Fix compiler warnings

(They were not reported, see next commit).
The reset function declaration didn't match its name in the definition;
the _defaults variant matches better with the rest.

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

[daniels: Updated to current master.]