Commit Graph

729 Commits (3bea189bd5bf4fd23a6b3b1a6f4e8b0c51426586)

Author SHA1 Message Date
Ran Benita 3bea189bd5 Make top level Handle*File functions nicer
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 82ee45b374 Use xkb_led_index_t throughout
And use XKB_LED_INVALID instead of _LED_Unbound, which served the same
purpose here.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 09dac54b97 vmod: remove unused fields
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 6eb5929d48 README: s/xkb_desc/xkb_keymap
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita 7c7e434151 Use only one set of core mod name-to-index functions
These were repeated 5 times.

Note that this changes the ABI slightly: XKB_MOD_NAME_CAPS is changed
from "Caps Lock" to "Lock", which is the ordinary legacy mod name for
it. Since its hidden behind a #define, it's best to stay compatible with
the old names (as I think was intended, given that "Mod1", etc. are the
same).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:42 +03:00
Ran Benita c6dee4640a map: fix incorrect return value
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 11:09:39 +03:00
Ran Benita ae968f855a map: fix virtual mod index calculation
The current code made us miss vmod index 0. Also look at the code in
vmod.c:LookupVModMask.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 10:50:15 +03:00
Ran Benita 80ab9f12b4 keymap-dump: use ActionTypeText
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 10:47:43 +03:00
Ran Benita d53fcf53f8 keymap-dump: use SITextMatch
text.c has the exact same function.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 10:47:43 +03:00
Ran Benita 20bef734d8 keymap-dump: clean up write_buf function
It would have been nice to use open_memstream here if it was portable
enough (maybe someday it will?).

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-08-07 10:47:41 +03:00
Ran Benita 4c21275301 Add an interactive evdev test
The program reads key events from evdev input devices, puts them through
the library and prints some information about them. It's nice for
experimenting, quick testing and trying to break it with random stuff
(already found some!).

It is called "interactive" for lack of a better name. It's a bit
hackish, but can easily be extended, made more portable etc, in the
future.

Signed-off-by: Ran Benita <ran234@gmail.com>

Conflicts:
	Makefile.am
	test/.gitignore
2012-07-28 11:43:15 +02:00
Ran Benita 41d9afc556 Remove ExprResult
Convert the IdentLookup typedef away from ExprResult, which drags along
everything else. This should also make all of the conversions explicit.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 15:31:03 +03:00
Ran Benita 6917901f81 expr: remove support for evaluating string as integer
As the comment nicely puts it, this is a bit weird. When you try to
evaluate an expression of type string into an integer, what it does is:
    "" -> 0
    "c" -> (ascii value, i.e. like a char literal)
    more than one char -> error
The first one is obviously not very useful; why not just write 0?
The second one might be useful (though I don't see where in a keymap
it would be), but I don't think anyone would consider trying "X" for
that anyway.

A look through xkeyboard-config shows "" only used once as a string, and
"X" also only used as strings (and mostly in geometry which we don't
evaluate anyway). And I seriously doubt it's used (purposely) anywhere
else. So remove it.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 14:15:39 +03:00
Daniel Stone dd0f3c6dc2 Don't create contexts with no include paths
Clean up the return code handling from
xkb_context_add_include_paths_default, and thus fail context creation if
we can't add any of the default include paths, but were asked to.  If
this happens, dump the DFLT_XKB_CONFIG_ROOT out in the log message, so
at least we know what we aren't looking at.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-27 11:59:55 +02:00
Daniel Stone ca7927ae60 context test: Use test_get_context()
So we don't die if we haven't got a valid global include path.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-07-27 11:59:55 +02:00
Ran Benita bd927abf3d expr: drop ExprResult from ResolveEnum
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:14 +03:00
Ran Benita 38614c886c expr: drop ExprResult from ResolveMask
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:14 +03:00
Ran Benita 2e4933cda7 expr: drop ExprResult from ResolveInteger
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita d568228988 expr: drop ExprResult from ResolveButton
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 6ec135700d expr: drop ExprResult from ResolveLevel
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 000528dd59 expr: drop ExprResult from ResolveKeyCode
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita e258f9ee07 expr: drop ExprResult from ResolveGroup
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 7026229210 expr: drop ExprResult from ResolveKeysym
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 0d262fa105 expr: drop ExprResult from ResolveBoolean
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
Ran Benita 27f9492969 expr: drop ExprResult from ResolveString
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-07-27 01:57:13 +03:00
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