platform/upstream/libxkbcommon.git
10 years agocompose/parser: one more skip_to_eol()
Ran Benita [Sun, 12 Oct 2014 21:16:59 +0000 (00:16 +0300)]
compose/parser: one more skip_to_eol()

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agocompose/parser: fix segfault when including
Ran Benita [Mon, 13 Oct 2014 15:51:12 +0000 (18:51 +0300)]
compose/parser: fix segfault when including

The keysym cache for the new scanner was not initialized.
To avoid such errors also in the future, require passing the priv
argument in scanner_init(), instead of initializing it separately.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoCOPYING: add copyright notice from libX11:modules/im/ximcp/imLcPrs.c
Ran Benita [Mon, 13 Oct 2014 11:28:27 +0000 (14:28 +0300)]
COPYING: add copyright notice from libX11:modules/im/ximcp/imLcPrs.c

We have used some portions of it, so add the notice.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoscanner-utils: optimize one-line comments
Ran Benita [Tue, 7 Oct 2014 20:42:08 +0000 (23:42 +0300)]
scanner-utils: optimize one-line comments

Compose files have a lot of those.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agobench/compose: add new benchmark
Ran Benita [Thu, 2 Oct 2014 21:30:43 +0000 (00:30 +0300)]
bench/compose: add new benchmark

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotest/interactive-evdev: add compose support
Ran Benita [Wed, 29 Jan 2014 11:46:42 +0000 (13:46 +0200)]
test/interactive-evdev: add compose support

To try, do e.g.:
sudo ./test/interactive-evdev -l us -v intl -o compose:ralt -d

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotest/compose: add new test
Ran Benita [Sun, 27 Oct 2013 18:37:27 +0000 (20:37 +0200)]
test/compose: add new test

Some results from the benchmark (compilation of en_US.UTF-8/Compose):

$ grep 'model name' /proc/cpuinfo
model name  : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz
model name  : Intel(R) Core(TM)2 Duo CPU     E8400  @ 3.00GHz

$ uname -a
Linux ran 3.16.1-1-ARCH #1 SMP PREEMPT Thu Aug 14 07:40:19 CEST 2014 x86_64 GNU/Linux

$ ./test/compose bench
compiled 1000 compose tables in 7.776488331s

So according to the above benchmark and valgrind --tool=massif, an
xkb_compose_table adds an overhead of about ~8ms time and ~130KB
resident memory.
For contrast, a plain US keymap adds an overhead of ~3ms time and 90KB
resident memory.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agocompose: add xkbcommon-compose - implementation
Ran Benita [Fri, 12 Sep 2014 15:44:30 +0000 (18:44 +0300)]
compose: add xkbcommon-compose - implementation

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agocompose: add xkbcommon-compose - API
Ran Benita [Fri, 12 Sep 2014 15:43:58 +0000 (18:43 +0300)]
compose: add xkbcommon-compose - API

xkbcommon-compose is a Compose implementation for xkbcommon. It mostly
behaves like libX11's Compose, but the support is somewhat low-level and
is not transparent like in libX11. The user must add some supporting code
in order to utilize it.

The intended audience are users who use xkbcommon but not a full-blown
input method. With this they can add Compose support in a straightforward
manner, so they have a fairly complete keyboard input for Latin-like
languages at least.

See the header documentation for details.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoscanner-utils: add priv member
Ran Benita [Fri, 12 Sep 2014 15:40:18 +0000 (18:40 +0300)]
scanner-utils: add priv member

For when a user of the scanner wants to pass something along with it.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodarray: add darray_shrink()
Ran Benita [Thu, 11 Sep 2014 21:31:40 +0000 (00:31 +0300)]
darray: add darray_shrink()

If we have a big array which can be finalized, on average we can give
back 1/4 of its size, which the allocator might be able to use.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeysym: add function to test if a keysym is for a modifier
Ran Benita [Wed, 5 Feb 2014 23:48:32 +0000 (01:48 +0200)]
keysym: add function to test if a keysym is for a modifier

Needed for compose.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoscanner-utils: add helper for appending an entire string
Ran Benita [Mon, 3 Feb 2014 12:55:37 +0000 (14:55 +0200)]
scanner-utils: add helper for appending an entire string

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoscanner-utils: add helper for hex string escape
Ran Benita [Sun, 27 Oct 2013 18:17:29 +0000 (20:17 +0200)]
scanner-utils: add helper for hex string escape

Like the already existing oct.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoMove benchmarks from tests to their own files in bench/
Ran Benita [Thu, 2 Oct 2014 19:03:28 +0000 (22:03 +0300)]
Move benchmarks from tests to their own files in bench/

The tests only contain tests, and the benchmarks are more visible.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agobuild: don't rebuild everything for libtest.la
Ran Benita [Thu, 2 Oct 2014 18:24:29 +0000 (21:24 +0300)]
build: don't rebuild everything for libtest.la

We added a -fvisibilty=default to the libtest.la CFLAGS. When automake
sees that the CFLAGS are different from those of libxkbcommon.la, it
figures it should recompile all of the $(libxkbcommon_la_SOURCES),
instead of reusing the already-compiled object files.

But actually, the convenience library is not a shared object, it's just
used as an archive, thus the -fvisibility is entirely pointless. So
avoid the recompilations by just removing it.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoscanner-utils: optimize str()/lit()
Ran Benita [Wed, 1 Oct 2014 16:14:36 +0000 (19:14 +0300)]
scanner-utils: optimize str()/lit()

Replace the dog-slow unneeded strncasecmp() with an inlineable memcmp().

Before:
compiled 2500 keymaps in 8.348715629s

After:
compiled 2500 keymaps in 7.872640338s

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap: rename XkbKeyGroupWidth to XkbKeyNumLevels
Ran Benita [Thu, 25 Sep 2014 19:01:17 +0000 (22:01 +0300)]
keymap: rename XkbKeyGroupWidth to XkbKeyNumLevels

The "width" terminology comes from the group*width+level layout of the
keysyms in a key, as used in the old implementations. We don't keep all
the keysyms of a key in one array so change it to a more accurate name.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agosymbols: improve FindKeyForSymbol()
Ran Benita [Thu, 25 Sep 2014 18:55:52 +0000 (21:55 +0300)]
symbols: improve FindKeyForSymbol()

A bit more involved, but can short circuit.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agosymbols: use correct max value
Ran Benita [Thu, 25 Sep 2014 18:25:39 +0000 (21:25 +0300)]
symbols: use correct max value

xkb_level_index_t was initially uint16_t, now it's 32.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodoc: disable alphabetical data structure index
Ran Benita [Mon, 22 Sep 2014 12:45:26 +0000 (15:45 +0300)]
doc: disable alphabetical data structure index

It is useless - we have very little data structures.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodoc: disable BRIEF_MEMBER_DESC
Ran Benita [Mon, 22 Sep 2014 12:31:51 +0000 (15:31 +0300)]
doc: disable BRIEF_MEMBER_DESC

It's easier to quickly go through the functions in a module this way.
The names provide enough "brief description" to get someone to click for
the full description.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodoc: disable tree view
Ran Benita [Mon, 22 Sep 2014 12:27:13 +0000 (15:27 +0300)]
doc: disable tree view

It is redundant with the header navigation.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodoc: linkify some references
Ran Benita [Mon, 22 Sep 2014 12:23:10 +0000 (15:23 +0300)]
doc: linkify some references

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agox11, doc: add note about Key{Press,Release}->state field
Ran Benita [Mon, 22 Sep 2014 08:44:51 +0000 (11:44 +0300)]
x11, doc: add note about Key{Press,Release}->state field

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agox11, doc: add note about per-client flags like detectable autorepeat
Ran Benita [Mon, 22 Sep 2014 08:24:17 +0000 (11:24 +0300)]
x11, doc: add note about per-client flags like detectable autorepeat

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap-dump: combine modifier_map's with the same modifier
Ran Benita [Sun, 21 Sep 2014 20:54:34 +0000 (23:54 +0300)]
keymap-dump: combine modifier_map's with the same modifier

A bit less efficient, but makes for shorter, nicer output.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agorules: fix mlvo-not-used warning
Ran Benita [Sun, 21 Sep 2014 14:09:58 +0000 (17:09 +0300)]
rules: fix mlvo-not-used warning

An mlvo can also be used in an expansion, but we didn't mark them in
this case in commit d8a4f52cb95d989b4. This caused wrongful warnings on
something like -l ch -v fr -- the `fr` is only added via expansion.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoquick-guide: fix xkb_state_key_get_syms() example
Ran Benita [Sat, 20 Sep 2014 21:59:11 +0000 (00:59 +0300)]
quick-guide: fix xkb_state_key_get_syms() example

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoquick-guide: fix Java-esque array syntax
Ran Benita [Sat, 20 Sep 2014 21:56:33 +0000 (00:56 +0300)]
quick-guide: fix Java-esque array syntax

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agorules: warn when an RMLVO component isn't used
Ran Benita [Sat, 20 Sep 2014 13:13:24 +0000 (16:13 +0300)]
rules: warn when an RMLVO component isn't used

Due to wildcard matches in the rules file, this is only really useful
for misspelled or missing options, e.g.

$ ./test/rmlvo-to-kccgst -o comprose:ralt > /dev/null
xkbcommon: ERROR: Unrecognized RMLVO option "comprose:ralt" was ignored

Although it is more of a warning, it indicates a misconfiguration which
the user probably wants to see. Therefore the log level is ERROR.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoparser: use "atom" instead of "sval" in yylval
Ran Benita [Sat, 20 Sep 2014 12:06:13 +0000 (15:06 +0300)]
parser: use "atom" instead of "sval" in yylval

"sval" is already used for "struct sval".

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodoc: reorder "Keymap Components" functions
Ran Benita [Fri, 19 Sep 2014 09:35:52 +0000 (12:35 +0300)]
doc: reorder "Keymap Components" functions

Put the general keymap stuff before key-specific functions.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodoc: move consumed modifier description to its own section
Ran Benita [Thu, 18 Sep 2014 21:56:16 +0000 (00:56 +0300)]
doc: move consumed modifier description to its own section

With small edits.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodoc: order the modules better
Ran Benita [Thu, 18 Sep 2014 18:09:41 +0000 (21:09 +0300)]
doc: order the modules better

Explicitly specify the files in INPUT so that "X11 Support" appears
after the main modules.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agox11, doc: fix typo
Ran Benita [Thu, 18 Sep 2014 09:13:59 +0000 (12:13 +0300)]
x11, doc: fix typo

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agox11, doc: add overview
Ran Benita [Thu, 18 Sep 2014 08:59:27 +0000 (11:59 +0300)]
x11, doc: add overview

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotest/keyseq: add test
Ran Benita [Thu, 11 Sep 2014 11:08:12 +0000 (14:08 +0300)]
test/keyseq: add test

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoconfigure.ac: add -Wdocumentation
Ran Benita [Thu, 11 Sep 2014 09:15:31 +0000 (12:15 +0300)]
configure.ac: add -Wdocumentation

It's supported by clang and warns about bad doxygen comments.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodoc: fix @param display for xkb_x11_setup_xkb_extension()
Ran Benita [Thu, 11 Sep 2014 09:09:57 +0000 (12:09 +0300)]
doc: fix @param display for xkb_x11_setup_xkb_extension()

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agosymbols: use darray_foreach_from for nicer loop
Ran Benita [Wed, 10 Sep 2014 23:55:51 +0000 (02:55 +0300)]
symbols: use darray_foreach_from for nicer loop

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoRemove compatibility symbols
Ran Benita [Wed, 10 Sep 2014 16:11:41 +0000 (19:11 +0300)]
Remove compatibility symbols

Remove the deprecated symbols that were used for ABI compatibility
during the transition period to the first stable version, 0.2.0.

The old *names* can still be used, programs which use the old names will
continue to work, as long as they were compiled against a stable
version (as they have been #defined to the new names from the start; see
xkbcommon/xkbcommon-compat.h). Namely, this will break binaries which:

1. Were compiled against a pre-stable version of libxkbcommon, and
2. Are linked against the next version of libxkbcommon, and
3. Expect to work.

This scenario is very unlikely, and will break in many other ways
anyway. Also, retaining support for these means including them in the
new symbol version file, which I would like to avoid.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agobuild: use symbol versioning
Jan Engelhardt [Tue, 9 Sep 2014 17:08:46 +0000 (19:08 +0200)]
build: use symbol versioning

Symbol versions provide a means by which ELF utilities can determine
whether a program is incompatible with a too-old library version so
that package management tools can autodetect version-based
dependencies and suggest upgrade paths.

[ran: swap xkbcommon.map and xkbcommon-x11.map]

Signed-off-by: Jan Engelhardt <jengelh@inai.de>
Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeycodes: fix keymap compilation with no aliases and malloc(0)==NULL
Ran Benita [Wed, 10 Sep 2014 10:29:52 +0000 (13:29 +0300)]
keycodes: fix keymap compilation with no aliases and malloc(0)==NULL

If the keymap doesn't have any key-aliases (which is certainly
possible), the calloc(num_key_aliases, ...) is allowed to return NULL
according to the C standard, but this is not an error.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoast-build: fix leak in error path
Ran Benita [Wed, 10 Sep 2014 10:10:33 +0000 (13:10 +0300)]
ast-build: fix leak in error path

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotest: make most tests portable by copying linux/input.h locally
Ran Benita [Sat, 6 Sep 2014 08:29:15 +0000 (11:29 +0300)]
test: make most tests portable by copying linux/input.h locally

There is really no reason to deny these tests from different platforms
only for a few #defines.

The only linux-only test (or test program, it is not run by make check)
is interactive-evdev, which actually uses evdev.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoRemove <linux/input.h> include from test/x11comp.c
Pino Toscano [Sat, 6 Sep 2014 08:05:44 +0000 (11:05 +0300)]
Remove <linux/input.h> include from test/x11comp.c

libxkbcommon 0.4.3 introduces a new test, x11comp, which does not build
on non-Linux OSes because of the unconditional <linux/input.h> include.

This seems not needed even on Linux, so attached there is a simple patch
to remove it.

https://bugs.freedesktop.org/show_bug.cgi?id=83551

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoMerge pull request #11 from michaelforney/master
Ran Benita [Mon, 1 Sep 2014 22:12:18 +0000 (01:12 +0300)]
Merge pull request #11 from michaelforney/master

Fix typo in default-variant configure option

10 years agoFix typo in default-variant configure option
Michael Forney [Mon, 1 Sep 2014 20:09:29 +0000 (13:09 -0700)]
Fix typo in default-variant configure option

10 years agotest/x11comp: don't hang if Xvfb is not available
Ran Benita [Mon, 1 Sep 2014 14:20:40 +0000 (17:20 +0300)]
test/x11comp: don't hang if Xvfb is not available

If Xvfb is not present, posix_spawn still forks, but the child fails.
In that case, since we left the write fd of the pipe open in the parent,
we just kept waiting on the read() without noticing that the other side
is dead.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap: fix typo
Ran Benita [Sun, 24 Aug 2014 07:16:17 +0000 (10:16 +0300)]
keymap: fix typo

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap: fix description of xkb_keymap_key_get_syms_by_level()
David Herrmann [Sun, 24 Aug 2014 07:09:14 +0000 (09:09 +0200)]
keymap: fix description of xkb_keymap_key_get_syms_by_level()

The @level argument is restricted by xkb_keymap_num_levels_for_key(). Fix
the description to no longer mention xkb_keymap_num_layouts_for_key().

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
10 years agoBump version to 0.4.3 upstream-git xkbcommon-0.4.3
Ran Benita [Tue, 19 Aug 2014 17:11:35 +0000 (20:11 +0300)]
Bump version to 0.4.3

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoUpdate NEWS
Ran Benita [Tue, 19 Aug 2014 17:11:06 +0000 (20:11 +0300)]
Update NEWS

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotest/state: add test_update_mask() test
Ran Benita [Mon, 18 Aug 2014 18:03:06 +0000 (21:03 +0300)]
test/state: add test_update_mask() test

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agostate: make sure the mods are fully resolved after xkb_state_update_mask()
Ran Benita [Mon, 18 Aug 2014 17:27:07 +0000 (20:27 +0300)]
state: make sure the mods are fully resolved after xkb_state_update_mask()

Virtual modifiers can have "mappings" to real modifiers, e.g. NumLock
may also set Mod2. In a normal turn of events, the various components
(depressed, latched, locked, and consequently effective) include the
mapped mods, because the masks are pre-resolved everywhere. However,
xkb_state_update_mask() accepts arbitrary mod masks, which may not be
resolved (if it comes from somewhere other than
xkb_state_serialize_mods()). So let's always resolve them ourselves.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoMake the effective mod mask calculation available to other files
Ran Benita [Sat, 24 Nov 2012 11:29:54 +0000 (13:29 +0200)]
Make the effective mod mask calculation available to other files

We will want to use that function in state.c as well.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agostate: no need for loop in xkb_state_update_mask()
Ran Benita [Mon, 18 Aug 2014 17:08:25 +0000 (20:08 +0300)]
state: no need for loop in xkb_state_update_mask()

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotest/x11comp: server writes \n to displayfd
Ran Benita [Mon, 18 Aug 2014 16:47:10 +0000 (19:47 +0300)]
test/x11comp: server writes \n to displayfd

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotest/x11-keyseq: new test
Ran Benita [Sat, 9 Aug 2014 19:14:34 +0000 (22:14 +0300)]
test/x11-keyseq: new test

It is like test/stringcomp, only instead of using
xkb_keymap_new_from_string(), it uses xkbcomp to upload the keymap to a
dummy Xvfb X server and then xkb_x11_keymap_new_from_device().

If any of these components are not present or fails, the test is shown
as skipped.

The test is messy, fragile, limited and depends on external tools, but I
will improve on that later -- it's better to have a test.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agox11/keymap: handle private actions
Ran Benita [Sat, 9 Aug 2014 19:41:01 +0000 (22:41 +0300)]
x11/keymap: handle private actions

Previously we treated them as NoAction().

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoutils: add a STATIC_ASSERT macro
Ran Benita [Sat, 9 Aug 2014 19:35:24 +0000 (22:35 +0300)]
utils: add a STATIC_ASSERT macro

It'd be nicer to use C11's static_assert(), but it's easier to roll our
own C99 version using a trick I saw in xv6.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap: remove "flags" field of xkb_private_action
Ran Benita [Sat, 9 Aug 2014 19:19:39 +0000 (22:19 +0300)]
keymap: remove "flags" field of xkb_private_action

Private actions have no flags - only serialized data.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agox11/keymap: be more defensive about the number of modifiers
Ran Benita [Fri, 8 Aug 2014 14:21:28 +0000 (17:21 +0300)]
x11/keymap: be more defensive about the number of modifiers

There can be at most 16 vmods, and we rely on the facts that #vmods +
NUM_REAL_MODS (8) <= XKB_MAX_MODS (32) when accessing keymap->mods.mods.
But msb_pos() can potentially return up to #vmods = 32 if the server is
malicious, so we need to truncate it.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agox11/keymap: don't forget to add the vmod offset in get_vmods
Ran Benita [Fri, 8 Aug 2014 13:36:42 +0000 (16:36 +0300)]
x11/keymap: don't forget to add the vmod offset in get_vmods

The first 8 modifiers in keymap->mods are the real modifiers; the virtual
 modifiers are then at slots 8-24. But XkbGetMap's virtualMods mask
starts the virtual modifiers at zero, so we need to add an offset (like
we do correctly in get_vmod_names()).

https://github.com/xkbcommon/libxkbcommon/issues/9

Reported-by: @rtcm
Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodocs: move keysym-transformations page to a better position
Ran Benita [Mon, 28 Jul 2014 15:04:34 +0000 (18:04 +0300)]
docs: move keysym-transformations page to a better position

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodocs: fix self-reference
Ran Benita [Mon, 28 Jul 2014 07:03:18 +0000 (10:03 +0300)]
docs: fix self-reference

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agointeractive-evdev: don't use sysexits.h
Ran Benita [Sun, 27 Jul 2014 13:36:11 +0000 (16:36 +0300)]
interactive-evdev: don't use sysexits.h

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoast-build: make sure InterpDef is freeable
Ran Benita [Sun, 27 Jul 2014 11:24:20 +0000 (14:24 +0300)]
ast-build: make sure InterpDef is freeable

With the following two rules:

    InterpretDecl   :       INTERPRET InterpretMatch OBRACE
                                VarDeclList
                            CBRACE SEMI
                            { $2->def = $4; $$ = $2; }
                    ;

    InterpretMatch  :       KeySym PLUS Expr
                            { $$ = InterpCreate($1, $3); }
                    |       KeySym
                            { $$ = InterpCreate($1, NULL); }
                    ;

And the fact that InterpCreate doesn't initialize ->def, if the
VarDeclList fails, the %destructor tries to recursively free the
uninitialized ->def VarDef. So always initialize it.

That was the only problematic code in the parser for %destructor (I'm
pretty sure).

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoparser: silence bison "unused value" warnings
Ran Benita [Sat, 26 Jul 2014 19:49:30 +0000 (22:49 +0300)]
parser: silence bison "unused value" warnings

Previous commit triggered these for some reason:

/home/ran/src/libxkbcommon/src/xkbcomp/parser.y:555.25-33: warning: unused value: $1 [-Wother]
 CoordList       :       CoordList COMMA Coord
                         ^^^^^^^^^

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoparser: don't leak AST nodes for discarded symbols
Ran Benita [Sat, 26 Jul 2014 19:34:05 +0000 (22:34 +0300)]
parser: don't leak AST nodes for discarded symbols

If the parser has symbols on the stack, and then enters an error, it
discards the symbols and fails. But their actions which allocate AST
nodes had already ran. So we must free these to avoid leaks.

We use %destructor declarations, see
http://www.gnu.org/software/bison/manual/html_node/Destructor-Decl.html

Note: byacc only supports %destructor when compiled with
--enable-btyacc. Also, it doesn't support using the parse-param in the
destructor. So we might revert this commit before the next release, or
forget about byacc.

https://github.com/xkbcommon/libxkbcommon/issues/8

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotest: add file with a syntax error
Ran Benita [Sat, 26 Jul 2014 19:29:22 +0000 (22:29 +0300)]
test: add file with a syntax error

We didn't really have any. It also a exposes a memory leak, since the
parser doesn't clean up the AST nodes of the discarded symbols.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoReplace darray_mem with a new darray_steal
Ran Benita [Fri, 25 Jul 2014 21:19:34 +0000 (00:19 +0300)]
Replace darray_mem with a new darray_steal

That's a more declarative interface.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoast-build: use cast instead of ->common
Ran Benita [Fri, 25 Jul 2014 21:13:54 +0000 (00:13 +0300)]
ast-build: use cast instead of ->common

Missed in 1b2bb204e0baa2246a6232aea762c1edb00cd44a.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotypes: refactor CopyKeyTypesToKeymap
Ran Benita [Fri, 25 Jul 2014 20:40:40 +0000 (23:40 +0300)]
types: refactor CopyKeyTypesToKeymap

So it's OOM-safe and doesn't clobber keymap on failure.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeycodes: split CopyKeyInfoToKeymap to several functions
Ran Benita [Fri, 25 Jul 2014 20:24:46 +0000 (23:24 +0300)]
keycodes: split CopyKeyInfoToKeymap to several functions

It's a bit easier to read and self-documenting. Also handles OOM better.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoparser: don't shadow "str"
Ran Benita [Mon, 30 Jun 2014 11:52:30 +0000 (14:52 +0300)]
parser: don't shadow "str"

It's a name of a function in scanner-utils.h and also of some
parameters.

https://bugs.freedesktop.org/show_bug.cgi?id=79898

Reported-by: Bryce Harrington <b.harrington@samsung.com>
Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agox11: don't iterate on empty batches
Ran Benita [Sun, 15 Jun 2014 12:30:51 +0000 (15:30 +0300)]
x11: don't iterate on empty batches

If count % SIZE == 0 we did a useless iteration where start==stop. It's
harmless but strange, so don't do that.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoRemove unnecessary !!(expressions)
Ran Benita [Sun, 1 Jun 2014 12:24:10 +0000 (15:24 +0300)]
Remove unnecessary !!(expressions)

_Bool already does that.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agorules: fix leak on failure
Ran Benita [Wed, 28 May 2014 17:32:16 +0000 (20:32 +0300)]
rules: fix leak on failure

matcher_match() builds up the kccgst's, and we steal the memory on
success. But on error we didn't free it.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoBump version to 0.4.2 xkbcommon-0.4.2
Ran Benita [Thu, 15 May 2014 09:07:00 +0000 (12:07 +0300)]
Bump version to 0.4.2

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoUpdate NEWS
Ran Benita [Thu, 15 May 2014 09:06:46 +0000 (12:06 +0300)]
Update NEWS

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agox11: fix out-of-bounds access in adopt_atoms() error handling
Ran Benita [Wed, 14 May 2014 08:44:29 +0000 (11:44 +0300)]
x11: fix out-of-bounds access in adopt_atoms() error handling

Two problems:

- `j` can be >= `SIZE`, and needs to be wrapped like in the rest of the
   code.

- `cookies[j % SIZE]` is not initialized if there's no atom in `from[j]`.

The is manifested when:

- We've already gone through one batch (>= 128 atoms) (in fact this
  cannot happen in call to `adopt_atoms` in the current code).

- An XCB request failed in the middle of a batch.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoast-build: don't leak on OOM in BoolVarCreate
Ran Benita [Sun, 11 May 2014 06:47:56 +0000 (09:47 +0300)]
ast-build: don't leak on OOM in BoolVarCreate

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoparser: show the keysym in "unrecognized keysym" messages
Ran Benita [Wed, 30 Apr 2014 05:57:16 +0000 (08:57 +0300)]
parser: show the keysym in "unrecognized keysym" messages

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodoc: fix new doxygen version warnings
Ran Benita [Thu, 24 Apr 2014 22:21:09 +0000 (01:21 +0300)]
doc: fix new doxygen version warnings

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeycodes: fix uninitialized variable
Ran Benita [Thu, 24 Apr 2014 22:14:31 +0000 (01:14 +0300)]
keycodes: fix uninitialized variable

Happened in one of the previous commits. For some reason, gcc doesn't
warn about this, but clang does...

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoxkbcomp: don't align enum values
Ran Benita [Tue, 22 Apr 2014 15:18:13 +0000 (18:18 +0300)]
xkbcomp: don't align enum values

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoxkbcomp: use straight assignment instead of CopyModSet
Ran Benita [Tue, 22 Apr 2014 15:05:24 +0000 (18:05 +0300)]
xkbcomp: use straight assignment instead of CopyModSet

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap, keycodes, compat: don't use darray for LEDs
Ran Benita [Tue, 22 Apr 2014 10:15:21 +0000 (13:15 +0300)]
keymap, keycodes, compat: don't use darray for LEDs

Use a static array of size XKB_MAX_LEDS instead, as in xkb_mod_set.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap: don't use darray in xkb_mod_set
Ran Benita [Tue, 22 Apr 2014 09:23:36 +0000 (12:23 +0300)]
keymap: don't use darray in xkb_mod_set

Instead just statically allocate the mods array (of size MAX_MOD_SIZE =
32). The limit is not going anywhere, and static allocations are nicer
(nicer code, no OOM, etc.). It's also small and dense enough.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap: add and use xkb_mods_{foreach,enumerate}()
Ran Benita [Tue, 22 Apr 2014 08:47:23 +0000 (11:47 +0300)]
keymap: add and use xkb_mods_{foreach,enumerate}()

To iterate over an xkb_mod_set. Slightly nicer interface and makes
transitioning from darray easier.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap: rename xkb_foreach_key to xkb_keys_foreach
Ran Benita [Tue, 22 Apr 2014 08:33:47 +0000 (11:33 +0300)]
keymap: rename xkb_foreach_key to xkb_keys_foreach

We'll use the format xkb_foos_foreach and xkb_foos_enumerate for the
various iterators.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agokeymap: protect xkb_foreach_key macro params
Ran Benita [Tue, 22 Apr 2014 08:22:22 +0000 (11:22 +0300)]
keymap: protect xkb_foreach_key macro params

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agodarray: remove unused darray_foreach_reverse()
Ran Benita [Tue, 22 Apr 2014 09:29:22 +0000 (12:29 +0300)]
darray: remove unused darray_foreach_reverse()

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agoutils: detect overflow in memdup()
Ran Benita [Tue, 22 Apr 2014 11:34:57 +0000 (14:34 +0300)]
utils: detect overflow in memdup()

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agosymbols: use xkb_mod_set instead of entire keymap
Ran Benita [Sat, 9 Feb 2013 17:10:56 +0000 (19:10 +0200)]
symbols: use xkb_mod_set instead of entire keymap

The keymap is not removed entirely from the Info (just constified),
since it is still needed in AddKeySymbols() for looking up aliases. This
dependency will be removed in the future.

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agotypes: use xkb_mod_set instead of entire keymap
Ran Benita [Sat, 9 Feb 2013 16:25:12 +0000 (18:25 +0200)]
types: use xkb_mod_set instead of entire keymap

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agocompat: use xkb_mod_set instead of entire keymap
Ran Benita [Fri, 8 Feb 2013 13:12:35 +0000 (15:12 +0200)]
compat: use xkb_mod_set instead of entire keymap

Signed-off-by: Ran Benita <ran234@gmail.com>
10 years agovmod: take xkb_mod_set instead of the entire keymap
Ran Benita [Fri, 8 Feb 2013 12:39:38 +0000 (14:39 +0200)]
vmod: take xkb_mod_set instead of the entire keymap

This is the only place where the modifier information is modified. We
will make it local to a given XKB file (after which it will be merged
into the keymap). Currently it changes the keymap directly, which
sidesteps the abstraction and leaves side-effects even if the XkbFile's
compilation fails.

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