platform/upstream/libxkbcommon.git
11 years agoMove xkb_context struct to xkb-priv.h
Daniel Stone [Fri, 3 Aug 2012 01:12:52 +0000 (03:12 +0200)]
Move xkb_context struct to xkb-priv.h

So we can print more intelligent debugging messages without needing
helper functions for the failed_includes array.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agocontext: Maintain list of failed include paths
Daniel Stone [Fri, 3 Aug 2012 01:11:19 +0000 (03:11 +0200)]
context: Maintain list of failed include paths

Keep around a list of paths we tried to add but couldn't.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoMore useful error message on failing RMLVO -> KcCGST
Daniel Stone [Fri, 3 Aug 2012 01:05:02 +0000 (03:05 +0200)]
More useful error message on failing RMLVO -> KcCGST

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoMove more of xkb_map_new_from_rmlvo into compilation
Daniel Stone [Fri, 3 Aug 2012 01:00:20 +0000 (03:00 +0200)]
Move more of xkb_map_new_from_rmlvo into compilation

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoStaticise xkb_map_new_from_kccgst
Daniel Stone [Fri, 3 Aug 2012 00:57:02 +0000 (02:57 +0200)]
Staticise xkb_map_new_from_kccgst

We didn't expose this to the outside world, and its only trivial user
was xkb_map_new_from_rules.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotest: Use test_compile_*() in interactive
Daniel Stone [Fri, 3 Aug 2012 00:51:40 +0000 (02:51 +0200)]
test: Use test_compile_*() in interactive

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoAdd support for default rules/model/layout
Daniel Stone [Fri, 3 Aug 2012 00:51:10 +0000 (02:51 +0200)]
Add support for default rules/model/layout

Right now it just comes from build-time, but eventually this should be
sourced from configuration files at runtime too.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotests: Fix uninitialised-use-of-'ret' warning
Daniel Stone [Fri, 3 Aug 2012 00:37:09 +0000 (02:37 +0200)]
tests: Fix uninitialised-use-of-'ret' warning

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agotest: Use test_get_context() in interactive
Daniel Stone [Fri, 3 Aug 2012 00:36:40 +0000 (02:36 +0200)]
test: Use test_get_context() in interactive

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoWarning fixes
Daniel Stone [Wed, 8 Aug 2012 11:30:05 +0000 (13:30 +0200)]
Warning fixes

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
11 years agoAdd API to query whether a modifier is consumed
Ran Benita [Mon, 6 Aug 2012 21:20:40 +0000 (00:20 +0300)]
Add API to query whether a modifier is consumed

Currently the user has no way of knowing which of the active modifiers
have been used in the translation of a keycode to its keysyms. The use
case is described in the GTK docs: say there's a menu accelerator
activated by "<Alt>+". Some layouts have "+" shifted, and some have it
on the first level. So in keymaps where "+" is shifted, the Shift
modifier is consumed and must be ignored when the user is testing
for "<Alt>+". Otherwise, we may get "<Alt><Shift>+" and the accelerator
should not actually fire.

For this we also use the preserve[] information in the key types, which
can forces us to report modifiers as unconsumed even if they were used
in the translation. Until now we didn't do anything with this
information.

The API tries to match its surronding. It's not very efficient but this
can be fixed.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: remove default type
Ran Benita [Tue, 7 Aug 2012 10:23:44 +0000 (13:23 +0300)]
types: remove default type

The default type is copied over for each new key type to build on.
Further, it can be modified from within the xkb_types section itself,
with statements such as "type.modifiers = Lock" which affect all
subsequent type definitions.

The default type is (well, by default) just the simplest one level type
possible, with name "default". When no types are defined at all, it is
copied over to the keymap as the single type.

xkeyboard-config never changes the default type. There is also no sane
use case for doing so; changing any thing there doesn't make sense. So
instead of doing all the hard work of maintaining and copying this type,
which is practically never used, just remove it and initialize new types
appropriately.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: store atoms instead of strings for level and type names
Ran Benita [Tue, 7 Aug 2012 08:40:07 +0000 (11:40 +0300)]
types: store atoms instead of strings for level and type names

We don't use these strings much, so storing them in the manner they
were compiled saves some copying and space.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: use regular array for map entries
Ran Benita [Tue, 7 Aug 2012 05:52:23 +0000 (08:52 +0300)]
types: use regular array for map entries

This array is only initialized once.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: use regular array for types
Ran Benita [Tue, 7 Aug 2012 05:38:20 +0000 (08:38 +0300)]
types: use regular array for types

The current code doesn't resize it any more.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: remove DeleteLevel1MapEntries
Ran Benita [Tue, 7 Aug 2012 05:17:26 +0000 (08:17 +0300)]
types: remove DeleteLevel1MapEntries

If there is no map entry for some modifier combination, the default is
to use level 1. The removed code is an optimization to save some space
by removing these entries. But it doesn't actually save any space, and
did not in fact remove all level 1 entries (it walks the array while
modifying it so there's an off-by-one error).

We can instead keep them in the types but just not print them in
keymap-dump.c, to get about the same behavior.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: move preserve directly into xkb_kt_map_entry
Ran Benita [Mon, 6 Aug 2012 18:31:17 +0000 (21:31 +0300)]
types: move preserve directly into xkb_kt_map_entry

Currently each xkb_key_type has a preserve array, which is only allocated
if a preserve[] statement is specified in the type. In this case each map
entry has an element in the array.

The space savings are negligible; put this field where it logically
belongs.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoFix virtual modifiers mask extraction
Ran Benita [Sun, 5 Aug 2012 16:38:31 +0000 (19:38 +0300)]
Fix virtual modifiers mask extraction

The calculations were performed incorrectly in several places,
specifically shifting by 16 instead of 8 (= XkbNumModifiers) and masking
with 0xff instead of 0xffff.

More stuff that probably never worked as intended. This also makes these
more grep-able when we remove the vmods/real_mods separation.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: small changes
Ran Benita [Sun, 5 Aug 2012 11:05:03 +0000 (14:05 +0300)]
types: small changes

Just make things easier to follow, no functional changes.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRemove xproto build dependency
Ran Benita [Wed, 1 Aug 2012 22:09:41 +0000 (01:09 +0300)]
Remove xproto build dependency

Very little left to do for this.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: don't use canonical/required types
Ran Benita [Wed, 1 Aug 2012 21:29:07 +0000 (00:29 +0300)]
types: don't use canonical/required types

Xkb required every keymap to have at least the four following canonical
types: ONE_LEVEL, TWO_LEVEL, ALPHABETIC, KEYPAD. This is specified in
e.g. the kbproto spec and XkbKeyTypesForCoreSymbols(3) man page.

If these types are not specified in the keymap, the code specifically
checks for them and adds them to the 4 first places in the types array,
such that they exist in every keymap. These are also the types (along
with some non-required 4-level ones) that are automatically assigned to
keys which do not explicitly declare a type (see FindAutomaticType in
symbols.c, this commit doesn't touch these heuristics, whcih are also not
very nice but necessary).

The xkeyboard-config does not rely on the builtin xkbcomp definitions of
these types and does specify them explicitly, in types/basic and
types/numpad, which are virtually always included.

This commit removes the special behavior:
- The code is ugly and makes keytypes.c harder to read.
- The code practically never gets run - everyone who uses
  xkeyboard-config or a keymap based upon it (i.e. everyone) doesn't need
  it. So it doesn't get tested.
- It mixes policy with implementation for not very good reasons, it
  seems mostly for default compatibility with X11 core.
- And of course we don't need to remain compatible with Xkb ABI neither.

Instead, if we read a keymap with no types specified at all, we simply
assign all keys a default one-level type (like ONE_LEVEL), and issue
plenty of warnings to make it clear (with verbosity >= 3). Note that
this default can actually be changed from within the keymap, by writing
something like
    type.modifier = Shift
    type.whatever_field = value
in the top level of the xkb_types section. (This functionality is
completely unused as well today, BTW, but makes some sense).

This change means that if someone writes a keymap from scratch and
doesn't add say ALPHABETIC, then something like <AE11> = { [ q Q ]; }; will
ignore the second level. But as stated above this should never happen.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: add a general overview
Ran Benita [Sun, 5 Aug 2012 10:46:56 +0000 (13:46 +0300)]
types: add a general overview

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agosymbols: remove support for key behaviors
Ran Benita [Sat, 4 Aug 2012 07:47:56 +0000 (10:47 +0300)]
symbols: remove support for key behaviors

The possible key behaviors are:
KB_RadioGroup, KB_Overlay1, KB_Overlay2: already removed support for
these.
KB_Lock (with or without KB_Permanent): used to ignore key presses or
releases to simulate and deal with some legacy keyboard behaviors
(like keys that physically lock). Not used at all.

We already ignore them while processing key events in state.c, so make
it official.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: small changes
Ran Benita [Sun, 29 Jul 2012 08:39:44 +0000 (11:39 +0300)]
keycodes: small changes

to make it a bit nicer.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoHandle key names consistently
Ran Benita [Sat, 28 Jul 2012 19:15:59 +0000 (22:15 +0300)]
Handle key names consistently

We treat the key names as fixed length, non NUL terminated strings of
length XkbKeyNameLength, and use the appropriate *Text functions to
print them. We also use strncpy everywhere instead of memcpy to copy
the names, because it does some NUL padding and we might as well.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeycodes: add a general overview
Ran Benita [Sat, 28 Jul 2012 09:10:44 +0000 (12:10 +0300)]
keycodes: add a general overview

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: make ResolveLevel return zero-based level
Ran Benita [Sun, 5 Aug 2012 11:10:45 +0000 (14:10 +0300)]
expr: make ResolveLevel return zero-based level

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoAdd and use xkb_level_index_t
Ran Benita [Sun, 5 Aug 2012 16:24:44 +0000 (19:24 +0300)]
Add and use xkb_level_index_t

Several types are used over the code for shift levels; better to use
just one.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoaction: drop global actionInitialized
Ran Benita [Thu, 2 Aug 2012 21:20:07 +0000 (00:20 +0300)]
action: drop global actionInitialized

The action.c needs to use two constant Expr values, constTrue and
constFalse. To do this is keeps to static globals Expr's of type boolean
and the values "true" and "false" which need to be interned (and thus
context specific). The interning means they can't be made static const,
so there's a global flag and initializer function.

Instead of using this unsafe global state, we can simply use an integer
boolean expression (1 and 0) instead of a string one ("true" and
"false") and make them const.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: constify function arguments
Ran Benita [Thu, 2 Aug 2012 21:33:40 +0000 (00:33 +0300)]
expr: constify function arguments

We need this for later.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agolog: allow to resore default log function
Ran Benita [Mon, 6 Aug 2012 17:04:22 +0000 (20:04 +0300)]
log: allow to resore default log function

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agodarray: fix formatting
Ran Benita [Thu, 2 Aug 2012 14:59:57 +0000 (17:59 +0300)]
darray: fix formatting

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agofilecomp: fix path and error message
Ran Benita [Sun, 5 Aug 2012 09:03:51 +0000 (12:03 +0300)]
filecomp: fix path and error message

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agointeractive: add support to run from keymap file
Ran Benita [Thu, 2 Aug 2012 06:54:38 +0000 (09:54 +0300)]
interactive: add support to run from keymap file

This is useful for quickly testing a random keymap file. Use -k <PATH>.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeyseq: use our own keysyms
Ran Benita [Wed, 1 Aug 2012 21:40:22 +0000 (00:40 +0300)]
keyseq: use our own keysyms

Instead of <X11/keysym.h>

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoReplace more defines with enums
Ran Benita [Wed, 1 Aug 2012 19:12:13 +0000 (22:12 +0300)]
Replace more defines with enums

Mostly the ones used to track the fields of types/keys/leds which were
already defined.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoMake top level Handle*File functions nicer
Ran Benita [Wed, 1 Aug 2012 15:46:01 +0000 (18:46 +0300)]
Make top level Handle*File functions nicer

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoUse xkb_led_index_t throughout
Ran Benita [Sat, 28 Jul 2012 20:21:46 +0000 (23:21 +0300)]
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>
11 years agovmod: remove unused fields
Ran Benita [Wed, 1 Aug 2012 18:31:36 +0000 (21:31 +0300)]
vmod: remove unused fields

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoREADME: s/xkb_desc/xkb_keymap
Ran Benita [Sat, 28 Jul 2012 20:31:08 +0000 (23:31 +0300)]
README: s/xkb_desc/xkb_keymap

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoUse only one set of core mod name-to-index functions
Ran Benita [Wed, 1 Aug 2012 08:25:34 +0000 (11:25 +0300)]
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>
11 years agomap: fix incorrect return value
Ran Benita [Wed, 1 Aug 2012 08:12:18 +0000 (11:12 +0300)]
map: fix incorrect return value

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agomap: fix virtual mod index calculation
Ran Benita [Wed, 1 Aug 2012 08:01:21 +0000 (11:01 +0300)]
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>
11 years agokeymap-dump: use ActionTypeText
Ran Benita [Thu, 2 Aug 2012 20:40:31 +0000 (23:40 +0300)]
keymap-dump: use ActionTypeText

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap-dump: use SITextMatch
Ran Benita [Thu, 2 Aug 2012 18:36:30 +0000 (21:36 +0300)]
keymap-dump: use SITextMatch

text.c has the exact same function.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agokeymap-dump: clean up write_buf function
Ran Benita [Thu, 2 Aug 2012 17:55:12 +0000 (20:55 +0300)]
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>
11 years agoAdd an interactive evdev test
Ran Benita [Sat, 7 Apr 2012 23:20:39 +0000 (02:20 +0300)]
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

11 years agoRemove ExprResult
Ran Benita [Fri, 27 Jul 2012 12:31:03 +0000 (15:31 +0300)]
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>
11 years agoexpr: remove support for evaluating string as integer
Ran Benita [Fri, 27 Jul 2012 11:15:39 +0000 (14:15 +0300)]
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>
11 years agoDon't create contexts with no include paths
Daniel Stone [Wed, 25 Jul 2012 08:53:36 +0000 (10:53 +0200)]
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>
11 years agocontext test: Use test_get_context()
Daniel Stone [Wed, 25 Jul 2012 08:55:06 +0000 (10:55 +0200)]
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>
11 years agoexpr: drop ExprResult from ResolveEnum
Ran Benita [Tue, 24 Jul 2012 16:39:59 +0000 (19:39 +0300)]
expr: drop ExprResult from ResolveEnum

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveMask
Ran Benita [Tue, 24 Jul 2012 14:21:29 +0000 (17:21 +0300)]
expr: drop ExprResult from ResolveMask

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveInteger
Ran Benita [Tue, 24 Jul 2012 07:39:15 +0000 (10:39 +0300)]
expr: drop ExprResult from ResolveInteger

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveButton
Ran Benita [Mon, 23 Jul 2012 22:22:26 +0000 (01:22 +0300)]
expr: drop ExprResult from ResolveButton

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveLevel
Ran Benita [Mon, 23 Jul 2012 21:51:19 +0000 (00:51 +0300)]
expr: drop ExprResult from ResolveLevel

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveKeyCode
Ran Benita [Mon, 23 Jul 2012 21:23:34 +0000 (00:23 +0300)]
expr: drop ExprResult from ResolveKeyCode

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveGroup
Ran Benita [Mon, 23 Jul 2012 21:10:07 +0000 (00:10 +0300)]
expr: drop ExprResult from ResolveGroup

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveKeysym
Ran Benita [Mon, 23 Jul 2012 20:56:28 +0000 (23:56 +0300)]
expr: drop ExprResult from ResolveKeysym

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveBoolean
Ran Benita [Mon, 23 Jul 2012 16:52:17 +0000 (19:52 +0300)]
expr: drop ExprResult from ResolveBoolean

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveString
Ran Benita [Mon, 23 Jul 2012 12:46:50 +0000 (15:46 +0300)]
expr: drop ExprResult from ResolveString

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveLhs
Ran Benita [Mon, 23 Jul 2012 09:20:05 +0000 (12:20 +0300)]
expr: drop ExprResult from ResolveLhs

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: drop ExprResult from ResolveKeyName
Ran Benita [Mon, 23 Jul 2012 08:56:13 +0000 (11:56 +0300)]
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>
11 years agoparser: untabify
Ran Benita [Wed, 25 Jul 2012 18:37:20 +0000 (21:37 +0300)]
parser: untabify

Run vim's :%retab and some resulting indention fixes.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoConvert defines to enums in xkbcomp.h
Ran Benita [Wed, 25 Jul 2012 14:29:08 +0000 (17:29 +0300)]
Convert defines to enums in xkbcomp.h

For statement / expression types.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoFix incorrect comparison
Ran Benita [Thu, 26 Jul 2012 22:47:32 +0000 (01:47 +0300)]
Fix incorrect comparison

ExprFieldRef goes into the ExprDef op field, not the type field.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoutils: add/replace string equality macros
Ran Benita [Tue, 24 Jul 2012 16:54:14 +0000 (19:54 +0300)]
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>
11 years agoDrop Xkbc prefix of text functions
Ran Benita [Tue, 24 Jul 2012 10:24:59 +0000 (13:24 +0300)]
Drop Xkbc prefix of text functions

Not really needed and inconsistent.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoUse xkb_mod_mask_t and xkb_mask_index_t throughout
Ran Benita [Tue, 24 Jul 2012 10:15:40 +0000 (13:15 +0300)]
Use xkb_mod_mask_t and xkb_mask_index_t throughout

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoRemove alloc.{c,h}
Ran Benita [Mon, 23 Jul 2012 18:30:28 +0000 (21:30 +0300)]
Remove alloc.{c,h}

These functions are more appropriate elsewhere now.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoscanner: don't strdup key names
Ran Benita [Mon, 23 Jul 2012 14:41:55 +0000 (17:41 +0300)]
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>
11 years agoSome atom related optimizations
Ran Benita [Mon, 23 Jul 2012 13:03:34 +0000 (16:03 +0300)]
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>
11 years agoexpr: don't divide by zero
Ran Benita [Mon, 23 Jul 2012 18:21:03 +0000 (21:21 +0300)]
expr: don't divide by zero

Calculator parser 101.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agotypes: fix canonical types copying
Ran Benita [Mon, 23 Jul 2012 18:18:18 +0000 (21:18 +0300)]
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>
11 years agokeycodes: fix valgrind warnings
Ran Benita [Mon, 23 Jul 2012 13:22:20 +0000 (16:22 +0300)]
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>
11 years agoparse: remove unused #define
Ran Benita [Mon, 23 Jul 2012 08:25:32 +0000 (11:25 +0300)]
parse: remove unused #define

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agoexpr: Remove ExprResolveFloat
Ran Benita [Mon, 23 Jul 2012 08:42:22 +0000 (11:42 +0300)]
expr: Remove ExprResolveFloat

Remnant from geometry.

Signed-off-by: Ran Benita <ran234@gmail.com>
11 years agomakekeys: Add top_srcdir to include path
Daniel Stone [Mon, 23 Jul 2012 22:10:07 +0000 (23:10 +0100)]
makekeys: Add top_srcdir to include path

Fixes distcheck with no /usr/include/xkbcommon.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
12 years agoAdd test for logging functionality
Ran Benita [Sun, 22 Jul 2012 16:38:14 +0000 (19:38 +0300)]
Add test for logging functionality

Just to make sure everything works properly.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoRemove old logging leftovers
Ran Benita [Sat, 21 Jul 2012 13:10:17 +0000 (16:10 +0300)]
Remove old logging leftovers

Everything has been converted.

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoxkbcomp: use new log functions
Ran Benita [Sat, 21 Jul 2012 12:39:18 +0000 (15:39 +0300)]
xkbcomp: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoparse: use new log functions
Ran Benita [Sat, 21 Jul 2012 12:44:48 +0000 (15:44 +0300)]
parse: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agopath: use new log functions
Ran Benita [Sat, 21 Jul 2012 12:37:33 +0000 (15:37 +0300)]
path: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agomisc: use new log functions
Ran Benita [Sat, 21 Jul 2012 12:35:17 +0000 (15:35 +0300)]
misc: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agovmod: use new log functions
Ran Benita [Sat, 21 Jul 2012 12:27:09 +0000 (15:27 +0300)]
vmod: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agorules: use new log functions
Ran Benita [Sat, 21 Jul 2012 12:19:27 +0000 (15:19 +0300)]
rules: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoexpr: use new log functions
Ran Benita [Sat, 21 Jul 2012 12:12:31 +0000 (15:12 +0300)]
expr: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agoaction: use new log functions
Ran Benita [Sat, 21 Jul 2012 11:53:49 +0000 (14:53 +0300)]
action: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agotypes: use new log functions
Ran Benita [Fri, 20 Jul 2012 23:08:14 +0000 (02:08 +0300)]
types: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agotypes: add keymap to KeyTypesInfo
Ran Benita [Fri, 20 Jul 2012 23:03:25 +0000 (02:03 +0300)]
types: add keymap to KeyTypesInfo

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agocompat: use new log functions
Ran Benita [Fri, 20 Jul 2012 22:35:46 +0000 (01:35 +0300)]
compat: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agocompat: add keymap to CompatInfo
Ran Benita [Fri, 20 Jul 2012 22:31:10 +0000 (01:31 +0300)]
compat: add keymap to CompatInfo

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: use new log functions
Ran Benita [Fri, 20 Jul 2012 21:58:25 +0000 (00:58 +0300)]
symbols: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agosymbols: add keymap to SymbolsInfo
Ran Benita [Fri, 20 Jul 2012 21:50:18 +0000 (00:50 +0300)]
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>
12 years agokeycodes: use new log functions
Ran Benita [Fri, 20 Jul 2012 16:38:36 +0000 (19:38 +0300)]
keycodes: use new log functions

Signed-off-by: Ran Benita <ran234@gmail.com>
12 years agokeycodes: add keymap to KeyNamesInfo
Ran Benita [Fri, 20 Jul 2012 15:27:37 +0000 (18:27 +0300)]
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>
12 years agoAdd logging API
Ran Benita [Fri, 20 Jul 2012 10:10:13 +0000 (13:10 +0300)]
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>
12 years agoutils: replace FATAL by malloc_or_die
Ran Benita [Fri, 20 Jul 2012 14:20:35 +0000 (17:20 +0300)]
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>
12 years agoutils: remove Xfuncproto.h and use our own macros
Ran Benita [Fri, 20 Jul 2012 14:09:49 +0000 (17:09 +0300)]
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>
12 years agoutils: remove uTypedAlloc/Calloc
Ran Benita [Fri, 20 Jul 2012 10:07:30 +0000 (13:07 +0300)]
utils: remove uTypedAlloc/Calloc

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