platform/upstream/libxkbcommon.git
5 years agotest: xkeyboard-config: print to stderr on failure, stdout otherwise
Peter Hutterer [Wed, 30 Oct 2019 00:53:58 +0000 (10:53 +1000)]
test: xkeyboard-config: print to stderr on failure, stdout otherwise

This is a change in behavior and requires any automated callers to adjust
accordingly. Still, much easier to get the errors that way rather than it
being mixed into a thousands-of-lines output file.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
5 years agotest: xkeyboard-config: add a multiprocessing.Pool() to speed up the test
Peter Hutterer [Tue, 29 Oct 2019 06:06:10 +0000 (16:06 +1000)]
test: xkeyboard-config: add a multiprocessing.Pool() to speed up the test

Collect all options into a dictionary, then process that as async actions
through a process pool. This of course requires collecting the various print
statements to avoid mangled output.

This dropped the time to completion from around 14 min to 8 min on my local
machine (unscientific single run only for the original timing).

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
5 years agotest: xkeyboard-config: use argparse for the path and the tool selection
Peter Hutterer [Wed, 30 Oct 2019 01:15:49 +0000 (11:15 +1000)]
test: xkeyboard-config: use argparse for the path and the tool selection

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
5 years agoscripts/makeheader: slight simplification
Ran Benita [Thu, 31 Oct 2019 19:21:35 +0000 (21:21 +0200)]
scripts/makeheader: slight simplification

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agoscripts/makeheader: allow overriding the prefix path of the X11 headers
Sebastian Wick [Thu, 31 Oct 2019 16:04:49 +0000 (17:04 +0100)]
scripts/makeheader: allow overriding the prefix path of the X11 headers
with X11_HEADERS_PREFIX

Signed-off-by: Sebastian Wick <sebastian@sebastianwick.net>
5 years agotest: add test for the various default include paths
Peter Hutterer [Mon, 28 Oct 2019 01:40:56 +0000 (11:40 +1000)]
test: add test for the various default include paths

All tests create a temporary directory, set up the environment for that
directory and then check the include paths for the presence of that directory,
ideally in the right position of the list.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
5 years agoUse XDG_CONFIG_HOME as first XKB search path
Peter Hutterer [Fri, 25 Oct 2019 04:36:16 +0000 (14:36 +1000)]
Use XDG_CONFIG_HOME as first XKB search path

Use $XDG_CONFIG_HOME/xkb as the primary lookup path for XKB rules. Same
motivation as in 3a91788d9254b, however the XDG directories are more standard
and recommended these days than application-specific dotfiles.

The XDG spec says to fall back to $HOME/.config where XDG_CONFIG_HOME is not
set so we implement that behavior as well.

Fixes #112

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
5 years agoBump version to 0.9.1 xkbcommon-0.9.1
Ran Benita [Sun, 20 Oct 2019 20:07:52 +0000 (23:07 +0300)]
Bump version to 0.9.1

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agocontext: Don't fail to create the context if HOME isn't available
Jan Alexander Steffens (heftig) [Sun, 20 Oct 2019 19:06:19 +0000 (19:06 +0000)]
context: Don't fail to create the context if HOME isn't available

E.g. when Mutter has CAP_SYS_NICE and thus secure_getenv returns NULL.

Fixes https://bugs.archlinux.org/task/64191

[ran: changed to ignore error]
Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agoREADME: update my email address
Ran Benita [Fri, 18 Oct 2019 21:55:21 +0000 (00:55 +0300)]
README: update my email address

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agoBump version to 0.9.0 xkbcommon-0.9.0
Ran Benita [Fri, 18 Oct 2019 21:33:09 +0000 (00:33 +0300)]
Bump version to 0.9.0

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agobuild: remove leftover autotools file
Ran Benita [Fri, 18 Oct 2019 21:41:16 +0000 (00:41 +0300)]
build: remove leftover autotools file

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agotest: fix printf("%s", NULL) in error path
Ran Benita [Fri, 18 Oct 2019 21:37:48 +0000 (00:37 +0300)]
test: fix printf("%s", NULL) in error path

    ../test/common.c: In function ‘test_get_path’:
    ../test/common.c:171:9: warning: ‘%s’ directive argument is null [-Wformat-overflow=]
      171 |         fprintf(stderr, "Failed to allocate path (%d chars) for %s\n",
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      172 |                 (int) path_len, path);
          |                 ~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agokeymap-dump: use consistent capitalization for "Group<N>"
Ran Benita [Wed, 16 Oct 2019 07:32:19 +0000 (10:32 +0300)]
keymap-dump: use consistent capitalization for "Group<N>"

It's used capitalized everywhere except a couple places.

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agokeymap-dump: fix invalid names used for levels above 8
Ran Benita [Wed, 16 Oct 2019 07:27:12 +0000 (10:27 +0300)]
keymap-dump: fix invalid names used for levels above 8

xkbcomp only accepts the "Level" prefix for a level name for levels 1 to
8, but the keymap dumping code added it always, e.g. "Level15".

The plain integer, e.g. "8", "15" is always accepted, so just use that.

Fixes https://github.com/xkbcommon/libxkbcommon/issues/113

Signed-off-by: Ran Benita <ran@unusedvar.com>
Reported-by: progandy
5 years agocontext: move ~/.xkb to before XKB_CONFIG_ROOT in the default include path
Ran Benita [Thu, 3 Oct 2019 14:27:00 +0000 (17:27 +0300)]
context: move ~/.xkb to before XKB_CONFIG_ROOT in the default include path

Previously, the default include path was XKB_CONFIG_ROOT:~/.xkb.

The ~/.xkb include path is intended to allow the local user to customize
their keymaps without having to modify system paths.

But usually, the user only wants to customize specific parts. When
XKB_CONFIG_ROOT is first, the user can only customize through the "entry
point" (the RMLVO). When ~/.xkb is first, the user can drop in a file
and it will override the system one.

The impetus for this change is the rules file. "evdev" is hard-coded
everywhere, so it not often not possible to change to something else.
And the rules files determines how the rest of the RMLVO is interpreted.
So, to enable customization, we have these options:

A: System includes user.
B: User includes system.
C: Library goes over both in one or the other order.

Option A is problematic due to backward compatibility and is also
unnatural.

Option B gives the user control and is backward compatible, so that's
what we choose. This is also how Compose files are handled, and that
seems to work fine in the wild.

Option C is actually less flexible than B, and more complicated.

(The rules file format doesn't have an include statement yet, but it's
planned).

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agobuild: Solaris needs __EXTENSIONS__ instead of _GNU_SOURCE
Alan Coopersmith [Tue, 10 Sep 2019 00:56:42 +0000 (17:56 -0700)]
build: Solaris needs __EXTENSIONS__ instead of _GNU_SOURCE

Fix meson build on Solaris by using __EXTENSIONS__ where Linux & other
platforms use _GNU_SOURCE.  Without this the build fails due to missing
prototypes for functions like strdup & getopt not defined in the C99
standard.  (In autoconf, this was handled by AC_USE_SYSTEM_EXTENSIONS.)

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
5 years agobuild: remove autotools build
Ran Benita [Sat, 10 Aug 2019 11:11:36 +0000 (14:11 +0300)]
build: remove autotools build

We introduced meson 2 years ago, hopefully that's was enough time for
everyone to convert.

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agoci: remove travis CI
Ran Benita [Sat, 10 Aug 2019 11:04:29 +0000 (14:04 +0300)]
ci: remove travis CI

We moved to Azure Pipelines.

Signed-off-by: Ran Benita <ran@unusedvar.com>
5 years agoSet up CI with Azure Pipelines
Ran Benita [Fri, 9 Aug 2019 20:07:28 +0000 (23:07 +0300)]
Set up CI with Azure Pipelines

[skip ci]

5 years agoCI: Install graphviz using APT
Adrian Perez de Castro [Tue, 6 Aug 2019 20:55:22 +0000 (23:55 +0300)]
CI: Install graphviz using APT

This adds the missing graphviz dependency, from which Doxygen uses
"dot" to create diagrams for the documentation. Also, the meson
dependency is removed as it is installed using Pip, and ninja-build
added.

5 years agoCI: Publish test results from Meson
Adrian Perez de Castro [Tue, 6 Aug 2019 15:59:10 +0000 (18:59 +0300)]
CI: Publish test results from Meson

5 years agoCI: Try builds both with Clang and GCC
Adrian Perez de Castro [Tue, 6 Aug 2019 14:25:25 +0000 (17:25 +0300)]
CI: Try builds both with Clang and GCC

5 years agoCI: Enable a macOS job
Adrian Perez de Castro [Tue, 6 Aug 2019 13:55:41 +0000 (16:55 +0300)]
CI: Enable a macOS job

5 years agoCI: Make Autotools and Meson builds parallel
Adrian Perez de Castro [Tue, 6 Aug 2019 13:24:43 +0000 (16:24 +0300)]
CI: Make Autotools and Meson builds parallel

This splits the steps for installing dependencies into a new template
file, as well as the build steps for Autotools. Both gets used to define
two jobs which can run in parallel for both build systems.

5 years agoCI: Always try to gather test results
Adrian Perez de Castro [Tue, 6 Aug 2019 13:16:21 +0000 (16:16 +0300)]
CI: Always try to gather test results

Resulting test logs should be always attached to the task, regardless
of whether the test suite ran successfully or not.

5 years agoCI: Split Meson build steps into a separate YAML file
Adrian Perez de Castro [Tue, 6 Aug 2019 12:34:37 +0000 (15:34 +0300)]
CI: Split Meson build steps into a separate YAML file

5 years agoCI: Save the Meson logs as downloadable files
Adrian Perez de Castro [Tue, 6 Aug 2019 09:25:29 +0000 (12:25 +0300)]
CI: Save the Meson logs as downloadable files

This uploads the files saves to meson-build/meson-logs/ and associates
them to the pipeline task, which makes them availabl for download in the
Azure Pipelines web interface.

5 years agoCI: Initial set up to use Azure Pipelines
Adrian Perez [Tue, 6 Aug 2019 08:53:02 +0000 (11:53 +0300)]
CI: Initial set up to use Azure Pipelines

For the moment, configure only basic builds with Ubuntu 16.04, more to be added as follow-ups. [skip ci]

5 years agotravis: improve configuration and add macOS
Ran Benita [Thu, 25 Jul 2019 07:12:53 +0000 (10:12 +0300)]
travis: improve configuration and add macOS

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agotest/symbols-leak-test: fix sed regex on macOS
Ran Benita [Thu, 25 Jul 2019 10:49:41 +0000 (13:49 +0300)]
test/symbols-leak-test: fix sed regex on macOS

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agobuild: fixup autotools build after 97f41fe
Ran Benita [Thu, 25 Jul 2019 10:34:49 +0000 (13:34 +0300)]
build: fixup autotools build after 97f41fe

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agotest/symbols-leak-test: make it work with macOS diff
Ran Benita [Thu, 25 Jul 2019 10:24:00 +0000 (13:24 +0300)]
test/symbols-leak-test: make it work with macOS diff

The <() stuff fails with an error:
    diff: extra operand `/dev/fd/61'

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agotest/rmlvo-to-keymap: drop basename usage
Ran Benita [Thu, 25 Jul 2019 08:59:07 +0000 (11:59 +0300)]
test/rmlvo-to-keymap: drop basename usage

It wants some libgen.h include which is POSIX only, let's just remove
it as it's hardly important.

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agotest/rmlvo-to-keymap.c: fix compilation on Darwin (#101)
worldofpeace [Fri, 19 Jul 2019 06:56:41 +0000 (02:56 -0400)]
test/rmlvo-to-keymap.c: fix compilation on Darwin (#101)

program_invocation_short_name isn't portable.

5 years agointeractive-wayland: Port to stable xdg-shell (#100)
Daniel Stone [Tue, 2 Jul 2019 12:48:32 +0000 (13:48 +0100)]
interactive-wayland: Port to stable xdg-shell (#100)

xdg_shell v6 was pretty close to the finalised stable version of
xdg-shell. We can now just use the stable version, which is supported
everywhere (Enlightenment, KWin, Mutter, Weston, wlroots).

This requires bumping the wayland-protocols dependency.

Signed-off-by: Daniel Stone <daniels@collabora.com>
5 years agoMerge pull request #98 from michaelforney/popcount
Ran Benita [Tue, 11 Jun 2019 16:59:25 +0000 (19:59 +0300)]
Merge pull request #98 from michaelforney/popcount

Use bitwise test for power-of-2 instead of popcount

5 years agoUse bitwise test instead of popcount to check if one bit is set
Michael Forney [Tue, 4 Jun 2019 21:01:02 +0000 (14:01 -0700)]
Use bitwise test instead of popcount to check if one bit is set

We don't need to determine the total number of bits set to determine if
exactly one is set.

Additionally, on x86_64 without any -march=* flag, __builtin_popcount
will get compiled to a function call to the compiler runtime (on gcc),
or a long sequence of bit operations (on clang).

Signed-off-by: Michael Forney <mforney@mforney.org>
5 years agoMerge pull request #96 from Jjagg/patch-1
Ran Benita [Wed, 5 Jun 2019 06:49:04 +0000 (09:49 +0300)]
Merge pull request #96 from Jjagg/patch-1

Fix a few doc typos

5 years agoFix some doc typos
Jesse [Tue, 4 Jun 2019 21:44:42 +0000 (23:44 +0200)]
Fix some doc typos

5 years agoMerge pull request #95 from Hi-Angel/fix-lgtm-warnings
Ran Benita [Sun, 24 Mar 2019 12:05:17 +0000 (14:05 +0200)]
Merge pull request #95 from Hi-Angel/fix-lgtm-warnings

Fix some of LGTM warnings

5 years agosymbols: add a comment to suppress warning from code analyzers
Konstantin Kharlamov [Sat, 23 Mar 2019 20:29:29 +0000 (23:29 +0300)]
symbols: add a comment to suppress warning from code analyzers

Signed-off-by: Konstantin Kharlamov <Hi-Angel@yandex.ru>
5 years agoMerge pull request #94 from milloni/milloni/m4
Ran Benita [Tue, 12 Mar 2019 17:39:23 +0000 (19:39 +0200)]
Merge pull request #94 from milloni/milloni/m4

Makefile.am: add include dir for AC_CONFIG_MACRO_DIR to work

5 years agoMakefile.am: add include dir for AC_CONFIG_MACRO_DIR to work
milloni [Tue, 12 Mar 2019 16:22:15 +0000 (16:22 +0000)]
Makefile.am: add include dir for AC_CONFIG_MACRO_DIR to work

With older versions of autotools, one needs to add this line to
Makefile.am. From the autoconf docs: "Note that if you use aclocal from
Automake to generate aclocal.m4, you must also set ACLOCAL_AMFLAGS = -I dir
in your top-level Makefile.am". [1]

I couldn't build with autoconf 2.68 without this.

[1] https://www.gnu.org/software/autoconf/manual/autoconf-2.65/html_node/Input.html

Signed-off-by: milloni <milloni@preemptable.org>
5 years agoREADME: usage questions are alright
Ran Benita [Tue, 26 Feb 2019 16:27:53 +0000 (18:27 +0200)]
README: usage questions are alright

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agoREADME: stop pointing at bugs.freedesktop.org
Ran Benita [Tue, 26 Feb 2019 16:26:01 +0000 (18:26 +0200)]
README: stop pointing at bugs.freedesktop.org

No-one filed bugs in there for a while, let's consolidate on the more
popular one.

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agomeson.build: use program from build machine not host or target.
maxice8 [Sat, 23 Feb 2019 08:55:00 +0000 (05:55 -0300)]
meson.build: use program from build machine not host or target.

We can't always execute binaries from the host or target machine,
as is the case in cross compilation.

closes #89

5 years agoBump version to 0.8.4 xkbcommon-0.8.4
Ran Benita [Fri, 22 Feb 2019 20:26:49 +0000 (22:26 +0200)]
Bump version to 0.8.4

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agoUpdate NEWS
Ran Benita [Fri, 22 Feb 2019 20:26:11 +0000 (22:26 +0200)]
Update NEWS

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agobuild: fix meson build from tarball generated by autotools
Ran Benita [Fri, 22 Feb 2019 13:37:27 +0000 (15:37 +0200)]
build: fix meson build from tarball generated by autotools

These files are used by the meson build only. Previously, trying to
build with meson using the tarball generated by distcheck would fail.

Fixes https://github.com/xkbcommon/libxkbcommon/issues/87.

Reported-by: manesm52
Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agomeson.build: link the sources directly into libxkbcommon-x11
Peter Hutterer [Sun, 10 Feb 2019 23:19:28 +0000 (09:19 +1000)]
meson.build: link the sources directly into libxkbcommon-x11

Similar to 75ce741ab97e3d17a0c9b06dd4bdf57c00d5538e, just for the -x11
sublibrary.

This works around meson bug 3937, 'link_whole' arguments don't get added into
the final static library and we end up with a virtually empty 8-byte
libxkbcommon-x11.a file, see https://github.com/mesonbuild/meson/issues/3937

The internal lib is still built for the one test case that requires it.

Fixes #86

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
5 years agoBump version to 0.8.3 xkbcommon-0.8.3
Ran Benita [Fri, 8 Feb 2019 10:39:01 +0000 (12:39 +0200)]
Bump version to 0.8.3

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agoUpdate NEWS
Ran Benita [Fri, 8 Feb 2019 10:38:02 +0000 (12:38 +0200)]
Update NEWS

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agomeson: make comment make sense now
Ran Benita [Fri, 8 Feb 2019 10:29:27 +0000 (12:29 +0200)]
meson: make comment make sense now

Signed-off-by: Ran Benita <ran234@gmail.com>
5 years agoMerge pull request #85 from whot/wip/static-lib-sources
Ran Benita [Fri, 8 Feb 2019 10:18:00 +0000 (12:18 +0200)]
Merge pull request #85 from whot/wip/static-lib-sources

meson.build: manually link all sources into the library

5 years agomeson.build: manually link all sources into the library
Peter Hutterer [Fri, 8 Feb 2019 02:15:48 +0000 (12:15 +1000)]
meson.build: manually link all sources into the library

This works around meson bug 3937, 'link_whole' arguments don't get added into
the final static library and we end up with a virtually empty 8-byte
libxkbcommon.a file, see https://github.com/mesonbuild/meson/issues/3937

Workaround is simply to add all sources to both libraries we need them in.
This obviously compiles them twice but this year's winter was cold and
bit of extra warmth will be appreciated.

Fixes #84

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
5 years agodocs: fix a doxygen reference warning
Ran Benita [Mon, 28 Jan 2019 14:29:09 +0000 (16:29 +0200)]
docs: fix a doxygen reference warning

5 years agoMerge pull request #81 from whot/master
Ran Benita [Fri, 25 Jan 2019 10:50:55 +0000 (12:50 +0200)]
Merge pull request #81 from whot/master

keysyms: fix comment for XKB_KEY_OCARON

5 years agokeysyms: fix comment for XKB_KEY_OCARON
Peter Hutterer [Thu, 24 Jan 2019 23:26:58 +0000 (09:26 +1000)]
keysyms: fix comment for XKB_KEY_OCARON

Reported-by: Keve Müller
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
5 years agoMerge pull request #79 from jwrdegoede/add-2-new-keysyms
Ran Benita [Tue, 22 Jan 2019 07:48:23 +0000 (09:48 +0200)]
Merge pull request #79 from jwrdegoede/add-2-new-keysyms

Sync Keysyms with recent xproto additions

5 years agoSync Keysyms with recent xproto additions
Hans de Goede [Tue, 22 Jan 2019 07:31:43 +0000 (08:31 +0100)]
Sync Keysyms with recent xproto additions

xproto recently has been extended with 2 new keysyms:
XF86XK_MonBrightnessCycle
XF86XK_RotationLockToggle

This commit is the result of running "scripts/update-keysyms" on a system
with the updated xproto installed.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
6 years agoMerge pull request #69 from alanc/master
Ran Benita [Mon, 1 Oct 2018 07:24:45 +0000 (10:24 +0300)]
Merge pull request #69 from alanc/master

Fix off-by-one error in index check in xkb_file_type_to_string

6 years agoFix off-by-one error in index check in xkb_file_type_to_string
Alan Coopersmith [Sun, 30 Sep 2018 23:04:29 +0000 (16:04 -0700)]
Fix off-by-one error in index check in xkb_file_type_to_string

Found by Oracle's Parfait 2.2 static analyzer:
Error: Buffer overrun
   Read outside array bounds [read-outside-array-bounds] (CWE 125):
      In array dereference of xkb_file_type_strings[type] with index type
      Array size is 56 bytes, index <= 56
        at line 734 of src/xkbcomp/ast-build.c in function 'xkb_file_type_to_string'.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
6 years agodarray: fix unprotected macro argument
Ran Benita [Fri, 24 Aug 2018 06:14:14 +0000 (09:14 +0300)]
darray: fix unprotected macro argument

Reported-by: @msmeissn
Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoMerge pull request #68 from whot/wip/xkeyboard-config-tester
Ran Benita [Tue, 21 Aug 2018 06:05:09 +0000 (09:05 +0300)]
Merge pull request #68 from whot/wip/xkeyboard-config-tester

xkeyboard-config combination tester

6 years agotest: allow for absolute paths to be resolved
Peter Hutterer [Mon, 20 Aug 2018 06:46:19 +0000 (16:46 +1000)]
test: allow for absolute paths to be resolved

This makes it possible to check a keymap sitting elsewhere than in the test
directory.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agotest: drop the rmlvo ability from print-compiled-keymap
Peter Hutterer [Mon, 20 Aug 2018 05:50:35 +0000 (15:50 +1000)]
test: drop the rmlvo ability from print-compiled-keymap

This is now handled by the rmlvo-to-keymap tool

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agotest: add a tool to test-compile all LVO combinations from xkeyboard-config
Peter Hutterer [Tue, 14 Aug 2018 01:16:30 +0000 (11:16 +1000)]
test: add a tool to test-compile all LVO combinations from xkeyboard-config

This test contains of two parts:
- a simple program to convert RMLVO commandline arguments into a keymap (and
  print that keymap if requested).
- a python script that runs through rules/evdev.xml, and tries to compile a
  keymap for sort-of every layout/variant/option combination. Sort-of, because
  we can have multiple options and it really only does one per layout(variant)
  combination.

Same thing can be done using xkbcomp, but right now it doesn't take that as
argument, it's hard-coded.

This takes quite a while, installing python-tqdm is recommended to see fancy
progress bars instead of just miles of dumps.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agobuild: turn off strict aliasing
Ran Benita [Sat, 18 Aug 2018 12:12:15 +0000 (15:12 +0300)]
build: turn off strict aliasing

The benchmarks don't show any effect, so turn it off to have one less
thing to worry about. The parser does a lot of casting between AST
nodes.

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agox11: fix undefined behavior when copying the coordinates of ptr movements actions
Ran Benita [Sat, 18 Aug 2018 11:28:15 +0000 (14:28 +0300)]
x11: fix undefined behavior when copying the coordinates of ptr movements actions

Left shift of a negative integer. For some reason the protocol
representation here got really botched (in the spec it is just a nice
and simple INT16).

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoBump version to 0.8.2 xkbcommon-0.8.2
Ran Benita [Sun, 5 Aug 2018 05:51:30 +0000 (08:51 +0300)]
Bump version to 0.8.2

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoUpdate NEWS
Ran Benita [Sun, 5 Aug 2018 05:49:36 +0000 (08:49 +0300)]
Update NEWS

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoMerge pull request #67 from fooishbar/fix-more-fuzz
Ran Benita [Sun, 5 Aug 2018 05:45:19 +0000 (08:45 +0300)]
Merge pull request #67 from fooishbar/fix-more-fuzz

Fix more fuzz-testing fallout

6 years agoFail expression lookup on invalid atoms
Daniel Stone [Mon, 30 Oct 2017 11:21:55 +0000 (11:21 +0000)]
Fail expression lookup on invalid atoms

If we fail atom lookup, then we should not claim that we successfully
looked up the expression.

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agoFix signed vs. unsigned confusion in name sanitisation
Daniel Stone [Mon, 26 Jun 2017 20:52:27 +0000 (21:52 +0100)]
Fix signed vs. unsigned confusion in name sanitisation

Don't try to divide through a signed char when indexing an array, lest
ye try to index off the start of it.

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agodarray: Don't call memcpy() on NULL
Daniel Stone [Mon, 26 Jun 2017 20:49:49 +0000 (21:49 +0100)]
darray: Don't call memcpy() on NULL

The only time we could ever hit this was with count == 0, which seems
unnecessarily pedantic. But OK.

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agotext: NULL-terminate SI mask names
Daniel Stone [Mon, 26 Jun 2017 20:38:52 +0000 (21:38 +0100)]
text: NULL-terminate SI mask names

The list should have a NULL sentry. Add one.

testcase: 'interpret KP_Delete+AnyOfOrNaneo(ll)'

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agoxkbcomp: Don't falsely promise from ExprResolveLhs
Daniel Stone [Mon, 26 Jun 2017 16:21:45 +0000 (17:21 +0100)]
xkbcomp: Don't falsely promise from ExprResolveLhs

Every user of ExprReturnLhs goes on to unconditionally dereference the
field return, which can be NULL if xkb_intern_atom fails. Return false
if this is the case, so we fail safely.

testcase: splice geometry data into interp

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agoxkbcomp: Don't explode on invalid virtual modifiers
Daniel Stone [Mon, 26 Jun 2017 16:18:16 +0000 (17:18 +0100)]
xkbcomp: Don't explode on invalid virtual modifiers

testcase: 'virtualModifiers=LevelThreC'

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agoxkbcomp: Don't crash on no-op modmask expressions
Daniel Stone [Mon, 26 Jun 2017 16:12:29 +0000 (17:12 +0100)]
xkbcomp: Don't crash on no-op modmask expressions

If we have an expression of the form 'l1' in an interp section, we
unconditionally try to dereference its args, even if it has none.

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agoparser: Don't set more maps when we don't have any
Daniel Stone [Mon, 26 Jun 2017 15:45:16 +0000 (16:45 +0100)]
parser: Don't set more maps when we don't have any

If the scanner indicates that we might have something which looks like a
map, but the parser in fact fails to create that map, we will try to
access the map regardless. Stop doing that.

testcase: 'xkb_keymap {' -> '#kb_keymap'

Signed-off-by: Daniel Stone <daniels@collabora.com>
6 years agoBump version to 0.8.1 xkbcommon-0.8.1
Ran Benita [Fri, 3 Aug 2018 10:55:52 +0000 (13:55 +0300)]
Bump version to 0.8.1

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoUpdate NEWS
Ran Benita [Fri, 3 Aug 2018 10:55:17 +0000 (13:55 +0300)]
Update NEWS

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoMerge pull request #66 from whot/master
Ran Benita [Wed, 1 Aug 2018 09:25:18 +0000 (12:25 +0300)]
Merge pull request #66 from whot/master

Coverity fixes (one real bug)

6 years agoaction: make a note that we may not null-terminate private strings
Peter Hutterer [Wed, 1 Aug 2018 08:47:24 +0000 (18:47 +1000)]
action: make a note that we may not null-terminate private strings

Coverity complains that a 7-byte string may not be null-terminated when copied
into act->data (size 7). This is fine, make a note of it.

All the strings in xkeyboard-config only use 6 bytes + null terminator so this
won't be an issue. The server (the only user of these) uses an 8-byte array
and forcibly null-terminates the string, see XkbDDXPrivate().

Everything else treats it as byte-array size 7 anyway so whether it's
null-terminated doesn't matter.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agoxkbcomp: fix pointer value for FreeStmt
Peter Hutterer [Mon, 30 Jul 2018 04:11:46 +0000 (14:11 +1000)]
xkbcomp: fix pointer value for FreeStmt

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agokeycodes: don't try to copy zero key aliases
Peter Hutterer [Mon, 23 Jul 2018 01:48:35 +0000 (11:48 +1000)]
keycodes: don't try to copy zero key aliases

Move the aliases copy to within the (num_key_aliases > 0) block.

Passing info->aliases into this fuction with invalid aliases will
cause log messages but num_key_aliases stays on 0. The key_aliases array
is never allocated and remains NULL. We then loop through the aliases, causing
a null-pointer dereference.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agotext: init the target buffer to zero
Peter Hutterer [Mon, 23 Jul 2018 01:17:17 +0000 (11:17 +1000)]
text: init the target buffer to zero

There's a (theoretical?) path where we might end up strcpy() buf without ever
writing to it. This happens if the mask is nonzero but specifies a modifier
larger than the one in the xkb_mod_set.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
6 years agocompose: fix infinite loop in parser on some inputs
Ran Benita [Mon, 12 Mar 2018 07:43:55 +0000 (09:43 +0200)]
compose: fix infinite loop in parser on some inputs

The parser would enter an infinite loop if an unterminated keysym
literal occurs at EOF.

Found with the afl fuzzer.

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoxkbcomp: fix crash when parsing an xkb_geometry section
Ran Benita [Sun, 11 Mar 2018 15:07:06 +0000 (17:07 +0200)]
xkbcomp: fix crash when parsing an xkb_geometry section

xkb_geometry sections are ignored; previously the had done so by
returning NULL for the section's XkbFile, however some sections of the
code do not expect this. Instead, create an XkbFile for it, it will
never be processes and discarded later.

Caught with the afl fuzzer.

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoxkbcomp: fix crashes in the parser when geometry tokens appear
Ran Benita [Sat, 10 Mar 2018 21:32:12 +0000 (23:32 +0200)]
xkbcomp: fix crashes in the parser when geometry tokens appear

In the XKB format, floats and various keywords can only be used in the
xkb_geometry section. xkbcommon removed support xkb_geometry, but still
parses it for backward compatibility. As part of ignoring it, the float
AST node and various keywords were removed, and instead NULL was
returned by their parsing actions. However, the rest of the code does
not handle NULLs, and so when they appear crashes usually ensue.

To fix this, restore the float AST node and the ignored keywords. None
of the evaluating code expects them, so nice error are displayed.

Caught with the afl fuzzer.

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoxkbcomp: fix stack overflow when evaluating boolean negation
Ran Benita [Sat, 10 Mar 2018 21:10:47 +0000 (23:10 +0200)]
xkbcomp: fix stack overflow when evaluating boolean negation

The expression evaluator would go into an infinite recursion when
evaluating something like this as a boolean: `!True`. Instead of
recursing to just `True` and negating, it recursed to `!True` itself
again.

Bug inherited from xkbcomp.

Caught with the afl fuzzer.

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoAdd fuzzing infrastructure
Ran Benita [Sat, 10 Mar 2018 22:04:05 +0000 (00:04 +0200)]
Add fuzzing infrastructure

Though text formats aren't exactly fuzzer's strong suit, fuzzers can
catch many surface-level bugs.

The fuzz/ directory contains target programs, testcases and dictionaries
to drive the afl fuzzer.

This commit adds a fuzzer for the XKB keymap text format and the Compose
text format. On my slow machine, using a single core, a full cycle of
the XKB fuzzer takes 5 hours. For Compose, it takes a few minutes.

Fuzzing for the other file formats (rules files mostly) will be added
later.

To do some fuzzing, run `./fuzz/fuzz.sh`.

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agoMerge pull request #65 from heftig/pc-fix2
Ran Benita [Tue, 17 Jul 2018 16:06:12 +0000 (19:06 +0300)]
Merge pull request #65 from heftig/pc-fix2

meson: Fix xkbcommon-x11.pc Requires versioning

6 years agomeson: Fix xkbcommon-x11.pc Requires versioning
Jan Alexander Steffens (heftig) [Tue, 17 Jul 2018 15:21:02 +0000 (17:21 +0200)]
meson: Fix xkbcommon-x11.pc Requires versioning

Old meson expects an array with one dependency per element. Providing a
string containing multiple deps results in only the first dep getting
its whitespace properly applied. As a result, the output was:

    Requires.private: xcb >= 1.10 xcb-xkb>=1.10

And downstream projects failed to find a package named 'xcb-xkb>=1.10'.

Specifying an array of versioned deps results in correct output:

    Requires.private: xcb >= 1.10, xcb-xkb >= 1.10

Fixes #64.

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
6 years agomeson: Fix xkbcommon-x11.pc Requires
Jan Alexander Steffens (heftig) [Mon, 16 Jul 2018 23:15:30 +0000 (01:15 +0200)]
meson: Fix xkbcommon-x11.pc Requires

The meson-generated pkgconfig file was missing Requires and
Requires.private.

[ran: adjust for older Meson versions.]

Signed-off-by: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>
Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agobench: simplify the bench helpers
Ran Benita [Thu, 5 Jul 2018 15:13:14 +0000 (18:13 +0300)]
bench: simplify the bench helpers

Trim the API a bit.

Also, just always use gettimeofday(), which is portable. Hopefully the
system clock doesn't change while a benchmark is running.

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agotravis: pin meson to an older version so it works with Python 3.4
Ran Benita [Sat, 23 Jun 2018 20:17:07 +0000 (23:17 +0300)]
travis: pin meson to an older version so it works with Python 3.4

The CI image only has Python 3.4. It's a bit of a hassle to change this,
so let's pin meson to the version before they bumped their requirement
instead.

I suppose it's not that bad in that it will guarantee compatibility with
older meson over time.

Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agokeysym-utf: reject out-of-range Unicode codepoints in xkb_keysym_to_utf{8,32}
Ran Benita [Sat, 23 Jun 2018 19:00:19 +0000 (22:00 +0300)]
keysym-utf: reject out-of-range Unicode codepoints in xkb_keysym_to_utf{8,32}

It used to be UTF-8 was defined for inputs > 0x10FFFF, but nowadays
that's the maximum and a codepoint is encoded up to 4 bytes, not 6.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/58
Fixes: https://github.com/xkbcommon/libxkbcommon/issues/59
Reported-by: @andrecbarros
Signed-off-by: Ran Benita <ran234@gmail.com>
6 years agokeysym-utf: replace the Unicode characters for leftanglebracket and rightanglebracket
Ran Benita [Tue, 27 Feb 2018 18:24:57 +0000 (20:24 +0200)]
keysym-utf: replace the Unicode characters for leftanglebracket and rightanglebracket

Looking at leftanglebracket

- The standard[1] does not specify any Unicode value for it.

- The keysym list keysymdef.h in x11proto[2] says U+27E9 MATHEMATICAL
  RIGHT ANGLE BRACKET in a comment.

- The keysym->unicode list in xkbcommon which comes from [3] has U+2329
  LEFT-POINTING ANGLE BRACKET.

- The keysym->unicode list in Xlib[4] has U+2039 SINGLE LEFT-POINTING
  ANGLE QUOTATION MARK.

[1] https://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html#Legacy_KEYSYMs
[2] https://cgit.freedesktop.org/xorg/proto/x11proto/tree/keysymdef.h
[3] https://www.cl.cam.ac.uk/%7Emgk25/ucs/keysym2ucs.c
[4] https://cgit.freedesktop.org/xorg/lib/libX11/tree/src/xlibi18n/imKStoUCS.c

The symbols we are using, {LEFT,RIGHT}-POINTING ANGLE BRACKET, are
deprecated according to Unicode[5]:

    These characters are deprecated and are strongly discouraged for
    mathematical use because of their canonical equivalence to CJK
    punctuation.

[5] https://www.unicode.org/charts/PDF/U2300.pdf

Hence, switch to the MATHEMATICAL codepoints which seem to be the best
fit.

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/47
Reported-by: @bytensky
Signed-off-by: Ran Benita <ran234@gmail.com>