summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2020-01-18Bump version to 0.10.0xkbcommon-0.10.0upstream_work_20200225upstream_bkup_20210105Ran Benita2-1/+78
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-01-18doc/rules-format.txt: document include supportRan Benita1-1/+15
Signed-off-by: Ran Benita <ran@unusedvar.com>
2020-01-18docs: add missing reference to $XDG_CONFIG_HOMERan Benita1-1/+1
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28CI: Add build instructions for WindowsAdrian Perez de Castro2-0/+20
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28MSVC: Provide an implementation of gettimeofday()Adrian Perez de Castro1-1/+31
2019-12-28MSVC: Provide implementations of [un]setenv()Adrian Perez de Castro1-0/+5
Reference: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/putenv-s-wputenv-s
2019-12-28MSVC: Provide implementations of test_{dis,en}able_stdin_echoAdrian Perez de Castro1-3/+24
This provides implementations of the test_enable_stdin_echo and test_disable_stdin_echo which do not require <termios.h>, which is not available on Windows.
2019-12-28MSVC: Use <io.h> as an alternative for <unistd.h>Adrian Perez de Castro4-3/+22
Only the input/output functions from <unistd.h> options are used, so using <io.h> when building with MSVC should be enough. The inclusion of the header in context-priv.c does not seem to be needed (tested on GNU/Linux) and so it is removed. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28build: Skip building some tests on MSVC for nowAdrian Perez de Castro1-8/+13
This is a stopgap measure to quickly get tests building with MSVC for now, at some point the tests could be rewritten to avoid using getopt() and mkdtemp() or to ship an implementation.
2019-12-28build: add some defines for MSVC to allow it to be unixyAdrian Perez de Castro1-0/+8
[ran: combined some commits]
2019-12-28ci: use consistent python for all jobsRan Benita4-6/+9
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28test/data: ensure files are checked out with LF, not CRLFRan Benita1-0/+1
The tests stringcomp and buffercomp do binary comparison on some files; if the files are changed to CRLF on checkout, the tests fail. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28CI: some tweaksAdrian Perez de Castro4-33/+27
[ran: extracted generic bits from Windows commit.] Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28xkbcomp/rules: support \r\n line endingsRan Benita1-1/+3
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28test/atom: use correct format specifier for size_tRan Benita2-7/+7
From MSVC: test\atom.c(98): note: consider using '%zu' in the format string test\atom.c(98): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(100): note: consider using '%zu' in the format string test\atom.c(100): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(114): note: consider using '%zu' in the format string test\atom.c(114): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(128): note: consider using '%zu' in the format string test\atom.c(128): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(130): note: consider using '%zu' in the format string test\atom.c(130): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 1 has type 'size_t' test\atom.c(137): note: consider using '%zu' in the format string test\atom.c(137): warning C4477: 'fprintf' : format string '%lu' requires an argument of type 'unsigned long', but variadic argument 2 has type 'size_t' Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28Open files in binary modeRan Benita11-14/+14
This turns off some misfeatures on Windows, and does nothing on POSIX. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28test/common: avoid double // in pathRan Benita1-1/+2
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-28test/common: simplify test_get_path()Ran Benita1-12/+10
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27xkbcomp: remove cast which triggers warning on gccRan Benita1-1/+1
Will need some other way to take care of the warning on MSVC. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27xkbcomp: make a couple of casts explicit to mark them as checkedRan Benita2-2/+5
This acknowledges some "possible loss of data cast" warnings from MSVC. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27test/context: use a more portable directory-exists checkRan Benita1-6/+7
MSVC doesn't have opendir/closedir. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27xkbcomp/keywords: regenerate with newer gperfRan Benita3-70/+109
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27parser: fix format string for int64_tRan Benita1-1/+1
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27Only add GCC diagnostic pragmas when compiler is GCC compatibleRan Benita4-4/+14
Avoid "unknown pragma" warnings on other compilers. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27xkbcomp: fix wrong return typeRan Benita1-1/+1
Detected by MSVC: xkbcomp\xkbcomp.c(111): warning C4047: 'return': 'bool' differs in levels of indirection from 'void *' Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27parser: use int64_t for all numbersRan Benita1-6/+4
Don't use int which can have different size on different machines. Also avoid some warnings from MSVC: xkbcomp/parser.y(760): warning C4244: '=': conversion from 'int64_t' to 'int', possible loss of data xkbcomp/parser.y(761): warning C4244: '=': conversion from 'int64_t' to 'int', possible loss of data xkbcomp/parser.y(767): warning C4244: '=': conversion from 'int64_t' to 'int', possible loss of data Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27scanner-utils: avoid possible implicit truncating of line/columnRan Benita1-3/+3
This increases the size of the struct a bit but it's not very important. Fixes these MSVC warnings: src\scanner-utils.h(112): warning C4267: '+=': conversion from 'size_t' to 'unsigned int', possible loss of data src\scanner-utils.h(147): warning C4267: '+=': conversion from 'size_t' to 'unsigned int', possible loss of data Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27utils: move macro defines to before they're usedRan Benita1-8/+8
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27utils: fix typo in strndup fallbackRan Benita1-1/+1
Fixup 93a1305 - we will have CI for this soon. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27meson.build: Take win_bison as a possible variant for BisonAdrian Perez de Castro2-2/+2
Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27build: include config.h manuallyRan Benita66-3/+128
Previously we included it with an `-include` compiler directive. But that's not portable. And it's better to be explicit anyway. Every .c file should have `include "config.h"` first thing. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27Provide a fallback implementation of [v]asprintf()Adrian Perez de Castro3-0/+58
Some environments (e.g. Windows + MSVC) do not provide asprintf() or vasprintf(). This tries to detect their presence, and provides suitable fallback implementations when not available.
2019-12-27Provide a fallback implementation of strndup()Adrian Perez de Castro2-0/+18
Some environments (e.g. Windows + MSVC) do not provide strndup(), this tries to detect its presence and provide a fallback implementation when not available. [ran: some tweaks]
2019-12-27Use built-in istr[n]cmp() instead of strcase[n]cmp()Adrian Perez de Castro1-1/+1
This avoids the problem that MSVC does not provide strcasecmp() nor strncasecmp(), and at the same time avoids potential problems due to locale configuration by using istrcmp() and istrncmp() which are already in the source tree and written to cover only ASCII.
2019-12-27utils: use MIN/MAX instead of min/maxRan Benita3-17/+3
min/max symbols conflict on some systems (msvc), so just use the macros. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-27xkbcomp: downgrade "Symbol added to modifier map for multiple modifiers" log ↵Ran Benita1-12/+12
to a warning This condition happens in xkeyboard-config keymaps and seems hard to fix. Currently it incessantly spams people's logs who have no idea what to do about it. So downgrade to "warning" level, so it doesn't show up by default. When working on keymaps, set `XKB_LOG_LEVEL=debug XKB_LOG_VERBOSITY=10` to see all possible messages. Refs https://github.com/xkbcommon/libxkbcommon/issues/111 Fixes https://github.com/xkbcommon/libxkbcommon/issues/128 Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-24rules: eliminate an extra fopen/fclose cyclePeter Hutterer1-15/+15
FindXkbFileInPath() opens the file so we're guaranteed that the file not only exists, but that we can read it. Changing that would alter behavior so instead let's just pass that file handle along and do the same for include files. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-24rules: add include statements to rules filesPeter Hutterer11-2/+328
The majority use-case for extending XKB on a machine is to override one or a few keys with custom keycodes, not to define whole layouts. Previously, we relied on the rules file to be a single file, making it hard to extend. libxkbcommon parses $XDG_CONFIG_HOME/xkb/ but that only works as long as there is a rule that matches the user-specified RMLVO. This works for MLV but not for options which don't have a wildcard defined. Users have to copy the whole rules file and then work from there - not something easy to extend and maintain. This patch adds a new ! include directive to rules files that allows including another file. The file path must be without quotes and may not start with the literal "include". Two directives are supported, %H to $HOME and %S for the system-installed rules directory (usually /usr/share/X11/xkb/rules). A user would typically use a custom rules file like this: ! option = symbols custom:foo = +custom(foo) custom:bar = +custom(baz) ! include %S/evdev Where the above defines the two options and then includes the system-installed evdev rule. Since most current implementations default to loading the "evdev" ruleset, it's best to name this $XDG_CONFIG_HOME/xkb/rules/evdev, but any valid name is allowed. The include functionally replaces the line with the content of the included file which means the behavior of rules files is maintained. Specifically, custom options must be defined before including another file because the first match usually wins. In other words, the following ruleset will not assign my_model as one would expect: ! include %S/evdev ! model = symbols my_model = +custom(foo) The default evdev ruleset has wildcards for model and those match before the my_model is hit. The actual resolved components need only be in one of the XKB lookup directories, e.g. for the example above: $ cat $XDG_CONFIG_HOME/xkb/symbols/custom partial alphanumeric_keys xkb_symbols "foo" { key <TLDE> { [ VoidSymbol ] }; }; partial alphanumeric_keys xkb_symbols "baz" { key <AB01> { [ k, K ] }; }; This can then be loaded with the XKB option "custom:foo,custom:bar". The use of "custom" is just as an example, there are no naming requirements beyond avoiding already-used ones. Also note the bar/baz above - the option names don't have to match the component names. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-24context: add a helper function to return the default system include pathPeter Hutterer2-5/+12
No functional changes but we'll need that same lookup in the rules file include handling in a future patch. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-24rules: move the matcher result handling to the callerPeter Hutterer1-38/+37
This shouldn't be processed in the matcher itself, especially in the glorious future when we can have nested matchers. Only handle this once in the caller to the original parsed file. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-24rules: put the scanner on the stackPeter Hutterer1-58/+65
This allows nesting the scanner for the future !include directive. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-24rules: simplify an error pathPeter Hutterer1-3/+3
Initialize to NULL so we don't have to care about whether the cleanups can be called or not. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-24rules: rename a variable from 's' to 'str'Peter Hutterer1-11/+11
To avoid name conflicts with a future patch. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-24rules: drop the matcher_err() macro and use scanner_err directlyPeter Hutterer1-17/+14
No functional changes, this is what the macro expanded to anyway. Prep work for putting the scanner on the stack and removing it from the matcher struct. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-24rules: factor out the function to parse a rules filePeter Hutterer1-13/+36
No functional changes, this just makes the part to parse a single rules file re-usable. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-22keysym: handle ssharp in XConvertCase()Peter Hutterer1-0/+4
lowercase: LATIN SMALL LETTER SHARP S (U+00DF) uppercase: LATIN CAPITAL LETTER SHARP S (U+1E9E) The uppercase sharp s (XK_ssharp) is a relatively recent addition to unicode but was added to the relevant keyboard layouts in xkeyboard-config-2.25 (d1411e5e95c) https://gitlab.freedesktop.org/xkeyboard-config/xkeyboard-config/issues/144 Alas, the CapsLock behavior was broken on the finnish layout (maybe others). This was due XConvertCase() never returning the uppercase characters. Let's make this function return the right lower/upper symbols for the sharp s and hope that the world won't get any worse because of it. Corresponding Xlib issue: https://gitlab.freedesktop.org/xorg/lib/libx11/issues/110 Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-12-14meson: remove redundant malloc scribblingRan Benita1-3/+0
Turns out meson already sets this (at least MALLOC_PERTURB) on its own for the `test` target. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-12-14parser: fix the remaining pointer chasingRan Benita1-22/+21
Fix the TODO added in 7c42945. Signed-off-by: Ran Benita <ran@unusedvar.com>
2019-11-18test: let rmlvo-to-kccgst take long options like rmlvo-to-keymapPeter Hutterer1-3/+20
The short options were left for backwards compatibility. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2019-11-14parser: fix quadratic pointer chasingRan Benita3-61/+73
In the AST, lists (e.g. the list of statements in a file) are kept in singly-linked lists -- each AST node has a `next` pointer available for this purpose. Previously, a node was added to the list by starting from the head, chasing to the last, and appending. So creating a list of length N would take ~N^2/2 pointer dereferences. Now, we always (temporarily) keep the last as well, so appending is O(1) instead of O(N). Given a keymap xkb_keymap { xkb_keycodes { minimum = 8; minimum = 8; minimum = 8; minimum = 8; minimum = 8; [... repeated N times ...] }; xkb_types {}; xkb_compat {}; xkb_symbols {}; }; The compilation times are N | Before | After --------|----------|------- 10,000 | 0.407s | 0.006s 20,000 | 1.851s | 0.015s 30,000 | 5.737s | 0.021s 40,000 | 12.759s | 0.023s 50,000 | 21.489s | 0.035s 60,000 | 40.473s | 0.041s 70,000 | 53.336s | 0.039s 80,000 | 72.485s | 0.044s 90,000 | 94.703s | 0.048s 100,000 | 118.390s | 0.057s Another option is to ditch the linked lists and use arrays instead. I got it to work, but its more involved and allocation heavy so turns out to be worse without further optimizations. Signed-off-by: Ran Benita <ran@unusedvar.com>