Commit Graph

1187 Commits (e91d2653dd18e6dcace8923596c1f1a29bb9d1d4)

Author SHA1 Message Date
Ran Benita e91d2653dd scanner: allow empty key name literals
Some keymaps actually have this, like the quartz.xkb which is tested. We
need to support these.

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

Reported-By: Gatis Paeglis <gatis.paeglis@digia.com>
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-08-02 11:40:27 +03:00
Ran Benita e731b2514b xkbcomp: handle empty keymaps
We should handle empty xkb_keycode and xkb_symbol sections, since
xkbcomp handles them, and apparently XQuartz uses it. There are also
files for it in xkeyboard-config (rules=base model=empty layout=empty,
which translate to keycodes/empty and symbols/empty).

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

Reported-By: Gatis Paeglis <gatis.paeglis@digia.com>
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-08-02 11:39:39 +03:00
Ran Benita d2383d3852 keymap-dump: use correct format specifiers
For keycodes, groups, levels, etc, which are unsigned. The really proper
inttypes.h ones seem a bit much though.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-08-01 21:49:48 +03:00
Ran Benita c0589be69b log: change the log prefixes to be more library-like
"Error: " is not very informative when intermingled with other logs. The
format that seems most suitable is:
    "xkbcommon: ERROR: %s"

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-31 10:58:25 +03:00
Ran Benita 990c09a3d0 keymap: update builtin fields directly in src/keymap.c
This fields are part of our API and every keymap should have them, not
just xkbcomp/ ones.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-31 10:58:25 +03:00
Ran Benita 5f787e5e91 keymap: be more careful in xkb_keymap_unref
To allow calling _unref on the keymap in whatever limbo state it happens
to be in.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-31 10:58:25 +03:00
Ran Benita be38862b2a keymap: remove struct xkb_key_redirect_action
The file src/xkbcomp/action.c already doesn't handle this action type
and fails if it encounters it. So lets not pretend to do something with
it, and ignore it rather than failing.

If we/someone wants this we can consider implementing it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-31 10:58:25 +03:00
Ran Benita 3a0adc0f5c doc: try to clarify some subtle points
Which to choose: xkb_state_update_key() / xkb_state_update_mask(). If you
use update_mask(), you don't (and shouldn't) use update_key().
If you use update_key(), be careful not to have unmatched UP/DOWN
calls; this can bring about stuck modifiers etc.

Probably want to use XKB_STATE_{MODS,LAYOUT}_EFFECTIVE. The others are
only useful in very special cases.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-31 10:55:20 +03:00
Ran Benita 7f1b7a1c36 test/keyseq: add de(neo) Level{6,7,8} tests
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-25 13:21:33 +03:00
Pino Toscano ec9a02a239 Get rid of the usage of PATH_MAX
PATH_MAX is optional in POSIX, so avoid its unconditional usage
allocating and freeing buffers as needed.
To avoid too many malloc/free in the for loop in FindFileInXkbPath,
a buffer is grown according to the size needed at each iteration.
2013-07-24 12:08:11 +03:00
Ran Benita 806d24b1a5 keymap: move RANGE_WRAP to be the first in the enum
This is the reasonable "zero-default" for this enum.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-23 11:36:01 +03:00
Ran Benita 0c8e9e0c9c test: sync test/data from xkeyboard-config 2.9
Needed for some tests. The tests need some adjustment, mostly because of
the resolution of xkeyboard-config bug
https://bugs.freedesktop.org/show_bug.cgi?id=50935

Also add the 'ch' symbols file for future tests.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-22 22:28:01 +03:00
Ran Benita c00ea5ff8e atom: really work with non-NUL-terminated strings
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-22 11:02:20 +03:00
Ran Benita 9e801ff782 ctx: adapt to the len-aware atom functions
xkb_atom_intern now takes a len parameter. Turns out though that almost
all of our xkb_atom_intern calls are called on string literals, the
length of which we know statically. So we add a macro to micro-optimize
this case.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-21 17:07:41 +03:00
Ran Benita 7e0ae4b4d5 atom: allow interning non-NUL-terminated strings
We need this later. The strlen was calculated anyway, so no loss here.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-21 17:07:41 +03:00
Ran Benita 9cd29453ae atom: expand variable names
A bit easier to understand at a glance.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-21 17:07:41 +03:00
Ran Benita 9ffe9dae1d keymap: don't use darray for sym_interprets
We want xkb_keymap to be easy to handle everywhere.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-21 10:00:37 +03:00
Ran Benita 4b560287f8 xkbcomp: escape the section names before storing them in the keymap
This ensures the names are escaped before having any interaction with
the user.

This was caught by noticing dump(compile(dump())) != dump. Since that's
a nice test we add it to stringcomp.

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

Reported-By: Auke Booij
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-07-18 14:50:21 +03:00
Daniel Stone 6bb727b227 Resync keysym database
xproto 7.0.24 adds XF86AudioMicMute.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-07-17 22:47:32 +01:00
Ran Benita 6f06eb5944 doc: Update Doxyfile
It gives:

Warning: Tag `SYMBOL_CACHE_SIZE' at line 346 of file doc/Doxyfile has become obsolete.
To avoid this warning please remove this line from your configuration file or upgrade it using "doxygen -u"

So run 'doxygen -u' as suggested.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-06-19 21:14:41 +03:00
Daniel Stone 9f01bd1e72 Bump version to 0.3.1
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-06-03 16:43:43 +01:00
Matthias Clasen b06de3072b Add keycode min/max and iteration API
Add three new pieces of API:
  - xkb_keymap_min_keycode does what it says on the tin
  - xkb_keymap_max_keycode likewise
  - xkb_keymap_key_for_each calls the provided function once for every
    valid key in the keymap

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-05-09 15:31:21 +01:00
Daniel Stone 17a956d807 Widen keycode range to 8/255 if possible (bug #63390)
If the keycode range is smaller than 8 → 255, artifically widen it when
dumping the keymap as not to displease X.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-05-09 14:47:09 +01:00
Ran Benita a392d2682b Replace flex scanner with a hand-written one
The scanner is very similar in structure to the one in xkbcomp/rules.c.
It avoids copying and has nicer error reporting.

It uses gperf to generate a hashtable for the keywords, which gives a
nice speed boost (compared to the naive strcasecmp method at least). But
since there's hardly a reason to regenerate it every time and require
people to install gperf, the output (keywords.c) is added here as well.

Here are some stats from test/rulescomp:

Before:
compiled 1000 keymaps in 4.052939625s
==22063==   total heap usage: 101,101 allocs, 101,101 frees, 11,840,834 bytes allocated

After:
compiled 1000 keymaps in 3.519665434s
==26505==   total heap usage: 99,945 allocs, 99,945 frees, 7,033,608 bytes allocated

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-04-01 18:20:57 +01:00
Ran Benita e4bceec880 utils: add {un,}map_file to read an entire file
This wraps the current mmap call and adds a fallback implementation for
systems which do not have mmap (e.g. mingw).

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-04-01 18:20:56 +01:00
Ran Benita 99f6e6fc28 Add scanner-utils.h for common scanner functions
We want to share the same functions for another scanner.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-04-01 18:20:54 +01:00
Daniel Stone 27a11762ab Bump version to 0.3.0
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-04-01 18:04:06 +01:00
David Herrmann 36f55c494e keymap: add xkb_keymap_new_from_buffer()
The current API doesn't allow the caller to create keymaps from mmap()'ed
files. The problem is, xkb_keymap_new_from_string() requires a terminating
0 byte. However, there is no way to guarantee that when using mmap() so a
user currently has to copy the whole file just to get the terminating zero
byte (assuming they cannot use xkb_keymap_new_from_file()).

This adds a new entry xkb_keymap_new_from_buffer() which takes a memory
location and the buffer size in bytes.

Internally, we depend on yy_scan_{string,byte}() helpers. According to
flex documentation these already copy the input string because they are
wrappers around yy_scan_buffer().
yy_scan_buffer() on the other hand has some insane requirements. The
buffer must be writeable and the last two bytes must be ASCII-NUL. But the
buffer may contain other 0 bytes just fine.

Because we don't want these constraints in our public API,
xkb_keymap_new_from_buffer() needs to create a copy of the input memory.
But it then calls yy_scan_buffer() directly. Hence, we have the same
number of buffer-copies as with *_from_string() but without the
terminating 0 requirement.
The explicit yy_scan_buffer() call is preferred over yy_scan_byte() so the
buffer-copy operation is not hidden somewhere in flex.

Maybe some day we no longer depend on flex and can have a zero-copy API. A
user could mmap() a file and it would get parsed right from this buffer.
But until then, we shouldn't expose this limitation in the API but instead
provide an API that some day can work with zero-copy.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>

[ran: rebased on top of my branch]
Conflicts:
	Makefile.am
	src/xkbcomp/xkbcomp.c
2013-04-01 18:04:06 +01:00
Ran Benita 094f1dc29a xkbcomp/keymap: silence a gcc warning
src/xkbcomp/keymap.c:127:12: error: 'found' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Not really, but why not.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-04-01 17:50:08 +01:00
Daniel Stone 38654f5e74 Add key-sequence checking to rulescomp
Make sure we're actually getting the keymaps we're hoping to
compile.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-04-01 17:50:08 +01:00
Daniel Stone 4d7600bd0c test: Add va_list variant of test_key_seq
For use when chaining tests.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-03-19 10:59:38 +00:00
Daniel Stone 40c46ecd5b Allow NULL rmlvo for xkb_keymap_new_from_names
Previously we allowed you to pass a names struct with five NULL members,
but not just pass NULL for the struct itself.  This was pretty dumb. :(

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-03-19 10:54:23 +00:00
Daniel Stone 22ba1fa1a6 test: Add environment checking to rulescomp
To ensure that overriding RMLVO from the environment works.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-03-19 10:54:23 +00:00
Daniel Stone 964b2a4023 test: Suppress RMLVO environment inheritance by default
But add a flag to allow it for later usage.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-03-19 10:54:23 +00:00
Daniel Stone fbe5e6751e Add environment overrides for default RMLVO
You can now set default values in the environment, as well as a context
option to ignore the environment, e.g. for tests.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-03-19 10:53:37 +00:00
Daniel Stone d4c22ecc8a test: Use test_get_context() in log.c
Since the only behavioural change is overriding default includes.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-03-19 10:34:28 +00:00
Daniel Stone 54f95f496f test: Add flags argument to test_get_context()
Allowing overriding of environment suppression, at first.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-03-19 10:28:23 +00:00
Daniel Stone a1f203c031 test: Move test_key_seq to common.c
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2013-03-19 10:25:52 +00:00
Ran Benita 0513686b5d rules: be more paranoid in scanner
This can't happen, but better safe than sorry. The optimizations were
noticeable but negligible.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:06 +00:00
Ran Benita 0e200bd507 rules: quiet a gcc warning
src/xkbcomp/rules.c:620:36: error: 'idx' may be used uninitialized in this function [-Werror=maybe-uninitialized]

Can't happen but no harm done.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:06 +00:00
Ran Benita 559252a1a8 keyseq: add a couple of tests
Tests the filter refcounting.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:06 +00:00
Ran Benita 9f75e0ab2e state: use stdbool in filters
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:06 +00:00
Ran Benita e8c0396f97 doc: use README as doxygen main page overview
The doxygen page looked a bit dead, the README fills it nicely, and is
already written in the markdown format which doxygen uses (I think?).

Unfortunately the USE_MDFILE_AS_MAINPAGE doxygen config doesn't seem to
do anything.. So we just add a {#mainpage} tag at the top of the README
which isn't so bad. BUT we still need some config option (the
no_extension=md part) so that doxygen will accept README instead of
README.md or somesuch. And that requires an even newer release, 1.8.3.1,
released 2013-01. But if an older version is used, it doesn't spew out
warnings but just skips the README, which is fine.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:06 +00:00
Ran Benita 40e5de9ac4 doc: update Doxyfile template to one from newer version
We want to use the USE_MDFILE_AS_MAINPAGE option which was introduced in
doxygen 1.8.3 (released 2012-12).

Right now the new options are commented, otherwise older doxygen spews
these these warnings, which can be ignored:

warning: ignoring unsupported tag `USE_MDFILE_AS_MAINPAGE =' at line 794, file doc/Doxyfile
warning: ignoring unsupported tag `MATHJAX_FORMAT         =' at line 1210, file doc/Doxyfile
warning: ignoring unsupported tag `EXTERNAL_SEARCH        =' at line 1257, file doc/Doxyfile
warning: ignoring unsupported tag `SEARCHENGINE_URL       =' at line 1265, file doc/Doxyfile
warning: ignoring unsupported tag `SEARCHDATA_FILE        =' at line 1271, file doc/Doxyfile
warning: ignoring unsupported tag `EXTERNAL_SEARCH_ID     =' at line 1278, file doc/Doxyfile
warning: ignoring unsupported tag `EXTRA_SEARCH_MAPPINGS  =' at line 1287, file doc/Doxyfile

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:06 +00:00
Ran Benita e33dd591bb doc: some improvements
Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:06 +00:00
Ran Benita 57bfde3aff keymap: rename xkb_kt_map_entry to xkb_key_type_entry
That's a better name and fits more nicely.
Also change type->map to type->entries.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:06 +00:00
Ran Benita 6a39a0657d Fix pointer style nit
(I really dislike this one for some reason..)

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:05 +00:00
Ran Benita 56ba986613 Remove file_id entirely
It is not used anymore.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:05 +00:00
Ran Benita 64c002627d symbols: remove file_id
See previous commits.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:05 +00:00
Ran Benita 4921eb7416 compat: remove file_id
See previous commit.

Signed-off-by: Ran Benita <ran234@gmail.com>
2013-03-18 22:20:05 +00:00