Commit Graph

754 Commits (262bf97f9bfeed535d94034cf5ded9dac962ffaa)

Author SHA1 Message Date
Ran Benita 025ca57905 expr: drop ExprResult from ResolveLhs
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 761b675cc3 expr: drop ExprResult from ResolveKeyName
Explicit is better than implicit, and this union makes it hard to follow
what's what, particularly the confusion with ival/uval.
The other Resolve functions will follow.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:56:11 +03:00
Ran Benita 01c81fa61e parser: untabify
Run vim's :%retab and some resulting indention fixes.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:49:09 +03:00
Ran Benita 724f62c8e3 Convert defines to enums in xkbcomp.h
For statement / expression types.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:49:06 +03:00
Ran Benita 35fb8b94cb Fix incorrect comparison
ExprFieldRef goes into the ExprDef op field, not the type field.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:47:32 +03:00
Ran Benita 89723b7cb7 utils: add/replace string equality macros
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>
2012-07-27 00:27:24 +03:00
Ran Benita 4f843c817b Drop Xkbc prefix of text functions
Not really needed and inconsistent.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 00:11:42 +03:00
Ran Benita 6cb9820000 Use xkb_mod_mask_t and xkb_mask_index_t throughout
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 00:04:45 +03:00
Ran Benita 74be17627e Remove alloc.{c,h}
These functions are more appropriate elsewhere now.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 00:02:59 +03:00
Ran Benita 13eb9c357d scanner: don't strdup key names
The key name is always XkbKeyNameLength (= 4) bytes, so we can maintain
it directly in YYSTYPE union and copy when needed, instead of treating
it like a full blown string and then copy. This means the scanner
checks the length itself.

rulescomp under valgrind, before:
==1038==   total heap usage: 168,403 allocs, 168,403 frees, 9,732,648 bytes allocated
after:
==9377==   total heap usage: 155,643 allocs, 155,643 frees, 9,672,788 bytes allocated

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 00:01:57 +03:00
Ran Benita 112cccb18a Some atom related optimizations
We often get a strdup'd string, just to pass it over the atom_intern and
then immediately free it. But atom_intern then strdup's it again (if
it's not interned already); so instead we can have the interning "steal"
the memory instead of allocing a new one and freeing the old one. This
is done by a new xkb_atom_steal function.

It also turns out, that every time we strdup an atom, we don't actually
modify it afterwards. Since we are guaranteed that the atom table will
live as long as the context, we can just use xkb_atom_text instead. This
removes a some more dynamic allocations.

For this change we had to remove the ability to append two strings, e.g.
    "foo" + "bar" -> "foobar"
which is only possible with string literals. This is unused and quite
useless for our purposes.

xkb_atom_strdup is left unused, as it may still be useful.

Running rulescomp in valgrind, Before:
==7907== total heap usage: 173,698 allocs, 173,698 frees, 9,775,973 bytes allocated
After:
==6348== total heap usage: 168,403 allocs, 168,403 frees, 9,732,648 bytes allocated

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 00:01:41 +03:00
Ran Benita c6279b8bae expr: don't divide by zero
Calculator parser 101.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-26 23:15:54 +03:00
Ran Benita 7662397fd4 types: fix canonical types copying
Without the re-initialization, the copying fails. This wasn't noticed
because this code practically never gets executed with ordinary keymaps.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-26 22:55:41 +03:00
Ran Benita 3c58072172 keycodes: fix valgrind warnings
==7071== Conditional jump or move depends on uninitialised value(s)
==7071==    at 0x40B6CB: AddIndicatorName (keycodes.c:148)
==7071==    by 0x40C34F: MergeIncludedKeycodes (keycodes.c:420)
==7071==    by 0x40C613: HandleIncludeKeycodes (keycodes.c:480)
==7071==    by 0x40D022: HandleKeycodesFile (keycodes.c:733)
==7071==    by 0x40D79F: CompileKeycodes (keycodes.c:881)
==7071==    by 0x401E22: compile_keymap (xkbcomp.c:157)
==7071==    by 0x402091: xkb_map_new_from_kccgst (xkbcomp.c:229)
==7071==    by 0x40216A: xkb_map_new_from_names (xkbcomp.c:254)
==7071==    by 0x4046F5: test_compile_rules (common.c:164)
==7071==    by 0x4015C1: test_rmlvo (rulescomp.c:44)
==7071==    by 0x40180D: main (rulescomp.c:98)

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-26 22:55:34 +03:00
Ran Benita d4eee86160 parse: remove unused #define
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-26 22:55:28 +03:00
Ran Benita 2e245a9a41 expr: Remove ExprResolveFloat
Remnant from geometry.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-26 22:55:17 +03:00
Daniel Stone 9bd55b55f8 makekeys: Add top_srcdir to include path
Fixes distcheck with no /usr/include/xkbcommon.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-23 23:10:07 +01:00
Ran Benita 3dc1252d2d Add test for logging functionality
Just to make sure everything works properly.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita 2c30fa7a60 Remove old logging leftovers
Everything has been converted.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita 70e3e7e5c3 xkbcomp: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita f48ee2d2af parse: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita 8e3958032c path: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita 885f6c8cb6 misc: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita 544a83e6d7 vmod: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita 3bb3e9c3a9 rules: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita d659f2b46b expr: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita e037f51862 action: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita 87444fb969 types: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:35 +03:00
Ran Benita 36df40c3cd types: add keymap to KeyTypesInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 8e62b368a7 compat: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 270ff8ad83 compat: add keymap to CompatInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 7dc51ea84a symbols: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 7ef648134d symbols: add keymap to SymbolsInfo
and use it. Also make sure info is the first argument to the functions
in this file.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 0ae1199a5a keycodes: use new log functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 37579ce9a5 keycodes: add keymap to KeyNamesInfo
and let the info always be the first argument to the various functions,
just for consistency (and it acting as the contex for this file).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 70f35cfbc0 Add logging API
Add new public API to provide the library users with some options to
control and customize the logging output from the library. It is based
upon the skeleton from the libabc demo libray:
https://git.kernel.org/?p=linux/kernel/git/kay/libabc.git
which is public domain and works pretty well.

This requires passing in the context object in every logging call, and
thus the conversion is done file by file. We also remove the global
warningLevel variable in favor of a verbosity level in the context,
which can be set by the user and is silent by default.

One issue is the ACTION calls, which, while nice, do not play very well
with line- and priority-based logging, and would require some
line continuation handling or keeping state or some other compromise. So
instead remove these and just inline them with their respective
warning/error. So instead of:
    ERROR("Memory allocation failed\n")
    ACTION("Removing all files on hardisk\n")
its something like that:
    log_err("Memory allocation failed; Removing all files on harddisk\n")

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 71c2f2e0e2 utils: replace FATAL by malloc_or_die
"Out of memory" is enough in this case. If we want to be OOM-safe this
makes it clear where to begin.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 58f8d2c151 utils: remove Xfuncproto.h and use our own macros
Add XKB_EXPORT to replace _X_EXPORT, and copy the definitions of
_X_ATTRIBUTE_FOO as ATTR_FOO.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 8b0e9f929c utils: remove uTypedAlloc/Calloc
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 5e164ff1f9 build: drop the include/ directory
The include/ dir is somewhat redundant and makes it just a bit harder to
handle the -I directives from out side of automake; without it the
default $(top_buildir) just works.
Here's also some further justifications I found:
http://smcv.pseudorandom.co.uk/2008/09/pc-uninstalled/

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-23 00:45:34 +03:00
Ran Benita 2fc0ad5001 Fix bison 2.6 and clang warnings
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-20 12:48:13 +03:00
Ran Benita db98696d0b Remove CommonInfo
Not used by anything anymore.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 21:06:07 +03:00
Ran Benita 250c925ce4 types: use list instead of CommonInfo for KeyTypeInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 21:06:07 +03:00
Ran Benita 85826c3c13 Simplify HandleInclude functions
Instead of special casing the first include, process it inside the loop
as well. It works perfectly fine.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 21:06:07 +03:00
Ran Benita 861e6a1751 Remove haveSelf include feature
When including a file from another file, its possible to do something
like this:
    include "+some(other)+files"
with the "+" or "|" in the beginning. What will happen then is that
instead of processing the include files separately and then merging into
the existing info, we instead start with the existing info and merge
into it as we go, as if it was written explicitly before the first "+".

It's not particulary clear what this may be useful for. Since it's not
used by xkeyboard-config, not documented anywhere (and google doesn't
bring up anything), completely untested and kind of ugly, remove this
"feature". It most likely never been used.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 20:40:33 +03:00
Ran Benita 730c2bc34f types: use list instead of CommonInfo in PreserveInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 15:25:41 +03:00
Ran Benita 85abd36bf4 types: move global static tok_ atoms into KeyTypesInfo
The atoms are context-dependent.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 15:25:41 +03:00
Ran Benita 119c952b82 compat: use list instead of CommonInfo in LEDInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 15:25:41 +03:00
Ran Benita 50b25a1210 Use xkb_group_index_t for group variables throughout
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 15:25:37 +03:00
Ran Benita 8237e9c77a Remove _X_EXPORT from xkb_key_get_group/level
We should add them to xkbcommon.h if they need to.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-18 14:07:02 +03:00