x11: add explicit cast in mods conversion

Explicit is better and all.

Signed-off-by: Ran Benita <ran234@gmail.com>
x11: add #actions == #syms check

This must always hold (but if there are no actions, #actions==0), and
explicitly ensures there won't be a division-by-zero a bit below.

Signed-off-by: Ran Benita <ran234@gmail.com>
state: use the XKB_MOD_MASK constant

Signed-off-by: Ran Benita <ran234@gmail.com>
scanner: avoid strlen in keyword lookup, we know the len

Signed-off-by: Ran Benita <ran234@gmail.com>
action: check range of MovePtr X,Y values

Signed-off-by: Ran Benita <ran234@gmail.com>
action: Use ResolveInteger for PtrBtn.count, not ResolveButton

It's not a button.

Signed-off-by: Ran Benita <ran234@gmail.com>
ast: make symsMapIndex unsigned

It doesn't need to be signed.

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

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>
action: change xkb_pointer_button_action::button to uint8_t

In XkbPtrBtnAction it is unsigned char, don't know how it became signed.

Signed-off-by: Ran Benita <ran234@gmail.com>
parser: fix unrecognized keysym handling

Integer may be negative, so also need to test >= 0.
Also, $$ was left uninitialized if the keysym wasn't recognized.

Signed-off-by: Ran Benita <ran234@gmail.com>
symbols: reduce some loop iterators scope

Signed-off-by: Ran Benita <ran234@gmail.com>
Fix sign-compare warnings

Signed-off-by: Ran Benita <ran234@gmail.com>
test/state: fix tautological test

test/state.c:376:5: warning: comparison of unsigned expression >= 0 is always true [-Wtype-limits]

Signed-off-by: Ran Benita <ran234@gmail.com>
darray: use unsigned int instead of size_t for array size

size_t is too large; if we ever need it, that's the least of our
problems. Besides, when we roll our own (e.g. in keymap.h) it's already
unsigned int. Instead, add some emergency overflow check. So, why?

- It plays nicer with all the other uint32_t's and unsigned int's (no
  extensions, etc.).
- Reduces keymap memory usage by 5% or so as a bonus.

Signed-off-by: Ran Benita <ran234@gmail.com>
ast: use more suitable types in a few ast nodes

The int ones cannot be signed (they come as such from the scanner, and
NEGATE is never applied to them).

The uint32_t one is really an atom, but presumably the type was never
converted to xkb_atom_t.

Signed-off-by: Ran Benita <ran234@gmail.com>
build: add -Wextra warnings

If it gets annoying, we can disable it. But for now it's clean.

Signed-off-by: Ran Benita <ran234@gmail.com>
Partially revert "ast: pack the ParseCommon struct"

This reverts commit 1e6e5669c6229846830f0b497591de4e3cf588eb.

It's probably safe, but let's not take any chances, as I don't have any
esoteric arch to test on. But keep the ATTR in case it's ever useful.

Signed-off-by: Ran Benita <ran234@gmail.com>
Define likely()/unlikely() macros

It serves as nice "hotspot" annotations, and can also help things, so
why not.

Signed-off-by: Ran Benita <ran234@gmail.com>
scanner-utils: add some likely/unlikely annotations

Signed-off-by: Ran Benita <ran234@gmail.com>
action: fix printing of underflowed value in error message

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