Perform bounds checking in ExprResolveLevel

Both callers perform the same bounds check, so move it into
ExprResolveLevel itself.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
Remove unused debug #defines

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove unused includes of "tokens.h"

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove ancient compatibility check

Other headers include malloc just fine.

Signed-off-by: Ran Benita <ran234@gmail.com>
makekeys: make buf local to main()

All the functions already accept it as a parameter. This clears -Wshadow
warnings.

Signed-off-by: Ran Benita <ran234@gmail.com>
makekeys: clear const and shadow warnings

The name 'index' is used by the standard library, so use 'ndx' like some
other files.

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove unneeded assignments and variables

Signed-off-by: Ran Benita <ran234@gmail.com>
Fix possible null dereferences

Fix all reported null dereferences from clang-analyzer.
There seems to be one false negative (in file indicators.c), but it is
fixed anyway.

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

These are all trivial/obvious fixes which clear a bunch of warnings.

Signed-off-by: Ran Benita <ran234@gmail.com>
Fix an incorrect sizeof

Signed-off-by: Ran Benita <ran234@gmail.com>
Fix warnings in scanner and parser

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

Signed-off-by: Ran Benita <ran234@gmail.com>
makekeys: Fix build/target word size mismatch when cross-compiling

This matches commit 24283d40b1e4314c6647dda49d2a159833341a8b from
libX11:

    Since makekeys is built using build environment's compiler and
    runs natively, we have to make sure that the size of the
    Signature type is the same on both the native environment
    and the target, otherwise we get mismatches upon running X,
    and some LSB test failures (xts5).

    Use an unsigned 32-bit integer on all platforms.

    Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
    Reviewed-by: Daniel Stone <daniel@fooishbar.org>

Signed-off-by: Ran Benita <ran234@gmail.com>
When makekeys fails to find a good hash, print error instead of divide-by-zero

This matches commit 78a894231ae8ec4959007b6d9b8d2a15d6333a1e from
libX11:
    Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>

Signed-off-by: Ran Benita <ran234@gmail.com>
makekeys: Receive the keysym files as arguments

Signed-off-by: Ran Benita <ran234@gmail.com>
makekeys: update to match the rest of libX11 makekeys

This integrates two commits from libX11:

ebd6ef0a4db0ddef0ae17ad14571518ccdeea5ba
   XStringToKeysym: Special case for XF86 keysyms

    Some XFree86 keysyms were in XKeysymDB as XF86_foo, despite really being
    XF86foo.  So, if we get to the bottom of XStringToKeysym and haven't
    found our XF86_foo, try it again as XF86foo.

    Signed-off-by: Daniel Stone <daniel@fooishbar.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>

00175397480b76d32bf82b0c7c94c91a2a95954e
    makekeys: Scan vendor keysyms as well as core

    Since we can't really live without vendor keysyms, scan them all in to
    generate ks_tables.h, rather than only doing the core ones, and leaving
    the vendor syms to be manually synchronised with XKeysymDB.

    Signed-off-by: Daniel Stone <daniel@fooishbar.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>

Notice that the xkey.sh test is changed to match libX11 behavior, i.e.
XKeysymToString(0x1008FE20) -> "XF86Ungrab" as opposed to "XF86_Ungrab".

Signed-off-by: Ran Benita <ran234@gmail.com>
Use yacc-generated header instead of tokens.h

The yacc implementation can generate all the necessary token
definitions itself; there is no need to maintain a hand written
file for that.

Signed-off-by: Ran Benita <ran234@gmail.com>
Don't check for NULL before free()

Signed-off-by: Ran Benita <ran234@gmail.com>
Use strdup instead of strlen + malloc + strcpy

Signed-off-by: Ran Benita <ran234@gmail.com>
Remove all uses of the register keyword

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