Commit Graph

827 Commits (2eba51c0f603535dc2663f2666437305b287efb3)

Author SHA1 Message Date
Ran Benita 5df53e4944 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>
2012-04-09 14:04:25 +01:00
Ran Benita 18e6a6a43e Remove Xfuncproto.h and XKB.h from xkbcommon/xkbcommon.h
The kbproto header is already 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>

[daniels: Updated for xkb_keymap changes.]
2012-04-09 14:04:11 +01:00
Ran Benita 073a21076c 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>
2012-04-09 13:58:44 +01:00
Ran Benita 467d7bb64e 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>

[daniels: Updated for xkb_keymap changes.]
2012-04-09 13:57:36 +01:00
Ran Benita b08629f92b Do not enable yacc trace facility unconditionally
Define DEBUG and set yydebug if you want that.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-09 13:56:32 +01:00
Ran Benita 913e0740cb Constify a global table and function arguments
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-09 13:56:23 +01:00
Ran Benita d116aaef9f Remove unused struct definition
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-09 13:56:20 +01:00
Ran Benita 28011e71ad Replace remaining use of Atom instead of xkb_atom_t
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-09 13:55:59 +01:00
Ran Benita e9537d50d0 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>
2012-04-09 13:54:15 +01:00
Ran Benita 8feba630fa Fix KeyInfo's syms array size calculation
When merging group info from two KeyInfo's, the new size of the keysym
array was off. Fix it to match how it is used a few lines below.

There are also some peripheral fixes, and some comments (took me a
few minutes to get what's going on).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-09 13:53:26 +01:00
Ran Benita 518debb3bc Set xorg-macros CFLAGS correctly
A previous commit messed up all warning flags. Oops.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-04-09 13:52:38 +01:00
Ran Benita 2590b5a15d 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.]
2012-04-09 13:48:00 +01:00
Daniel Stone d007cd0a1f 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>
2012-04-09 13:47:23 +01:00
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