Commit Graph

640 Commits (c705a82d60f72852baa9386644c4259eb45cb15b)

Author SHA1 Message Date
Daniel Stone 243daf80d0 Add test for xkb_map_new_from_string
Using data from xkb_map_get_as_string.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-29 15:08:35 +01:00
Daniel Stone ebd397e184 Add xkb_map_get_as_string
Returns a newly-allocated string representing the specified keymap.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-29 15:07:18 +01:00
Daniel Stone 208d957806 Fix signed vs. unsigned confusion in actions
Some actions could also take relative rather than absolute parameters,
so they really needed to be signed instead of explicitly unsigned.
Oops.

Fixes, e.g., action= MovePtr(x=-1,y=+1), which was reported as
(x=+65535,y=+1).

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
2012-05-25 18:02:19 +01:00
Ran Benita ccc047c4e0 compat: use darray for acts and key_acts in the server map
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 18:02:40 +03:00
Ran Benita 89c5e88603 keycodes: use darray in KeyNamesInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 15:45:42 +03:00
Ran Benita 07c88b551b symbols: use darray for xkb_sym_map
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 15:20:47 +03:00
Ran Benita 4daa34b5a3 keytypes: use darray for level names
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita ee990d53a5 symbols: use darray for KeyInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita dcdbd14925 parser: use darray for keysym list
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita c65a3596ae keytypes: use darray for xkb_kt_map_entry's
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita 374b0c9814 alloc: use darray in xkb_key_names
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:24 +03:00
Ran Benita c2ac3a2b20 keytypes: use darray for key types in the client map
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita 561504162f compat: use darray for sym_interprets
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita d0288bb288 context: use darray for include paths
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita ef51b572aa atom: use darray for the node_table
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita 0c271e093a rules: use darray for input line
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita 28bbb7dc51 rules: use darray for rules and groups
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita c815ff96d9 Import darray.h for common dynamic array code
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita cb047bb0fc Constify a static variable
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 14:19:23 +03:00
Ran Benita 9e72a6a7af Fix incorrect indexing while freeing
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-22 08:50:25 +03:00
Ran Benita 869c687190 rules: add test
Add a non-extensive test to check that some basic things (e.g. rule
matching, var substitution, indexes and groups) work as expected.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:49 +03:00
Ran Benita 68edd5f0df rules: allow wildcard match against "" layout/varaint
Currently, if you pass in an rmlvo with an empty string for layout or
variant, it would not match layout and variant rules even with
wildcards. But if the rules file had set an appropriate default, and someone
passes in the empty string, than he should get the default.

NULL in this case signifies not wanting to match against the layout or
variant at all, and so the rule should still fail to match NULLs.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:49 +03:00
Ran Benita c900c41760 rules: remove struct var_defs
We can just use struct xkb_rule_names which we already receive as an
argument.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:49 +03:00
Ran Benita 3d28b6d116 rules: reformat components_from_rules
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:49 +03:00
Ran Benita 7895eeb8ce rules: reformat LoadRules and XkbRF_Free
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:49 +03:00
Ran Benita d18cf31595 rules: remove unused struct describe_vars
It's not actually used for anything.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:49 +03:00
Ran Benita 56b125fcc7 rules: reformat AddRule and AddGroup
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:49 +03:00
Ran Benita f790257fa7 rules: reformat GetComponents
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:49 +03:00
Ran Benita 52939d4bea rules: reformat SubstituteVars
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita a9477b5754 rules: reformat CheckApplyRules and ApplyPartialMatches
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita a47dd25219 rules: reformat CheckGroup and CheckApplyRule
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita 18d331b86b rules: rewrite MatchOneOf
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita c02c9ab2f2 rules: reformat ApplyRule
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita 06205717c3 rules: reformat MakeMultiDefs
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita f7de62861f rules: use asprintf instead of _Concat function
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita 5f54764d0d rules: reformat CheckLine and break into several functions
And remove struct file_spec which is really unneeded. Should be
slightly more clear now.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita 2df35895b5 rules: reformat SetUpRemap and struct remap_spec
Rename to more descriptive names and reformat.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita b8ae68c2a3 rules: rewrite get_index to use sscanf
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita ef76ba97b3 rules: don't typedef the structs and rename them
The long prefix is unnecessary now that they are all private.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita 478a6a31d5 rules: reformat input line handling
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita 72d1f2edef rules: don't use custom logging functions
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita b73bd67615 rules: only export a single function
Really all we need from this file is a way to get xkb_component_names
from an xkb_rule_names, which is now the only thing being exposed. This
should allow for some much needed refactoring of this code.

Since this is only used by xkbcomp.c and uses xkbcomp functions, also
move rules.{c,h} under the xkbcomp dir.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita 0c25ebf341 rules: remove unused struct fields and use size_t
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:48 +03:00
Ran Benita beccc37509 Don't run the benchmark by default
For people running 'make check' on every compilation, this can be
a nuisance.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-20 20:31:19 +03:00
Ran Benita db3e8f2c08 Create path.h for the path.c functions
No need to stash them in xkbcomp-priv.h; files which need the functions
should explicitly include them.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-19 02:21:26 +03:00
Ran Benita b89b8e7023 Change xkb_map_new_from_fd to use FILE*
i.e. xkb_map_new_from_file. The reason is that flex only works with
FILE's, so we must use fdopen on the file descriptor; but to avoid a
memory leak, we must also fclose() it, which, in turn, closes the file
descriptor itself.

Either way is not acceptable, so we can either:
* dup() the fd and use fdopen on that, or
* have the user call fdopen on his own, and accept a FILE* instead of an
  fd.

The second one seems better, and is standard C, so why not. We must add
stdio.h to xkbcommon.h though, which is regrettable, but not a big deal.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-18 20:54:33 +03:00
Ran Benita d15fa57a4b Remove FileHandler callback argument
It's unneeded; the same function is always passed.

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-18 20:54:33 +03:00
Ran Benita e82bb5c043 Remove unused allowNone from KeyInfo
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-18 20:54:33 +03:00
Ran Benita 5200132f4d Revert "Fix KeyInfo's syms array size calculation"
This partly reverts commit 8feba630fa.

This seems to fix valgrind errors:
==9581== Invalid read of size 4
==9581==    at 0x4E50928: MergeKeyGroups (symbols.c:544)
==9581==    by 0x4E510F3: MergeKeys (symbols.c:644)
==9581==    by 0x4E514C6: AddKeySymbols (symbols.c:722)
==9581==    by 0x4E51A3F: MergeIncludedSymbols (symbols.c:854)
==9581==    by 0x4E51E97: HandleIncludeSymbols (symbols.c:952)
==9581==    by 0x4E53D75: HandleSymbolsFile (symbols.c:1619)
==9581==    by 0x4E55A0B: CompileSymbols (symbols.c:2187)
==9581==    by 0x4E4056C: CompileKeymap (keymap.c:160)
==9581==    by 0x4E56953: compile_keymap (xkbcomp.c:149)
==9581==    by 0x4E56AC5: xkb_map_new_from_kccgst (xkbcomp.c:195)
==9581==    by 0x4009D7: test_names (namescomp.c:56)
==9581==    by 0x400A55: main (namescomp.c:75)
==9581==  Address 0x5729b04 is 0 bytes after a block of size 4 alloc'd
==9581==    at 0x4C29024: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==9581==    by 0x4E5C37B: recalloc (utils.c:41)
==9581==    by 0x4E4FF50: ResizeKeyGroup (symbols.c:356)
==9581==    by 0x4E5229E: AddSymbolsToKey (symbols.c:1058)
==9581==    by 0x4E52ABB: SetSymbolsField (symbols.c:1214)
==9581==    by 0x4E536C7: HandleSymbolsBody (symbols.c:1481)
==9581==    by 0x4E53A63: HandleSymbolsDef (symbols.c:1543)
==9581==    by 0x4E53DAD: HandleSymbolsFile (symbols.c:1623)
==9581==    by 0x4E51CA4: HandleIncludeSymbols (symbols.c:909)
==9581==    by 0x4E53D75: HandleSymbolsFile (symbols.c:1619)
==9581==    by 0x4E51E74: HandleIncludeSymbols (symbols.c:951)
==9581==    by 0x4E53D75: HandleSymbolsFile (symbols.c:1619)

Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-18 20:54:33 +03:00
Ran Benita 75ff2cefda Various static analyzer fixes
Signed-off-by: Ran Benita <ran234@gmail.com>
2012-05-18 20:54:33 +03:00