Commit Graph

964 Commits (be3cbc993eaba8f2239e237ba43df6b4de236041)

Author SHA1 Message Date
Daniel Stone ef88c7efab 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>
2012-04-09 13:47:23 +01:00
Daniel Stone bc872252f3 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>
2012-04-09 13:47:23 +01:00
Daniel Stone 632d9f0336 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>
2012-04-09 13:47:23 +01:00
Daniel Stone 495d87b06d 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>
2012-04-03 15:12:04 +01:00
Daniel Stone 151fb4fc6d Remove unused device_spec
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-04-03 15:12:03 +01:00
Daniel Stone f249919ec6 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.]
2012-04-03 15:11:42 +01:00
Daniel Stone 0002b8524c Add cscope output to .gitignore
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-04-03 13:01:10 +01:00
Daniel Stone 69111405b0 Properly document xkb_key_get_syms
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-04-03 12:48:05 +01:00
Ran Benita aeaa623d27 Constify a global table
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-02 13:12:31 +01:00
Ran Benita c83043b3c1 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>
2012-04-02 13:12:27 +01:00
Ran Benita 3c9493795b 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.]
2012-04-02 13:11:59 +01:00
Ran Benita ffb610c943 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>
2012-04-02 13:10:52 +01:00
Ran Benita 7a7ec9b14a 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.]
2012-04-02 13:10:38 +01:00
Ran Benita 5c5f7fcb7c 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>
2012-04-02 13:09:44 +01:00
Ran Benita 84ec6b61a7 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>
2012-04-02 13:09:40 +01:00
Ran Benita 9813778e73 makekeys: free strings before exiting
Just to make valgrind happy.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-02 13:09:36 +01:00
Ran Benita 8f2c9597ba Use straight strtok_r instead of wrapper
strtok_r is POSIX-2001 and should be fine.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-02 13:09:21 +01:00
Ran Benita fb606b06a9 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>
2012-04-02 13:09:06 +01:00
Daniel Stone cc5588c65b Fail gracefully on failure to find component include
If we can't find the component of the include file we're looking for,
make sure we don't return success when we meant failure, segfault, or
spectacularly leak everything.

Tested with incorrect component includes for keycodes, compat, symbols,
and types.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reported-by: David Herrmann <dh.herrmann@googlemail.com>
2012-03-29 17:39:11 +01:00
Daniel Stone 9b14e0c311 Tests: Release context on failure to build keymap
No practical effect since they exit(1) regardless, but it keeps valgrind
happy.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-29 17:38:44 +01:00
Daniel Stone 93ce9c7d4f Full support for multiple keysyms per level
Which also involved moving the global symbol map to be per-key instead;
this should probably be split out into a separate commit.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-29 16:31:09 +01:00
Daniel Stone 9cdc1990fa Parsing support for multiple keysyms per entry
Instead of allowing only one keysym per level per group, do as the
external API indicates and allow multiples.  The existing syntax is:
    key <AD01> { [ q, Q ] };
where the new syntax is:
    key <AD01> { [ q, Q, { H, E, L, L, O },
                 { Y, E, S, space, T, H, I, S, space, I, S, space, D, O, G } };

to make the key in the extreme top left of the keyboard do pretty
surprising things in levels 3 and 4.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-29 01:57:06 +01:00
Daniel Stone 36b8771e1f Don't leak strings in merge declarations
Introduced by the reentrant scanner commit.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-29 01:49:55 +01:00
Daniel Stone aa9f2bf98d Don't leak include_paths in context
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-29 01:41:40 +01:00
Daniel Stone 6628cf0bed Remove unused rtrnValue declaration
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-28 19:50:45 +01:00
Ran Benita bb6ca7682c Make parser and scanner reentrant
All global state is removed from the parser and scanner.
This makes use of the standard facilities in Bison and Flex for
reentrant/pure scanner/lexer and location tracking.

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

[daniels: Updated to current sources.]
2012-03-27 22:41:22 +01:00
Daniel Stone 034ffce664 Use xkb_contexts in keymap compilation
Primarily for the include path, but also for the logging in future.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 17:22:35 +01:00
Daniel Stone 3e9dd7512c Add new context API
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 16:59:01 +01:00
Daniel Stone f0cb4ee219 Update xkb_filter_group_lock_func for xkb_key_direction
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 16:15:06 +01:00
Daniel Stone 21f1bff4af Fix distcheck with non-recursive Makefiles
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 15:56:06 +01:00
Daniel Stone bc8bbf50dc Fix build for X11 modifier masks
Exposed by include path changes, oops.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 15:51:24 +01:00
Ran Benita 3fa7fdd089 Handle group lock actions
The spec is simple here, as this action has no effect on key releases.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:17:39 +01:00
Ran Benita b5efe41f19 Make build non-recursive
Unify all the different Makefile.am into a single short top level one
(the test/Makefile.am file is left intact though).

This makes the build system simpler to look and should encourage
unifying more currently-disparate code.

Some further motivation can be found in this page:
http://www.flameeyes.eu/autotools-mythbuster/automake/nonrecursive.html

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:17:34 +01:00
Ran Benita 602e87805b Define our own NoSymbol value and use it
Since we have our own xkb_keysym_t type, it makes sense to have our own
NoSymbol value instead of the one from X11/X.h.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:16:36 +01:00
Ran Benita d3908b631c Define our own None atom value
Since we define our own xkb_atom_t type, it makes sense not to use the
X11/X.h None value. This way we can also remove a lot of X11 includes.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:16:11 +01:00
Ran Benita 2165e16ed9 Fix all -Wsign-compare warnings
i.e comparison of signed and unsigned values. These are mostly
harmless but fixing them allows to compile cleanly with -Wextra.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:15:31 +01:00
Ran Benita 813ddf255d Silence -Wcast-qual warnings
There are some cases where we must free a string with a const qualifier.
Add a macro UNCONSTIFY to trick the compiler into silencing the warning
in the cases where we know what we're doing.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:15:11 +01:00
Ran Benita f08ce9b71b Use strcasecmp consistently instead of uStrCaseCmp
There's no use calling the same thing by a different name.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:13:24 +01:00
Ran Benita 3104a8ef18 Move utility macro from XKBcommonint.h to utils.h
And merge all the similar ones into the same name.
The u* prefix is chosen over the _Xkb prefix because it has more uses
throughout the codebase. But It should now be simple to choose a nice
prefix and stay consistent.

Signed-off-by: Ran Benita <ran234@gmail.com>
[daniels: fixed for the case where we have strcasecmp]
2012-03-27 14:12:34 +01:00
Ran Benita 2a5f641657 Remove some more useless stuff
Some unused defines and geometry-removal leftovers (specifically the
file geom.c and the struct for the keyboard coordinates).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:09:53 +01:00
Ran Benita 861b0c79c4 Rewrite recalloc to the correct type
The recalloc function should be expressed in terms of bytes to match its
name. However uTypedRecalloc retains its type so nothing is changed.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:09:50 +01:00
Ran Benita 0480f427ad Remove useless stuff from utils
Signed-off-by: Ran Benita <ran234@gmail.com>

[daniels: fixed conflicts from strcasecmp, added includes to make
          filecomp build again]
2012-03-27 14:09:27 +01:00
Daniel Stone 2ac8610fad Remove fallback strcasecmp/strncasecmp
Sorry if your libc doesn't have this, but it's not my problem.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Reported-by: Ran Benita <ran234@gmail.com>
2012-03-27 14:06:56 +01:00
Daniel Stone 55b76a6389 Add include/ to makekeys include path
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-03-27 14:05:14 +01:00
Ran Benita d22b8dbbd0 Move utils.{c,h} to be used by the entire project
This is a first step for making consistent use of utils.h also outside
of xkbcomp/ .

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:51 +01:00
Ran Benita 7cc17ec507 Fix a scanf type mismatch
"%o" takes an unsigned int.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:50 +01:00
Ran Benita f52671a4d1 Remove a few remaining uses of the KeySym type
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:22 +01:00
Ran Benita 8b3e2b9b00 Add xkb test file to EXTRA_DIST
To appease make distcheck.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:19 +01:00
Ran Benita 1b17708c88 Fix incorrect usage of && instead of &
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:17 +01:00
Ran Benita eeb0a21448 Update gitignore for 'state' test
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-03-27 13:59:15 +01:00