expr: Remove ExprResolveFloat

Remnant from geometry.

Signed-off-by: Ran Benita <ran234@gmail.com>
parse: remove unused #define

Signed-off-by: Ran Benita <ran234@gmail.com>
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>
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>
expr: don't divide by zero

Calculator parser 101.

Signed-off-by: Ran Benita <ran234@gmail.com>
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>
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>
Remove alloc.{c,h}

These functions are more appropriate elsewhere now.

Signed-off-by: Ran Benita <ran234@gmail.com>
Use xkb_mod_mask_t and xkb_mask_index_t throughout

Signed-off-by: Ran Benita <ran234@gmail.com>
Drop Xkbc prefix of text functions

Not really needed and inconsistent.

Signed-off-by: Ran Benita <ran234@gmail.com>
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>
Fix incorrect comparison

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

Signed-off-by: Ran Benita <ran234@gmail.com>
Convert defines to enums in xkbcomp.h

For statement / expression types.

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

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

Signed-off-by: Ran Benita <ran234@gmail.com>
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>
expr: drop ExprResult from ResolveLhs

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: drop ExprResult from ResolveString

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: drop ExprResult from ResolveBoolean

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: drop ExprResult from ResolveKeysym

Signed-off-by: Ran Benita <ran234@gmail.com>
expr: drop ExprResult from ResolveGroup

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