Age | Commit message (Collapse) | Author | Files | Lines |
|
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>
|
|
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>
|
|
That's a more declarative interface.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
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>
|
|
First, make the rules and xkb scanners/parsers use the same logging
functions instead of rolling their own.
Second, use the gcc ##__VA_ARGS extension instead of dealing with C99
stupidity. I hope all relevant compilers support it.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Previously the early-exit codepath might have left some values
unexpanded, and we'd go looking for e.g "%l%(v)".
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
There can be multiple include paths. But it's nicer in any case.
This also makes scanner_error actually use log_err instead of log_warn -
oops.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Use the scanner token_{line,column} like we do in the other places.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
It doesn't matter (I think), since the implicit conversion doesn't have
any effect (e.g. sign-extension). But it's better to be aware of the
type.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
See: b9b3593cbdeb7f5b02d50cecaba6a0b47d4979ad
So these should be unsigned int's now.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
We have quite diverged from the upstream file, so let's make it at least
easier to look at. Remove some unused macros and rename some for
consistency.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
We were failing to scan something like\
this correctly.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
ctype.h is locale-dependent, so using it in our scanners is not optimal.
Let's be deterministic with our own simple functions.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Improve safety with parenthesis, make the matcher macros use the scanner
ones, and make the 1 variant use %s instead of embedding the msg; this
way the compiler can reuse the string in the binary.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
There are some big functions there, and this might help reduce the
cognitive load a bit.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
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>
|
|
We want to share the same functions for another scanner.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
This can't happen, but better safe than sorry. The optimizations were
noticeable but negligible.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
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>
|
|
This is a more appropriate name now.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
gcc didn't catch this one.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
- Add context.h and move context-related functions from xkb-priv.h to
it.
- Move xkb_context definition back to context.c.
- Add keysym.h and move keysym upper/lower/keypad from xkb-priv.h to it.
- Rename xkb-priv.h to map.h since it only contains keymap-related
definitions and declarations now.
- Remove unnecessary includes and some and some other small cleanups.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Only report it once, and not only for rules.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
With Dan Nicholson's permission (via email), update his copyright and
license statements to the standard X.Org boilerplate MIT license, as
both myself and Ran have been using.
Clean up my copyright declarations (in some cases to correct ownership),
and add copyright/license statements from myself and/or Ran where
appropriate.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
There's no noticeable speed difference, but I think it's nicer and more
explicit than the previous code. Some people just don't like goto,
though..
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Rewrite the rules file parser for clarity, performance and memory usage
reduction. The previous implementation was quite hard to navigate and
did a lot of unnecessary work and copying.
This implementation keeps along just the state necessary, and doesn't
perform any copying of the file's content (although the entire file is
mmap'ed as before). Hopefully it's also easier to understand, has better
documentation, and better error checking and reporting. We try to
reproduce the previous behavior in every case.
Note: the diff is pretty confusing; it's likely better to look at the
file directly.
Benchmarks:
On an old 32-bit Intel processor.
gcc -O2 -pg
./test/rulescomp bench
grof test/rulescomp
Before:
compiled 1000 keymaps in 14.863564304s
% cumulative self self total
time seconds seconds calls ms/call ms/call name
49.33 4.43 4.43 30610000 0.00 0.00 yylex
17.93 6.04 1.61 31000 0.05 0.22 yyparse
6.57 6.63 0.59 1000 0.59 0.59 load_rules
3.23 6.92 0.29 3637000 0.00 0.00 AppendStmt
2.45 7.14 0.22 472000 0.00 0.00 AddKeySymbols
2.12 7.33 0.19 3591000 0.00 0.00 atom_intern
2.12 7.52 0.19 518000 0.00 0.00 FindNamedKey
2.00 7.70 0.18 230000 0.00 0.00 FreeStmt
1.78 7.86 0.16 1000 0.16 0.17 UpdateModifiersFromCompat
1.34 7.98 0.12 732000 0.00 0.00 AddKeyName
1.34 8.10 0.12 __x86.get_pc_thunk.bx
After:
compiled 1000 keymaps in 13.874666269s
% cumulative self self total
time seconds seconds calls ms/call ms/call name
49.82 4.26 4.26 30610000 0.00 0.00 yylex
22.22 6.16 1.90 31000 0.06 0.22 yyparse
2.92 6.41 0.25 3591000 0.00 0.00 atom_intern
2.57 6.63 0.22 1000 0.22 0.25 xkb_components_from_rules
2.11 6.81 0.18 3637000 0.00 0.00 AppendStmt
2.11 6.99 0.18 230000 0.00 0.00 FreeStmt
1.99 7.16 0.17 518000 0.00 0.00 FindNamedKey
1.99 7.33 0.17 1000 0.17 0.17 UpdateModifiersFromCompat
1.99 7.50 0.17 __x86.get_pc_thunk.bx
1.52 7.63 0.13 150000 0.00 0.00 AddInterp
1.40 7.75 0.12 472000 0.00 0.00 AddKeySymbols
On a newer 64-bit Intel processor.
gcc -O2
./test/rules-file bench
Before:
processed 20000 times in 15.940546625s
After:
processed 20000 times in 5.295026345s
Allocations:
gcc -O2
valgrind test/rulescomp
Before:
total heap usage: 257,519 allocs, 257,519 frees, 14,766,529 bytes allocated
After:
total heap usage: 240,756 allocs, 240,756 frees, 14,007,886 bytes allocated
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
There are two ways to separate multiple files in XKB include statements:
'+' will cause the later file to override the first in case of conflict,
while '|' will cause it augment it (this is done by xkbcomp). '!' is
unrelated here.
Since '|' is practically never used, this wasn't noticed.
In the modified test, the '|some_compat' previously was just ignored.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Various non-functional changes:
- Re-add keycodes.h and move some stuff there.
- Add parser-priv.h for internal bison/flex stuff.
- Don't include headers from other headers, such that file dependencies
are immediate in each file.
- Rename xkbcomp.h -> ast.h, parseutils.{c,h} -> ast-build.{c,h}
- Rename path.{c,h} -> include.{c,h}
- Rename keytypes.c -> types.c
- Make the naming of XkbFile-related functions more consistent.
- Move xkb_map_{new,ref,unref} to map.c.
- Remove most extern keyword from function declarations, it's just
noise (XKB_EXPORT is what's important here).
- Append XKBCOMP_ to include guards.
- Shuffle some code around to make all of this work.
Splitting this would be a headache..
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Instead of malloc'ing it as well. Also improve the error handling.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Good for a small performance win on my system.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
Thus giving a hint as to which directory we're trying to find.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
It's more tidy and less error prone, since we use strcasecmp == 0 a lot.
We replace strcmp == 0 by streq, strcasecmp == 0 by istreq,
uStrCasePrefix by istreq_prefix and uDupString by strdup_safe.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
.uncrustify.cfg committed for future reference also, but had to manually
fix up a few things: it really likes justifying struct initialisers.
Signed-off-by: Daniel Stone <daniel@fooishbar.org>
|
|
This was broken by commit 18d331b86b4942ba54fe087ca07e47c9383d768b
(where only the first option out of a comma-separated string was
matched). Do it correctly this time and add a test.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
This commit removes the ability to specify a keymap *in a rules file*,
e.g. in /usr/share/X11/xkb/rules/evdev or somesuch. This is unused in
xkeyboard-data, and the current code has never even supported it,
because xkb_map_new_from_kccgst (which is no longer exposed in the API)
checks to see that one of the usual components (e.g. symbols, types, ..)
has been filled, while the rules parser, on the other hand, doesn't
allow to specify a keymap and other stuff at the same time.
( The idea was to remove xkb_map_new_from_kccgst entirely, but it's used
by a test so it can stay. )
tl;dr: dead code. Of course passing a keymap file to
xkb_map_new_from_file still works.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
enums are nice for some type safety and readability. This one also
removes the distinction between file type mask / file type index and
some naming consistency.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
- Make darray_free also initialize the array back to an empty state, and
stop worrying about it everywhere.
- Add darray_mem, to access the underlying memory, which we do manually
now using &darray_item(arr, 0). This makes a bit more clear when we
actually mean to take the address of a specific item.
- Add darray_copy, to make a deep copy of a darray.
- Add darray_same, to test whether two darrays have the same underlying
memory (e.g. if the struct itself was value copied). This should used
where previously two arrays were compared for pointer equality.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Here are some quick numbers from valgrind, running rulescomp only with a
simple, common "us,de" rule set:
before darray: cb047bb
total heap usage: 44,924 allocs, 44,924 frees, 3,162,342 bytes allocated
after darray: c87468e
total heap usage: 52,670 allocs, 52,670 frees, 2,844,517 bytes allocated
tweaking specific inital allocation sizes:
total heap usage: 52,652 allocs, 52,652 frees, 2,841,814 bytes allocated
changing initial alloc = 2 globally
total heap usage: 47,802 allocs, 47,802 frees, 2,833,614 bytes allocated
changing initial alloc = 3 globally
total heap usage: 47,346 allocs, 47,346 frees, 3,307,110 bytes allocated
changing initial alloc = 4 globally
total heap usage: 44,643 allocs, 44,643 frees, 2,853,646 bytes allocated
[ Changing the geometric progression constant from 2 only made things
worse. I tried the golden ratio - not so golden :) ]
The last one is obviously the best, so it was chosen, with the specific
tweaks thrown in as well (these were there before but don't make much
difference). Overall it seems to do better than the previous manual
allocations which is a bit surprising.
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|
|
Signed-off-by: Ran Benita <ran234@gmail.com>
|