diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/aclocal.m4 libxkbcommon-0.1.0~git20120530.c87468e9/aclocal.m4 --- libxkbcommon-0.1.0~git20120520.8ca8f05a/aclocal.m4 2012-05-20 08:51:21.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/aclocal.m4 2012-05-30 06:42:04.000000000 +0000 @@ -14,8 +14,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, -[m4_warning([this file was generated for autoconf 2.68. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, +[m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/ChangeLog libxkbcommon-0.1.0~git20120530.c87468e9/ChangeLog --- libxkbcommon-0.1.0~git20120520.8ca8f05a/ChangeLog 2012-05-20 08:51:24.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/ChangeLog 2012-05-30 06:42:06.000000000 +0000 @@ -1,9 +1,539 @@ -commit 997a1abab1168d20978e21fdf9f61d1884f4d545 +commit b6edf191c7481f9903b12d27cd3addd4227a4c39 Author: Rico Tzschichholz -Date: Sun May 20 10:51:13 2012 +0200 +Date: Wed May 30 08:41:46 2012 +0200 Add debian tree from origin/debian-experimental +commit c87468e926f75fef29e5f6c997d8baa28d8bc8a9 +Author: Daniel Stone +Date: Tue May 29 16:15:07 2012 +0100 + + stringcomp: NULL-terminate string + + Signed-off-by: Daniel Stone + +commit a3ae0e84e4bf86012d690e1a2cf94f398695dbf0 +Author: Daniel Stone +Date: Tue May 29 16:12:54 2012 +0100 + + Pass merge down through indicator creation + + To avoid using potentially undefined memory. + + Signed-off-by: Daniel Stone + +commit 243daf80d0deb2fe87757c094c7d84f52525bbd3 +Author: Daniel Stone +Date: Tue May 29 15:08:35 2012 +0100 + + Add test for xkb_map_new_from_string + + Using data from xkb_map_get_as_string. + + Signed-off-by: Daniel Stone + +commit ebd397e184a9f0b6127d37fed96e75ed32be8ae1 +Author: Daniel Stone +Date: Fri May 25 17:05:39 2012 +0100 + + Add xkb_map_get_as_string + + Returns a newly-allocated string representing the specified keymap. + + Signed-off-by: Daniel Stone + +commit 208d957806f5555809c1e511a587211d50c13b70 +Author: Daniel Stone +Date: Fri May 25 17:58:32 2012 +0100 + + 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 + +commit ccc047c4e08e6c7a229d5e9fdee91451e0b07ef2 +Author: Ran Benita +Date: Tue May 22 18:00:56 2012 +0300 + + compat: use darray for acts and key_acts in the server map + + Signed-off-by: Ran Benita + +commit 89c5e88603f3eaab733e53b6852ee881f3fc1460 +Author: Ran Benita +Date: Tue May 22 15:45:42 2012 +0300 + + keycodes: use darray in KeyNamesInfo + + Signed-off-by: Ran Benita + +commit 07c88b551bc1a0515252f3519dc4b2f239c86b96 +Author: Ran Benita +Date: Tue May 22 15:20:47 2012 +0300 + + symbols: use darray for xkb_sym_map + + Signed-off-by: Ran Benita + +commit 4daa34b5a30cb01f2e6755fa70be42dbc54b93f3 +Author: Ran Benita +Date: Tue May 22 14:18:48 2012 +0300 + + keytypes: use darray for level names + + Signed-off-by: Ran Benita + +commit ee990d53a579298ed4af6512c44f0365521af4eb +Author: Ran Benita +Date: Tue May 22 14:00:16 2012 +0300 + + symbols: use darray for KeyInfo + + Signed-off-by: Ran Benita + +commit dcdbd149258b0d85db7b58681a804488f242e8c8 +Author: Ran Benita +Date: Tue May 22 12:24:54 2012 +0300 + + parser: use darray for keysym list + + Signed-off-by: Ran Benita + +commit c65a3596aed46cf24c1df295c76a3984f90f4137 +Author: Ran Benita +Date: Tue May 22 10:59:46 2012 +0300 + + keytypes: use darray for xkb_kt_map_entry's + + Signed-off-by: Ran Benita + +commit 374b0c98142dfd4736a935ef0c6055bbf7d23a80 +Author: Ran Benita +Date: Tue May 22 08:39:09 2012 +0300 + + alloc: use darray in xkb_key_names + + Signed-off-by: Ran Benita + +commit c2ac3a2b20a3f762a0089b983f0b72032cf8d110 +Author: Ran Benita +Date: Tue May 22 08:07:52 2012 +0300 + + keytypes: use darray for key types in the client map + + Signed-off-by: Ran Benita + +commit 561504162fe84094f87e8389e1eb249fa31feb8e +Author: Ran Benita +Date: Tue May 22 00:52:28 2012 +0300 + + compat: use darray for sym_interprets + + Signed-off-by: Ran Benita + +commit d0288bb2882cb9c9a90c1366e9c3fa03c1d5b279 +Author: Ran Benita +Date: Tue May 22 00:37:53 2012 +0300 + + context: use darray for include paths + + Signed-off-by: Ran Benita + +commit ef51b572aabc785f6c056873c78e34c96f6fa9fb +Author: Ran Benita +Date: Tue May 22 00:26:58 2012 +0300 + + atom: use darray for the node_table + + Signed-off-by: Ran Benita + +commit 0c271e093a6ff6b68d24e94bf72b45fd06629ec1 +Author: Ran Benita +Date: Tue May 22 00:14:34 2012 +0300 + + rules: use darray for input line + + Signed-off-by: Ran Benita + +commit 28bbb7dc5102afd275388f96eea62fe51d78c641 +Author: Ran Benita +Date: Mon May 21 23:47:44 2012 +0300 + + rules: use darray for rules and groups + + Signed-off-by: Ran Benita + +commit c815ff96d97590085b7b542dcd12f20c1ccd3018 +Author: Ran Benita +Date: Mon May 21 23:33:56 2012 +0300 + + Import darray.h for common dynamic array code + + Signed-off-by: Ran Benita + +commit cb047bb0fcec699cd0d4a37e404a55be775f89e1 +Author: Ran Benita +Date: Tue May 22 12:32:06 2012 +0300 + + Constify a static variable + + Signed-off-by: Ran Benita + +commit 9e72a6a7af512bb0e0209172066893ed00099854 +Author: Ran Benita +Date: Tue May 22 08:04:59 2012 +0300 + + Fix incorrect indexing while freeing + + Signed-off-by: Ran Benita + +commit 869c6871906526bcef2c835e2072a1a71ad03c33 +Author: Ran Benita +Date: Sat May 19 02:35:15 2012 +0300 + + 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 + +commit 68edd5f0df85c0bce5368c9c7aa52be219e50011 +Author: Ran Benita +Date: Sat May 19 12:50:47 2012 +0300 + + 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 + +commit c900c41760c61438b7f0f64399fc198f4aef88d9 +Author: Ran Benita +Date: Sat May 19 01:00:52 2012 +0300 + + 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 + +commit 3d28b6d11673ddb97ffbe8f59b212d871d7f4b47 +Author: Ran Benita +Date: Sat May 19 00:53:57 2012 +0300 + + rules: reformat components_from_rules + + Signed-off-by: Ran Benita + +commit 7895eeb8ce4ebf5bf664530c6732f4c2fdf7abd7 +Author: Ran Benita +Date: Fri May 18 19:39:25 2012 +0300 + + rules: reformat LoadRules and XkbRF_Free + + Signed-off-by: Ran Benita + +commit d18cf315951de3e734facb38261bea643579dacd +Author: Ran Benita +Date: Fri May 18 19:37:01 2012 +0300 + + rules: remove unused struct describe_vars + + It's not actually used for anything. + + Signed-off-by: Ran Benita + +commit 56b125fcc7d2c91191453415efe60179feae08e8 +Author: Ran Benita +Date: Fri May 18 18:38:06 2012 +0300 + + rules: reformat AddRule and AddGroup + + Signed-off-by: Ran Benita + +commit f790257fa72753755d1acc74d5fed78293574f59 +Author: Ran Benita +Date: Fri May 18 18:34:47 2012 +0300 + + rules: reformat GetComponents + + Signed-off-by: Ran Benita + +commit 52939d4beac8387bf72126bfcf35020bdb7dcf9c +Author: Ran Benita +Date: Fri May 18 18:25:59 2012 +0300 + + rules: reformat SubstituteVars + + Signed-off-by: Ran Benita + +commit a9477b57543982cc89598cf2ba68ee7b0164bf01 +Author: Ran Benita +Date: Fri May 18 12:02:29 2012 +0300 + + rules: reformat CheckApplyRules and ApplyPartialMatches + + Signed-off-by: Ran Benita + +commit a47dd25219edb2eef741363b423c0cb5fada4d7c +Author: Ran Benita +Date: Fri May 18 10:43:24 2012 +0300 + + rules: reformat CheckGroup and CheckApplyRule + + Signed-off-by: Ran Benita + +commit 18d331b86b4942ba54fe087ca07e47c9383d768b +Author: Ran Benita +Date: Fri May 18 11:01:20 2012 +0300 + + rules: rewrite MatchOneOf + + Signed-off-by: Ran Benita + +commit c02c9ab2f29848480f668490b2675f82d0db1d4c +Author: Ran Benita +Date: Fri May 18 10:33:38 2012 +0300 + + rules: reformat ApplyRule + + Signed-off-by: Ran Benita + +commit 06205717c347e4d1130b102f5d226ac65cba3a10 +Author: Ran Benita +Date: Fri May 18 02:53:29 2012 +0300 + + rules: reformat MakeMultiDefs + + Signed-off-by: Ran Benita + +commit f7de62861fa44dcc00aa71e0c4c30557c78819c4 +Author: Ran Benita +Date: Fri May 18 02:20:14 2012 +0300 + + rules: use asprintf instead of _Concat function + + Signed-off-by: Ran Benita + +commit 5f54764d0d493e9aa3dc590c267ed8379d2adc12 +Author: Ran Benita +Date: Thu May 17 16:15:46 2012 +0300 + + 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 + +commit 2df35895b5204e2a06e39d2b551c8cb433195127 +Author: Ran Benita +Date: Thu May 17 14:18:31 2012 +0300 + + rules: reformat SetUpRemap and struct remap_spec + + Rename to more descriptive names and reformat. + + Signed-off-by: Ran Benita + +commit b8ae68c2a345934902abcce6ea15a46b39d3ff07 +Author: Ran Benita +Date: Thu May 17 13:55:38 2012 +0300 + + rules: rewrite get_index to use sscanf + + Signed-off-by: Ran Benita + +commit ef76ba97b3295d2fbfc483f15358cf2b9213ec0b +Author: Ran Benita +Date: Wed May 16 10:09:03 2012 +0300 + + 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 + +commit 478a6a31d5b54888fe160150c9e1a21f197ef820 +Author: Ran Benita +Date: Wed May 16 09:49:32 2012 +0300 + + rules: reformat input line handling + + Signed-off-by: Ran Benita + +commit 72d1f2edef1a378a4081cdf3e1274bf8ee19be4d +Author: Ran Benita +Date: Wed May 16 09:39:01 2012 +0300 + + rules: don't use custom logging functions + + Signed-off-by: Ran Benita + +commit b73bd676156fc36fe1859661348511bdd55610d8 +Author: Ran Benita +Date: Sun May 13 09:49:08 2012 +0300 + + 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 + +commit 0c25ebf341a2a63fc5e9c3ad5bd196e5b575e3d5 +Author: Ran Benita +Date: Fri May 11 10:04:26 2012 +0300 + + rules: remove unused struct fields and use size_t + + Signed-off-by: Ran Benita + +commit beccc375095c921b8c212b0f992ae88c87ca95ca +Author: Ran Benita +Date: Fri May 18 18:09:50 2012 +0300 + + 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 + +commit db3e8f2c0842aeaf1d00177c248ff908073fe73a +Author: Ran Benita +Date: Sun May 13 10:14:10 2012 +0300 + + 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 + +commit b89b8e70237f401aa39b963313324f60396bdda8 +Author: Ran Benita +Date: Sun May 13 23:31:59 2012 +0300 + + 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 + +commit d15fa57a4b1402a6a419ed34f0fc309f0a26df4f +Author: Ran Benita +Date: Sun May 13 17:21:02 2012 +0300 + + Remove FileHandler callback argument + + It's unneeded; the same function is always passed. + + Signed-off-by: Ran Benita + +commit e82bb5c04392869d8d49c8d1b5a9caba2ab29d37 +Author: Ran Benita +Date: Sun May 13 17:23:28 2012 +0300 + + Remove unused allowNone from KeyInfo + + Signed-off-by: Ran Benita + +commit 5200132f4d11e01e7d1e9ae6439f8c5ce8bd1e9e +Author: Ran Benita +Date: Sun May 13 23:13:10 2012 +0300 + + Revert "Fix KeyInfo's syms array size calculation" + + This partly reverts commit 8feba630fa7a4b720c42a9b5b4e4280b0e17a500. + + 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 + +commit 75ff2cefdaf03008dcbe5d721315851eb46dfabc +Author: Ran Benita +Date: Sun May 13 18:45:43 2012 +0300 + + Various static analyzer fixes + + Signed-off-by: Ran Benita + +commit b571b8345928056aaf172d01a9f8c0aa84e484cf +Author: Ran Benita +Date: Sun May 13 10:38:51 2012 +0300 + + Fix a memleak + + Introduced in 38cb639082ec4b31725d4ce4e35af63938691631. + + Signed-off-by: Ran Benita + +commit ab82e0ebc388dfc494bda3123517ac7608dde865 +Author: Ran Benita +Date: Thu May 10 01:02:29 2012 +0300 + + Fix configure check for xkbparse.c instead of parser.c + + This obscure test is easy to miss. + + Signed-off-by: Ran Benita + commit 8ca8f05aab86423c2495cd917489becfecca4632 Author: Pekka Paalanen Date: Tue May 15 15:23:42 2012 +0300 diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/configure libxkbcommon-0.1.0~git20120530.c87468e9/configure --- libxkbcommon-0.1.0~git20120520.8ca8f05a/configure 2012-05-20 08:51:22.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/configure 2012-05-30 06:42:05.000000000 +0000 @@ -1,13 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.68 for libxkbcommon 0.1.0. +# Generated by GNU Autoconf 2.69 for libxkbcommon 0.1.0. # # Report bugs to . # # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software -# Foundation, Inc. +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -136,6 +134,31 @@ # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -169,7 +192,8 @@ else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -222,21 +246,25 @@ if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - # Preserve -v and -x to the replacement shell. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - case $- in # (((( - *v*x* | *x*v* ) as_opts=-vx ;; - *v* ) as_opts=-v ;; - *x* ) as_opts=-x ;; - * ) as_opts= ;; - esac - exec "$CONFIG_SHELL" $as_opts "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -340,6 +368,14 @@ } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -461,6 +497,10 @@ chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -495,16 +535,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -516,28 +556,8 @@ as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -1260,8 +1280,6 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1551,9 +1569,9 @@ if $ac_init_version; then cat <<\_ACEOF libxkbcommon configure 0.1.0 -generated by GNU Autoconf 2.68 +generated by GNU Autoconf 2.69 -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1830,7 +1848,7 @@ test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1966,7 +1984,7 @@ running configure, to aid debugging if configure makes a mistake. It was created by libxkbcommon $as_me 0.1.0, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2387,7 +2405,7 @@ # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -2556,7 +2574,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2596,7 +2614,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2647,7 +2665,7 @@ test -z "$as_dir" && as_dir=. for ac_prog in mkdir gmkdir; do for ac_exec_ext in '' $ac_executable_extensions; do - { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue + as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #( 'mkdir (GNU coreutils) '* | \ 'mkdir (coreutils) '* | \ @@ -2700,7 +2718,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2936,7 +2954,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2976,7 +2994,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3029,7 +3047,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3070,7 +3088,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3128,7 +3146,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3172,7 +3190,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3618,8 +3636,7 @@ /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3987,7 +4004,7 @@ for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -4053,7 +4070,7 @@ for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -4260,8 +4277,8 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -4480,7 +4497,7 @@ for ac_prog in sed gsed; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_SED="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue + as_fn_executable_p "$ac_path_SED" || continue # Check for GNU ac_path_SED and select it if it is found. # Check for GNU $ac_path_SED case `"$ac_path_SED" --version 2>&1` in @@ -4559,7 +4576,7 @@ for ac_prog in fgrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue + as_fn_executable_p "$ac_path_FGREP" || continue # Check for GNU ac_path_FGREP and select it if it is found. # Check for GNU $ac_path_FGREP case `"$ac_path_FGREP" --version 2>&1` in @@ -4815,7 +4832,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -4859,7 +4876,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DUMPBIN="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5283,7 +5300,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5323,7 +5340,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OBJDUMP="objdump" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5629,7 +5646,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5669,7 +5686,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DLLTOOL="dlltool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5772,7 +5789,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AR="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5816,7 +5833,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_AR="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5941,7 +5958,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -5981,7 +5998,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6040,7 +6057,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6080,7 +6097,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_RANLIB="ranlib" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6729,7 +6746,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6769,7 +6786,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_MANIFEST_TOOL="mt" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6849,7 +6866,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6889,7 +6906,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_DSYMUTIL="dsymutil" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6941,7 +6958,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -6981,7 +6998,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_NMEDIT="nmedit" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7033,7 +7050,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LIPO="${ac_tool_prefix}lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7073,7 +7090,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_LIPO="lipo" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7125,7 +7142,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL="${ac_tool_prefix}otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7165,7 +7182,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL="otool" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7217,7 +7234,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -7257,7 +7274,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_OTOOL64="otool64" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -11652,7 +11669,7 @@ return 0; } _ACEOF -for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99 +for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -D_STDC_C99= -qlanglvl=extc99 do CC="$ac_save_CC $ac_arg" if ac_fn_c_try_compile "$LINENO"; then : @@ -11736,7 +11753,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -11779,7 +11796,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -12288,7 +12305,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Wformat=2" >&5 $as_echo_n "checking if $CC supports-Wformat=2... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Wformat=2" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Wformat_2 if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14007,7 +14024,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=implicit" >&5 $as_echo_n "checking if $CC supports-Werror=implicit... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=implicit" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_implicit if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14056,7 +14073,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED" >&5 $as_echo_n "checking if $CC supports-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-errwarn=E_NO_EXPLICIT_TYPE_GIVEN -errwarn=E_NO_IMPLICIT_DECL_ALLOWED" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__errwarn_E_NO_EXPLICIT_TYPE_GIVEN__errwarn_E_NO_IMPLICIT_DECL_ALLOWED if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14174,7 +14191,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=nonnull" >&5 $as_echo_n "checking if $CC supports-Werror=nonnull... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=nonnull" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_nonnull if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14292,7 +14309,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=init-self" >&5 $as_echo_n "checking if $CC supports-Werror=init-self... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=init-self" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_init_self if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14410,7 +14427,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=main" >&5 $as_echo_n "checking if $CC supports-Werror=main... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=main" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_main if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14528,7 +14545,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=missing-braces" >&5 $as_echo_n "checking if $CC supports-Werror=missing-braces... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=missing-braces" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_missing_braces if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14646,7 +14663,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=sequence-point" >&5 $as_echo_n "checking if $CC supports-Werror=sequence-point... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=sequence-point" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_sequence_point if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14764,7 +14781,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=return-type" >&5 $as_echo_n "checking if $CC supports-Werror=return-type... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=return-type" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_return_type if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14813,7 +14830,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-errwarn=E_FUNC_HAS_NO_RETURN_STMT" >&5 $as_echo_n "checking if $CC supports-errwarn=E_FUNC_HAS_NO_RETURN_STMT... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-errwarn=E_FUNC_HAS_NO_RETURN_STMT" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__errwarn_E_FUNC_HAS_NO_RETURN_STMT if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -14931,7 +14948,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=trigraphs" >&5 $as_echo_n "checking if $CC supports-Werror=trigraphs... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=trigraphs" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_trigraphs if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -15049,7 +15066,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=array-bounds" >&5 $as_echo_n "checking if $CC supports-Werror=array-bounds... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=array-bounds" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_array_bounds if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -15167,7 +15184,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=write-strings" >&5 $as_echo_n "checking if $CC supports-Werror=write-strings... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=write-strings" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_write_strings if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -15285,7 +15302,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=address" >&5 $as_echo_n "checking if $CC supports-Werror=address... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=address" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_address if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -15403,7 +15420,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=int-to-pointer-cast" >&5 $as_echo_n "checking if $CC supports-Werror=int-to-pointer-cast... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=int-to-pointer-cast" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_int_to_pointer_cast if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -15452,7 +15469,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-errwarn=E_BAD_PTR_INT_COMBINATION" >&5 $as_echo_n "checking if $CC supports-errwarn=E_BAD_PTR_INT_COMBINATION... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-errwarn=E_BAD_PTR_INT_COMBINATION" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__errwarn_E_BAD_PTR_INT_COMBINATION if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -15570,7 +15587,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=pointer-to-int-cast" >&5 $as_echo_n "checking if $CC supports-Werror=pointer-to-int-cast... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=pointer-to-int-cast" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_pointer_to_int_cast if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -17546,7 +17563,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC supports-Werror=attributes" >&5 $as_echo_n "checking if $CC supports-Werror=attributes... " >&6; } - cacheid=`$as_echo "xorg_cv_cc_flag_-Werror=attributes" | $as_tr_sh` + cacheid=xorg_cv_cc_flag__Werror_attributes if eval \${$cacheid+:} false; then : $as_echo_n "(cached) " >&6 else @@ -17826,6 +17843,104 @@ +# Check for compiler features +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 +$as_echo_n "checking for inline... " >&6; } +if ${ac_cv_c_inline+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_inline=no +for ac_kw in inline __inline__ __inline; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __cplusplus +typedef int foo_t; +static $ac_kw foo_t static_foo () {return 0; } +$ac_kw foo_t foo () {return 0; } +#endif + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_inline=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_inline" != no && break +done + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 +$as_echo "$ac_cv_c_inline" >&6; } + +case $ac_cv_c_inline in + inline | yes) ;; + *) + case $ac_cv_c_inline in + no) ac_val=;; + *) ac_val=$ac_cv_c_inline;; + esac + cat >>confdefs.h <<_ACEOF +#ifndef __cplusplus +#define inline $ac_val +#endif +_ACEOF + ;; +esac + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for typeof syntax and keyword spelling" >&5 +$as_echo_n "checking for typeof syntax and keyword spelling... " >&6; } +if ${ac_cv_c_typeof+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_typeof=no + for ac_kw in typeof __typeof__ no; do + test $ac_kw = no && break + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + int value; + typedef struct { + char a [1 + + ! (($ac_kw (value)) + (($ac_kw (value)) 0 < ($ac_kw (value)) -1 + ? ($ac_kw (value)) - 1 + : ~ (~ ($ac_kw (value)) 0 + << sizeof ($ac_kw (value)))))]; } + ac__typeof_type_; + return + (! ((void) ((ac__typeof_type_ *) 0), 0)); + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_typeof=$ac_kw +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test $ac_cv_c_typeof != no && break + done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_typeof" >&5 +$as_echo "$ac_cv_c_typeof" >&6; } + if test $ac_cv_c_typeof != no; then + +$as_echo "#define HAVE_TYPEOF 1" >>confdefs.h + + if test $ac_cv_c_typeof != typeof; then + +cat >>confdefs.h <<_ACEOF +#define typeof $ac_cv_c_typeof +_ACEOF + + fi + fi + + # Check for programs for ac_prog in flex lex do @@ -17845,7 +17960,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_LEX="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -17877,7 +17992,8 @@ b { REJECT; } c { yymore (); } d { yyless (1); } -e { yyless (input () != 0); } +e { /* IRIX 6.5 flex 2.5.4 underquotes its yyless argument. */ + yyless ((input () != 0)); } f { unput (yytext[0]); } . { BEGIN INITIAL; } %% @@ -18003,7 +18119,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_YACC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -18046,7 +18162,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_YACC_INST="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -18068,9 +18184,9 @@ fi -if test ! -f "src/xkbcomp/xkbparse.c"; then +if test ! -f "src/xkbcomp/parser.c"; then if test -z "$YACC_INST"; then - as_fn_error $? "yacc not found - unable to compile src/xkbcomp/xkbparse.y" "$LINENO" 5 + as_fn_error $? "yacc not found - unable to compile src/xkbcomp/parser.y" "$LINENO" 5 fi fi @@ -18129,7 +18245,7 @@ IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_path_CC_FOR_BUILD="$as_dir/$ac_word$ac_exec_ext" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -18729,16 +18845,16 @@ # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -18798,28 +18914,16 @@ as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -18841,7 +18945,7 @@ # values after options handling. ac_log=" This file was extended by libxkbcommon $as_me 0.1.0, which was -generated by GNU Autoconf 2.68. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -18907,10 +19011,10 @@ ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ libxkbcommon config.status 0.1.0 -configured by $0, generated by GNU Autoconf 2.68, +configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" -Copyright (C) 2010 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -19001,7 +19105,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/configure.ac libxkbcommon-0.1.0~git20120530.c87468e9/configure.ac --- libxkbcommon-0.1.0~git20120520.8ca8f05a/configure.ac 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/configure.ac 2012-05-30 06:41:46.000000000 +0000 @@ -45,13 +45,17 @@ XORG_DEFAULT_OPTIONS XORG_CHECK_MALLOC_ZERO +# Check for compiler features +AC_C_INLINE +AC_C_TYPEOF + # Check for programs AC_PROG_LEX AC_PROG_YACC AC_PATH_PROG([YACC_INST], $YACC) -if test ! -f "src/xkbcomp/xkbparse.c"; then +if test ! -f "src/xkbcomp/parser.c"; then if test -z "$YACC_INST"; then - AC_MSG_ERROR([yacc not found - unable to compile src/xkbcomp/xkbparse.y]) + AC_MSG_ERROR([yacc not found - unable to compile src/xkbcomp/parser.y]) fi fi diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/debian/changelog libxkbcommon-0.1.0~git20120530.c87468e9/debian/changelog --- libxkbcommon-0.1.0~git20120520.8ca8f05a/debian/changelog 2012-05-30 07:47:26.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/debian/changelog 2012-05-30 07:47:26.000000000 +0000 @@ -1,12 +1,12 @@ -libxkbcommon (0.1.0~git20120520.8ca8f05a-0ubuntu0ricotz~precise) precise; urgency=medium +libxkbcommon (0.1.0~git20120530.c87468e9-0ubuntu0ricotz~precise) precise; urgency=medium - * Checkout from git 20120520 (master branch) up to commit - 8ca8f05aab86423c2495cd917489becfecca4632 + * Checkout from git 20120530 (master branch) up to commit + c87468e926f75fef29e5f6c997d8baa28d8bc8a9 * Only added debian/ tree from origin/debian-experimental * hook: Adjust install path for headers in libxkbcommon-dev * hook: Drop hard dependency generation - -- Rico Tzschichholz Sun, 20 May 2012 10:51:25 +0200 + -- Rico Tzschichholz Wed, 30 May 2012 08:42:07 +0200 libxkbcommon (0.1.0~1-1) experimental; urgency=low diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/include/xkbcommon/xkbcommon.h libxkbcommon-0.1.0~git20120530.c87468e9/include/xkbcommon/xkbcommon.h --- libxkbcommon-0.1.0~git20120520.8ca8f05a/include/xkbcommon/xkbcommon.h 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/include/xkbcommon/xkbcommon.h 2012-05-30 06:41:46.000000000 +0000 @@ -82,6 +82,7 @@ #include #include +#include #include #include @@ -260,11 +261,11 @@ /** * Creates an XKB keymap from a full text XKB keymap passed into the - * file descriptor. + * file. */ struct xkb_keymap * -xkb_map_new_from_fd(struct xkb_context *context, - int fd, enum xkb_keymap_format format, +xkb_map_new_from_file(struct xkb_context *context, + FILE *file, enum xkb_keymap_format format, enum xkb_map_compile_flags flags); /** @@ -278,6 +279,13 @@ enum xkb_map_compile_flags flags); /** + * Returns the compiled XKB map as a string which can later be fed back into + * xkb_map_new_from_string to return the exact same keymap. + */ +char * +xkb_map_get_as_string(struct xkb_keymap *keymap); + +/** * Takes a new reference on a keymap. */ struct xkb_keymap * diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/.lastcommit libxkbcommon-0.1.0~git20120530.c87468e9/.lastcommit --- libxkbcommon-0.1.0~git20120520.8ca8f05a/.lastcommit 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/.lastcommit 2012-05-30 06:41:46.000000000 +0000 @@ -1 +1 @@ -commit 8ca8f05aab86423c2495cd917489becfecca4632 +commit c87468e926f75fef29e5f6c997d8baa28d8bc8a9 diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/Makefile.am libxkbcommon-0.1.0~git20120530.c87468e9/Makefile.am --- libxkbcommon-0.1.0~git20120520.8ca8f05a/Makefile.am 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/Makefile.am 2012-05-30 06:41:46.000000000 +0000 @@ -58,6 +58,9 @@ src/xkbcomp/parseutils.c \ src/xkbcomp/parseutils.h \ src/xkbcomp/path.c \ + src/xkbcomp/path.h \ + src/xkbcomp/rules.c \ + src/xkbcomp/rules.h \ src/xkbcomp/scanner.l \ src/xkbcomp/symbols.c \ src/xkbcomp/vmod.c \ @@ -70,11 +73,11 @@ src/atom.c \ src/atom.h \ src/context.c \ + src/darray.h \ + src/keymap-dump.c \ src/keysym.c \ src/map.c \ src/misc.c \ - src/rules.c \ - src/rules.h \ src/state.c \ src/text.c \ src/text.h \ @@ -98,6 +101,12 @@ # Tests +# Some tests need to use unexported symbols, so we link them against +# a private copy of libxkbcommon with all symbols exposed. +noinst_LTLIBRARIES = libxkbcommon-priv.la +libxkbcommon_priv_la_LDFLAGS = $(libxkbcommon_la_LDFLAGS) +libxkbcommon_priv_la_SOURCES = $(libxkbcommon_la_SOURCES) + TESTS_ENVIRONMENT = TESTS = \ @@ -107,8 +116,11 @@ test/rulescomp \ test/canonicalise \ test/state \ - test/context -TESTS_LDADD = libxkbcommon.la + test/context \ + test/rules-file \ + test/dump \ + test/stringcomp +TESTS_LDADD = libxkbcommon-priv.la test_xkey_LDADD = $(TESTS_LDADD) test_filecomp_LDADD = $(TESTS_LDADD) @@ -117,6 +129,10 @@ test_canonicalise_LDADD = $(TESTS_LDADD) test_state_LDADD = $(TESTS_LDADD) test_context_LDADD = $(TESTS_LDADD) +test_rules_file_CFLAGS = $(AM_CFLAGS) -Wno-declaration-after-statement +test_rules_file_LDADD = $(TESTS_LDADD) +test_dump_LDADD = $(TESTS_LDADD) +test_stringcomp_LDADD = $(TESTS_LDADD) check_PROGRAMS = $(TESTS) diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/Makefile.in libxkbcommon-0.1.0~git20120530.c87468e9/Makefile.in --- libxkbcommon-0.1.0~git20120520.8ca8f05a/Makefile.in 2012-05-20 08:51:24.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/Makefile.in 2012-05-30 06:42:06.000000000 +0000 @@ -56,7 +56,8 @@ TESTS = test/xkey$(EXEEXT) test/filecomp$(EXEEXT) \ test/namescomp$(EXEEXT) test/rulescomp$(EXEEXT) \ test/canonicalise$(EXEEXT) test/state$(EXEEXT) \ - test/context$(EXEEXT) + test/context$(EXEEXT) test/rules-file$(EXEEXT) \ + test/dump$(EXEEXT) test/stringcomp$(EXEEXT) check_PROGRAMS = $(am__EXEEXT_1) subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ @@ -108,24 +109,42 @@ } am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgconfigdir)" \ "$(DESTDIR)$(xkbcommonincludedir)" -LTLIBRARIES = $(lib_LTLIBRARIES) -libxkbcommon_la_LIBADD = +LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES) +libxkbcommon_priv_la_LIBADD = am__dirstamp = $(am__leading_dot)dirstamp -am_libxkbcommon_la_OBJECTS = src/xkbcomp/action.lo \ - src/xkbcomp/alias.lo src/xkbcomp/compat.lo src/xkbcomp/expr.lo \ +am__objects_1 = src/xkbcomp/action.lo src/xkbcomp/alias.lo \ + src/xkbcomp/compat.lo src/xkbcomp/expr.lo \ src/xkbcomp/indicators.lo src/xkbcomp/keycodes.lo \ src/xkbcomp/keymap.lo src/xkbcomp/keytypes.lo \ src/xkbcomp/misc.lo src/xkbcomp/parser.lo \ src/xkbcomp/parseutils.lo src/xkbcomp/path.lo \ - src/xkbcomp/scanner.lo src/xkbcomp/symbols.lo \ - src/xkbcomp/vmod.lo src/xkbcomp/xkbcomp.lo src/alloc.lo \ - src/atom.lo src/context.lo src/keysym.lo src/map.lo \ - src/misc.lo src/rules.lo src/state.lo src/text.lo src/utils.lo \ - src/xkb.lo -libxkbcommon_la_OBJECTS = $(am_libxkbcommon_la_OBJECTS) + src/xkbcomp/rules.lo src/xkbcomp/scanner.lo \ + src/xkbcomp/symbols.lo src/xkbcomp/vmod.lo \ + src/xkbcomp/xkbcomp.lo src/alloc.lo src/atom.lo src/context.lo \ + src/keymap-dump.lo src/keysym.lo src/map.lo src/misc.lo \ + src/state.lo src/text.lo src/utils.lo src/xkb.lo +am_libxkbcommon_priv_la_OBJECTS = $(am__objects_1) +libxkbcommon_priv_la_OBJECTS = $(am_libxkbcommon_priv_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) am__v_lt_0 = --silent +libxkbcommon_priv_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(libxkbcommon_priv_la_LDFLAGS) \ + $(LDFLAGS) -o $@ +libxkbcommon_la_LIBADD = +am_libxkbcommon_la_OBJECTS = src/xkbcomp/action.lo \ + src/xkbcomp/alias.lo src/xkbcomp/compat.lo src/xkbcomp/expr.lo \ + src/xkbcomp/indicators.lo src/xkbcomp/keycodes.lo \ + src/xkbcomp/keymap.lo src/xkbcomp/keytypes.lo \ + src/xkbcomp/misc.lo src/xkbcomp/parser.lo \ + src/xkbcomp/parseutils.lo src/xkbcomp/path.lo \ + src/xkbcomp/rules.lo src/xkbcomp/scanner.lo \ + src/xkbcomp/symbols.lo src/xkbcomp/vmod.lo \ + src/xkbcomp/xkbcomp.lo src/alloc.lo src/atom.lo src/context.lo \ + src/keymap-dump.lo src/keysym.lo src/map.lo src/misc.lo \ + src/state.lo src/text.lo src/utils.lo src/xkb.lo +libxkbcommon_la_OBJECTS = $(am_libxkbcommon_la_OBJECTS) libxkbcommon_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(libxkbcommon_la_LDFLAGS) $(LDFLAGS) \ @@ -133,25 +152,39 @@ am__EXEEXT_1 = test/xkey$(EXEEXT) test/filecomp$(EXEEXT) \ test/namescomp$(EXEEXT) test/rulescomp$(EXEEXT) \ test/canonicalise$(EXEEXT) test/state$(EXEEXT) \ - test/context$(EXEEXT) + test/context$(EXEEXT) test/rules-file$(EXEEXT) \ + test/dump$(EXEEXT) test/stringcomp$(EXEEXT) test_canonicalise_SOURCES = test/canonicalise.c test_canonicalise_OBJECTS = test/canonicalise.$(OBJEXT) test_canonicalise_DEPENDENCIES = $(TESTS_LDADD) test_context_SOURCES = test/context.c test_context_OBJECTS = test/context.$(OBJEXT) test_context_DEPENDENCIES = $(TESTS_LDADD) +test_dump_SOURCES = test/dump.c +test_dump_OBJECTS = test/dump.$(OBJEXT) +test_dump_DEPENDENCIES = $(TESTS_LDADD) test_filecomp_SOURCES = test/filecomp.c test_filecomp_OBJECTS = test/filecomp.$(OBJEXT) test_filecomp_DEPENDENCIES = $(TESTS_LDADD) test_namescomp_SOURCES = test/namescomp.c test_namescomp_OBJECTS = test/namescomp.$(OBJEXT) test_namescomp_DEPENDENCIES = $(TESTS_LDADD) +test_rules_file_SOURCES = test/rules-file.c +test_rules_file_OBJECTS = test/test_rules_file-rules-file.$(OBJEXT) +test_rules_file_DEPENDENCIES = $(TESTS_LDADD) +test_rules_file_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(test_rules_file_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \ + -o $@ test_rulescomp_SOURCES = test/rulescomp.c test_rulescomp_OBJECTS = test/rulescomp.$(OBJEXT) test_rulescomp_DEPENDENCIES = $(TESTS_LDADD) test_state_SOURCES = test/state.c test_state_OBJECTS = test/state.$(OBJEXT) test_state_DEPENDENCIES = $(TESTS_LDADD) +test_stringcomp_SOURCES = test/stringcomp.c +test_stringcomp_OBJECTS = test/stringcomp.$(OBJEXT) +test_stringcomp_DEPENDENCIES = $(TESTS_LDADD) test_xkey_SOURCES = test/xkey.c test_xkey_OBJECTS = test/xkey.$(OBJEXT) test_xkey_DEPENDENCIES = $(TESTS_LDADD) @@ -196,12 +229,14 @@ AM_V_GEN = $(am__v_GEN_@AM_V@) am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) am__v_GEN_0 = @echo " GEN " $@; -SOURCES = $(libxkbcommon_la_SOURCES) test/canonicalise.c \ - test/context.c test/filecomp.c test/namescomp.c \ - test/rulescomp.c test/state.c test/xkey.c -DIST_SOURCES = $(libxkbcommon_la_SOURCES) test/canonicalise.c \ - test/context.c test/filecomp.c test/namescomp.c \ - test/rulescomp.c test/state.c test/xkey.c +SOURCES = $(libxkbcommon_priv_la_SOURCES) $(libxkbcommon_la_SOURCES) \ + test/canonicalise.c test/context.c test/dump.c test/filecomp.c \ + test/namescomp.c test/rules-file.c test/rulescomp.c \ + test/state.c test/stringcomp.c test/xkey.c +DIST_SOURCES = $(libxkbcommon_priv_la_SOURCES) \ + $(libxkbcommon_la_SOURCES) test/canonicalise.c test/context.c \ + test/dump.c test/filecomp.c test/namescomp.c test/rules-file.c \ + test/rulescomp.c test/state.c test/stringcomp.c test/xkey.c RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ html-recursive info-recursive install-data-recursive \ install-dvi-recursive install-exec-recursive \ @@ -561,6 +596,9 @@ src/xkbcomp/parseutils.c \ src/xkbcomp/parseutils.h \ src/xkbcomp/path.c \ + src/xkbcomp/path.h \ + src/xkbcomp/rules.c \ + src/xkbcomp/rules.h \ src/xkbcomp/scanner.l \ src/xkbcomp/symbols.c \ src/xkbcomp/vmod.c \ @@ -573,11 +611,11 @@ src/atom.c \ src/atom.h \ src/context.c \ + src/darray.h \ + src/keymap-dump.c \ src/keysym.c \ src/map.c \ src/misc.c \ - src/rules.c \ - src/rules.h \ src/state.c \ src/text.c \ src/text.h \ @@ -595,8 +633,14 @@ CLEANFILES = $(BUILT_SOURCES) # Tests + +# Some tests need to use unexported symbols, so we link them against +# a private copy of libxkbcommon with all symbols exposed. +noinst_LTLIBRARIES = libxkbcommon-priv.la +libxkbcommon_priv_la_LDFLAGS = $(libxkbcommon_la_LDFLAGS) +libxkbcommon_priv_la_SOURCES = $(libxkbcommon_la_SOURCES) TESTS_ENVIRONMENT = -TESTS_LDADD = libxkbcommon.la +TESTS_LDADD = libxkbcommon-priv.la test_xkey_LDADD = $(TESTS_LDADD) test_filecomp_LDADD = $(TESTS_LDADD) test_namescomp_LDADD = $(TESTS_LDADD) @@ -604,6 +648,10 @@ test_canonicalise_LDADD = $(TESTS_LDADD) test_state_LDADD = $(TESTS_LDADD) test_context_LDADD = $(TESTS_LDADD) +test_rules_file_CFLAGS = $(AM_CFLAGS) -Wno-declaration-after-statement +test_rules_file_LDADD = $(TESTS_LDADD) +test_dump_LDADD = $(TESTS_LDADD) +test_stringcomp_LDADD = $(TESTS_LDADD) EXTRA_DIST = test/data all: $(BUILT_SOURCES) $(MAKE) $(AM_MAKEFLAGS) all-recursive @@ -695,6 +743,15 @@ echo "rm -f \"$${dir}/so_locations\""; \ rm -f "$${dir}/so_locations"; \ done + +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done src/xkbcomp/$(am__dirstamp): @$(MKDIR_P) src/xkbcomp @: > src/xkbcomp/$(am__dirstamp) @@ -728,6 +785,8 @@ src/xkbcomp/$(DEPDIR)/$(am__dirstamp) src/xkbcomp/path.lo: src/xkbcomp/$(am__dirstamp) \ src/xkbcomp/$(DEPDIR)/$(am__dirstamp) +src/xkbcomp/rules.lo: src/xkbcomp/$(am__dirstamp) \ + src/xkbcomp/$(DEPDIR)/$(am__dirstamp) src/xkbcomp/scanner.lo: src/xkbcomp/$(am__dirstamp) \ src/xkbcomp/$(DEPDIR)/$(am__dirstamp) src/xkbcomp/symbols.lo: src/xkbcomp/$(am__dirstamp) \ @@ -745,14 +804,16 @@ src/alloc.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/atom.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/context.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +src/keymap-dump.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/keysym.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/map.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/misc.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) -src/rules.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/state.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/text.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/utils.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) src/xkb.lo: src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp) +libxkbcommon-priv.la: $(libxkbcommon_priv_la_OBJECTS) $(libxkbcommon_priv_la_DEPENDENCIES) $(EXTRA_libxkbcommon_priv_la_DEPENDENCIES) + $(AM_V_CCLD)$(libxkbcommon_priv_la_LINK) $(libxkbcommon_priv_la_OBJECTS) $(libxkbcommon_priv_la_LIBADD) $(LIBS) libxkbcommon.la: $(libxkbcommon_la_OBJECTS) $(libxkbcommon_la_DEPENDENCIES) $(EXTRA_libxkbcommon_la_DEPENDENCIES) $(AM_V_CCLD)$(libxkbcommon_la_LINK) -rpath $(libdir) $(libxkbcommon_la_OBJECTS) $(libxkbcommon_la_LIBADD) $(LIBS) @@ -780,6 +841,11 @@ test/context$(EXEEXT): $(test_context_OBJECTS) $(test_context_DEPENDENCIES) $(EXTRA_test_context_DEPENDENCIES) test/$(am__dirstamp) @rm -f test/context$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_context_OBJECTS) $(test_context_LDADD) $(LIBS) +test/dump.$(OBJEXT): test/$(am__dirstamp) \ + test/$(DEPDIR)/$(am__dirstamp) +test/dump$(EXEEXT): $(test_dump_OBJECTS) $(test_dump_DEPENDENCIES) $(EXTRA_test_dump_DEPENDENCIES) test/$(am__dirstamp) + @rm -f test/dump$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_dump_OBJECTS) $(test_dump_LDADD) $(LIBS) test/filecomp.$(OBJEXT): test/$(am__dirstamp) \ test/$(DEPDIR)/$(am__dirstamp) test/filecomp$(EXEEXT): $(test_filecomp_OBJECTS) $(test_filecomp_DEPENDENCIES) $(EXTRA_test_filecomp_DEPENDENCIES) test/$(am__dirstamp) @@ -790,6 +856,11 @@ test/namescomp$(EXEEXT): $(test_namescomp_OBJECTS) $(test_namescomp_DEPENDENCIES) $(EXTRA_test_namescomp_DEPENDENCIES) test/$(am__dirstamp) @rm -f test/namescomp$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_namescomp_OBJECTS) $(test_namescomp_LDADD) $(LIBS) +test/test_rules_file-rules-file.$(OBJEXT): test/$(am__dirstamp) \ + test/$(DEPDIR)/$(am__dirstamp) +test/rules-file$(EXEEXT): $(test_rules_file_OBJECTS) $(test_rules_file_DEPENDENCIES) $(EXTRA_test_rules_file_DEPENDENCIES) test/$(am__dirstamp) + @rm -f test/rules-file$(EXEEXT) + $(AM_V_CCLD)$(test_rules_file_LINK) $(test_rules_file_OBJECTS) $(test_rules_file_LDADD) $(LIBS) test/rulescomp.$(OBJEXT): test/$(am__dirstamp) \ test/$(DEPDIR)/$(am__dirstamp) test/rulescomp$(EXEEXT): $(test_rulescomp_OBJECTS) $(test_rulescomp_DEPENDENCIES) $(EXTRA_test_rulescomp_DEPENDENCIES) test/$(am__dirstamp) @@ -800,6 +871,11 @@ test/state$(EXEEXT): $(test_state_OBJECTS) $(test_state_DEPENDENCIES) $(EXTRA_test_state_DEPENDENCIES) test/$(am__dirstamp) @rm -f test/state$(EXEEXT) $(AM_V_CCLD)$(LINK) $(test_state_OBJECTS) $(test_state_LDADD) $(LIBS) +test/stringcomp.$(OBJEXT): test/$(am__dirstamp) \ + test/$(DEPDIR)/$(am__dirstamp) +test/stringcomp$(EXEEXT): $(test_stringcomp_OBJECTS) $(test_stringcomp_DEPENDENCIES) $(EXTRA_test_stringcomp_DEPENDENCIES) test/$(am__dirstamp) + @rm -f test/stringcomp$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(test_stringcomp_OBJECTS) $(test_stringcomp_LDADD) $(LIBS) test/xkey.$(OBJEXT): test/$(am__dirstamp) \ test/$(DEPDIR)/$(am__dirstamp) test/xkey$(EXEEXT): $(test_xkey_OBJECTS) $(test_xkey_DEPENDENCIES) $(EXTRA_test_xkey_DEPENDENCIES) test/$(am__dirstamp) @@ -814,14 +890,14 @@ -rm -f src/atom.lo -rm -f src/context.$(OBJEXT) -rm -f src/context.lo + -rm -f src/keymap-dump.$(OBJEXT) + -rm -f src/keymap-dump.lo -rm -f src/keysym.$(OBJEXT) -rm -f src/keysym.lo -rm -f src/map.$(OBJEXT) -rm -f src/map.lo -rm -f src/misc.$(OBJEXT) -rm -f src/misc.lo - -rm -f src/rules.$(OBJEXT) - -rm -f src/rules.lo -rm -f src/state.$(OBJEXT) -rm -f src/state.lo -rm -f src/text.$(OBJEXT) @@ -854,6 +930,8 @@ -rm -f src/xkbcomp/parseutils.lo -rm -f src/xkbcomp/path.$(OBJEXT) -rm -f src/xkbcomp/path.lo + -rm -f src/xkbcomp/rules.$(OBJEXT) + -rm -f src/xkbcomp/rules.lo -rm -f src/xkbcomp/scanner.$(OBJEXT) -rm -f src/xkbcomp/scanner.lo -rm -f src/xkbcomp/symbols.$(OBJEXT) @@ -864,10 +942,13 @@ -rm -f src/xkbcomp/xkbcomp.lo -rm -f test/canonicalise.$(OBJEXT) -rm -f test/context.$(OBJEXT) + -rm -f test/dump.$(OBJEXT) -rm -f test/filecomp.$(OBJEXT) -rm -f test/namescomp.$(OBJEXT) -rm -f test/rulescomp.$(OBJEXT) -rm -f test/state.$(OBJEXT) + -rm -f test/stringcomp.$(OBJEXT) + -rm -f test/test_rules_file-rules-file.$(OBJEXT) -rm -f test/xkey.$(OBJEXT) distclean-compile: @@ -876,10 +957,10 @@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/alloc.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/atom.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/context.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/keymap-dump.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/keysym.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/map.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/misc.Plo@am__quote@ -@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/rules.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/state.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/text.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/utils.Plo@am__quote@ @@ -896,16 +977,20 @@ @AMDEP_TRUE@@am__include@ @am__quote@src/xkbcomp/$(DEPDIR)/parser.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/xkbcomp/$(DEPDIR)/parseutils.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/xkbcomp/$(DEPDIR)/path.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@src/xkbcomp/$(DEPDIR)/rules.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/xkbcomp/$(DEPDIR)/scanner.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/xkbcomp/$(DEPDIR)/symbols.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/xkbcomp/$(DEPDIR)/vmod.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@src/xkbcomp/$(DEPDIR)/xkbcomp.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/canonicalise.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/context.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/dump.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/filecomp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/namescomp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/rulescomp.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/state.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/stringcomp.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/test_rules_file-rules-file.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@test/$(DEPDIR)/xkey.Po@am__quote@ .c.o: @@ -932,6 +1017,20 @@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< +test/test_rules_file-rules-file.o: test/rules-file.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_rules_file_CFLAGS) $(CFLAGS) -MT test/test_rules_file-rules-file.o -MD -MP -MF test/$(DEPDIR)/test_rules_file-rules-file.Tpo -c -o test/test_rules_file-rules-file.o `test -f 'test/rules-file.c' || echo '$(srcdir)/'`test/rules-file.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) test/$(DEPDIR)/test_rules_file-rules-file.Tpo test/$(DEPDIR)/test_rules_file-rules-file.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test/rules-file.c' object='test/test_rules_file-rules-file.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_rules_file_CFLAGS) $(CFLAGS) -c -o test/test_rules_file-rules-file.o `test -f 'test/rules-file.c' || echo '$(srcdir)/'`test/rules-file.c + +test/test_rules_file-rules-file.obj: test/rules-file.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_rules_file_CFLAGS) $(CFLAGS) -MT test/test_rules_file-rules-file.obj -MD -MP -MF test/$(DEPDIR)/test_rules_file-rules-file.Tpo -c -o test/test_rules_file-rules-file.obj `if test -f 'test/rules-file.c'; then $(CYGPATH_W) 'test/rules-file.c'; else $(CYGPATH_W) '$(srcdir)/test/rules-file.c'; fi` +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) test/$(DEPDIR)/test_rules_file-rules-file.Tpo test/$(DEPDIR)/test_rules_file-rules-file.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='test/rules-file.c' object='test/test_rules_file-rules-file.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(test_rules_file_CFLAGS) $(CFLAGS) -c -o test/test_rules_file-rules-file.obj `if test -f 'test/rules-file.c'; then $(CYGPATH_W) 'test/rules-file.c'; else $(CYGPATH_W) '$(srcdir)/test/rules-file.c'; fi` + .l.c: $(AM_V_LEX)$(am__skiplex) $(SHELL) $(YLWRAP) $< $(LEX_OUTPUT_ROOT).c $@ -- $(LEXCOMPILE) @@ -1267,6 +1366,12 @@ @p='test/state$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) test/context.log: test/context$(EXEEXT) @p='test/context$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +test/rules-file.log: test/rules-file$(EXEEXT) + @p='test/rules-file$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +test/dump.log: test/dump$(EXEEXT) + @p='test/dump$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +test/stringcomp.log: test/stringcomp$(EXEEXT) + @p='test/stringcomp$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) .test.log: @p='$<'; $(am__check_pre) $(TEST_LOG_COMPILE) "$$tst" $(am__check_post) @am__EXEEXT_TRUE@.test$(EXEEXT).log: @@ -1522,7 +1627,7 @@ clean: clean-recursive clean-am: clean-checkPROGRAMS clean-generic clean-libLTLIBRARIES \ - clean-libtool mostlyclean-am + clean-libtool clean-noinstLTLIBRARIES mostlyclean-am distclean: distclean-recursive -rm -f $(am__CONFIG_DISTCLEAN_FILES) @@ -1601,15 +1706,16 @@ .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ all all-am am--mostlyclean-test-html am--refresh check \ check-TESTS check-am check-html clean clean-checkPROGRAMS \ - clean-generic clean-libLTLIBRARIES clean-libtool ctags \ - ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-hook \ - dist-lzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ - distcheck distclean distclean-compile distclean-generic \ - distclean-hdr distclean-libtool distclean-tags distcleancheck \ - distdir distuninstallcheck dvi dvi-am html html-am info \ - info-am install install-am install-data install-data-am \ - install-dvi install-dvi-am install-exec install-exec-am \ - install-html install-html-am install-info install-info-am \ + clean-generic clean-libLTLIBRARIES clean-libtool \ + clean-noinstLTLIBRARIES ctags ctags-recursive dist dist-all \ + dist-bzip2 dist-gzip dist-hook dist-lzip dist-lzma dist-shar \ + dist-tarZ dist-xz dist-zip distcheck distclean \ + distclean-compile distclean-generic distclean-hdr \ + distclean-libtool distclean-tags distcleancheck distdir \ + distuninstallcheck dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am \ install-libLTLIBRARIES install-man install-pdf install-pdf-am \ install-pkgconfigDATA install-ps install-ps-am install-strip \ install-xkbcommonincludeHEADERS installcheck installcheck-am \ diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/alloc.c libxkbcommon-0.1.0~git20120530.c87468e9/src/alloc.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/alloc.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/alloc.c 2012-05-30 06:41:46.000000000 +0000 @@ -28,62 +28,29 @@ int XkbcAllocClientMap(struct xkb_keymap *keymap, unsigned which, - unsigned nTotalTypes) + size_t nTotalTypes) { - struct xkb_client_map * map; - if (!keymap || ((nTotalTypes > 0) && (nTotalTypes < XkbNumRequiredTypes))) return BadValue; if (!keymap->map) { - map = uTypedCalloc(1, struct xkb_client_map); - if (!map) + keymap->map = calloc(1, sizeof(*keymap->map)); + if (!keymap->map) return BadAlloc; - keymap->map = map; + darray_init(keymap->map->types); } - else - map = keymap->map; - - if ((which & XkbKeyTypesMask) && (nTotalTypes > 0)) { - if (!map->types) { - map->types = uTypedCalloc(nTotalTypes, struct xkb_key_type); - if (!map->types) - return BadAlloc; - - map->num_types = 0; - map->size_types = nTotalTypes; - } - else if (map->size_types < nTotalTypes) { - struct xkb_key_type *prev_types = map->types; - map->types = uTypedRealloc(map->types, nTotalTypes, - struct xkb_key_type); - if (!map->types) { - free(prev_types); - map->num_types = map->size_types = 0; - return BadAlloc; - } - - map->size_types = nTotalTypes; - memset(&map->types[map->num_types], 0, - (map->size_types - map->num_types) * sizeof(struct xkb_key_type)); - } - } + if (which & XkbKeyTypesMask) + darray_growalloc(keymap->map->types, nTotalTypes); - if (which & XkbKeySymsMask) { - if (!map->key_sym_map) { - map->key_sym_map = uTypedCalloc(keymap->max_key_code + 1, - struct xkb_sym_map); - if (!map->key_sym_map) - return BadAlloc; - } - } + if (which & XkbKeySymsMask) + darray_resize0(keymap->map->key_sym_map, keymap->max_key_code + 1); if (which & XkbModifierMapMask) { - if (!map->modmap) { - map->modmap = uTypedCalloc(keymap->max_key_code + 1, - unsigned char); - if (!map->modmap) + if (!keymap->map->modmap) { + keymap->map->modmap = uTypedCalloc(keymap->max_key_code + 1, + unsigned char); + if (!keymap->map->modmap) return BadAlloc; } } @@ -127,36 +94,8 @@ if (nNewActions < 1) nNewActions = 1; - if (!map->acts) { - map->acts = uTypedCalloc(nNewActions + 1, union xkb_action); - if (!map->acts) - return BadAlloc; - map->num_acts = 1; - map->size_acts = nNewActions + 1; - } - else if ((map->size_acts - map->num_acts) < (int)nNewActions) { - unsigned need; - union xkb_action *prev_acts = map->acts; - - need = map->num_acts + nNewActions; - map->acts = uTypedRealloc(map->acts, need, union xkb_action); - if (!map->acts) { - free(prev_acts); - map->num_acts = map->size_acts = 0; - return BadAlloc; - } - - map->size_acts = need; - memset(&map->acts[map->num_acts], 0, - (map->size_acts - map->num_acts) * sizeof(union xkb_action)); - } - - if (!map->key_acts) { - i = keymap->max_key_code + 1; - map->key_acts = uTypedCalloc(i, unsigned short); - if (!map->key_acts) - return BadAlloc; - } + darray_resize0(map->acts, darray_size(map->acts) + nNewActions + 1); + darray_resize0(map->key_acts, keymap->max_key_code + 1); if (!map->behaviors) { i = keymap->max_key_code + 1; @@ -176,38 +115,33 @@ } int -XkbcCopyKeyType(struct xkb_key_type * from, struct xkb_key_type * into) +XkbcCopyKeyType(const struct xkb_key_type *from, struct xkb_key_type *into) { int i; if (!from || !into) return BadMatch; - free(into->map); - into->map = NULL; + darray_free(into->map); free(into->preserve); - into->preserve= NULL; for (i = 0; i < into->num_levels; i++) free(UNCONSTIFY(into->level_names[i])); free(into->level_names); - into->level_names = NULL; *into = *from; - if (from->map && (into->map_count > 0)) { - into->map = uTypedCalloc(into->map_count, struct xkb_kt_map_entry); - if (!into->map) - return BadAlloc; - memcpy(into->map, from->map, - into->map_count * sizeof(struct xkb_kt_map_entry)); - } - - if (from->preserve && (into->map_count > 0)) { - into->preserve = uTypedCalloc(into->map_count, struct xkb_mods); + darray_init(into->map); + darray_from_items(into->map, + &darray_item(from->map, 0), + darray_size(from->map)); + + if (from->preserve && !darray_empty(into->map)) { + into->preserve = calloc(darray_size(into->map), + sizeof(*into->preserve)); if (!into->preserve) return BadAlloc; memcpy(into->preserve, from->preserve, - into->map_count * sizeof(struct xkb_mods)); + darray_size(into->map) * sizeof(*into->preserve)); } if (from->level_names && (into->num_levels > 0)) { @@ -225,20 +159,20 @@ XkbcResizeKeySyms(struct xkb_keymap *keymap, xkb_keycode_t key, unsigned int needed) { - if (keymap->map->key_sym_map[key].size_syms >= needed) + struct xkb_sym_map *sym_map = + &darray_item(keymap->map->key_sym_map, key); + + if (sym_map->size_syms >= needed) return true; - keymap->map->key_sym_map[key].syms = - uTypedRecalloc(keymap->map->key_sym_map[key].syms, - keymap->map->key_sym_map[key].size_syms, - needed, - xkb_keysym_t); - if (!keymap->map->key_sym_map[key].syms) { - keymap->map->key_sym_map[key].size_syms = 0; + sym_map->syms = uTypedRecalloc(sym_map->syms, sym_map->size_syms, + needed, xkb_keysym_t); + if (!sym_map->syms) { + sym_map->size_syms = 0; return false; } - keymap->map->key_sym_map[key].size_syms = needed; + sym_map->size_syms = needed; return true; } @@ -246,61 +180,41 @@ XkbcResizeKeyActions(struct xkb_keymap *keymap, xkb_keycode_t key, uint32_t needed) { - xkb_keycode_t i, nActs; - union xkb_action *newActs; + size_t old_ndx, old_num_acts, new_ndx; if (needed == 0) { - keymap->server->key_acts[key] = 0; + darray_item(keymap->server->key_acts, key) = 0; return NULL; } if (XkbKeyHasActions(keymap, key) && - (XkbKeyGroupsWidth(keymap, key) >= needed)) + XkbKeyGroupsWidth(keymap, key) >= needed) return XkbKeyActionsPtr(keymap, key); - if (keymap->server->size_acts - keymap->server->num_acts >= (int)needed) { - keymap->server->key_acts[key] = keymap->server->num_acts; - keymap->server->num_acts += needed; - - return &keymap->server->acts[keymap->server->key_acts[key]]; - } - - keymap->server->size_acts = keymap->server->num_acts + needed + 8; - newActs = uTypedCalloc(keymap->server->size_acts, union xkb_action); - if (!newActs) - return NULL; - newActs[0].type = XkbSA_NoAction; - nActs = 1; - - for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) { - xkb_keycode_t nKeyActs, nCopy; - - if ((keymap->server->key_acts[i] == 0) && (i != key)) - continue; - - nCopy = nKeyActs = XkbKeyNumActions(keymap, i); - if (i == key) { - nKeyActs= needed; - if (needed < nCopy) - nCopy = needed; - } - - if (nCopy > 0) - memcpy(&newActs[nActs], XkbKeyActionsPtr(keymap, i), - nCopy * sizeof(union xkb_action)); - if (nCopy < nKeyActs) - memset(&newActs[nActs + nCopy], 0, - (nKeyActs - nCopy) * sizeof(union xkb_action)); - - keymap->server->key_acts[i] = nActs; - nActs += nKeyActs; - } - - free(keymap->server->acts); - keymap->server->acts = newActs; - keymap->server->num_acts = nActs; + /* + * The key may already be in the array, but without enough space. + * This should not happen often, so in order to avoid moving and + * copying stuff from acts and key_acts, we just allocate new + * space for the key at the end, and leave the old space alone. + */ + + old_ndx = darray_item(keymap->server->key_acts, key); + old_num_acts = XkbKeyNumActions(keymap, key); + new_ndx = darray_size(keymap->server->acts); + + darray_resize0(keymap->server->acts, new_ndx + needed); + darray_item(keymap->server->key_acts, key) = new_ndx; + + /* + * The key was already in the array, copy the old actions to the + * new space. + */ + if (old_ndx != 0) + memcpy(&darray_item(keymap->server->acts, new_ndx), + &darray_item(keymap->server->acts, old_ndx), + old_num_acts * sizeof(union xkb_action)); - return &keymap->server->acts[keymap->server->key_acts[key]]; + return XkbKeyActionsPtr(keymap, key); } void @@ -308,33 +222,30 @@ { struct xkb_client_map * map; struct xkb_key_type * type; - xkb_keycode_t key; - int i; + struct xkb_sym_map *sym_map; if (!keymap || !keymap->map) return; map = keymap->map; - for (i = 0, type = map->types; i < map->num_types && type; i++, type++) { + darray_foreach(type, map->types) { int j; - free(type->map); + darray_free(type->map); free(type->preserve); for (j = 0; j < type->num_levels; j++) free(UNCONSTIFY(type->level_names[j])); free(type->level_names); free(UNCONSTIFY(type->name)); } - free(map->types); + darray_free(map->types); - if (map->key_sym_map) { - for (key = keymap->min_key_code; key < keymap->max_key_code; key++) { - free(map->key_sym_map[key].sym_index); - free(map->key_sym_map[key].num_syms); - free(map->key_sym_map[key].syms); - } + darray_foreach(sym_map, map->key_sym_map) { + free(sym_map->sym_index); + free(sym_map->num_syms); + free(sym_map->syms); } - free(map->key_sym_map); + darray_free(map->key_sym_map); free(map->modmap); free(keymap->map); @@ -346,14 +257,14 @@ { struct xkb_server_map * map; - if (keymap || keymap->server) + if (!keymap || !keymap->server) return; map = keymap->server; free(map->explicit); - free(map->key_acts); - free(map->acts); + darray_free(map->key_acts); + darray_free(map->acts); free(map->behaviors); free(map->vmodmap); free(keymap->server); @@ -363,49 +274,21 @@ int XkbcAllocCompatMap(struct xkb_keymap *keymap, unsigned nSI) { - struct xkb_compat_map * compat; - struct xkb_sym_interpret *prev_interpret; - if (!keymap) return BadMatch; - if (keymap->compat) { - if (keymap->compat->size_si >= nSI) - return Success; - - compat = keymap->compat; - compat->size_si = nSI; - if (!compat->sym_interpret) - compat->num_si = 0; - - prev_interpret = compat->sym_interpret; - compat->sym_interpret = uTypedRecalloc(compat->sym_interpret, - compat->num_si, nSI, - struct xkb_sym_interpret); - if (!compat->sym_interpret) { - free(prev_interpret); - compat->size_si = compat->num_si = 0; + if (!keymap->compat) { + keymap->compat = calloc(1, sizeof(*keymap->compat)); + if (!keymap->compat) return BadAlloc; - } - - return Success; + darray_init(keymap->compat->sym_interpret); } - compat = uTypedCalloc(1, struct xkb_compat_map); - if (!compat) - return BadAlloc; + darray_growalloc(keymap->compat->sym_interpret, nSI); + darray_resize(keymap->compat->sym_interpret, 0); - if (nSI > 0) { - compat->sym_interpret = uTypedCalloc(nSI, struct xkb_sym_interpret); - if (!compat->sym_interpret) { - free(compat); - return BadAlloc; - } - } - compat->size_si = nSI; - compat->num_si = 0; - memset(&compat->groups[0], 0, XkbNumKbdGroups * sizeof(struct xkb_mods)); - keymap->compat = compat; + memset(keymap->compat->groups, 0, + XkbNumKbdGroups * sizeof(*keymap->compat->groups)); return Success; } @@ -414,40 +297,33 @@ static void XkbcFreeCompatMap(struct xkb_keymap *keymap) { - struct xkb_compat_map * compat; - if (!keymap || !keymap->compat) return; - compat = keymap->compat; - - free(compat->sym_interpret); - free(compat); + darray_free(keymap->compat->sym_interpret); + free(keymap->compat); keymap->compat = NULL; } int -XkbcAllocNames(struct xkb_keymap *keymap, unsigned which, - unsigned nTotalAliases) +XkbcAllocNames(struct xkb_keymap *keymap, unsigned which, size_t nTotalAliases) { - struct xkb_names * names; - if (!keymap) return BadMatch; if (!keymap->names) { - keymap->names = uTypedCalloc(1, struct xkb_names); + keymap->names = calloc(1, sizeof(*keymap->names)); if (!keymap->names) return BadAlloc; + + darray_init(keymap->names->keys); + darray_init(keymap->names->key_aliases); } - names = keymap->names; - if ((which & XkbKTLevelNamesMask) && keymap->map && keymap->map->types) { - int i; + if ((which & XkbKTLevelNamesMask) && keymap->map) { struct xkb_key_type * type; - type = keymap->map->types; - for (i = 0; i < keymap->map->num_types; i++, type++) { + darray_foreach(type, keymap->map->types) { if (!type->level_names) { type->level_names = uTypedCalloc(type->num_levels, const char *); if (!type->level_names) @@ -456,35 +332,11 @@ } } - if ((which & XkbKeyNamesMask) && !names->keys) { - names->keys = uTypedCalloc(keymap->max_key_code + 1, - struct xkb_key_name); - if (!names->keys) - return BadAlloc; - } + if (which & XkbKeyNamesMask) + darray_resize0(keymap->names->keys, keymap->max_key_code + 1); - if ((which & XkbKeyAliasesMask) && (nTotalAliases > 0)) { - if (!names->key_aliases) - names->key_aliases = uTypedCalloc(nTotalAliases, - struct xkb_key_alias); - else if (nTotalAliases > names->num_key_aliases) { - struct xkb_key_alias *prev_aliases = names->key_aliases; - - names->key_aliases = uTypedRecalloc(names->key_aliases, - names->num_key_aliases, - nTotalAliases, - struct xkb_key_alias); - if (!names->key_aliases) - free(prev_aliases); - } - - if (!names->key_aliases) { - names->num_key_aliases = 0; - return BadAlloc; - } - - names->num_key_aliases = nTotalAliases; - } + if (which & XkbKeyAliasesMask) + darray_resize0(keymap->names->key_aliases, nTotalAliases); return Success; } @@ -494,6 +346,7 @@ { struct xkb_names * names; struct xkb_client_map * map; + struct xkb_key_type *type; int i; if (!keymap || !keymap->names) @@ -502,13 +355,11 @@ names = keymap->names; map = keymap->map; - if (map && map->types) { - struct xkb_key_type * type = map->types; - - for (i = 0; i < map->num_types; i++, type++) { + if (map) { + darray_foreach(type, map->types) { int j; for (j = 0; j < type->num_levels; j++) - free(UNCONSTIFY(type->level_names[i])); + free(UNCONSTIFY(type->level_names[j])); free(type->level_names); type->level_names = NULL; } @@ -521,8 +372,8 @@ for (i = 0; i < XkbNumKbdGroups; i++) free(UNCONSTIFY(names->groups[i])); - free(names->keys); - free(names->key_aliases); + darray_free(names->keys); + darray_free(names->key_aliases); free(names); keymap->names = NULL; } diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/alloc.h libxkbcommon-0.1.0~git20120530.c87468e9/src/alloc.h --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/alloc.h 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/alloc.h 2012-05-30 06:41:46.000000000 +0000 @@ -34,7 +34,7 @@ extern int XkbcAllocNames(struct xkb_keymap *keymap, unsigned which, - unsigned nTotalAliases); + size_t nTotalAliases); extern int XkbcAllocControls(struct xkb_keymap *keymap); @@ -50,14 +50,14 @@ extern int XkbcAllocClientMap(struct xkb_keymap *keymap, unsigned which, - unsigned nTotalTypes); + size_t nTotalTypes); extern int XkbcAllocServerMap(struct xkb_keymap *keymap, unsigned which, unsigned nNewActions); extern int -XkbcCopyKeyType(struct xkb_key_type *from, struct xkb_key_type *into); +XkbcCopyKeyType(const struct xkb_key_type *from, struct xkb_key_type *into); extern bool XkbcResizeKeySyms(struct xkb_keymap *keymap, xkb_keycode_t key, diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/atom.c libxkbcommon-0.1.0~git20120530.c87468e9/src/atom.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/atom.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/atom.c 2012-05-30 06:41:46.000000000 +0000 @@ -72,8 +72,6 @@ #include "atom.h" -#define INITIAL_TABLE_SIZE 100 - struct atom_node { struct atom_node *left, *right; uint32_t a; @@ -82,10 +80,8 @@ }; struct atom_table { - xkb_atom_t last_atom; - struct atom_node *atom_root; - size_t table_length; - struct atom_node **node_table; + struct atom_node *root; + darray(struct atom_node *) table; }; struct atom_table * @@ -97,7 +93,7 @@ if (!table) return NULL; - table->last_atom = XKB_ATOM_NONE; + darray_append(table->table, NULL); return table; } @@ -120,19 +116,19 @@ if (!table) return; - free_atom(table->atom_root); - free(table->node_table); + free_atom(table->root); + darray_free(table->table); free(table); } const char * atom_text(struct atom_table *table, xkb_atom_t atom) { - if (atom == XKB_ATOM_NONE || atom > table->last_atom || - !table->node_table[atom]) + if (atom >= darray_size(table->table) || + darray_item(table->table, atom) == NULL) return NULL; - return table->node_table[atom]->string; + return darray_item(table->table, atom)->string; } char * @@ -156,7 +152,7 @@ return XKB_ATOM_NONE; len = strlen(string); - np = &table->atom_root; + np = &table->root; for (i = 0; i < (len + 1) / 2; i++) { fp = fp * 27 + string[i]; fp = fp * 27 + string[len - 1 - i]; @@ -191,34 +187,11 @@ strncpy(nd->string, string, len); nd->string[len] = 0; - if ((table->last_atom + 1) >= table->table_length) { - struct atom_node **new_node_table; - int new_length; - - if (table->table_length == 0) - new_length = INITIAL_TABLE_SIZE; - else - new_length = table->table_length * 2; - - new_node_table = realloc(table->node_table, - new_length * sizeof(*new_node_table)); - if (!new_node_table) { - if (nd->string != string) - free(nd->string); - free(nd); - return XKB_ATOM_NONE; - } - new_node_table[XKB_ATOM_NONE] = NULL; - - table->table_length = new_length; - table->node_table = new_node_table; - } - *np = nd; nd->left = nd->right = NULL; nd->fingerprint = fp; - nd->a = (++table->last_atom); - *(table->node_table + table->last_atom) = nd; + nd->a = darray_size(table->table); + darray_append(table->table, nd); return nd->a; } diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/config.h.in libxkbcommon-0.1.0~git20120530.c87468e9/src/config.h.in --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/config.h.in 2012-05-20 08:51:23.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/config.h.in 2012-05-30 06:42:06.000000000 +0000 @@ -39,6 +39,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H +/* Define to 1 if typeof works with your compiler. */ +#undef HAVE_TYPEOF + /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H @@ -117,3 +120,12 @@ /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE + +/* Define to `__inline__' or `__inline' if that's what the C compiler + calls it, or to nothing if 'inline' is not supported under any name. */ +#ifndef __cplusplus +#undef inline +#endif + +/* Define to __typeof__ if your compiler spells it that way. */ +#undef typeof diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/context.c libxkbcommon-0.1.0~git20120530.c87468e9/src/context.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/context.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/context.c 2012-05-30 06:41:46.000000000 +0000 @@ -34,9 +34,7 @@ struct xkb_context { int refcnt; - char **include_paths; - int num_include_paths; - int size_include_paths; + darray(char *) includes; /* xkbcomp needs to assign sequential IDs to XkbFile's it creates. */ int file_id; @@ -52,20 +50,7 @@ { struct stat stat_buf; int err; - - if (ctx->size_include_paths <= ctx->num_include_paths) { - int new_size; - char **new_paths; - new_size = ctx->size_include_paths + 2; - new_paths = uTypedRecalloc(ctx->include_paths, - ctx->size_include_paths, - new_size, - char *); - if (!new_paths) - return 0; - ctx->include_paths = new_paths; - ctx->size_include_paths = new_size; - } + char *tmp; err = stat(path, &stat_buf); if (err != 0) @@ -81,11 +66,11 @@ return 0; #endif - ctx->include_paths[ctx->num_include_paths] = strdup(path); - if (!ctx->include_paths[ctx->num_include_paths]) + tmp = strdup(path); + if (!tmp) return 0; - ctx->num_include_paths++; + darray_append(ctx->includes, tmp); return 1; } @@ -95,7 +80,7 @@ _X_EXPORT int xkb_context_include_path_append_default(struct xkb_context *ctx) { - const char *home = getenv("HOME"); + const char *home; char *user_path; int err; @@ -119,15 +104,12 @@ _X_EXPORT void xkb_context_include_path_clear(struct xkb_context *ctx) { - int i; + char **path; - for (i = 0; i < ctx->num_include_paths; i++) { - free(ctx->include_paths[i]); - ctx->include_paths[i] = NULL; - } - free(ctx->include_paths); - ctx->include_paths = NULL; - ctx->num_include_paths = 0; + darray_foreach(path, ctx->includes) + free(*path); + + darray_free(ctx->includes); } /** @@ -146,7 +128,7 @@ _X_EXPORT unsigned int xkb_context_num_include_paths(struct xkb_context *ctx) { - return ctx->num_include_paths; + return darray_size(ctx->includes); } /** @@ -159,7 +141,7 @@ if (idx >= xkb_context_num_include_paths(ctx)) return NULL; - return ctx->include_paths[idx]; + return darray_item(ctx->includes, idx); } int diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/darray.h libxkbcommon-0.1.0~git20120530.c87468e9/src/darray.h --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/darray.h 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/darray.h 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,355 @@ +/* + * Copyright (C) 2011 Joseph Adams + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef CCAN_DARRAY_H +#define CCAN_DARRAY_H + +#include +#include +#include "config.h" + +/* + * SYNOPSIS + * + * Life cycle of a darray (dynamically-allocated array): + * + * darray(int) a = darray_new(); + * darray_free(a); + * + * struct {darray(int) a;} foo; + * darray_init(foo.a); + * darray_free(foo.a); + * + * const struct { + * darray(int) a; + * } foo = { + * .a = darray_lit({1, 2, 3}) + * }; + * + * Typedefs for darrays of common types: + * + * darray_char, darray_schar, darray_uchar + * darray_short, darray_int, darray_long + * darray_ushort, darray_uint, darray_ulong + * + * Access: + * + * T darray_item(darray(T) arr, size_t index); + * size_t darray_size(darray(T) arr); + * size_t darray_alloc(darray(T) arr); + * bool darray_empty(darray(T) arr); + * + * Insertion (single item): + * + * void darray_append(darray(T) arr, T item); + * void darray_prepend(darray(T) arr, T item); + * void darray_push(darray(T) arr, T item); // same as darray_append + * + * Insertion (multiple items): + * + * void darray_append_items(darray(T) arr, T *items, size_t count); + * void darray_prepend_items(darray(T) arr, T *items, size_t count); + * + * void darray_appends(darray(T) arr, [T item, [...]]); + * void darray_prepends(darray(T) arr, [T item, [...]]); + * + * // Same functionality as above, but does not require typeof. + * void darray_appends_t(darray(T) arr, #T, [T item, [...]]); + * void darray_prepends_t(darray(T) arr, #T, [T item, [...]]); + * + * Removal: + * + * T darray_pop(darray(T) arr | darray_size(arr) != 0); + * T* darray_pop_check(darray(T*) arr); + * + * Replacement: + * + * void darray_from_items(darray(T) arr, T *items, size_t count); + * void darray_from_c(darray(T) arr, T c_array[N]); + * + * String buffer: + * + * void darray_append_string(darray(char) arr, const char *str); + * void darray_append_lit(darray(char) arr, char stringLiteral[N+1]); + * + * void darray_prepend_string(darray(char) arr, const char *str); + * void darray_prepend_lit(darray(char) arr, char stringLiteral[N+1]); + * + * void darray_from_string(darray(T) arr, const char *str); + * void darray_from_lit(darray(char) arr, char stringLiteral[N+1]); + * + * Size management: + * + * void darray_resize(darray(T) arr, size_t newSize); + * void darray_resize0(darray(T) arr, size_t newSize); + * + * void darray_realloc(darray(T) arr, size_t newAlloc); + * void darray_growalloc(darray(T) arr, size_t newAlloc); + * + * void darray_make_room(darray(T) arr, size_t room); + * + * Traversal: + * + * darray_foreach(T *&i, darray(T) arr) {...} + * darray_foreach_reverse(T *&i, darray(T) arr) {...} + * + * Except for darray_foreach and darray_foreach_reverse, + * all macros evaluate their non-darray arguments only once. + */ + +/*** Life cycle ***/ + +#define darray(type) struct {type *item; size_t size; size_t alloc;} + +#define darray_new() {0,0,0} +#define darray_lit(c_array) {(c_array), sizeof(c_array) / sizeof(*(c_array)), 0} +#define darray_init(arr) do {(arr).item=0; (arr).size=0; (arr).alloc=0;} while(0) +#define darray_free(arr) do {free((arr).item);} while(0) + + +/* + * Typedefs for darrays of common types. These are useful + * when you want to pass a pointer to an darray(T) around. + * + * The following will produce an incompatible pointer warning: + * + * void foo(darray(int) *arr); + * darray(int) arr = darray_new(); + * foo(&arr); + * + * The workaround: + * + * void foo(darray_int *arr); + * darray_int arr = darray_new(); + * foo(&arr); + */ + +typedef darray(char) darray_char; +typedef darray(signed char) darray_schar; +typedef darray(unsigned char) darray_uchar; + +typedef darray(short) darray_short; +typedef darray(int) darray_int; +typedef darray(long) darray_long; + +typedef darray(unsigned short) darray_ushort; +typedef darray(unsigned int) darray_uint; +typedef darray(unsigned long) darray_ulong; + + +/*** Access ***/ + +#define darray_item(arr, i) ((arr).item[i]) +#define darray_size(arr) ((arr).size) +#define darray_alloc(arr) ((arr).alloc) +#define darray_empty(arr) ((arr).size == 0) + + +/*** Insertion (single item) ***/ + +#define darray_append(arr, ...) do { \ + darray_resize(arr, (arr).size+1); \ + (arr).item[(arr).size-1] = (__VA_ARGS__); \ + } while(0) +#define darray_prepend(arr, ...) do { \ + darray_resize(arr, (arr).size+1); \ + memmove((arr).item+1, (arr).item, ((arr).size-1)*sizeof(*(arr).item)); \ + (arr).item[0] = (__VA_ARGS__); \ + } while(0) +#define darray_push(arr, ...) darray_append(arr, __VA_ARGS__) + + +/*** Insertion (multiple items) ***/ + +#define darray_append_items(arr, items, count) do { \ + size_t __count = (count), __oldSize = (arr).size; \ + darray_resize(arr, __oldSize + __count); \ + memcpy((arr).item + __oldSize, items, __count * sizeof(*(arr).item)); \ + } while(0) + +#define darray_prepend_items(arr, items, count) do { \ + size_t __count = (count), __oldSize = (arr).size; \ + darray_resize(arr, __count + __oldSize); \ + memmove((arr).item + __count, (arr).item, __oldSize * sizeof(*(arr).item)); \ + memcpy((arr).item, items, __count * sizeof(*(arr).item)); \ + } while(0) + +#define darray_append_items_nullterminate(arr, items, count) do { \ + size_t __count = (count), __oldSize = (arr).size; \ + darray_resize(arr, __oldSize + __count + 1); \ + memcpy((arr).item + __oldSize, items, __count * sizeof(*(arr).item)); \ + (arr).item[--(arr).size] = 0; \ + } while(0) + +#define darray_prepend_items_nullterminate(arr, items, count) do { \ + size_t __count = (count), __oldSize = (arr).size; \ + darray_resize(arr, __count + __oldSize + 1); \ + memmove((arr).item + __count, (arr).item, __oldSize * sizeof(*(arr).item)); \ + memcpy((arr).item, items, __count * sizeof(*(arr).item)); \ + (arr).item[--(arr).size] = 0; \ + } while(0) + +#if HAVE_TYPEOF +#define darray_appends(arr, ...) darray_appends_t(arr, typeof((*(arr).item)), __VA_ARGS__) +#define darray_prepends(arr, ...) darray_prepends_t(arr, typeof((*(arr).item)), __VA_ARGS__) +#endif + +#define darray_appends_t(arr, type, ...) do { \ + type __src[] = {__VA_ARGS__}; \ + darray_append_items(arr, __src, sizeof(__src)/sizeof(*__src)); \ + } while(0) +#define darray_prepends_t(arr, type, ...) do { \ + type __src[] = {__VA_ARGS__}; \ + darray_prepend_items(arr, __src, sizeof(__src)/sizeof(*__src)); \ + } while(0) + + +/*** Removal ***/ + +/* Warning: Do not call darray_pop on an empty darray. */ +#define darray_pop(arr) ((arr).item[--(arr).size]) +#define darray_pop_check(arr) ((arr).size ? darray_pop(arr) : NULL) + + +/*** Replacement ***/ + +#define darray_from_items(arr, items, count) do {size_t __count = (count); darray_resize(arr, __count); memcpy((arr).item, items, __count*sizeof(*(arr).item));} while(0) +#define darray_from_c(arr, c_array) darray_from_items(arr, c_array, sizeof(c_array)/sizeof(*(c_array))) + + +/*** String buffer ***/ + +#define darray_append_string(arr, str) do {const char *__str = (str); darray_append_items(arr, __str, strlen(__str)+1); (arr).size--;} while(0) +#define darray_append_lit(arr, stringLiteral) do {darray_append_items(arr, stringLiteral, sizeof(stringLiteral)); (arr).size--;} while(0) + +#define darray_prepend_string(arr, str) do { \ + const char *__str = (str); \ + darray_prepend_items_nullterminate(arr, __str, strlen(__str)); \ + } while(0) +#define darray_prepend_lit(arr, stringLiteral) \ + darray_prepend_items_nullterminate(arr, stringLiteral, sizeof(stringLiteral) - 1) + +#define darray_from_string(arr, str) do {const char *__str = (str); darray_from_items(arr, __str, strlen(__str)+1); (arr).size--;} while(0) +#define darray_from_lit(arr, stringLiteral) do {darray_from_items(arr, stringLiteral, sizeof(stringLiteral)); (arr).size--;} while(0) + + +/*** Size management ***/ + +#define darray_resize(arr, newSize) darray_growalloc(arr, (arr).size = (newSize)) +#define darray_resize0(arr, newSize) do { \ + size_t __oldSize = (arr).size, __newSize = (newSize); \ + (arr).size = __newSize; \ + if (__newSize > __oldSize) { \ + darray_growalloc(arr, __newSize); \ + memset(&(arr).item[__oldSize], 0, (__newSize - __oldSize) * sizeof(*(arr).item)); \ + } \ + } while(0) + +#define darray_realloc(arr, newAlloc) do { \ + (arr).item = realloc((arr).item, ((arr).alloc = (newAlloc)) * sizeof(*(arr).item)); \ + } while(0) +#define darray_growalloc(arr, need) do { \ + size_t __need = (need); \ + if (__need > (arr).alloc) \ + darray_realloc(arr, darray_next_alloc((arr).alloc, __need)); \ + } while(0) + +#if HAVE_STATEMENT_EXPR==1 +#define darray_make_room(arr, room) ({size_t newAlloc = (arr).size+(room); if ((arr).alloc &(arr).item[0]; ) + + +#endif /* CCAN_DARRAY_H */ + +/* + +darray_growalloc(arr, newAlloc) sees if the darray can currently hold newAlloc items; + if not, it increases the alloc to satisfy this requirement, allocating slack + space to avoid having to reallocate for every size increment. + +darray_from_string(arr, str) copies a string to an darray_char. + +darray_push(arr, item) pushes an item to the end of the darray. +darray_pop(arr) pops it back out. Be sure there is at least one item in the darray before calling. +darray_pop_check(arr) does the same as darray_pop, but returns NULL if there are no more items left in the darray. + +darray_make_room(arr, room) ensures there's 'room' elements of space after the end of the darray, and it returns a pointer to this space. +Currently requires HAVE_STATEMENT_EXPR, but I plan to remove this dependency by creating an inline function. + +The following require HAVE_TYPEOF==1 : + +darray_appends(arr, item0, item1...) appends a collection of comma-delimited items to the darray. +darray_prepends(arr, item0, item1...) prepends a collection of comma-delimited items to the darray.\ + + +Examples: + + darray(int) arr; + int *i; + + darray_appends(arr, 0,1,2,3,4); + darray_appends(arr, -5,-4,-3,-2,-1); + darray_foreach(i, arr) + printf("%d ", *i); + printf("\n"); + + darray_free(arr); + + + typedef struct {int n,d;} Fraction; + darray(Fraction) fractions; + Fraction *i; + + darray_appends(fractions, {3,4}, {3,5}, {2,1}); + darray_foreach(i, fractions) + printf("%d/%d\n", i->n, i->d); + + darray_free(fractions); +*/ diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/keymap-dump.c libxkbcommon-0.1.0~git20120530.c87468e9/src/keymap-dump.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/keymap-dump.c 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/keymap-dump.c 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,932 @@ +/************************************************************ + Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. + + Permission to use, copy, modify, and distribute this + software and its documentation for any purpose and without + fee is hereby granted, provided that the above copyright + notice appear in all copies and that both that copyright + notice and this permission notice appear in supporting + documentation, and that the name of Silicon Graphics not be + used in advertising or publicity pertaining to distribution + of the software without specific prior written permission. + Silicon Graphics makes no representation about the suitability + of this software for any purpose. It is provided "as is" + without any express or implied warranty. + + SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH + THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ********************************************************/ + +/* + * Copyright © 2012 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + * Author: Daniel Stone + */ + +#include + +#include +#include +#include + +#include "xkb-priv.h" +#include "text.h" + +#define VMOD_HIDE_VALUE 0 +#define VMOD_SHOW_VALUE 1 +#define VMOD_COMMENT_VALUE 2 + +#define BUF_CHUNK_SIZE 4096 + +static bool +do_realloc(char **buf, size_t *size, size_t offset, size_t at_least) +{ + char *new; + + *size += BUF_CHUNK_SIZE; + if (at_least >= BUF_CHUNK_SIZE) + *size += at_least; + + new = realloc(*buf, *size); + if (!new) + return false; + *buf = new; + + memset(*buf + offset, 0, *size - offset); + + return true; +} + +/* This whole thing should be a function, but you can't call vsnprintf + * multiple times. */ +#define check_write_buf(keymap, buf, size, offset, ...) \ +do { \ + size_t _printed; \ + bool _ret = true; \ + \ + /* Concatenate the strings, and check whether or not the output was \ + * truncated. */ \ + while ((_printed = snprintf(*buf + *offset, *size - *offset, \ + __VA_ARGS__)) >= \ + (*size - *offset)) {\ + /* If it was truncated, embiggen the string and roll from the top. */ \ + if (!do_realloc(buf, size, *offset, _printed)) { \ + fprintf(stderr, \ + "xkbcommon: failed to allocate %lu bytes for keymap\n", \ + (unsigned long) *size); \ + free(*buf); \ + *buf = NULL; \ + _ret = false; \ + break; \ + } \ + } \ + if (_ret == true) \ + *offset += _printed; \ +} while (0) + +#define write_buf(keymap, buf, size, offset, ...) \ +do { \ + check_write_buf(keymap, buf, size, offset, __VA_ARGS__); \ + if (*buf == NULL) \ + return false; \ +} while (0) + +static bool +write_vmods(struct xkb_keymap *keymap, char **buf, size_t *size, size_t *offset) +{ + int num_vmods = 0; + int i; + + for (i = 0; i < XkbNumVirtualMods; i++) { + if (!keymap->names->vmods[i]) + continue; + if (num_vmods == 0) + write_buf(keymap, buf, size, offset, "\t\tvirtual_modifiers "); + else + write_buf(keymap, buf, size, offset, ","); + write_buf(keymap, buf, size, offset, "%s", keymap->names->vmods[i]); + num_vmods++; + } + + if (num_vmods > 0) + write_buf(keymap, buf, size, offset, ";\n\n"); + + return true; +} + +#define GET_TEXT_BUF_SIZE 512 + +#define append_get_text(...) do { \ + int _size = snprintf(ret, GET_TEXT_BUF_SIZE, __VA_ARGS__); \ + if (_size >= GET_TEXT_BUF_SIZE) \ + return NULL; \ +} while(0) + +/* FIXME: Merge with src/xkbcomp/expr.c::modIndexNames. */ +static const char *core_mod_names[] = { + "Shift", + "Lock", + "Control", + "Mod1", + "Mod2", + "Mod3", + "Mod4", + "Mod5", +}; + +static const char * +get_mod_index_text(uint8_t real_mod) +{ + return core_mod_names[real_mod]; +} + +static char * +get_mod_mask_text(struct xkb_keymap *keymap, uint8_t real_mods, uint32_t vmods) +{ + static char ret[GET_TEXT_BUF_SIZE], ret2[GET_TEXT_BUF_SIZE]; + int i; + + memset(ret, 0, GET_TEXT_BUF_SIZE); + + if (real_mods == 0 && vmods == 0) { + strcpy(ret, "none"); + return ret; + } + + /* This is so broken. If we have a real modmask of 0xff and a + * vmodmask, we'll get, e.g., all+RightControl. But, it's what xkbfile + * does, so ... */ + if (real_mods == 0xff) { + strcpy(ret, "all"); + } + else if (real_mods) { + for (i = 0; i < XkbNumModifiers; i++) { + if (!(real_mods & (1 << i))) + continue; + if (ret[0] != '\0') { + strcpy(ret2, ret); + append_get_text("%s+%s", ret2, core_mod_names[i]); + } + else { + append_get_text("%s", core_mod_names[i]); + } + } + } + + if (vmods == 0) + return ret; + + for (i = 0; i < XkbNumVirtualMods; i++) { + if (!(vmods & (1 << i))) + continue; + if (ret[0] != '\0') { + strcpy(ret2, ret); + append_get_text("%s+%s", ret2, keymap->names->vmods[i]); + } + else { + append_get_text("%s", keymap->names->vmods[i]); + } + } + + return ret; +} + +static char * +get_indicator_state_text(uint8_t which) +{ + int i; + static char ret[GET_TEXT_BUF_SIZE]; + /* FIXME: Merge with ... something ... in xkbcomp? */ + static const char *state_names[] = { + "base", + "latched", + "locked", + "effective", + "compat" + }; + + memset(ret, 0, GET_TEXT_BUF_SIZE); + + which &= XkbIM_UseAnyMods; + + if (which == 0) { + strcpy(ret, "0"); + return NULL; + } + + for (i = 0; which != 0; i++) { + if (!(which & (1 << i))) + continue; + which &= ~(1 << i); + + if (ret[0] != '\0') + append_get_text("%s+%s", ret, state_names[i]); + else + append_get_text("%s", state_names[i]); + } + + return ret; +} + +static char * +get_control_mask_text(uint32_t control_mask) +{ + int i; + static char ret[GET_TEXT_BUF_SIZE]; + /* FIXME: Merge with ... something ... in xkbcomp. */ + static const char *ctrl_names[] = { + "repeatKeys", + "slowKeys", + "bounceKeys", + "stickyKeys", + "mouseKeys", + "mouseKeysAccel", + "accessXKeys", + "accessXTimeout", + "accessXFeedback", + "audibleBell", + "overlay1", + "overlay2", + "ignoreGroupLock" + }; + + memset(ret, 0, GET_TEXT_BUF_SIZE); + + control_mask &= XkbAllBooleanCtrlsMask; + + if (control_mask == 0) { + strcpy(ret, "none"); + return ret; + } + else if (control_mask == XkbAllBooleanCtrlsMask) { + strcpy(ret, "all"); + return ret; + } + + for (i = 0; control_mask; i++) { + if (!(control_mask & (1 << i))) + continue; + control_mask &= ~(1 << i); + + if (ret[0] != '\0') + append_get_text("%s+%s", ret, ctrl_names[i]); + else + append_get_text("%s", ctrl_names[i]); + } + + return ret; +} + +static bool +write_keycodes(struct xkb_keymap *keymap, char **buf, size_t *size, + size_t *offset) +{ + xkb_keycode_t key; + struct xkb_key_alias *alias; + int i; + + write_buf(keymap, buf, size, offset, "\txkb_keycodes {\n"); + write_buf(keymap, buf, size, offset, "\t\tminimum = %d;\n", + keymap->min_key_code); + write_buf(keymap, buf, size, offset, "\t\tmaximum = %d;\n", + keymap->max_key_code); + + for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) { + const char *alternate = ""; + + if (darray_item(keymap->names->keys, key).name[0] == '\0') + continue; + if (XkbcFindKeycodeByName(keymap, + darray_item(keymap->names->keys, key).name, + true) != key) + alternate = "alternate "; + write_buf(keymap, buf, size, offset, "\t\t%s%6s = %d;\n", alternate, + XkbcKeyNameText(darray_item(keymap->names->keys, key).name), + key); + } + + for (i = 0; i < XkbNumIndicators; i++) { + if (!keymap->names->indicators[i]) + continue; + write_buf(keymap, buf, size, offset, "\t\tindicator %d = \"%s\";\n", + i + 1, keymap->names->indicators[i]); + } + + + for (i = 0; i < darray_size(keymap->names->key_aliases); i++) { + alias = &darray_item(keymap->names->key_aliases, i); + write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n", + XkbcKeyNameText(alias->alias), + XkbcKeyNameText(alias->real)); + } + + write_buf(keymap, buf, size, offset, "\t};\n\n"); + return true; +} + +static bool +write_types(struct xkb_keymap *keymap, char **buf, size_t *size, + size_t *offset) +{ + int i, n; + struct xkb_key_type *type; + + write_buf(keymap, buf, size, offset, "\txkb_types {\n\n"); + write_vmods(keymap, buf, size, offset); + + for (i = 0; i < darray_size(keymap->map->types); i++) { + type = &darray_item(keymap->map->types, i); + write_buf(keymap, buf, size, offset, "\t\ttype \"%s\" {\n", + type->name); + write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n", + get_mod_mask_text(keymap, type->mods.real_mods, + type->mods.vmods)); + + for (n = 0; n < darray_size(type->map); n++) { + struct xkb_kt_map_entry *entry = &darray_item(type->map, n); + char *str; + + str = get_mod_mask_text(keymap, entry->mods.real_mods, + entry->mods.vmods); + write_buf(keymap, buf, size, offset, "\t\t\tmap[%s]= Level%d;\n", + str, entry->level + 1); + + if (!type->preserve || (!type->preserve[n].real_mods && + !type->preserve[n].vmods)) + continue; + write_buf(keymap, buf, size, offset, "\t\t\tpreserve[%s]= ", str); + write_buf(keymap, buf, size, offset, "%s;\n", + get_mod_mask_text(keymap, type->preserve[n].real_mods, + type->preserve[n].vmods)); + } + + if (type->level_names) { + for (n = 0; n < type->num_levels; n++) { + if (!type->level_names[n]) + continue; + write_buf(keymap, buf, size, offset, + "\t\t\tlevel_name[Level%d]= \"%s\";\n", n + 1, + type->level_names[n]); + } + } + write_buf(keymap, buf, size, offset, "\t\t};\n"); + } + + write_buf(keymap, buf, size, offset, "\t};\n\n"); + return true; +} + +static bool +write_indicator_map(struct xkb_keymap *keymap, char **buf, size_t *size, + size_t *offset, int num) +{ + struct xkb_indicator_map *led = &keymap->indicators->maps[num]; + + write_buf(keymap, buf, size, offset, "\t\tindicator \"%s\" {\n", + keymap->names->indicators[num]); + + if (led->which_groups) { + if (led->which_groups != XkbIM_UseEffective) { + write_buf(keymap, buf, size, offset, "\t\t\twhichGroupState= %s;\n", + get_indicator_state_text(led->which_groups)); + } + write_buf(keymap, buf, size, offset, "\t\t\tgroups= 0x%02x;\n", + led->groups); + } + + if (led->which_mods) { + if (led->which_mods != XkbIM_UseEffective) { + write_buf(keymap, buf, size, offset, "\t\t\twhichModState= %s;\n", + get_indicator_state_text(led->which_mods)); + } + write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n", + get_mod_mask_text(keymap, led->mods.real_mods, + led->mods.vmods)); + } + + if (led->ctrls) { + write_buf(keymap, buf, size, offset, "\t\t\tcontrols= %s;\n", + get_control_mask_text(led->ctrls)); + } + + write_buf(keymap, buf, size, offset, "\t\t};\n"); + return true; +} + +static char * +get_interp_match_text(uint8_t type) +{ + static char ret[16]; + + switch (type & XkbSI_OpMask) { + case XkbSI_NoneOf: + sprintf(ret, "NoneOf"); + break; + case XkbSI_AnyOfOrNone: + sprintf(ret, "AnyOfOrNone"); + break; + case XkbSI_AnyOf: + sprintf(ret, "AnyOf"); + break; + case XkbSI_AllOf: + sprintf(ret, "AllOf"); + break; + case XkbSI_Exactly: + sprintf(ret, "Exactly"); + break; + default: + sprintf(ret, "0x%x", type & XkbSI_OpMask); + break; + } + + return ret; +} + +static bool +write_action(struct xkb_keymap *keymap, char **buf, size_t *size, + size_t *offset, union xkb_action *action, const char *prefix, + const char *suffix) +{ + const char *type = NULL; + const char *args = NULL; + + if (!prefix) + prefix = ""; + if (!suffix) + suffix = ""; + + if (action->any.type == XkbSA_NoAction) + return true; + + switch (action->any.type) { + case XkbSA_SetMods: + if (!type) + type = "SetMods"; + case XkbSA_LatchMods: + if (!type) + type = "LatchMods"; + case XkbSA_LockMods: + if (!type) + type = "LockMods"; + if (action->mods.flags & XkbSA_UseModMapMods) + args = "modMapMods"; + else + args = get_mod_mask_text(keymap, action->mods.real_mods, + action->mods.vmods); + write_buf(keymap, buf, size, offset, "%s%s(modifiers=%s%s%s)%s", + prefix, type, args, + (action->any.type != XkbSA_LockGroup && + action->mods.flags & XkbSA_ClearLocks) ? ",clearLocks" : "", + (action->any.type != XkbSA_LockGroup && + action->mods.flags & XkbSA_LatchToLock) ? ",latchToLock" : "", + suffix); + break; + case XkbSA_SetGroup: + if (!type) + type = "SetGroup"; + case XkbSA_LatchGroup: + if (!type) + type = "LatchGroup"; + case XkbSA_LockGroup: + if (!type) + type = "LockGroup"; + write_buf(keymap, buf, size, offset, "%s%s(group=%s%d%s%s)%s", + prefix, type, + (!(action->group.flags & XkbSA_GroupAbsolute) && + action->group.group > 0) ? "+" : "", + (action->group.flags & XkbSA_GroupAbsolute) ? + action->group.group + 1 : action->group.group, + (action->any.type != XkbSA_LockGroup && + action->group.flags & XkbSA_ClearLocks) ? ",clearLocks" : "", + (action->any.type != XkbSA_LockGroup && + action->group.flags & XkbSA_LatchToLock) ? ",latchToLock" : "", + suffix); + break; + case XkbSA_Terminate: + write_buf(keymap, buf, size, offset, "%sTerminate()%s", prefix, suffix); + break; + case XkbSA_MovePtr: + write_buf(keymap, buf, size, offset, "%sMovePtr(x=%s%d,y=%s%d%s)%s", + prefix, + (!(action->ptr.flags & XkbSA_MoveAbsoluteX) && + action->ptr.x >= 0) ? "+" : "", + action->ptr.x, + (!(action->ptr.flags & XkbSA_MoveAbsoluteY) && + action->ptr.y >= 0) ? "+" : "", + action->ptr.y, + (action->ptr.flags & XkbSA_NoAcceleration) ? ",!accel" : "", + suffix); + break; + case XkbSA_PtrBtn: + if (!type) + type = "PtrBtn"; + case XkbSA_LockPtrBtn: + if (!type) { + type = "LockPtrBtn"; + switch (action->btn.flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) { + case XkbSA_LockNoUnlock: + args = ",affect=lock"; + break; + case XkbSA_LockNoLock: + args = ",affect=unlock"; + break; + case XkbSA_LockNoLock | XkbSA_LockNoUnlock: + args = ",affect=neither"; + break; + default: + args = ",affect=both"; + break; + } + } + else { + args = NULL; + } + write_buf(keymap, buf, size, offset, "%s%s(button=", prefix, type); + if (action->btn.button > 0 && action->btn.button <= 5) + write_buf(keymap, buf, size, offset, "%d", action->btn.button); + else + write_buf(keymap, buf, size, offset, "default"); + if (action->btn.count) + write_buf(keymap, buf, size, offset, ",count=%d", + action->btn.count); + if (args) + write_buf(keymap, buf, size, offset, "%s", args); + write_buf(keymap, buf, size, offset, ")%s", suffix); + break; + case XkbSA_SetPtrDflt: + write_buf(keymap, buf, size, offset, "%sSetPtrDflt(", prefix); + if (action->dflt.affect == XkbSA_AffectDfltBtn) + write_buf(keymap, buf, size, offset, "affect=button,button=%s%d", + (!(action->dflt.flags & XkbSA_DfltBtnAbsolute) && + action->dflt.value >= 0) ? "+" : "", + action->dflt.value); + write_buf(keymap, buf, size, offset, ")%s", suffix); + break; + case XkbSA_SwitchScreen: + write_buf(keymap, buf, size, offset, + "%sSwitchScreen(screen=%s%d,%ssame)%s", prefix, + (!(action->screen.flags & XkbSA_SwitchAbsolute) && + action->screen.screen >= 0) ? "+" : "", + action->screen.screen, + (action->screen.flags & XkbSA_SwitchApplication) ? "!" : "", + suffix); + break; + /* Deprecated actions below here */ + case XkbSA_SetControls: + if (!type) + type = "SetControls"; + case XkbSA_LockControls: + if (!type) + type = "LockControls"; + write_buf(keymap, buf, size, offset, "%s%s(controls=%s)%s", + prefix, type, get_control_mask_text(action->ctrls.ctrls), + suffix); + break; + case XkbSA_ISOLock: + case XkbSA_ActionMessage: + case XkbSA_RedirectKey: + case XkbSA_DeviceBtn: + case XkbSA_LockDeviceBtn: + /* XXX TODO */ + write_buf(keymap, buf, size, offset, "%sNoAction()%s", prefix, suffix); + break; + case XkbSA_XFree86Private: + default: + write_buf(keymap, buf, size, offset, + "%sPrivate(type=0x%02x,data[0]=0x%02x,data[1]=0x%02x,data[2]=0x%02x,data[3]=0x%02x,data[4]=0x%02x,data[5]=0x%02x,data[6]=0x%02x)%s", + prefix, action->any.type, action->any.data[0], + action->any.data[1], action->any.data[2], + action->any.data[3], action->any.data[4], + action->any.data[5], action->any.data[6], suffix); + break; + } + + return true; +} + +static bool +write_compat(struct xkb_keymap *keymap, char **buf, size_t *size, + size_t *offset) +{ + int i; + struct xkb_sym_interpret *interp; + + write_buf(keymap, buf, size, offset, "\txkb_compatibility {\n\n"); + + write_vmods(keymap, buf, size, offset); + + write_buf(keymap, buf, size, offset, "\t\tinterpret.useModMapMods= AnyLevel;\n"); + write_buf(keymap, buf, size, offset, "\t\tinterpret.repeat= false;\n"); + write_buf(keymap, buf, size, offset, "\t\tinterpret.locking= false;\n"); + + for (i = 0; i < darray_size(keymap->compat->sym_interpret); i++) { + char keysym_name[64]; + interp = &darray_item(keymap->compat->sym_interpret, i); + + if (interp->sym == XKB_KEY_NoSymbol) + sprintf(keysym_name, "Any"); + else + xkb_keysym_get_name(interp->sym, keysym_name, 64); + + write_buf(keymap, buf, size, offset, "\t\tinterpret %s+%s(%s) {\n", + keysym_name, + get_interp_match_text(interp->match), + get_mod_mask_text(keymap, interp->mods, 0)); + + if (interp->virtual_mod != XkbNoModifier) { + write_buf(keymap, buf, size, offset, "\t\t\tvirtualModifier= %s;\n", + keymap->names->vmods[interp->virtual_mod]); + } + + if (interp->match & XkbSI_LevelOneOnly) + write_buf(keymap, buf, size, offset, "\t\t\tuseModMapMods=level1;\n"); + if (interp->flags & XkbSI_LockingKey) + write_buf(keymap, buf, size, offset, "\t\t\tlocking= true;\n"); + if (interp->flags & XkbSI_AutoRepeat) + write_buf(keymap, buf, size, offset, "\t\t\trepeat= true;\n"); + + write_action(keymap, buf, size, offset, &interp->act, + "\t\t\taction= ", ";\n"); + write_buf(keymap, buf, size, offset, "\t\t};\n"); + } + + for (i = 0; i < XkbNumKbdGroups; i++) { + struct xkb_mods *gc; + + gc = &keymap->compat->groups[i]; + if (gc->real_mods == 0 && gc->vmods ==0) + continue; + write_buf(keymap, buf, size, offset, + "\t\tgroup %d = %s;\n", i + 1, + get_mod_mask_text(keymap, gc->real_mods, gc->vmods)); + } + + for (i = 0; i < XkbNumIndicators; i++) { + struct xkb_indicator_map *map = &keymap->indicators->maps[i]; + if (map->flags == 0 && map->which_groups == 0 && + map->groups == 0 && map->which_mods == 0 && + map->mods.real_mods == 0 && map->mods.vmods == 0 && + map->ctrls == 0) + continue; + write_indicator_map(keymap, buf, size, offset, i); + } + + write_buf(keymap, buf, size, offset, "\t};\n\n"); + + return true; +} + +static bool +write_keysyms(struct xkb_keymap *keymap, char **buf, size_t *size, + size_t *offset, xkb_keycode_t key, unsigned int group) +{ + const xkb_keysym_t *syms; + int num_syms, level; +#define OUT_BUF_LEN 128 + char out_buf[OUT_BUF_LEN]; + + for (level = 0; level < XkbKeyGroupWidth(keymap, key, group); level++) { + if (level != 0) + write_buf(keymap, buf, size, offset, ", "); + num_syms = xkb_key_get_syms_by_level(keymap, key, group, level, + &syms); + if (num_syms == 0) { + write_buf(keymap, buf, size, offset, "%15s", "NoSymbol"); + } + else if (num_syms == 1) { + xkb_keysym_get_name(syms[0], out_buf, OUT_BUF_LEN); + write_buf(keymap, buf, size, offset, "%15s", out_buf); + } + else { + int s; + write_buf(keymap, buf, size, offset, "{ "); + for (s = 0; s < num_syms; s++) { + if (s != 0) + write_buf(keymap, buf, size, offset, ", "); + xkb_keysym_get_name(syms[s], out_buf, OUT_BUF_LEN); + write_buf(keymap, buf, size, offset, "%15s", out_buf); + } + write_buf(keymap, buf, size, offset, " }"); + } + } +#undef OUT_BUF_LEN + + return true; +} + +static bool +write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size, + size_t *offset) +{ + struct xkb_client_map *map = keymap->map; + struct xkb_server_map *srv = keymap->server; + xkb_keycode_t key; + int group, tmp; + bool showActions; + + write_buf(keymap, buf, size, offset, "\txkb_symbols {\n\n"); + + for (tmp = group = 0; group < XkbNumKbdGroups; group++) { + if (!keymap->names->groups[group]) + continue; + write_buf(keymap, buf, size, offset, + "\t\tname[group%d]=\"%s\";\n", group + 1, + keymap->names->groups[group]); + tmp++; + } + if (tmp > 0) + write_buf(keymap, buf, size, offset, "\n"); + + for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) { + bool simple = true; + + if (xkb_key_num_groups(keymap, key) == 0) + continue; + if (XkbcFindKeycodeByName(keymap, + darray_item(keymap->names->keys, key).name, + true) != key) + continue; + + write_buf(keymap, buf, size, offset, "\t\tkey %6s {", + XkbcKeyNameText(darray_item(keymap->names->keys, key).name)); + if (srv->explicit) { + if ((srv->explicit[key] & XkbExplicitKeyTypesMask)) { + bool multi_type = false; + int type = XkbKeyTypeIndex(keymap, key, 0); + + simple = false; + + for (group = 0; group < xkb_key_num_groups(keymap, key); group++) { + if (XkbKeyTypeIndex(keymap, key, group) != type) { + multi_type = true; + break; + } + } + if (multi_type) { + for (group = 0; + group < xkb_key_num_groups(keymap, key); + group++) { + if (!(srv->explicit[key] & (1 << group))) + continue; + type = XkbKeyTypeIndex(keymap, key, group); + write_buf(keymap, buf, size, offset, + "\n\t\t\ttype[Group%d]= \"%s\",", + group + 1, + darray_item(map->types, type).name); + } + } + else { + write_buf(keymap, buf, size, offset, + "\n\t\t\ttype= \"%s\",", + darray_item(map->types, type).name); + } + } + if (keymap->ctrls && (srv->explicit[key] & XkbExplicitAutoRepeatMask)) { + if (keymap->ctrls->per_key_repeat[key / 8] & (1 << (key % 8))) + write_buf(keymap, buf, size, offset, + "\n\t\t\trepeat= Yes,"); + else + write_buf(keymap, buf, size, offset, + "\n\t\t\trepeat= No,"); + simple = false; + } + if (keymap->server->vmodmap[key] && + (srv->explicit[key] & XkbExplicitVModMapMask)) { + write_buf(keymap, buf, size, offset, "\n\t\t\tvirtualMods= %s,", + get_mod_mask_text(keymap, 0, keymap->server->vmodmap[key])); + } + } + + switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(keymap, key))) { + case XkbClampIntoRange: + write_buf(keymap, buf, size, offset, "\n\t\t\tgroupsClamp,"); + break; + case XkbRedirectIntoRange: + write_buf(keymap, buf, size, offset, + "\n\t\t\tgroupsRedirect= Group%d,", + XkbOutOfRangeGroupNumber(XkbKeyGroupInfo(keymap, key)) + 1); + break; + } + + if (srv->explicit == NULL || + (srv->explicit[key] & XkbExplicitInterpretMask)) + showActions = XkbKeyHasActions(keymap, key); + else + showActions = false; + + if (xkb_key_num_groups(keymap, key) > 1 || showActions) + simple = false; + + if (simple) { + write_buf(keymap, buf, size, offset, "\t[ "); + if (!write_keysyms(keymap, buf, size, offset, key, 0)) + return false; + write_buf(keymap, buf, size, offset, " ] };\n"); + } + else { + union xkb_action *acts; + int level; + + acts = XkbKeyActionsPtr(keymap, key); + for (group = 0; group < xkb_key_num_groups(keymap, key); group++) { + if (group != 0) + write_buf(keymap, buf, size, offset, ","); + write_buf(keymap, buf, size, offset, + "\n\t\t\tsymbols[Group%d]= [ ", group + 1); + if (!write_keysyms(keymap, buf, size, offset, key, group)) + return false; + write_buf(keymap, buf, size, offset, " ]"); + if (showActions) { + write_buf(keymap, buf, size, offset, + ",\n\t\t\tactions[Group%d]= [ ", group + 1); + for (level = 0; + level < XkbKeyGroupWidth(keymap, key, group); + level++) { + if (level != 0) + write_buf(keymap, buf, size, offset, ", "); + write_action(keymap, buf, size, offset, &acts[level], + NULL, NULL); + } + write_buf(keymap, buf, size, offset, " ]"); + acts += XkbKeyGroupsWidth(keymap, key); + } + } + write_buf(keymap, buf, size, offset, "\n\t\t};\n"); + } + } + if (map && map->modmap) { + for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) { + int mod; + char name[5]; + + if (map->modmap[key] == 0) + continue; + + for (mod = 0; mod < XkbNumModifiers; mod++) { + if (!(map->modmap[key] & (1 << mod))) + continue; + + memcpy(name, darray_item(keymap->names->keys, key).name, 4); + name[4]= '\0'; + + write_buf(keymap, buf, size, offset, + "\t\tmodifier_map %s { <%s> };\n", + get_mod_index_text(mod), name); + } + } + } + + write_buf(keymap, buf, size, offset, "\t};\n\n"); + return true; +} + +_X_EXPORT char * +xkb_map_get_as_string(struct xkb_keymap *keymap) +{ + char *ret = NULL; + size_t size = 0; + size_t offset = 0; + + check_write_buf(keymap, &ret, &size, &offset, "xkb_keymap {\n"); + if (ret == NULL) + return NULL; + if (!write_keycodes(keymap, &ret, &size, &offset)) + return NULL; + if (!write_types(keymap, &ret, &size, &offset)) + return NULL; + if (!write_compat(keymap, &ret, &size, &offset)) + return NULL; + if (!write_symbols(keymap, &ret, &size, &offset)) + return NULL; + check_write_buf(keymap, &ret, &size, &offset, "};\n"); + if (ret == NULL) + return NULL; + + return ret; +} diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/map.c libxkbcommon-0.1.0~git20120530.c87468e9/src/map.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/map.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/map.c 2012-05-30 06:41:46.000000000 +0000 @@ -246,14 +246,15 @@ { struct xkb_keymap *keymap = state->keymap; struct xkb_key_type *type = XkbKeyType(keymap, key, group); + struct xkb_kt_map_entry *entry; unsigned int active_mods = state->mods & type->mods.mask; - int i; - for (i = 0; i < type->map_count; i++) { - if (!type->map[i].active) + darray_foreach(entry, type->map) { + if (!entry->active) continue; - if (type->map[i].mods.mask == active_mods) - return type->map[i].level; + + if (entry->mods.mask == active_mods) + return entry->level; } return 0; diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/misc.c libxkbcommon-0.1.0~git20120530.c87468e9/src/misc.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/misc.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/misc.c 2012-05-30 06:41:46.000000000 +0000 @@ -27,51 +27,77 @@ #include "xkb-priv.h" #include "alloc.h" -#define mapSize(m) (sizeof(m) / sizeof(struct xkb_kt_map_entry)) static struct xkb_kt_map_entry map2Level[]= { - { true, ShiftMask, {1, ShiftMask, 0} } + { + .active = true, + .level = ShiftMask, + .mods = {.mask = 1, .vmods = ShiftMask, .real_mods = 0 } + } }; static struct xkb_kt_map_entry mapAlpha[]= { - { true, ShiftMask, { 1, ShiftMask, 0 } }, - { true, LockMask, { 0, LockMask, 0 } } + { + .active = true, + .level = ShiftMask, + .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 } + }, + { + .active = true, + .level = LockMask, + .mods = { .mask = 0, .vmods = LockMask, .real_mods = 0 } + } }; static struct xkb_mods preAlpha[]= { - { 0, 0, 0 }, - { LockMask, LockMask, 0 } + { .mask = 0, .vmods = 0, .real_mods = 0 }, + { .mask = LockMask, .vmods = LockMask, .real_mods = 0 } }; #define NL_VMOD_MASK 0 -static struct xkb_kt_map_entry mapKeypad[]= { - { true, ShiftMask, { 1, ShiftMask, 0 } }, - { false, 0, { 1, 0, NL_VMOD_MASK } } +static struct xkb_kt_map_entry mapKeypad[]= { + { + .active = true, + .level = ShiftMask, + .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 } + }, + { + .active = false, + .level = 0, + .mods = { .mask = 1, .vmods = 0, .real_mods = NL_VMOD_MASK } + } }; -static struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = { - { { 0, 0, 0 }, - 1, /* num_levels */ - 0, /* map_count */ - NULL, NULL, - NULL, NULL +static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = { + { + .mods = { .mask = 0, .vmods = 0, .real_mods = 0 }, + .num_levels = 1, + .preserve = NULL, + .name = NULL, + .level_names = NULL }, - { { ShiftMask, ShiftMask, 0 }, - 2, /* num_levels */ - mapSize(map2Level), /* map_count */ - map2Level, NULL, - NULL, NULL + { + .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = 0 }, + .num_levels = 2, + .map = darray_lit(map2Level), + .preserve = NULL, + .name = NULL, + .level_names = NULL }, - { { ShiftMask|LockMask, ShiftMask|LockMask, 0 }, - 2, /* num_levels */ - mapSize(mapAlpha), /* map_count */ - mapAlpha, preAlpha, - NULL, NULL + { + .mods = { .mask = ShiftMask|LockMask, .vmods = ShiftMask|LockMask, .real_mods = 0 }, + .num_levels = 2, + .map = darray_lit(mapAlpha), + .preserve = preAlpha, + .name = NULL, + .level_names = NULL }, - { { ShiftMask, ShiftMask, NL_VMOD_MASK }, - 2, /* num_levels */ - mapSize(mapKeypad), /* map_count */ - mapKeypad, NULL, - NULL, NULL + { + .mods = { .mask = ShiftMask, .vmods = ShiftMask, .real_mods = NL_VMOD_MASK }, + .num_levels = 2, + .map = darray_lit(mapKeypad), + .preserve = NULL, + .name = NULL, + .level_names = NULL } }; @@ -80,7 +106,7 @@ int keypadVMod) { struct xkb_client_map * map; - struct xkb_key_type *from, *to; + const struct xkb_key_type *from; int rtrn; if (!keymap) @@ -96,37 +122,44 @@ rtrn = Success; from = canonicalTypes; - to = map->types; if (which & XkbOneLevelMask) - rtrn = XkbcCopyKeyType(&from[XkbOneLevelIndex], &to[XkbOneLevelIndex]); + rtrn = XkbcCopyKeyType(&from[XkbOneLevelIndex], + &darray_item(map->types, XkbOneLevelIndex)); if ((which & XkbTwoLevelMask) && (rtrn == Success)) - rtrn = XkbcCopyKeyType(&from[XkbTwoLevelIndex], &to[XkbTwoLevelIndex]); + rtrn = XkbcCopyKeyType(&from[XkbTwoLevelIndex], + &darray_item(map->types, XkbTwoLevelIndex)); if ((which & XkbAlphabeticMask) && (rtrn == Success)) rtrn = XkbcCopyKeyType(&from[XkbAlphabeticIndex], - &to[XkbAlphabeticIndex]); + &darray_item(map->types, XkbAlphabeticIndex)); if ((which & XkbKeypadMask) && (rtrn == Success)) { struct xkb_key_type * type; - rtrn = XkbcCopyKeyType(&from[XkbKeypadIndex], &to[XkbKeypadIndex]); - type = &to[XkbKeypadIndex]; + rtrn = XkbcCopyKeyType(&from[XkbKeypadIndex], + &darray_item(map->types, XkbKeypadIndex)); + type = &darray_item(map->types, XkbKeypadIndex); if ((keypadVMod >= 0) && (keypadVMod < XkbNumVirtualMods) && (rtrn == Success)) { + struct xkb_kt_map_entry *entry; type->mods.vmods = (1 << keypadVMod); - type->map[0].active = true; - type->map[0].mods.mask = ShiftMask; - type->map[0].mods.real_mods = ShiftMask; - type->map[0].mods.vmods = 0; - type->map[0].level = 1; - type->map[1].active = false; - type->map[1].mods.mask = 0; - type->map[1].mods.real_mods = 0; - type->map[1].mods.vmods = (1 << keypadVMod); - type->map[1].level = 1; + + entry = &darray_item(type->map, 0); + entry->active = true; + entry->mods.mask = ShiftMask; + entry->mods.real_mods = ShiftMask; + entry->mods.vmods = 0; + entry->level = 1; + + entry = &darray_item(type->map, 1); + entry->active = false; + entry->mods.mask = 0; + entry->mods.real_mods = 0; + entry->mods.vmods = (1 << keypadVMod); + entry->level = 1; } } @@ -210,3 +243,29 @@ return rtrn; } + +xkb_keycode_t +XkbcFindKeycodeByName(struct xkb_keymap *keymap, const char *name, + bool use_aliases) +{ + struct xkb_key_alias *alias; + xkb_keycode_t i; + + for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) { + if (strncmp(darray_item(keymap->names->keys, i).name, name, + XkbKeyNameLength) == 0) + return i; + } + + if (!use_aliases) + return 0; + + + for (i = 0; i < darray_size(keymap->names->key_aliases); i++) { + alias = &darray_item(keymap->names->key_aliases, i); + if (strncmp(name, alias->alias, XkbKeyNameLength) == 0) + return XkbcFindKeycodeByName(keymap, alias->real, false); + } + + return 0; +} diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/rules.c libxkbcommon-0.1.0~git20120530.c87468e9/src/rules.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/rules.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/rules.c 1970-01-01 00:00:00.000000000 +0000 @@ -1,996 +0,0 @@ -/************************************************************ - Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc. - - Permission to use, copy, modify, and distribute this - software and its documentation for any purpose and without - fee is hereby granted, provided that the above copyright - notice appear in all copies and that both that copyright - notice and this permission notice appear in supporting - documentation, and that the name of Silicon Graphics not be - used in advertising or publicity pertaining to distribution - of the software without specific prior written permission. - Silicon Graphics makes no representation about the suitability - of this software for any purpose. It is provided "as is" - without any express or implied warranty. - - SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS - SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON - GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL - DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, - DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH - THE USE OR PERFORMANCE OF THIS SOFTWARE. - - ********************************************************/ - -#include -#include - -#include "rules.h" - -#ifdef DEBUG -#define PR_DEBUG(s) fprintf(stderr,s) -#define PR_DEBUG1(s,a) fprintf(stderr,s,a) -#define PR_DEBUG2(s,a,b) fprintf(stderr,s,a,b) -#else -#define PR_DEBUG(s) -#define PR_DEBUG1(s,a) -#define PR_DEBUG2(s,a,b) -#endif - -/***====================================================================***/ - -#define DFLT_LINE_SIZE 128 - -typedef struct { - int line_num; - int sz_line; - int num_line; - char buf[DFLT_LINE_SIZE]; - char * line; -} InputLine; - -static void -InitInputLine(InputLine *line) -{ - line->line_num= 1; - line->num_line= 0; - line->sz_line= DFLT_LINE_SIZE; - line->line= line->buf; -} - -static void -FreeInputLine(InputLine *line) -{ - if (line->line!=line->buf) - free(line->line); - line->line_num= 1; - line->num_line= 0; - line->sz_line= DFLT_LINE_SIZE; - line->line= line->buf; -} - -static int -InputLineAddChar(InputLine *line,int ch) -{ - if (line->num_line>=line->sz_line) { - if (line->line==line->buf) { - line->line = malloc(line->sz_line * 2); - memcpy(line->line,line->buf,line->sz_line); - } - else { - line->line = realloc(line->line, line->sz_line * 2); - } - line->sz_line*= 2; - } - line->line[line->num_line++]= ch; - return ch; -} - -#define ADD_CHAR(l,c) ((l)->num_line<(l)->sz_line?\ - (int)((l)->line[(l)->num_line++]= (c)):\ - InputLineAddChar(l,c)) - -static bool -GetInputLine(FILE *file,InputLine *line,bool checkbang) -{ - int ch; - bool endOfFile,spacePending,slashPending,inComment; - - endOfFile= false; - while ((!endOfFile)&&(line->num_line==0)) { - spacePending= slashPending= inComment= false; - while (((ch=getc(file))!='\n')&&(ch!=EOF)) { - if (ch=='\\') { - if ((ch=getc(file))==EOF) - break; - if (ch=='\n') { - inComment= false; - ch= ' '; - line->line_num++; - } - } - if (inComment) - continue; - if (ch=='/') { - if (slashPending) { - inComment= true; - slashPending= false; - } - else { - slashPending= true; - } - continue; - } - else if (slashPending) { - if (spacePending) { - ADD_CHAR(line,' '); - spacePending= false; - } - ADD_CHAR(line,'/'); - slashPending= false; - } - if (isspace(ch)) { - while (isspace(ch)&&(ch!='\n')&&(ch!=EOF)) { - ch= getc(file); - } - if (ch==EOF) - break; - if ((ch!='\n')&&(line->num_line>0)) - spacePending= true; - ungetc(ch,file); - } - else { - if (spacePending) { - ADD_CHAR(line,' '); - spacePending= false; - } - if (checkbang && ch=='!') { - if (line->num_line!=0) { - PR_DEBUG("The '!' legal only at start of line\n"); - PR_DEBUG("Line containing '!' ignored\n"); - line->num_line= 0; - break; - } - - } - ADD_CHAR(line,ch); - } - } - if (ch==EOF) - endOfFile= true; -/* else line->num_line++;*/ - } - if ((line->num_line==0)&&(endOfFile)) - return false; - ADD_CHAR(line,'\0'); - return true; -} - -/***====================================================================***/ - -#define MODEL 0 -#define LAYOUT 1 -#define VARIANT 2 -#define OPTION 3 -#define KEYCODES 4 -#define SYMBOLS 5 -#define TYPES 6 -#define COMPAT 7 -#define GEOMETRY 8 -#define KEYMAP 9 -#define MAX_WORDS 10 - -#define PART_MASK 0x000F -#define COMPONENT_MASK 0x03F0 - -static const char * cname[MAX_WORDS] = { - "model", "layout", "variant", "option", - "keycodes", "symbols", "types", "compat", "geometry", "keymap" -}; - -typedef struct _RemapSpec { - int number; - int num_remap; - struct { - int word; - int index; - } remap[MAX_WORDS]; -} RemapSpec; - -typedef struct _FileSpec { - char * name[MAX_WORDS]; - struct _FileSpec * pending; -} FileSpec; - -typedef struct { - const char * model; - const char * layout[XkbNumKbdGroups+1]; - const char * variant[XkbNumKbdGroups+1]; - char * options; -} XkbRF_MultiDefsRec, *XkbRF_MultiDefsPtr; - -#define NDX_BUFF_SIZE 4 - -/***====================================================================***/ - -static char* -get_index(char *str, int *ndx) -{ - char ndx_buf[NDX_BUFF_SIZE]; - char *end; - - if (*str != '[') { - *ndx = 0; - return str; - } - str++; - end = strchr(str, ']'); - if (end == NULL) { - *ndx = -1; - return str - 1; - } - if ( (end - str) >= NDX_BUFF_SIZE) { - *ndx = -1; - return end + 1; - } - strncpy(ndx_buf, str, end - str); - ndx_buf[end - str] = '\0'; - *ndx = atoi(ndx_buf); - return end + 1; -} - -static void -SetUpRemap(InputLine *line,RemapSpec *remap) -{ - char *tok, *str; - unsigned present, l_ndx_present, v_ndx_present; - int i; - size_t len; - int ndx; - char *strtok_buf; -#ifdef DEBUG - bool found; -#endif - - - l_ndx_present = v_ndx_present = present= 0; - str= &line->line[1]; - len = remap->number; - memset(remap, 0, sizeof(RemapSpec)); - remap->number = len; - while ((tok = strtok_r(str, " ", &strtok_buf)) != NULL) { -#ifdef DEBUG - found= false; -#endif - str= NULL; - if (strcmp(tok,"=")==0) - continue; - for (i=0;i len) { - char *end = get_index(tok+len, &ndx); - if ((i != LAYOUT && i != VARIANT) || - *end != '\0' || ndx == -1) - break; - if (ndx < 1 || ndx > XkbNumKbdGroups) { - PR_DEBUG2("Illegal %s index: %d\n", cname[i], ndx); - PR_DEBUG1("Index must be in range 1..%d\n", - XkbNumKbdGroups); - break; - } - } else { - ndx = 0; - } -#ifdef DEBUG - found= true; -#endif - if (present&(1<remap[remap->num_remap].word= i; - remap->remap[remap->num_remap++].index= ndx; - break; - } - } -#ifdef DEBUG - if (!found) { - fprintf(stderr,"Unknown component \"%s\" ignored\n",tok); - } -#endif - } - if ((present&PART_MASK)==0) { -#ifdef DEBUG - unsigned mask= PART_MASK; - fprintf(stderr,"Mapping needs at least one of "); - for (i=0; (inum_remap= 0; - return; - } - if ((present&COMPONENT_MASK)==0) { - PR_DEBUG("Mapping needs at least one component\n"); - PR_DEBUG("Illegal mapping ignored\n"); - remap->num_remap= 0; - return; - } - if (((present&COMPONENT_MASK)&(1<num_remap= 0; - return; - } - remap->number++; -} - -static bool -MatchOneOf(char *wanted,char *vals_defined) -{ - char *str, *next; - int want_len = strlen(wanted); - - for (str=vals_defined,next=NULL;str!=NULL;str=next) { - int len; - next= strchr(str,','); - if (next) { - len= next-str; - next++; - } - else { - len= strlen(str); - } - if ((len==want_len)&&(strncmp(wanted,str,len)==0)) - return true; - } - return false; -} - -/***====================================================================***/ - -static bool -CheckLine( InputLine * line, - RemapSpec * remap, - XkbRF_RulePtr rule, - XkbRF_GroupPtr group) -{ - char *str, *tok; - int nread, i; - FileSpec tmp; - char *strtok_buf; - bool append = false; - - if (line->line[0]=='!') { - if (line->line[1] == '$' || - (line->line[1] == ' ' && line->line[2] == '$')) { - char *gname = strchr(line->line, '$'); - char *words = strchr(gname, ' '); - if(!words) - return false; - *words++ = '\0'; - for (; *words; words++) { - if (*words != '=' && *words != ' ') - break; - } - if (*words == '\0') - return false; - group->name = uDupString(gname); - group->words = uDupString(words); - for (i = 1, words = group->words; *words; words++) { - if ( *words == ' ') { - *words++ = '\0'; - i++; - } - } - group->number = i; - return true; - } else { - SetUpRemap(line,remap); - return false; - } - } - - if (remap->num_remap==0) { - PR_DEBUG("Must have a mapping before first line of data\n"); - PR_DEBUG("Illegal line of data ignored\n"); - return false; - } - memset(&tmp, 0, sizeof(FileSpec)); - str= line->line; - for (nread = 0; (tok = strtok_r(str, " ", &strtok_buf)) != NULL; nread++) { - str= NULL; - if (strcmp(tok,"=")==0) { - nread--; - continue; - } - if (nread>remap->num_remap) { - PR_DEBUG("Too many words on a line\n"); - PR_DEBUG1("Extra word \"%s\" ignored\n",tok); - continue; - } - tmp.name[remap->remap[nread].word]= tok; - if (*tok == '+' || *tok == '|') - append = true; - } - if (nreadnum_remap) { - PR_DEBUG1("Too few words on a line: %s\n", line->line); - PR_DEBUG("line ignored\n"); - return false; - } - - rule->flags= 0; - rule->number = remap->number; - if (tmp.name[OPTION]) - rule->flags|= XkbRF_Option; - else if (append) - rule->flags|= XkbRF_Append; - else - rule->flags|= XkbRF_Normal; - rule->model= uDupString(tmp.name[MODEL]); - rule->layout= uDupString(tmp.name[LAYOUT]); - rule->variant= uDupString(tmp.name[VARIANT]); - rule->option= uDupString(tmp.name[OPTION]); - - rule->keycodes= uDupString(tmp.name[KEYCODES]); - rule->symbols= uDupString(tmp.name[SYMBOLS]); - rule->types= uDupString(tmp.name[TYPES]); - rule->compat= uDupString(tmp.name[COMPAT]); - rule->keymap= uDupString(tmp.name[KEYMAP]); - - rule->layout_num = rule->variant_num = 0; - for (i = 0; i < nread; i++) { - if (remap->remap[i].index) { - if (remap->remap[i].word == LAYOUT) - rule->layout_num = remap->remap[i].index; - if (remap->remap[i].word == VARIANT) - rule->variant_num = remap->remap[i].index; - } - } - return true; -} - -static char * -_Concat(char *str1,char *str2) -{ - int len; - - if ((!str1)||(!str2)) - return str1; - len= strlen(str1)+strlen(str2)+1; - str1 = uTypedRealloc(str1, len, char); - if (str1) - strcat(str1,str2); - return str1; -} - -static void -squeeze_spaces(char *p1) -{ - char *p2; - for (p2 = p1; *p2; p2++) { - *p1 = *p2; - if (*p1 != ' ') p1++; - } - *p1 = '\0'; -} - -static bool -MakeMultiDefs(XkbRF_MultiDefsPtr mdefs, XkbRF_VarDefsPtr defs) -{ - memset(mdefs, 0, sizeof(XkbRF_MultiDefsRec)); - mdefs->model = defs->model; - mdefs->options = uDupString(defs->options); - if (mdefs->options) squeeze_spaces(mdefs->options); - - if (defs->layout) { - if (!strchr(defs->layout, ',')) { - mdefs->layout[0] = defs->layout; - } else { - char *p; - int i; - p = uDupString(defs->layout); - if (p == NULL) - return false; - squeeze_spaces(p); - mdefs->layout[1] = p; - for (i = 2; i <= XkbNumKbdGroups; i++) { - if ((p = strchr(p, ','))) { - *p++ = '\0'; - mdefs->layout[i] = p; - } else { - break; - } - } - if (p && (p = strchr(p, ','))) - *p = '\0'; - } - } - - if (defs->variant) { - if (!strchr(defs->variant, ',')) { - mdefs->variant[0] = defs->variant; - } else { - char *p; - int i; - p = uDupString(defs->variant); - if (p == NULL) - return false; - squeeze_spaces(p); - mdefs->variant[1] = p; - for (i = 2; i <= XkbNumKbdGroups; i++) { - if ((p = strchr(p, ','))) { - *p++ = '\0'; - mdefs->variant[i] = p; - } else { - break; - } - } - if (p && (p = strchr(p, ','))) - *p = '\0'; - } - } - return true; -} - -static void -FreeMultiDefs(XkbRF_MultiDefsPtr defs) -{ - free(defs->options); - free(UNCONSTIFY(defs->layout[1])); - free(UNCONSTIFY(defs->variant[1])); -} - -static void -Apply(char *src, char **dst) -{ - if (src) { - if (*src == '+' || *src == '!') { - *dst= _Concat(*dst, src); - } else { - if (*dst == NULL) - *dst= uDupString(src); - } - } -} - -static void -XkbRF_ApplyRule( XkbRF_RulePtr rule, - struct xkb_component_names * names) -{ - rule->flags&= ~XkbRF_PendingMatch; /* clear the flag because it's applied */ - - Apply(rule->keycodes, &names->keycodes); - Apply(rule->symbols, &names->symbols); - Apply(rule->types, &names->types); - Apply(rule->compat, &names->compat); - Apply(rule->keymap, &names->keymap); -} - -static bool -CheckGroup( XkbRF_RulesPtr rules, - const char * group_name, - const char * name) -{ - int i; - const char *p; - XkbRF_GroupPtr group; - - for (i = 0, group = rules->groups; i < rules->num_groups; i++, group++) { - if (! strcmp(group->name, group_name)) { - break; - } - } - if (i == rules->num_groups) - return false; - for (i = 0, p = group->words; i < group->number; i++, p += strlen(p)+1) { - if (! strcmp(p, name)) { - return true; - } - } - return false; -} - -static int -XkbRF_CheckApplyRule( XkbRF_RulePtr rule, - XkbRF_MultiDefsPtr mdefs, - struct xkb_component_names * names, - XkbRF_RulesPtr rules) -{ - bool pending = false; - - if (rule->model != NULL) { - if(mdefs->model == NULL) - return 0; - if (strcmp(rule->model, "*") == 0) { - pending = true; - } else { - if (rule->model[0] == '$') { - if (!CheckGroup(rules, rule->model, mdefs->model)) - return 0; - } else { - if (strcmp(rule->model, mdefs->model) != 0) - return 0; - } - } - } - if (rule->option != NULL) { - if (mdefs->options == NULL) - return 0; - if ((!MatchOneOf(rule->option,mdefs->options))) - return 0; - } - - if (rule->layout != NULL) { - if(mdefs->layout[rule->layout_num] == NULL || - *mdefs->layout[rule->layout_num] == '\0') - return 0; - if (strcmp(rule->layout, "*") == 0) { - pending = true; - } else { - if (rule->layout[0] == '$') { - if (!CheckGroup(rules, rule->layout, - mdefs->layout[rule->layout_num])) - return 0; - } else { - if (strcmp(rule->layout, mdefs->layout[rule->layout_num]) != 0) - return 0; - } - } - } - if (rule->variant != NULL) { - if (mdefs->variant[rule->variant_num] == NULL || - *mdefs->variant[rule->variant_num] == '\0') - return 0; - if (strcmp(rule->variant, "*") == 0) { - pending = true; - } else { - if (rule->variant[0] == '$') { - if (!CheckGroup(rules, rule->variant, - mdefs->variant[rule->variant_num])) - return 0; - } else { - if (strcmp(rule->variant, - mdefs->variant[rule->variant_num]) != 0) - return 0; - } - } - } - if (pending) { - rule->flags|= XkbRF_PendingMatch; - return rule->number; - } - /* exact match, apply it now */ - XkbRF_ApplyRule(rule,names); - return rule->number; -} - -static void -XkbRF_ClearPartialMatches(XkbRF_RulesPtr rules) -{ - int i; - XkbRF_RulePtr rule; - - for (i=0,rule=rules->rules;inum_rules;i++,rule++) { - rule->flags&= ~XkbRF_PendingMatch; - } -} - -static void -XkbRF_ApplyPartialMatches(XkbRF_RulesPtr rules,struct xkb_component_names * names) -{ - int i; - XkbRF_RulePtr rule; - - for (rule = rules->rules, i = 0; i < rules->num_rules; i++, rule++) { - if ((rule->flags&XkbRF_PendingMatch)==0) - continue; - XkbRF_ApplyRule(rule,names); - } -} - -static void -XkbRF_CheckApplyRules( XkbRF_RulesPtr rules, - XkbRF_MultiDefsPtr mdefs, - struct xkb_component_names * names, - unsigned int flags) -{ - int i; - XkbRF_RulePtr rule; - int skip; - - for (rule = rules->rules, i=0; i < rules->num_rules; rule++, i++) { - if ((rule->flags & flags) != flags) - continue; - skip = XkbRF_CheckApplyRule(rule, mdefs, names, rules); - if (skip && !(flags & XkbRF_Option)) { - for ( ;(i < rules->num_rules) && (rule->number == skip); - rule++, i++); - rule--; i--; - } - } -} - -/***====================================================================***/ - -static char * -XkbRF_SubstituteVars(char *name, XkbRF_MultiDefsPtr mdefs) -{ - char *str, *outstr, *orig, *var; - size_t len; - int ndx; - - orig= name; - str= strchr(name,'%'); - if (str==NULL) - return name; - len= strlen(name); - while (str!=NULL) { - char pfx= str[1]; - int extra_len= 0; - if ((pfx=='+')||(pfx=='|')||(pfx=='_')||(pfx=='-')) { - extra_len= 1; - str++; - } - else if (pfx=='(') { - extra_len= 2; - str++; - } - var = str + 1; - str = get_index(var + 1, &ndx); - if (ndx == -1) { - str = strchr(str,'%'); - continue; - } - if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx]) - len+= strlen(mdefs->layout[ndx])+extra_len; - else if ((*var=='m')&&mdefs->model) - len+= strlen(mdefs->model)+extra_len; - else if ((*var=='v') && mdefs->variant[ndx] && *mdefs->variant[ndx]) - len+= strlen(mdefs->variant[ndx])+extra_len; - if ((pfx=='(')&&(*str==')')) { - str++; - } - str= strchr(&str[0],'%'); - } - name = malloc(len + 1); - str= orig; - outstr= name; - while (*str!='\0') { - if (str[0]=='%') { - char pfx,sfx; - str++; - pfx= str[0]; - sfx= '\0'; - if ((pfx=='+')||(pfx=='|')||(pfx=='_')||(pfx=='-')) { - str++; - } - else if (pfx=='(') { - sfx= ')'; - str++; - } - else pfx= '\0'; - - var = str; - str = get_index(var + 1, &ndx); - if (ndx == -1) { - continue; - } - if ((*var=='l') && mdefs->layout[ndx] && *mdefs->layout[ndx]) { - if (pfx) *outstr++= pfx; - strcpy(outstr,mdefs->layout[ndx]); - outstr+= strlen(mdefs->layout[ndx]); - if (sfx) *outstr++= sfx; - } - else if ((*var=='m')&&(mdefs->model)) { - if (pfx) *outstr++= pfx; - strcpy(outstr,mdefs->model); - outstr+= strlen(mdefs->model); - if (sfx) *outstr++= sfx; - } - else if ((*var=='v') && mdefs->variant[ndx] && *mdefs->variant[ndx]) { - if (pfx) *outstr++= pfx; - strcpy(outstr,mdefs->variant[ndx]); - outstr+= strlen(mdefs->variant[ndx]); - if (sfx) *outstr++= sfx; - } - if ((pfx=='(')&&(*str==')')) - str++; - } - else { - *outstr++= *str++; - } - } - *outstr++= '\0'; - if (orig!=name) - free(orig); - return name; -} - -/***====================================================================***/ - -bool -XkbcRF_GetComponents( XkbRF_RulesPtr rules, - XkbRF_VarDefsPtr defs, - struct xkb_component_names * names) -{ - XkbRF_MultiDefsRec mdefs; - - MakeMultiDefs(&mdefs, defs); - - memset(names, 0, sizeof(struct xkb_component_names)); - XkbRF_ClearPartialMatches(rules); - XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Normal); - XkbRF_ApplyPartialMatches(rules, names); - XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Append); - XkbRF_ApplyPartialMatches(rules, names); - XkbRF_CheckApplyRules(rules, &mdefs, names, XkbRF_Option); - XkbRF_ApplyPartialMatches(rules, names); - - if (names->keycodes) - names->keycodes= XkbRF_SubstituteVars(names->keycodes, &mdefs); - if (names->symbols) - names->symbols= XkbRF_SubstituteVars(names->symbols, &mdefs); - if (names->types) - names->types= XkbRF_SubstituteVars(names->types, &mdefs); - if (names->compat) - names->compat= XkbRF_SubstituteVars(names->compat, &mdefs); - if (names->keymap) - names->keymap= XkbRF_SubstituteVars(names->keymap, &mdefs); - - FreeMultiDefs(&mdefs); - return (names->keycodes && names->symbols && names->types && - names->compat) || names->keymap; -} - -static XkbRF_RulePtr -XkbcRF_AddRule(XkbRF_RulesPtr rules) -{ - if (rules->sz_rules<1) { - rules->sz_rules= 16; - rules->num_rules= 0; - rules->rules= uTypedCalloc(rules->sz_rules,XkbRF_RuleRec); - } - else if (rules->num_rules>=rules->sz_rules) { - rules->sz_rules*= 2; - rules->rules= uTypedRealloc(rules->rules,rules->sz_rules, - XkbRF_RuleRec); - } - if (!rules->rules) { - rules->sz_rules= rules->num_rules= 0; -#ifdef DEBUG - fprintf(stderr,"Allocation failure in XkbcRF_AddRule\n"); -#endif - return NULL; - } - memset(&rules->rules[rules->num_rules], 0, sizeof(XkbRF_RuleRec)); - return &rules->rules[rules->num_rules++]; -} - -static XkbRF_GroupPtr -XkbcRF_AddGroup(XkbRF_RulesPtr rules) -{ - if (rules->sz_groups<1) { - rules->sz_groups= 16; - rules->num_groups= 0; - rules->groups= uTypedCalloc(rules->sz_groups,XkbRF_GroupRec); - } - else if (rules->num_groups >= rules->sz_groups) { - rules->sz_groups *= 2; - rules->groups= uTypedRealloc(rules->groups,rules->sz_groups, - XkbRF_GroupRec); - } - if (!rules->groups) { - rules->sz_groups= rules->num_groups= 0; - return NULL; - } - - memset(&rules->groups[rules->num_groups], 0, sizeof(XkbRF_GroupRec)); - return &rules->groups[rules->num_groups++]; -} - -bool -XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules) -{ -InputLine line; -RemapSpec remap; -XkbRF_RuleRec trule,*rule; -XkbRF_GroupRec tgroup,*group; - - if (!(rules && file)) - return false; - memset(&remap, 0, sizeof(RemapSpec)); - memset(&tgroup, 0, sizeof(XkbRF_GroupRec)); - InitInputLine(&line); - while (GetInputLine(file, &line, true)) { - if (CheckLine(&line,&remap,&trule,&tgroup)) { - if (tgroup.number) { - if ((group= XkbcRF_AddGroup(rules))!=NULL) { - *group= tgroup; - memset(&tgroup, 0, sizeof(XkbRF_GroupRec)); - } - } else { - if ((rule= XkbcRF_AddRule(rules))!=NULL) { - *rule= trule; - memset(&trule, 0, sizeof(XkbRF_RuleRec)); - } - } - } - line.num_line= 0; - } - FreeInputLine(&line); - return true; -} - -static void -XkbRF_ClearVarDescriptions(XkbRF_DescribeVarsPtr var) -{ - int i; - - for (i=0;inum_desc;i++) { - free(var->desc[i].name); - free(var->desc[i].desc); - var->desc[i].name= var->desc[i].desc= NULL; - } - free(var->desc); - var->desc= NULL; -} - -void -XkbcRF_Free(XkbRF_RulesPtr rules) -{ - int i; - XkbRF_RulePtr rule; - XkbRF_GroupPtr group; - - if (!rules) - return; - XkbRF_ClearVarDescriptions(&rules->models); - XkbRF_ClearVarDescriptions(&rules->layouts); - XkbRF_ClearVarDescriptions(&rules->variants); - XkbRF_ClearVarDescriptions(&rules->options); - if (rules->extra) { - for (i = 0; i < rules->num_extra; i++) { - XkbRF_ClearVarDescriptions(&rules->extra[i]); - } - free(rules->extra); - } - for (i=0, rule = rules->rules; i < rules->num_rules && rules; i++, rule++) { - free(rule->model); - free(rule->layout); - free(rule->variant); - free(rule->option); - free(rule->keycodes); - free(rule->symbols); - free(rule->types); - free(rule->compat); - free(rule->keymap); - } - free(rules->rules); - - for (i=0, group = rules->groups; i < rules->num_groups && group; i++, group++) { - free(group->name); - free(group->words); - } - free(rules->groups); - - free(rules); -} diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/rules.h libxkbcommon-0.1.0~git20120530.c87468e9/src/rules.h --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/rules.h 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/rules.h 1970-01-01 00:00:00.000000000 +0000 @@ -1,113 +0,0 @@ -/* -Copyright 2009 Dan Nicholson - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN -ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the names of the authors or their -institutions shall not be used in advertising or otherwise to promote the -sale, use or other dealings in this Software without prior written -authorization from the authors. -*/ - -#ifndef RULES_H -#define RULES_H - -#include - -#include "xkb-priv.h" - -/* From filecommon */ - -typedef struct _XkbRF_VarDefs { - const char * model; - const char * layout; - const char * variant; - const char * options; - unsigned short sz_extra; - unsigned short num_extra; - char * extra_names; - char ** extra_values; -} XkbRF_VarDefsRec,*XkbRF_VarDefsPtr; - -typedef struct _XkbRF_VarDesc { - char * name; - char * desc; -} XkbRF_VarDescRec, *XkbRF_VarDescPtr; - -typedef struct _XkbRF_DescribeVars { - int sz_desc; - int num_desc; - XkbRF_VarDescPtr desc; -} XkbRF_DescribeVarsRec,*XkbRF_DescribeVarsPtr; - -typedef struct _XkbRF_Rule { - int number; - int layout_num; - int variant_num; - char * model; - char * layout; - char * variant; - char * option; - /* yields */ - char * keycodes; - char * symbols; - char * types; - char * compat; - char * keymap; - unsigned flags; -} XkbRF_RuleRec,*XkbRF_RulePtr; - -typedef struct _XkbRF_Group { - int number; - char * name; - char * words; -} XkbRF_GroupRec, *XkbRF_GroupPtr; - -#define XkbRF_PendingMatch (1L<<1) -#define XkbRF_Option (1L<<2) -#define XkbRF_Append (1L<<3) -#define XkbRF_Normal (1L<<4) -#define XkbRF_Invalid (1L<<5) - -typedef struct _XkbRF_Rules { - XkbRF_DescribeVarsRec models; - XkbRF_DescribeVarsRec layouts; - XkbRF_DescribeVarsRec variants; - XkbRF_DescribeVarsRec options; - unsigned short num_extra; - XkbRF_DescribeVarsPtr extra; - - unsigned short sz_rules; - unsigned short num_rules; - XkbRF_RulePtr rules; - unsigned short sz_groups; - unsigned short num_groups; - XkbRF_GroupPtr groups; -} XkbRF_RulesRec, *XkbRF_RulesPtr; - -extern bool -XkbcRF_GetComponents(XkbRF_RulesPtr rules, XkbRF_VarDefsPtr defs, - struct xkb_component_names * names); - -extern bool -XkbcRF_LoadRules(FILE *file, XkbRF_RulesPtr rules); - -extern void -XkbcRF_Free(XkbRF_RulesPtr rules); - -#endif /* RULES_H */ diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkb.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkb.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkb.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkb.c 2012-05-30 06:41:46.000000000 +0000 @@ -119,7 +119,6 @@ XkbcComputeEffectiveMap(struct xkb_keymap *keymap, struct xkb_key_type *type, unsigned char *map_rtrn) { - int i; unsigned tmp; struct xkb_kt_map_entry * entry = NULL; @@ -131,8 +130,7 @@ return false; type->mods.mask = tmp | type->mods.real_mods; - entry = type->map; - for (i = 0; i < type->map_count; i++, entry++) { + darray_foreach(entry, type->map) { tmp = 0; if (entry->mods.vmods != 0) { if (!VirtualModsToReal(keymap, entry->mods.vmods, &tmp)) @@ -152,8 +150,8 @@ if (map_rtrn) { memset(map_rtrn, 0, type->mods.mask + 1); if (entry && entry->active) - for (i = 0; i < type->map_count; i++) - map_rtrn[type->map[i].mods.mask] = type->map[i].level; + darray_foreach(entry, type->map) + map_rtrn[entry->mods.mask] = entry->level; } return true; diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/alias.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/alias.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/alias.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/alias.c 2012-05-30 06:41:46.000000000 +0000 @@ -157,8 +157,8 @@ if (*info_in == NULL) return true; - nOld = (keymap->names ? keymap->names->num_key_aliases : 0); - old = (keymap->names ? keymap->names->key_aliases : NULL); + nOld = (keymap->names ? darray_size(keymap->names->key_aliases) : 0); + old = (keymap->names ? &darray_item(keymap->names->key_aliases, 0) : NULL); for (nNew = 0, info = *info_in; info != NULL; info = (AliasInfo *) info->def.next) { @@ -214,15 +214,14 @@ *info_in = NULL; return true; } + status = XkbcAllocNames(keymap, XkbKeyAliasesMask, nOld + nNew); - if (keymap->names) - old = keymap->names->key_aliases; if (status != Success) { WSGO("Allocation failure in ApplyAliases\n"); return false; } - a = keymap->names ? &keymap->names->key_aliases[nOld] : NULL; + a = keymap->names ? &darray_item(keymap->names->key_aliases, nOld) : NULL; for (info = *info_in; info != NULL; info = (AliasInfo *) info->def.next) { if (info->alias[0] != '\0') diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/compat.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/compat.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/compat.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/compat.c 2012-05-30 06:41:46.000000000 +0000 @@ -386,12 +386,13 @@ } } -typedef void (*FileHandler) (XkbFile *rtrn, struct xkb_keymap *keymap, - unsigned merge, CompatInfo *info); +static void +HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, unsigned merge, + CompatInfo *info); static bool HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap, - CompatInfo *info, FileHandler hndlr) + CompatInfo *info) { unsigned newMerge; XkbFile *rtrn; @@ -416,7 +417,7 @@ included.ledDflt.defs.fileID = rtrn->id; included.ledDflt.defs.merge = newMerge; included.act = info->act; - (*hndlr) (rtrn, keymap, MergeOverride, &included); + HandleCompatMapFile(rtrn, keymap, MergeOverride, &included); if (stmt->stmt != NULL) { free(included.name); @@ -457,7 +458,7 @@ next_incl.ledDflt.defs.fileID = rtrn->id; next_incl.ledDflt.defs.merge = op; next_incl.act = info->act; - (*hndlr) (rtrn, keymap, MergeOverride, &next_incl); + HandleCompatMapFile(rtrn, keymap, MergeOverride, &next_incl); MergeIncludedCompatMaps(&included, &next_incl, op); if (info->act != NULL) next_incl.act = NULL; @@ -710,8 +711,7 @@ switch (stmt->stmtType) { case StmtInclude: - if (!HandleIncludeCompatMap((IncludeStmt *) stmt, keymap, info, - HandleCompatMapFile)) + if (!HandleIncludeCompatMap((IncludeStmt *) stmt, keymap, info)) info->errorCount++; break; case StmtInterpDef: @@ -776,13 +776,7 @@ (needSymbol && (si->interp.sym == XKB_KEY_NoSymbol)) || ((!needSymbol) && (si->interp.sym != XKB_KEY_NoSymbol))) continue; - if (compat->num_si >= compat->size_si) - { - WSGO("No room to merge symbol interpretations\n"); - ACTION("Symbol interpretations lost\n"); - return; - } - compat->sym_interpret[compat->num_si++] = si->interp; + darray_append(compat->sym_interpret, si->interp); } } @@ -893,16 +887,15 @@ uint32_t group, uint32_t level) { struct xkb_sym_interpret *ret = NULL; + struct xkb_sym_interpret *interp; const xkb_keysym_t *syms; int num_syms; - int i; num_syms = xkb_key_get_syms_by_level(keymap, key, group, level, &syms); if (num_syms == 0) return NULL; - for (i = 0; i < keymap->compat->num_si; i++) { - struct xkb_sym_interpret *interp = &keymap->compat->sym_interpret[i]; + darray_foreach(interp, keymap->compat->sym_interpret) { uint32_t mods; bool found; @@ -1032,6 +1025,8 @@ { xkb_keycode_t key; int i; + struct xkb_key_type *type; + struct xkb_kt_map_entry *entry; /* Find all the interprets for the key and bind them to actions, * which will also update the vmodmap. */ @@ -1053,8 +1048,7 @@ } /* Now update the level masks for all the types to reflect the vmods. */ - for (i = 0; i < keymap->map->num_types; i++) { - struct xkb_key_type *type = &keymap->map->types[i]; + darray_foreach(type, keymap->map->types) { uint32_t mask = 0; int j; type->mods.mask = type->mods.real_mods; @@ -1064,10 +1058,10 @@ continue; mask |= keymap->server->vmods[j]; } - for (j = 0; j < type->map_count; j++) { - struct xkb_mods *mods = &type->map[j].mods; - mods->mask = mods->real_mods | VModsToReal(keymap, mods->vmods); - } + + darray_foreach(entry, type->map) + entry->mods.mask = entry->mods.real_mods | + VModsToReal(keymap, entry->mods.vmods); } /* Update action modifiers. */ diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/keycodes.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/keycodes.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/keycodes.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/keycodes.c 2012-05-30 06:41:46.000000000 +0000 @@ -69,10 +69,9 @@ xkb_keycode_t computedMax; /* highest keycode stored */ xkb_keycode_t explicitMin; xkb_keycode_t explicitMax; - xkb_keycode_t arraySize; - unsigned long *names; - unsigned *files; - unsigned char *has_alt_forms; + darray(unsigned long) names; + darray(unsigned int) files; + darray(unsigned char) has_alt_forms; IndicatorNameInfo *leds; AliasInfo *aliases; } KeyNamesInfo; @@ -80,51 +79,15 @@ static void HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap, unsigned merge, KeyNamesInfo *info); -static int +static void ResizeKeyNameArrays(KeyNamesInfo *info, int newMax) { - void *tmp; - int i; - - tmp = uTypedRealloc(info->names, newMax + 1, unsigned long); - if (!tmp) { - ERROR - ("Couldn't reallocate for larger maximum keycode (%d)\n", - newMax); - ACTION("Maximum key value not changed\n"); - return 0; - } - info->names = tmp; - for (i = info->arraySize + 1; i <= newMax; i++) - info->names[i] = 0; - - tmp = uTypedRealloc(info->files, newMax + 1, unsigned); - if (!tmp) { - ERROR - ("Couldn't reallocate for larger maximum keycode (%d)\n", - newMax); - ACTION("Maximum key value not changed\n"); - return 0; - } - info->files = tmp; - for (i = info->arraySize + 1; i <= newMax; i++) - info->files[i] = 0; - - tmp = uTypedRealloc(info->has_alt_forms, newMax + 1, unsigned char); - if (!tmp) { - ERROR - ("Couldn't reallocate for larger maximum keycode (%d)\n", - newMax); - ACTION("Maximum key value not changed\n"); - return 0; - } - info->has_alt_forms = tmp; - for (i = info->arraySize + 1; i <= newMax; i++) - info->has_alt_forms[i] = 0; - - info->arraySize = newMax; + if (newMax < darray_size(info->names)) + return; - return 1; + darray_resize0(info->names, newMax + 1); + darray_resize0(info->files, newMax + 1); + darray_resize0(info->has_alt_forms, newMax + 1); } static void @@ -193,14 +156,13 @@ } static bool -AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, +AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, unsigned merge, IndicatorNameInfo *new) { IndicatorNameInfo *old; bool replace; - replace = (new->defs.merge == MergeReplace) || - (new->defs.merge == MergeOverride); + replace = (merge == MergeReplace) || (merge == MergeOverride); old = FindIndicatorByName(info, new->name); if (old) { @@ -318,13 +280,12 @@ info->name = NULL; info->computedMax = info->explicitMax = info->explicitMin = 0; info->computedMin = XKB_KEYCODE_MAX; - info->arraySize = 0; - free(info->names); - info->names = NULL; - free(info->files); - info->files = NULL; - free(info->has_alt_forms); - info->has_alt_forms = NULL; + darray_free(info->names); + darray_init(info->names); + darray_free(info->files); + darray_init(info->files); + darray_free(info->has_alt_forms); + darray_init(info->has_alt_forms); if (info->leds) ClearIndicatorNameInfo(info->leds, info); if (info->aliases) @@ -337,9 +298,9 @@ info->name = NULL; info->leds = NULL; info->aliases = NULL; - info->names = NULL; - info->files = NULL; - info->has_alt_forms = NULL; + darray_init(info->names); + darray_init(info->files); + darray_init(info->has_alt_forms); ClearKeyNamesInfo(info); info->errorCount = 0; } @@ -350,10 +311,9 @@ uint64_t i; for (i = info->computedMin; i <= info->computedMax; i++) - { - if (info->names[i] == name) + if (darray_item(info->names, i) == name) return i; - } + return 0; } @@ -370,11 +330,8 @@ xkb_keycode_t old; unsigned long lval; - if (kc > info->arraySize && !ResizeKeyNameArrays(info, kc)) { - ERROR("Couldn't resize KeyNames arrays for keycode %d\n", kc); - ACTION("Ignoring key %d\n", kc); - return false; - } + ResizeKeyNameArrays(info, kc); + if (kc < info->computedMin) info->computedMin = kc; if (kc > info->computedMax) @@ -383,25 +340,23 @@ if (reportCollisions) { - reportCollisions = ((warningLevel > 7) || - ((warningLevel > 0) - && (fileID == info->files[kc]))); + reportCollisions = (warningLevel > 7 || + (warningLevel > 0 && + fileID == darray_item(info->files, kc))); } - if (info->names[kc] != 0) + if (darray_item(info->names, kc) != 0) { char buf[6]; - LongToKeyName(info->names[kc], buf); + LongToKeyName(darray_item(info->names, kc), buf); buf[4] = '\0'; - if (info->names[kc] == lval) + if (darray_item(info->names, kc) == lval) { - if (info->has_alt_forms[kc] || (merge == MergeAltForm)) - { - info->has_alt_forms[kc] = true; + if (darray_item(info->has_alt_forms, kc) || (merge == MergeAltForm)) { + darray_item(info->has_alt_forms, kc) = true; } - else if (reportCollisions) - { + else if (reportCollisions) { WARN("Multiple identical key name definitions\n"); ACTION("Later occurences of \"<%s> = %d\" ignored\n", buf, kc); @@ -424,8 +379,8 @@ WARN("Multiple names for keycode %d\n", kc); ACTION("Using <%s>, ignoring <%s>\n", name, buf); } - info->names[kc] = 0; - info->files[kc] = 0; + darray_item(info->names, kc) = 0; + darray_item(info->files, kc) = 0; } } old = FindKeyByLong(info, lval); @@ -433,9 +388,9 @@ { if (merge == MergeOverride) { - info->names[old] = 0; - info->files[old] = 0; - info->has_alt_forms[old] = true; + darray_item(info->names, old) = 0; + darray_item(info->files, old) = 0; + darray_item(info->has_alt_forms, old) = true; if (reportCollisions) { WARN("Key name <%s> assigned to multiple keys\n", name); @@ -455,12 +410,12 @@ } else { - info->has_alt_forms[old] = true; + darray_item(info->has_alt_forms, old) = true; } } - info->names[kc] = lval; - info->files[kc] = fileID; - info->has_alt_forms[kc] = (merge == MergeAltForm); + darray_item(info->names, kc) = lval; + darray_item(info->files, kc) = fileID; + darray_item(info->has_alt_forms, kc) = (merge == MergeAltForm); return true; } @@ -483,22 +438,17 @@ into->name = from->name; from->name = NULL; } - if (from->computedMax > into->arraySize && - !ResizeKeyNameArrays(into, from->computedMax)) { - ERROR("Couldn't resize KeyNames arrays for key %d\n", - from->computedMax); - ACTION("Ignoring include file %s\n", from->name); - into->errorCount += 10; - return; - } + + ResizeKeyNameArrays(into, from->computedMax); + for (i = from->computedMin; i <= from->computedMax; i++) { unsigned thisMerge; - if (from->names[i] == 0) + if (darray_item(from->names, i) == 0) continue; - LongToKeyName(from->names[i], buf); + LongToKeyName(darray_item(from->names, i), buf); buf[4] = '\0'; - if (from->has_alt_forms[i]) + if (darray_item(from->has_alt_forms, i)) thisMerge = MergeAltForm; else thisMerge = merge; @@ -512,7 +462,7 @@ { if (merge != MergeDefault) led->defs.merge = merge; - if (!AddIndicatorName(into, keymap, led)) + if (!AddIndicatorName(into, keymap, led->defs.merge, led)) into->errorCount++; next = (IndicatorNameInfo *) led->defs.next; } @@ -757,7 +707,7 @@ static int HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap, - KeyNamesInfo *info) + unsigned merge, KeyNamesInfo *info) { IndicatorNameInfo ii; ExprResult tmp; @@ -781,7 +731,7 @@ ii.name = xkb_atom_intern(keymap->ctx, tmp.str); free(tmp.str); ii.virtual = def->virtual; - if (!AddIndicatorName(info, keymap, &ii)) + if (!AddIndicatorName(info, keymap, merge, &ii)) return false; return true; } @@ -830,7 +780,8 @@ info->errorCount++; break; case StmtIndicatorNameDef: /* e.g. indicator 1 = "Caps Lock"; */ - if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, keymap, info)) + if (!HandleIndicatorNameDef((IndicatorNameDef *) stmt, keymap, + merge, info)) info->errorCount++; break; case StmtInterpDef: @@ -897,7 +848,8 @@ == Success) { uint64_t i; for (i = info.computedMin; i <= info.computedMax; i++) - LongToKeyName(info.names[i], keymap->names->keys[i].name); + LongToKeyName(darray_item(info.names, i), + darray_item(keymap->names->keys, i).name); } else { WSGO("Cannot create struct xkb_names in CompileKeycodes\n"); goto err_info; diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/keymap.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/keymap.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/keymap.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/keymap.c 2012-05-30 06:41:46.000000000 +0000 @@ -68,7 +68,7 @@ return false; } have = 0; - ok = 1; + /* Check for duplicate entries in the input file */ for (file = (XkbFile *) file->defs; file; file = (XkbFile *) file->common.next) { diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/keytypes.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/keytypes.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/keytypes.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/keytypes.c 2012-05-30 06:41:46.000000000 +0000 @@ -53,12 +53,9 @@ unsigned vmask; bool groupInfo; unsigned numLevels; - unsigned nEntries; - unsigned szEntries; - struct xkb_kt_map_entry * entries; + darray(struct xkb_kt_map_entry) entries; PreserveInfo *preserve; - unsigned szNames; - xkb_atom_t *lvlNames; + darray(xkb_atom_t) lvlNames; } KeyTypeInfo; typedef struct _KeyTypesInfo @@ -122,34 +119,24 @@ info->dflt.vmask = 0; info->dflt.groupInfo = false; info->dflt.numLevels = 1; - info->dflt.nEntries = info->dflt.szEntries = 0; - info->dflt.entries = NULL; - info->dflt.szNames = 0; - info->dflt.lvlNames = NULL; + darray_init(info->dflt.entries); + darray_init(info->dflt.lvlNames); info->dflt.preserve = NULL; InitVModInfo(&info->vmods, keymap); if (from != NULL) { info->dflt = from->dflt; - if (from->dflt.entries) - { - info->dflt.entries = uTypedCalloc(from->dflt.szEntries, - struct xkb_kt_map_entry); - if (info->dflt.entries) - { - unsigned sz = from->dflt.nEntries * sizeof(struct xkb_kt_map_entry); - memcpy(info->dflt.entries, from->dflt.entries, sz); - } - } - if (from->dflt.lvlNames) - { - info->dflt.lvlNames = uTypedCalloc(from->dflt.szNames, xkb_atom_t); - if (info->dflt.lvlNames) - { - unsigned sz = from->dflt.szNames * sizeof(xkb_atom_t); - memcpy(info->dflt.lvlNames, from->dflt.lvlNames, sz); - } - } + + darray_init(info->dflt.entries); + darray_from_items(info->dflt.entries, + &darray_item(from->dflt.entries, 0), + darray_size(from->dflt.entries)); + + darray_init(info->dflt.lvlNames); + darray_from_items(info->dflt.lvlNames, + &darray_item(from->dflt.lvlNames, 0), + darray_size(from->dflt.lvlNames)); + if (from->dflt.preserve) { PreserveInfo *old, *new, *last; @@ -175,10 +162,10 @@ static void FreeKeyTypeInfo(KeyTypeInfo * type) { - free(type->entries); - type->entries = NULL; - free(type->lvlNames); - type->lvlNames = NULL; + darray_free(type->entries); + darray_init(type->entries); + darray_free(type->lvlNames); + darray_init(type->lvlNames); if (type->preserve != NULL) { ClearCommonInfo(&type->preserve->defs); @@ -294,10 +281,9 @@ } FreeKeyTypeInfo(old); *old = *new; - new->szEntries = new->nEntries = 0; - new->entries = NULL; + darray_init(new->entries); + darray_init(new->lvlNames); new->preserve = NULL; - new->lvlNames = NULL; old->defs.next = &next->defs; return true; } @@ -316,10 +302,8 @@ return false; *old = *new; old->defs.next = NULL; - new->nEntries = new->szEntries = 0; - new->entries = NULL; - new->szNames = 0; - new->lvlNames = NULL; + darray_init(new->entries); + darray_init(new->lvlNames); new->preserve = NULL; return true; } @@ -352,12 +336,13 @@ into->stdPresent |= from->stdPresent; } -typedef void (*FileHandler) (XkbFile *file, struct xkb_keymap *keymap, - unsigned merge, KeyTypesInfo *included); +static void +HandleKeyTypesFile(XkbFile *file, struct xkb_keymap *keymap, + unsigned merge, KeyTypesInfo *info); static bool HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap, - KeyTypesInfo *info, FileHandler hndlr) + KeyTypesInfo *info) { unsigned newMerge; XkbFile *rtrn; @@ -378,7 +363,7 @@ included.fileID = included.dflt.defs.fileID = rtrn->id; included.dflt.defs.merge = newMerge; - (*hndlr) (rtrn, keymap, newMerge, &included); + HandleKeyTypesFile(rtrn, keymap, newMerge, &included); if (stmt->stmt != NULL) { free(included.name); @@ -412,7 +397,7 @@ InitKeyTypesInfo(&next_incl, keymap, &included); next_incl.fileID = next_incl.dflt.defs.fileID = rtrn->id; next_incl.dflt.defs.merge = op; - (*hndlr) (rtrn, keymap, op, &next_incl); + HandleKeyTypesFile(rtrn, keymap, op, &next_incl); MergeIncludedKeyTypes(&included, &next_incl, op, keymap); FreeKeyTypesInfo(&next_incl); FreeXKBFile(rtrn); @@ -440,14 +425,12 @@ static struct xkb_kt_map_entry * FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask) { - unsigned int i; - struct xkb_kt_map_entry * entry; + struct xkb_kt_map_entry *entry; - for (i = 0, entry = type->entries; i < type->nEntries; i++, entry++) - { - if ((entry->mods.real_mods == mask) && (entry->mods.vmods == vmask)) + darray_foreach(entry, type->entries) + if (entry->mods.real_mods == mask && entry->mods.vmods == vmask) return entry; - } + return NULL; } @@ -456,54 +439,22 @@ { unsigned int i, n; - for (i = 0; i < type->nEntries; i++) - { - if (type->entries[i].level == 0) - { - for (n = i; n < type->nEntries - 1; n++) - { - type->entries[n] = type->entries[n + 1]; - } - type->nEntries--; + /* TODO: Be just a bit more clever here. */ + for (i = 0; i < darray_size(type->entries); i++) { + if (darray_item(type->entries, i).level == 0) { + for (n = i; n < darray_size(type->entries) - 1; n++) + darray_item(type->entries, n) = + darray_item(type->entries, n + 1); + (void)darray_pop(type->entries); } } } -/** - * Return a pointer to the next free XkbcKTMapEntry, reallocating space if - * necessary. - */ static struct xkb_kt_map_entry * NextMapEntry(struct xkb_keymap *keymap, KeyTypeInfo * type) { - if (type->entries == NULL) - { - type->entries = uTypedCalloc(2, struct xkb_kt_map_entry); - if (type->entries == NULL) - { - ERROR("Couldn't allocate map entries for %s\n", - TypeTxt(keymap, type)); - ACTION("Map entries lost\n"); - return NULL; - } - type->szEntries = 2; - type->nEntries = 0; - } - else if (type->nEntries >= type->szEntries) - { - type->szEntries *= 2; - type->entries = uTypedRecalloc(type->entries, - type->nEntries, type->szEntries, - struct xkb_kt_map_entry); - if (type->entries == NULL) - { - ERROR("Couldn't reallocate map entries for %s\n", - TypeTxt(keymap, type)); - ACTION("Map entries lost\n"); - return NULL; - } - } - return &type->entries[type->nEntries++]; + darray_resize0(type->entries, darray_size(type->entries) + 1); + return &darray_item(type->entries, darray_size(type->entries) - 1); } static bool @@ -732,50 +683,36 @@ AddLevelName(struct xkb_keymap *keymap, KeyTypeInfo *type, unsigned level, xkb_atom_t name, bool clobber) { - if ((type->lvlNames == NULL) || (type->szNames <= level)) - { - type->lvlNames = - uTypedRecalloc(type->lvlNames, type->szNames, level + 1, xkb_atom_t); - if (type->lvlNames == NULL) - { - ERROR("Couldn't allocate level names for type %s\n", - TypeTxt(keymap, type)); - ACTION("Level names lost\n"); - type->szNames = 0; - return false; - } - type->szNames = level + 1; - } - else if (type->lvlNames[level] == name) - { - if (warningLevel > 9) - { + if (level >= darray_size(type->lvlNames)) + darray_resize0(type->lvlNames, level + 1); + + if (darray_item(type->lvlNames, level) == name) { + if (warningLevel > 9) { WARN("Duplicate names for level %d of key type %s\n", - level + 1, TypeTxt(keymap, type)); + level + 1, TypeTxt(keymap, type)); ACTION("Ignored\n"); } return true; } - else if (type->lvlNames[level] != XKB_ATOM_NONE) - { - if (warningLevel > 0) - { + else if (darray_item(type->lvlNames, level) != XKB_ATOM_NONE) { + if (warningLevel > 0) { const char *old, *new; - old = xkb_atom_text(keymap->ctx, type->lvlNames[level]); + old = xkb_atom_text(keymap->ctx, + darray_item(type->lvlNames, level)); new = xkb_atom_text(keymap->ctx, name); WARN("Multiple names for level %d of key type %s\n", - level + 1, TypeTxt(keymap, type)); + level + 1, TypeTxt(keymap, type)); if (clobber) ACTION("Using %s, ignoring %s\n", new, old); else ACTION("Using %s, ignoring %s\n", old, new); } + if (!clobber) return true; } - if (level >= type->numLevels) - type->numLevels = level + 1; - type->lvlNames[level] = name; + + darray_item(type->lvlNames, level) = name; return true; } @@ -929,6 +866,7 @@ { unsigned int i; KeyTypeInfo type; + struct xkb_kt_map_entry *entry; if (def->merge != MergeDefault) merge = def->merge; @@ -942,10 +880,8 @@ type.vmask = info->dflt.vmask; type.groupInfo = info->dflt.groupInfo; type.numLevels = 1; - type.nEntries = type.szEntries = 0; - type.entries = NULL; - type.szNames = 0; - type.lvlNames = NULL; + darray_init(type.entries); + darray_init(type.lvlNames); type.preserve = NULL; /* Parse the actual content. */ @@ -957,15 +893,10 @@ /* now copy any appropriate map, preserve or level names from the */ /* default type */ - for (i = 0; i < info->dflt.nEntries; i++) - { - struct xkb_kt_map_entry * dflt; - dflt = &info->dflt.entries[i]; - if (((dflt->mods.real_mods & type.mask) == dflt->mods.real_mods) && - ((dflt->mods.vmods & type.vmask) == dflt->mods.vmods)) - { - AddMapEntry(keymap, &type, dflt, false, false); - } + darray_foreach(entry, info->dflt.entries) { + if ((entry->mods.real_mods & type.mask) == entry->mods.real_mods && + (entry->mods.vmods & type.vmask) == entry->mods.vmods) + AddMapEntry(keymap, &type, entry, false, false); } if (info->dflt.preserve) { @@ -980,13 +911,16 @@ dflt = (PreserveInfo *) dflt->defs.next; } } - for (i = 0; i < info->dflt.szNames; i++) - { - if ((i < type.numLevels) && (info->dflt.lvlNames[i] != XKB_ATOM_NONE)) + + for (i = 0; i < darray_size(info->dflt.lvlNames); i++) { + if (i < type.numLevels && + darray_item(info->dflt.lvlNames, i) != XKB_ATOM_NONE) { - AddLevelName(keymap, &type, i, info->dflt.lvlNames[i], false); + AddLevelName(keymap, &type, i, + darray_item(info->dflt.lvlNames, i), false); } } + /* Now add the new keytype to the info struct */ if (!AddKeyType(keymap, info, &type)) { @@ -1017,8 +951,7 @@ switch (stmt->stmtType) { case StmtInclude: - if (!HandleIncludeKeyTypes((IncludeStmt *) stmt, keymap, info, - HandleKeyTypesFile)) + if (!HandleIncludeKeyTypes((IncludeStmt *) stmt, keymap, info)) info->errorCount++; break; case StmtKeyTypeDef: /* e.g. type "ONE_LEVEL" */ @@ -1088,16 +1021,15 @@ ACTION("Aborting\n"); return false; } - pre->matchingMapIndex = match - def->entries; + pre->matchingMapIndex = match - &darray_item(def->entries, 0); } type->mods.real_mods = def->mask; type->mods.vmods = def->vmask; type->num_levels = def->numLevels; - type->map_count = def->nEntries; - type->map = def->entries; + memcpy(&type->map, &def->entries, sizeof(def->entries)); if (def->preserve) { - type->preserve = uTypedCalloc(type->map_count, struct xkb_mods); + type->preserve = uTypedCalloc(darray_size(type->map), struct xkb_mods); if (!type->preserve) { WARN("Couldn't allocate preserve array in CopyDefToKeyType\n"); @@ -1119,24 +1051,21 @@ else type->preserve = NULL; type->name = xkb_atom_strdup(keymap->ctx, def->name); - if (def->szNames > 0) - { - type->level_names = uTypedCalloc(def->numLevels, const char *); + + if (!darray_empty(def->lvlNames)) { + type->level_names = uTypedCalloc(darray_size(def->lvlNames), + const char *); /* assert def->szNames<=def->numLevels */ - for (i = 0; i < def->szNames; i++) - { - type->level_names[i] = xkb_atom_strdup(keymap->ctx, - def->lvlNames[i]); - } + for (i = 0; i < darray_size(def->lvlNames); i++) + type->level_names[i] = + xkb_atom_strdup(keymap->ctx, darray_item(def->lvlNames, i)); } - else - { + else { type->level_names = NULL; } - def->nEntries = def->szEntries = 0; - def->entries = NULL; + darray_init(def->entries); return XkbcComputeEffectiveMap(keymap, type, NULL); } @@ -1171,7 +1100,7 @@ goto err_info; } - keymap->map->num_types = i; + darray_resize0(keymap->map->types, i); if (XkbAllRequiredTypes & (~info.stdPresent)) { unsigned missing, keypadVMod; @@ -1185,29 +1114,29 @@ } if (missing & XkbOneLevelMask) - keymap->map->types[XkbOneLevelIndex].name = + darray_item(keymap->map->types, XkbOneLevelIndex).name = xkb_atom_strdup(keymap->ctx, tok_ONE_LEVEL); if (missing & XkbTwoLevelMask) - keymap->map->types[XkbTwoLevelIndex].name = + darray_item(keymap->map->types, XkbTwoLevelIndex).name = xkb_atom_strdup(keymap->ctx, tok_TWO_LEVEL); if (missing & XkbAlphabeticMask) - keymap->map->types[XkbAlphabeticIndex].name = + darray_item(keymap->map->types, XkbAlphabeticIndex).name = xkb_atom_strdup(keymap->ctx, tok_ALPHABETIC); if (missing & XkbKeypadMask) - keymap->map->types[XkbKeypadIndex].name = + darray_item(keymap->map->types, XkbKeypadIndex).name = xkb_atom_strdup(keymap->ctx, tok_KEYPAD); } - next = &keymap->map->types[XkbLastRequiredType + 1]; + next = &darray_item(keymap->map->types, XkbLastRequiredType + 1); for (i = 0, def = info.types; i < info.nTypes; i++) { if (def->name == tok_ONE_LEVEL) - type = &keymap->map->types[XkbOneLevelIndex]; + type = &darray_item(keymap->map->types, XkbOneLevelIndex); else if (def->name == tok_TWO_LEVEL) - type = &keymap->map->types[XkbTwoLevelIndex]; + type = &darray_item(keymap->map->types, XkbTwoLevelIndex); else if (def->name == tok_ALPHABETIC) - type = &keymap->map->types[XkbAlphabeticIndex]; + type = &darray_item(keymap->map->types, XkbAlphabeticIndex); else if (def->name == tok_KEYPAD) - type = &keymap->map->types[XkbKeypadIndex]; + type = &darray_item(keymap->map->types, XkbKeypadIndex); else type = next++; diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/misc.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/misc.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/misc.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/misc.c 2012-05-30 06:41:46.000000000 +0000 @@ -25,6 +25,7 @@ ********************************************************/ #include "xkbcomp-priv.h" +#include "path.h" #include "parseutils.h" #include "keycodes.h" @@ -243,12 +244,12 @@ } *kc_rtrn = 0; /* some callers rely on this */ - if (keymap && keymap->names && keymap->names->keys) + if (keymap && keymap->names && !darray_empty(keymap->names->keys)) { for (n = start_from; n <= keymap->max_key_code; n++) { unsigned long tmp; - tmp = KeyNameToLong(keymap->names->keys[n].name); + tmp = KeyNameToLong(darray_item(keymap->names->keys, n).name); if (tmp == name) { *kc_rtrn = n; @@ -265,7 +266,7 @@ } if (create) { - if ((!keymap->names) || (!keymap->names->keys)) + if ((!keymap->names) || darray_empty(keymap->names->keys)) { if (XkbcAllocNames(keymap, XkbKeyNamesMask, 0) != Success) { @@ -281,11 +282,12 @@ /* Find first unused keycode and store our key here */ for (n = keymap->min_key_code; n <= keymap->max_key_code; n++) { - if (keymap->names->keys[n].name[0] == '\0') + if (darray_item(keymap->names->keys, n).name[0] == '\0') { char buf[XkbKeyNameLength + 1]; LongToKeyName(name, buf); - memcpy(keymap->names->keys[n].name, buf, XkbKeyNameLength); + memcpy(darray_item(keymap->names->keys, n).name, buf, + XkbKeyNameLength); *kc_rtrn = n; return true; } @@ -298,19 +300,14 @@ FindKeyNameForAlias(struct xkb_keymap *keymap, unsigned long lname, unsigned long *real_name) { - unsigned int i; char name[XkbKeyNameLength + 1]; + struct xkb_key_alias *a; - if (keymap && keymap->names && keymap->names->key_aliases) - { - struct xkb_key_alias * a; - a = keymap->names->key_aliases; + if (keymap && keymap->names) { LongToKeyName(lname, name); name[XkbKeyNameLength] = '\0'; - for (i = 0; i < keymap->names->num_key_aliases; i++, a++) - { - if (strncmp(name, a->alias, XkbKeyNameLength) == 0) - { + darray_foreach(a, keymap->names->key_aliases) { + if (strncmp(name, a->alias, XkbKeyNameLength) == 0) { *real_name = KeyNameToLong(a->real); return true; } diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/parseutils.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/parseutils.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/parseutils.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/parseutils.c 2012-05-30 06:41:46.000000000 +0000 @@ -25,6 +25,7 @@ ********************************************************/ #include "parseutils.h" +#include "path.h" ParseCommon * AppendStmt(ParseCommon * to, ParseCommon * append) @@ -384,59 +385,6 @@ return NULL; } -static bool -ResizeKeysymList(ExprDef *list, unsigned int extra) -{ - int i; - - if (list->value.list.nSyms + extra > list->value.list.szSyms) - { - list->value.list.szSyms *= 2; - list->value.list.szSyms += extra; - if (list->value.list.szSyms == 1) - list->value.list.szSyms = 4; - list->value.list.syms = uTypedRecalloc(list->value.list.syms, - list->value.list.nSyms, - list->value.list.szSyms, - char *); - if (list->value.list.syms == NULL) - { - FATAL("Couldn't resize list of symbols for append\n"); - return false; - } - } - if (list->value.list.nLevels >= list->value.list.szLevels) - { - list->value.list.szLevels *= 2; - if (list->value.list.szLevels == 0) - list->value.list.szLevels = 4; - list->value.list.symsMapIndex = - uTypedRecalloc(list->value.list.symsMapIndex, - list->value.list.nLevels, - list->value.list.szLevels, - int); - if (list->value.list.symsMapIndex == NULL) - { - FATAL("Couldn't resize keysym index map for append\n"); - return false; - } - list->value.list.symsNumEntries = - uTypedRecalloc(list->value.list.symsNumEntries, - list->value.list.nLevels, - list->value.list.szLevels, - unsigned int); - if (list->value.list.symsNumEntries == NULL) - { - FATAL("Couldn't resize num keysym entries for append\n"); - return false; - } - for (i = list->value.list.nLevels; i < list->value.list.szLevels; i++) - list->value.list.symsMapIndex[i] = -1; - } - - return true; -} - ExprDef * CreateKeysymList(char *sym) { @@ -449,25 +397,13 @@ return NULL; } - def->value.list.nSyms = 0; - def->value.list.szSyms = 0; - def->value.list.nLevels = 0; - def->value.list.szLevels = 0; - def->value.list.syms = NULL; - def->value.list.symsMapIndex = NULL; - def->value.list.symsNumEntries = NULL; - - if (!ResizeKeysymList(def, 1)) - { - FreeStmt(&def->common); - return NULL; - } - - def->value.list.syms[0] = sym; - def->value.list.symsMapIndex[0] = 0; - def->value.list.symsNumEntries[0] = 1; - def->value.list.nLevels = 1; - def->value.list.nSyms = 1; + darray_init(def->value.list.syms); + darray_init(def->value.list.symsMapIndex); + darray_init(def->value.list.symsNumEntries); + + darray_append(def->value.list.syms, sym); + darray_append(def->value.list.symsMapIndex, 0); + darray_append(def->value.list.symsNumEntries, 1); return def; } @@ -475,16 +411,12 @@ ExprDef * CreateMultiKeysymList(ExprDef *list) { - int i; + size_t nLevels = darray_size(list->value.list.symsMapIndex); - for (i = 1; i < list->value.list.szLevels; i++) - { - list->value.list.symsMapIndex[i] = -1; - list->value.list.symsNumEntries[i] = 0; - } - list->value.list.symsMapIndex[0] = 0; - list->value.list.symsNumEntries[0] = list->value.list.nLevels; - list->value.list.nLevels = 1; + darray_resize(list->value.list.symsMapIndex, 1); + darray_resize(list->value.list.symsNumEntries, 1); + darray_item(list->value.list.symsMapIndex, 0) = 0; + darray_item(list->value.list.symsNumEntries, 0) = nLevels; return list; } @@ -492,36 +424,28 @@ ExprDef * AppendKeysymList(ExprDef * list, char *sym) { - if (!ResizeKeysymList(list, 1)) - return NULL; + size_t nSyms = darray_size(list->value.list.syms); + + darray_append(list->value.list.symsMapIndex, nSyms); + darray_append(list->value.list.symsNumEntries, 1); + darray_append(list->value.list.syms, sym); - list->value.list.symsMapIndex[list->value.list.nLevels] = - list->value.list.nSyms; - list->value.list.symsNumEntries[list->value.list.nLevels] = 1; - list->value.list.syms[list->value.list.nSyms++] = sym; - list->value.list.nLevels++; return list; } ExprDef * AppendMultiKeysymList(ExprDef * list, ExprDef * append) { - int i; + size_t nSyms = darray_size(list->value.list.syms); + size_t numEntries = darray_size(append->value.list.syms); - if (!ResizeKeysymList(list, append->value.list.nSyms)) - return NULL; - - list->value.list.symsMapIndex[list->value.list.nLevels] = - list->value.list.nSyms; - list->value.list.symsNumEntries[list->value.list.nLevels] = - append->value.list.nSyms; - for (i = 0; i < append->value.list.nSyms; i++) { - list->value.list.syms[list->value.list.nSyms++] = - append->value.list.syms[i]; - append->value.list.syms[i] = NULL; - } - list->value.list.nLevels++; + darray_append(list->value.list.symsMapIndex, nSyms); + darray_append(list->value.list.symsNumEntries, numEntries); + darray_append_items(list->value.list.syms, + &darray_item(append->value.list.syms, 0), + numEntries); + darray_resize(append->value.list.syms, 0); FreeStmt(&append->common); return list; @@ -716,7 +640,7 @@ static void FreeExpr(ExprDef *expr) { - int i; + char **sym; if (!expr) return; @@ -745,11 +669,11 @@ FreeStmt(&expr->value.array.entry->common); break; case ExprKeysymList: - for (i = 0; i < expr->value.list.nSyms; i++) - free(expr->value.list.syms[i]); - free(expr->value.list.syms); - free(expr->value.list.symsMapIndex); - free(expr->value.list.symsNumEntries); + darray_foreach(sym, expr->value.list.syms) + free(*sym); + darray_free(expr->value.list.syms); + darray_free(expr->value.list.symsMapIndex); + darray_free(expr->value.list.symsNumEntries); break; default: break; diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/path.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/path.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/path.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/path.c 2012-05-30 06:41:46.000000000 +0000 @@ -27,7 +27,7 @@ #include #include -#include "xkbcomp-priv.h" +#include "path.h" /** * Extract the first token from an include statement. diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/path.h libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/path.h --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/path.h 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/path.h 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,45 @@ +/************************************************************ + Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. + + Permission to use, copy, modify, and distribute this + software and its documentation for any purpose and without + fee is hereby granted, provided that the above copyright + notice appear in all copies and that both that copyright + notice and this permission notice appear in supporting + documentation, and that the name of Silicon Graphics not be + used in advertising or publicity pertaining to distribution + of the software without specific prior written permission. + Silicon Graphics makes no representation about the suitability + of this software for any purpose. It is provided "as is" + without any express or implied warranty. + + SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH + THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ********************************************************/ + +#ifndef XKBCOMP_PATH_H +#define XKBCOMP_PATH_H + +#include + +#include "xkbcomp-priv.h" + +bool +XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn, + char *nextop_rtrn, char **extra_data); + +const char * +XkbDirectoryForInclude(unsigned type); + +FILE * +XkbFindFileInPath(struct xkb_context *ctx, + const char *name, unsigned type, char **pathRtrn); + +#endif /* XKBCOMP_PATH_H */ diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/rules.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/rules.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/rules.c 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/rules.c 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,1099 @@ +/************************************************************ + Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc. + + Permission to use, copy, modify, and distribute this + software and its documentation for any purpose and without + fee is hereby granted, provided that the above copyright + notice appear in all copies and that both that copyright + notice and this permission notice appear in supporting + documentation, and that the name of Silicon Graphics not be + used in advertising or publicity pertaining to distribution + of the software without specific prior written permission. + Silicon Graphics makes no representation about the suitability + of this software for any purpose. It is provided "as is" + without any express or implied warranty. + + SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS + SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON + GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL + DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, + DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE + OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH + THE USE OR PERFORMANCE OF THIS SOFTWARE. + + ********************************************************/ + +#include +#include + +#include "rules.h" +#include "path.h" + +static bool +input_line_get(FILE *file, darray_char *line) +{ + int ch; + bool end_of_file = false; + bool space_pending; + bool slash_pending; + bool in_comment; + + while (!end_of_file && darray_empty(*line)) { + space_pending = slash_pending = in_comment = false; + + while ((ch = getc(file)) != '\n' && ch != EOF) { + if (ch == '\\') { + ch = getc(file); + + if (ch == EOF) + break; + + if (ch == '\n') { + in_comment = false; + ch = ' '; + } + } + + if (in_comment) + continue; + + if (ch == '/') { + if (slash_pending) { + in_comment = true; + slash_pending = false; + } + else { + slash_pending = true; + } + + continue; + } + + if (slash_pending) { + if (space_pending) { + darray_append(*line, ' '); + space_pending = false; + } + + darray_append(*line, '/'); + slash_pending = false; + } + + if (isspace(ch)) { + while (isspace(ch) && ch != '\n' && ch != EOF) + ch = getc(file); + + if (ch == EOF) + break; + + if (ch != '\n' && !darray_empty(*line)) + space_pending = true; + + ungetc(ch, file); + } + else { + if (space_pending) { + darray_append(*line, ' '); + space_pending = false; + } + + if (ch == '!') { + if (!darray_empty(*line)) { + WARN("The '!' is legal only at start of line\n"); + ACTION("Line containing '!' ignored\n"); + darray_resize(*line, 0); + break; + } + } + + darray_append(*line, ch); + } + } + + if (ch == EOF) + end_of_file = true; + } + + if (darray_empty(*line) && end_of_file) + return false; + + darray_append(*line, '\0'); + return true; +} + +/***====================================================================***/ + +enum { + /* "Parts" - the MLVO which rules file maps to components. */ + MODEL = 0, + LAYOUT, + VARIANT, + OPTION, + +#define PART_MASK \ + ((1 << MODEL) | (1 << LAYOUT) | (1 << VARIANT) | (1 << OPTION)) + + /* Components */ + KEYCODES, + SYMBOLS, + TYPES, + COMPAT, + GEOMETRY, + KEYMAP, + +#define COMPONENT_MASK \ + ((1 << KEYCODES) | (1 << SYMBOLS) | (1 << TYPES) | (1 << COMPAT) | \ + (1 << GEOMETRY) | (1 << KEYMAP)) + + MAX_WORDS +}; + +static const char *cname[] = { + [MODEL] = "model", + [LAYOUT] = "layout", + [VARIANT] = "variant", + [OPTION] = "option", + + [KEYCODES] = "keycodes", + [SYMBOLS] = "symbols", + [TYPES] = "types", + [COMPAT] = "compat", + [GEOMETRY] = "geometry", + [KEYMAP] = "keymap", +}; + +struct multi_defs { + const char *model; + const char *layout[XkbNumKbdGroups + 1]; + const char *variant[XkbNumKbdGroups + 1]; + char *options; +}; + +struct mapping { + /* Sequential id for the mappings. */ + int number; + size_t num_maps; + + struct { + int word; + int index; + } map[MAX_WORDS]; +}; + +struct var_desc { + char *name; + char *desc; +}; + +struct group { + int number; + char *name; + char *words; +}; + +enum rule_flag { + RULE_FLAG_PENDING_MATCH = (1L << 1), + RULE_FLAG_OPTION = (1L << 2), + RULE_FLAG_APPEND = (1L << 3), + RULE_FLAG_NORMAL = (1L << 4), +}; + +struct rule { + int number; + + char *model; + char *layout; + int layout_num; + char *variant; + int variant_num; + char *option; + + /* yields */ + + char *keycodes; + char *symbols; + char *types; + char *compat; + char *keymap; + unsigned flags; +}; + +struct rules { + darray(struct rule) rules; + darray(struct group) groups; +}; + +/***====================================================================***/ + +/* + * Resolve numeric index, such as "[4]" in layout[4]. Missing index + * means zero. + */ +static char * +get_index(char *str, int *ndx) +{ + int empty = 0, consumed = 0, num; + + sscanf(str, "[%n%d]%n", &empty, &num, &consumed); + if (consumed > 0) { + *ndx = num; + str += consumed; + } else if (empty > 0) { + *ndx = -1; + } else { + *ndx = 0; + } + + return str; +} + +/* + * Match a mapping line which opens a rule, e.g: + * ! model layout[4] variant[4] = symbols geometry + * Which will be followed by lines such as: + * * ben basic = +in(ben):4 nec(pc98) + * So if the MLVO matches the LHS of some line, we'll get the components + * on the RHS. + * In this example, we will get for the second and fourth columns: + * mapping->map[1] = {.word = LAYOUT, .index = 4} + * mapping->map[3] = {.word = SYMBOLS, .index = 0} + */ +static void +match_mapping_line(darray_char *line, struct mapping *mapping) +{ + char *tok; + char *str = &darray_item(*line, 1); + unsigned present = 0, layout_ndx_present = 0, variant_ndx_present = 0; + int i, tmp; + size_t len; + int ndx; + char *strtok_buf; + bool found; + + /* + * Remember the last sequential mapping id (incremented if the match + * is successful). + */ + tmp = mapping->number; + memset(mapping, 0, sizeof(*mapping)); + mapping->number = tmp; + + while ((tok = strtok_r(str, " ", &strtok_buf)) != NULL) { + found = false; + str = NULL; + + if (strcmp(tok, "=") == 0) + continue; + + for (i = 0; i < MAX_WORDS; i++) { + len = strlen(cname[i]); + + if (strncmp(cname[i], tok, len) == 0) { + if (strlen(tok) > len) { + char *end = get_index(tok + len, &ndx); + + if ((i != LAYOUT && i != VARIANT) || + *end != '\0' || ndx == -1) { + WARN("Illegal %s index: %d\n", cname[i], ndx); + WARN("Can only index layout and variant\n"); + break; + } + + if (ndx < 1 || ndx > XkbNumKbdGroups) { + WARN("Illegal %s index: %d\n", cname[i], ndx); + WARN("Index must be in range 1..%d\n", XkbNumKbdGroups); + break; + } + } else { + ndx = 0; + } + + found = true; + + if (present & (1 << i)) { + if ((i == LAYOUT && layout_ndx_present & (1 << ndx)) || + (i == VARIANT && variant_ndx_present & (1 << ndx))) { + WARN("Component \"%s\" listed twice\n", tok); + ACTION("Second definition ignored\n"); + break; + } + } + + present |= (1 << i); + if (i == LAYOUT) + layout_ndx_present |= 1 << ndx; + if (i == VARIANT) + variant_ndx_present |= 1 << ndx; + + mapping->map[mapping->num_maps].word = i; + mapping->map[mapping->num_maps].index = ndx; + mapping->num_maps++; + break; + } + } + + if (!found) { + WARN("Unknown component \"%s\"\n", tok); + ACTION("ignored\n"); + } + } + + if ((present & PART_MASK) == 0) { + WARN("Mapping needs at least one MLVO part\n"); + ACTION("Illegal mapping ignored\n"); + mapping->num_maps = 0; + return; + } + + if ((present & COMPONENT_MASK) == 0) { + WARN("Mapping needs at least one component\n"); + ACTION("Illegal mapping ignored\n"); + mapping->num_maps = 0; + return; + } + + if (((present & COMPONENT_MASK) & (1 << KEYMAP)) && + ((present & COMPONENT_MASK) != (1 << KEYMAP))) { + WARN("Keymap cannot appear with other components\n"); + ACTION("Illegal mapping ignored\n"); + mapping->num_maps = 0; + return; + } + + mapping->number++; +} + +/* + * Match a line such as: + * ! $pcmodels = pc101 pc102 pc104 pc105 + */ +static bool +match_group_line(darray_char *line, struct group *group) +{ + int i; + char *name = strchr(&darray_item(*line, 0), '$'); + char *words = strchr(name, ' '); + + if (!words) + return false; + + *words++ = '\0'; + + for (; *words; words++) { + if (*words != '=' && *words != ' ') + break; + } + + if (*words == '\0') + return false; + + group->name = strdup(name); + group->words = strdup(words); + + words = group->words; + for (i = 1; *words; words++) { + if (*words == ' ') { + *words++ = '\0'; + i++; + } + } + group->number = i; + + return true; + +} + +/* Match lines following a mapping (see match_mapping_line comment). */ +static bool +match_rule_line(darray_char *line, struct mapping *mapping, + struct rule *rule) +{ + char *str, *tok; + int nread, i; + char *strtok_buf; + bool append = false; + const char *names[MAX_WORDS] = { NULL }; + + if (mapping->num_maps == 0) { + WARN("Must have a mapping before first line of data\n"); + ACTION("Illegal line of data ignored\n"); + return false; + } + + str = &darray_item(*line, 0); + + for (nread = 0; (tok = strtok_r(str, " ", &strtok_buf)) != NULL; nread++) { + str = NULL; + + if (strcmp(tok, "=") == 0) { + nread--; + continue; + } + + if (nread > mapping->num_maps) { + WARN("Too many words on a line\n"); + ACTION("Extra word \"%s\" ignored\n", tok); + continue; + } + + names[mapping->map[nread].word] = tok; + if (*tok == '+' || *tok == '|') + append = true; + } + + if (nread < mapping->num_maps) { + WARN("Too few words on a line: %s\n", &darray_item(*line, 0)); + ACTION("line ignored\n"); + return false; + } + + rule->flags = 0; + rule->number = mapping->number; + + if (names[OPTION]) + rule->flags |= RULE_FLAG_OPTION; + else if (append) + rule->flags |= RULE_FLAG_APPEND; + else + rule->flags |= RULE_FLAG_NORMAL; + + rule->model = uDupString(names[MODEL]); + rule->layout = uDupString(names[LAYOUT]); + rule->variant = uDupString(names[VARIANT]); + rule->option = uDupString(names[OPTION]); + + rule->keycodes = uDupString(names[KEYCODES]); + rule->symbols = uDupString(names[SYMBOLS]); + rule->types = uDupString(names[TYPES]); + rule->compat = uDupString(names[COMPAT]); + rule->keymap = uDupString(names[KEYMAP]); + + rule->layout_num = rule->variant_num = 0; + for (i = 0; i < nread; i++) { + if (mapping->map[i].index) { + if (mapping->map[i].word == LAYOUT) + rule->layout_num = mapping->map[i].index; + if (mapping->map[i].word == VARIANT) + rule->variant_num = mapping->map[i].index; + } + } + + return true; +} + +static bool +match_line(darray_char *line, struct mapping *mapping, + struct rule *rule, struct group *group) +{ + if (darray_item(*line, 0) != '!') + return match_rule_line(line, mapping, rule); + + if (darray_item(*line, 1) == '$' || + (darray_item(*line, 1) == ' ' && darray_item(*line, 2) == '$')) + return match_group_line(line, group); + + match_mapping_line(line, mapping); + return false; +} + +static void +squeeze_spaces(char *p1) +{ + char *p2; + + for (p2 = p1; *p2; p2++) { + *p1 = *p2; + if (*p1 != ' ') + p1++; + } + + *p1 = '\0'; +} + +/* + * Expand the layout and variant of the rule_names and remove extraneous + * spaces. If there's one layout/variant, it is kept in + * .layout[0]/.variant[0], else is kept in [1], [2] and so on, and [0] + * remains empty. For example, this rule_names: + * .model = "pc105", + * .layout = "us,il,ru,ca" + * .variant = ",,,multix" + * .options = "grp:alts_toggle, ctrl:nocaps, compose:rwin" + * Is expanded into this multi_defs: + * .model = "pc105" + * .layout = {NULL, "us", "il", "ru", "ca"}, + * .variant = {NULL, "", "", "", "multix"}, + * .options = "grp:alts_toggle,ctrl:nocaps,compose:rwin" + */ +static bool +make_multi_defs(struct multi_defs *mdefs, const struct xkb_rule_names *mlvo) +{ + char *p; + int i; + + memset(mdefs, 0, sizeof(*mdefs)); + + if (mlvo->model) { + mdefs->model = mlvo->model; + } + + if (mlvo->options) { + mdefs->options = strdup(mlvo->options); + if (mdefs->options == NULL) + return false; + + squeeze_spaces(mdefs->options); + } + + if (mlvo->layout) { + if (!strchr(mlvo->layout, ',')) { + mdefs->layout[0] = mlvo->layout; + } + else { + p = strdup(mlvo->layout); + if (p == NULL) + return false; + + squeeze_spaces(p); + mdefs->layout[1] = p; + + for (i = 2; i <= XkbNumKbdGroups; i++) { + if ((p = strchr(p, ','))) { + *p++ = '\0'; + mdefs->layout[i] = p; + } + else { + break; + } + } + + if (p && (p = strchr(p, ','))) + *p = '\0'; + } + } + + if (mlvo->variant) { + if (!strchr(mlvo->variant, ',')) { + mdefs->variant[0] = mlvo->variant; + } + else { + p = strdup(mlvo->variant); + if (p == NULL) + return false; + + squeeze_spaces(p); + mdefs->variant[1] = p; + + for (i = 2; i <= XkbNumKbdGroups; i++) { + if ((p = strchr(p, ','))) { + *p++ = '\0'; + mdefs->variant[i] = p; + } else { + break; + } + } + + if (p && (p = strchr(p, ','))) + *p = '\0'; + } + } + + return true; +} + +static void +free_multi_defs(struct multi_defs *defs) +{ + free(defs->options); + /* + * See make_multi_defs comment for the hack; the same strdup'd + * string is split among the indexes, but the one in [0] is const. + */ + free(UNCONSTIFY(defs->layout[1])); + free(UNCONSTIFY(defs->variant[1])); +} + +/* See apply_rule below. */ +static void +apply(const char *src, char **dst) +{ + int ret; + char *tmp; + + if (!src) + return; + + if (*src == '+' || *src == '!') { + tmp = *dst; + ret = asprintf(dst, "%s%s", *dst, src); + if (ret < 0) + *dst = NULL; + free(tmp); + } + else if (*dst == NULL) { + *dst = strdup(src); + } +} + +/* + * Add the info from the matching rule to the resulting + * xkb_component_names. If we already had a match for something + * (e.g. keycodes), and the rule is not an appending one (e.g. + * +whatever), than we don't override but drop the new one. + */ +static void +apply_rule(struct rule *rule, struct xkb_component_names *kccgst) +{ + /* Clear the flag because it's applied. */ + rule->flags &= ~RULE_FLAG_PENDING_MATCH; + + apply(rule->keycodes, &kccgst->keycodes); + apply(rule->symbols, &kccgst->symbols); + apply(rule->types, &kccgst->types); + apply(rule->compat, &kccgst->compat); + apply(rule->keymap, &kccgst->keymap); +} + +/* + * Match if name is part of the group, e.g. if the following + * group is defined: + * ! $qwertz = al cz de hr hu ro si sk + * then + * match_group_member(rules, "qwertz", "hr") + * will return true. + */ +static bool +match_group_member(struct rules *rules, const char *group_name, + const char *name) +{ + int i; + const char *word; + struct group *iter, *group = NULL; + + darray_foreach(iter, rules->groups) { + if (strcmp(iter->name, group_name) == 0) { + group = iter; + break; + } + } + + if (!group) + return false; + + word = group->words; + for (i = 0; i < group->number; i++, word += strlen(word) + 1) + if (strcmp(word, name) == 0) + return true; + + return false; +} + +/* Match @needle out of @sep-seperated @haystack. */ +static bool +match_one_of(const char *haystack, const char *needle, char sep) +{ + const char *s = strstr(haystack, needle); + + if (s == NULL) + return false; + + if (s != haystack && *s != sep) + return false; + + s += strlen(needle); + if (*s != '\0' && *s != sep) + return false; + + return true; +} + +static int +apply_rule_if_matches(struct rules *rules, struct rule *rule, + struct multi_defs *mdefs, + struct xkb_component_names *kccgst) +{ + bool pending = false; + + if (rule->model) { + if (mdefs->model == NULL) + return 0; + + if (strcmp(rule->model, "*") == 0) { + pending = true; + } + else if (rule->model[0] == '$') { + if (!match_group_member(rules, rule->model, mdefs->model)) + return 0; + } + else if (strcmp(rule->model, mdefs->model) != 0) { + return 0; + } + } + + if (rule->option) { + if (mdefs->options == NULL) + return 0; + + if (!match_one_of(mdefs->options, rule->option, ',')) + return 0; + } + + if (rule->layout) { + if (mdefs->layout[rule->layout_num] == NULL) + return 0; + + if (strcmp(rule->layout, "*") == 0) { + pending = true; + } + else if (rule->layout[0] == '$') { + if (!match_group_member(rules, rule->layout, + mdefs->layout[rule->layout_num])) + return 0; + } + else if (strcmp(rule->layout, + mdefs->layout[rule->layout_num]) != 0) { + return 0; + } + } + + if (rule->variant) { + if (mdefs->variant[rule->variant_num] == NULL) + return 0; + + if (strcmp(rule->variant, "*") == 0) { + pending = true; + } else if (rule->variant[0] == '$') { + if (!match_group_member(rules, rule->variant, + mdefs->variant[rule->variant_num])) + return 0; + } + else if (strcmp(rule->variant, + mdefs->variant[rule->variant_num]) != 0) { + return 0; + } + } + + if (pending) { + rule->flags |= RULE_FLAG_PENDING_MATCH; + } else { + /* Exact match, apply it now. */ + apply_rule(rule, kccgst); + } + + return rule->number; +} + +static void +clear_partial_matches(struct rules *rules) +{ + struct rule *rule; + + darray_foreach(rule, rules->rules) + rule->flags &= ~RULE_FLAG_PENDING_MATCH; +} + +static void +apply_partial_matches(struct rules *rules, struct xkb_component_names *kccgst) +{ + struct rule *rule; + + darray_foreach(rule, rules->rules) + if (rule->flags & RULE_FLAG_PENDING_MATCH) + apply_rule(rule, kccgst); +} + +static void +apply_matching_rules(struct rules *rules, struct multi_defs *mdefs, + struct xkb_component_names *kccgst, unsigned int flags) +{ + int skip = -1; + struct rule *rule; + + darray_foreach(rule, rules->rules) { + if ((rule->flags & flags) != flags) + continue; + + if ((flags & RULE_FLAG_OPTION) == 0 && rule->number == skip) + continue; + + skip = apply_rule_if_matches(rules, rule, mdefs, kccgst); + } +} + +/***====================================================================***/ + +static char * +substitute_vars(char *name, struct multi_defs *mdefs) +{ + char *str, *outstr, *var; + char *orig = name; + size_t len, extra_len; + char pfx, sfx; + int ndx; + + if (!name) + return NULL; + + str = strchr(name, '%'); + if (str == NULL) + return name; + + len = strlen(name); + + while (str != NULL) { + pfx = str[1]; + extra_len = 0; + + if (pfx == '+' || pfx == '|' || pfx == '_' || pfx == '-') { + extra_len = 1; + str++; + } + else if (pfx == '(') { + extra_len = 2; + str++; + } + + var = str + 1; + str = get_index(var + 1, &ndx); + if (ndx == -1) { + str = strchr(str, '%'); + continue; + } + + if (*var == 'l' && mdefs->layout[ndx] && *mdefs->layout[ndx]) + len += strlen(mdefs->layout[ndx]) + extra_len; + else if (*var == 'm' && mdefs->model) + len += strlen(mdefs->model) + extra_len; + else if (*var == 'v' && mdefs->variant[ndx] && *mdefs->variant[ndx]) + len += strlen(mdefs->variant[ndx]) + extra_len; + + if (pfx == '(' && *str == ')') + str++; + + str = strchr(&str[0], '%'); + } + + name = malloc(len + 1); + str = orig; + outstr = name; + + while (*str != '\0') { + if (str[0] == '%') { + str++; + pfx = str[0]; + sfx = '\0'; + + if (pfx == '+' || pfx == '|' || pfx == '_' || pfx == '-') { + str++; + } + else if (pfx == '(') { + sfx = ')'; + str++; + } + else { + pfx = '\0'; + } + + var = str; + str = get_index(var + 1, &ndx); + if (ndx == -1) + continue; + + if (*var == 'l' && mdefs->layout[ndx] && *mdefs->layout[ndx]) { + if (pfx) + *outstr++ = pfx; + + strcpy(outstr, mdefs->layout[ndx]); + outstr += strlen(mdefs->layout[ndx]); + + if (sfx) + *outstr++ = sfx; + } + else if (*var == 'm' && mdefs->model) { + if (pfx) + *outstr++ = pfx; + + strcpy(outstr, mdefs->model); + outstr += strlen(mdefs->model); + + if (sfx) + *outstr++ = sfx; + } + else if (*var == 'v' && mdefs->variant[ndx] && *mdefs->variant[ndx]) { + if (pfx) + *outstr++ = pfx; + + strcpy(outstr, mdefs->variant[ndx]); + outstr += strlen(mdefs->variant[ndx]); + + if (sfx) + *outstr++ = sfx; + } + + if (pfx == '(' && *str == ')') + str++; + } + else { + *outstr++= *str++; + } + } + + *outstr++= '\0'; + + if (orig != name) + free(orig); + + return name; +} + +/***====================================================================***/ + +static bool +get_components(struct rules *rules, const struct xkb_rule_names *mlvo, + struct xkb_component_names *kccgst) +{ + struct multi_defs mdefs; + + make_multi_defs(&mdefs, mlvo); + + clear_partial_matches(rules); + + apply_matching_rules(rules, &mdefs, kccgst, RULE_FLAG_NORMAL); + apply_partial_matches(rules, kccgst); + + apply_matching_rules(rules, &mdefs, kccgst, RULE_FLAG_APPEND); + apply_partial_matches(rules, kccgst); + + apply_matching_rules(rules, &mdefs, kccgst, RULE_FLAG_OPTION); + apply_partial_matches(rules, kccgst); + + kccgst->keycodes = substitute_vars(kccgst->keycodes, &mdefs); + kccgst->symbols = substitute_vars(kccgst->symbols, &mdefs); + kccgst->types = substitute_vars(kccgst->types, &mdefs); + kccgst->compat = substitute_vars(kccgst->compat, &mdefs); + kccgst->keymap = substitute_vars(kccgst->keymap, &mdefs); + + free_multi_defs(&mdefs); + + return (kccgst->keycodes && kccgst->symbols && kccgst->types && + kccgst->compat) || kccgst->keymap; +} + +static struct rules * +load_rules(FILE *file) +{ + darray_char line; + struct mapping mapping; + struct rule trule; + struct group tgroup; + struct rules *rules; + + rules = calloc(1, sizeof(*rules)); + if (!rules) + return NULL; + + memset(&mapping, 0, sizeof(mapping)); + memset(&tgroup, 0, sizeof(tgroup)); + darray_init(line); + + while (input_line_get(file, &line)) { + if (match_line(&line, &mapping, &trule, &tgroup)) { + if (tgroup.number) { + darray_append(rules->groups, tgroup); + memset(&tgroup, 0, sizeof(tgroup)); + } else { + darray_append(rules->rules, trule); + memset(&trule, 0, sizeof(trule)); + } + } + + darray_resize(line, 0); + } + + darray_free(line); + return rules; +} + +static void +free_rules(struct rules *rules) +{ + struct rule *rule; + struct group *group; + + if (!rules) + return; + + darray_foreach(rule, rules->rules) { + free(rule->model); + free(rule->layout); + free(rule->variant); + free(rule->option); + free(rule->keycodes); + free(rule->symbols); + free(rule->types); + free(rule->compat); + free(rule->keymap); + } + darray_free(rules->rules); + + darray_foreach(group, rules->groups) { + free(group->name); + free(group->words); + } + darray_free(rules->groups); + + free(rules); +} + +struct xkb_component_names * +xkb_components_from_rules(struct xkb_context *ctx, + const struct xkb_rule_names *rmlvo) +{ + int i; + FILE *file; + char *path; + struct rules *rules; + struct xkb_component_names *kccgst = NULL; + + file = XkbFindFileInPath(ctx, rmlvo->rules, XkmRulesFile, &path); + if (!file) { + ERROR("could not find \"%s\" rules in XKB path\n", rmlvo->rules); + ERROR("%d include paths searched:\n", + xkb_context_num_include_paths(ctx)); + for (i = 0; i < xkb_context_num_include_paths(ctx); i++) + ERROR("\t%s\n", xkb_context_include_path_get(ctx, i)); + return NULL; + } + + rules = load_rules(file); + if (!rules) { + ERROR("failed to load XKB rules \"%s\"\n", path); + goto err; + } + + kccgst = calloc(1, sizeof(*kccgst)); + if (!kccgst) { + ERROR("failed to allocate XKB components\n"); + goto err; + } + + if (!get_components(rules, rmlvo, kccgst)) { + free(kccgst->keymap); + free(kccgst->keycodes); + free(kccgst->types); + free(kccgst->compat); + free(kccgst->symbols); + free(kccgst); + kccgst = NULL; + ERROR("no components returned from XKB rules \"%s\"\n", path); + goto err; + } + +err: + free_rules(rules); + if (file) + fclose(file); + free(path); + return kccgst; +} diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/rules.h libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/rules.h --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/rules.h 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/rules.h 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,36 @@ +/* +Copyright 2009 Dan Nicholson + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors or their +institutions shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the authors. +*/ + +#ifndef RULES_H +#define RULES_H + +#include "xkbcomp-priv.h" + +struct xkb_component_names * +xkb_components_from_rules(struct xkb_context *ctx, + const struct xkb_rule_names *rmlvo); + +#endif /* RULES_H */ diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/symbols.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/symbols.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/symbols.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/symbols.c 2012-05-30 06:41:46.000000000 +0000 @@ -78,7 +78,6 @@ unsigned repeat; struct xkb_behavior behavior; unsigned short vmodmap; - unsigned long allowNone; xkb_atom_t dfltType; } KeyInfo; @@ -89,7 +88,7 @@ InitKeyInfo(KeyInfo * info) { int i; - static char dflt[4] = "*"; + static const char dflt[4] = "*"; info->defs.defined = 0; info->defs.fileID = 0; @@ -113,7 +112,6 @@ info->behavior.data = 0; info->vmodmap = 0; info->repeat = RepeatUndefined; - info->allowNone = 0; } /** @@ -149,7 +147,6 @@ info->behavior.data = 0; info->vmodmap = 0; info->repeat = RepeatUndefined; - info->allowNone = 0; } /** @@ -259,8 +256,8 @@ } u; } ModMapEntry; -#define SYMBOLS_INIT_SIZE 110 -#define SYMBOLS_CHUNK 20 +#define SYMBOLS_INIT_SIZE 110 + typedef struct _SymbolsInfo { char *name; /* e.g. pc+us+inet(evdev) */ @@ -269,9 +266,7 @@ unsigned merge; unsigned explicit_group; unsigned groupInfo; - unsigned szKeys; - unsigned nKeys; - KeyInfo *keys; + darray(KeyInfo) keys; KeyInfo dflt; VModInfo vmods; ActionInfo *action; @@ -292,9 +287,8 @@ info->fileID = 0; info->merge = MergeOverride; info->groupInfo = 0; - info->szKeys = SYMBOLS_INIT_SIZE; - info->nKeys = 0; - info->keys = uTypedCalloc(SYMBOLS_INIT_SIZE, KeyInfo); + darray_init(info->keys); + darray_growalloc(info->keys, SYMBOLS_INIT_SIZE); info->modMap = NULL; for (i = 0; i < XkbNumKbdGroups; i++) info->groupNames[i] = XKB_ATOM_NONE; @@ -307,15 +301,12 @@ static void FreeSymbolsInfo(SymbolsInfo * info) { - unsigned int i; + KeyInfo *key; free(info->name); - if (info->keys) - { - for (i = 0; i < info->nKeys; i++) - FreeKeyInfo(&info->keys[i]); - free(info->keys); - } + darray_foreach(key, info->keys) + FreeKeyInfo(key); + darray_free(info->keys); if (info->modMap) ClearCommonInfo(&info->modMap->defs); if (info->aliases) @@ -484,10 +475,14 @@ if (into->symsMapNumEntries[group] && (i < into->numLevels[group])) toSize = into->symsMapNumEntries[group][i]; - if ((fromSize != 0 && toSize == 0) || clobber) + if (fromSize == 0 || fromSize == toSize || clobber) + { + fromSize += toSize; + } + else if (toSize == 0) + { resultSize += fromSize; - else - resultSize += toSize; + } } if (resultSize == 0) @@ -709,35 +704,21 @@ static bool AddKeySymbols(SymbolsInfo *info, KeyInfo *key, struct xkb_keymap *keymap) { - unsigned int i; unsigned long real_name; + KeyInfo *iter, *new; + + darray_foreach(iter, info->keys) + if (iter->name == key->name) + return MergeKeys(info, keymap, iter, key); - for (i = 0; i < info->nKeys; i++) - { - if (info->keys[i].name == key->name) - return MergeKeys(info, keymap, &info->keys[i], key); - } if (FindKeyNameForAlias(keymap, key->name, &real_name)) - { - for (i = 0; i < info->nKeys; i++) - { - if (info->keys[i].name == real_name) - return MergeKeys(info, keymap, &info->keys[i], key); - } - } - if (info->nKeys >= info->szKeys) - { - info->szKeys += SYMBOLS_CHUNK; - info->keys = - uTypedRecalloc(info->keys, info->nKeys, info->szKeys, KeyInfo); - if (!info->keys) - { - WSGO("Could not allocate key symbols descriptions\n"); - ACTION("Some key symbols definitions may be lost\n"); - return false; - } - } - return CopyKeyInfo(key, &info->keys[info->nKeys++], true); + darray_foreach(iter, info->keys) + if (iter->name == real_name) + return MergeKeys(info, keymap, iter, key); + + darray_resize0(info->keys, darray_size(info->keys) + 1); + new = &darray_item(info->keys, darray_size(info->keys) - 1); + return CopyKeyInfo(key, new, true); } static bool @@ -843,13 +824,15 @@ into->groupNames[i] = from->groupNames[i]; } } - for (i = 0, key = from->keys; i < from->nKeys; i++, key++) - { + + darray_foreach(key, from->keys) { if (merge != MergeDefault) key->defs.merge = merge; + if (!AddKeySymbols(into, key, keymap)) into->errorCount++; } + if (from->modMap != NULL) { ModMapEntry *mm, *next; @@ -868,12 +851,13 @@ into->errorCount++; } -typedef void (*FileHandler) (XkbFile *rtrn, struct xkb_keymap *keymap, - unsigned merge, SymbolsInfo *included); +static void +HandleSymbolsFile(XkbFile *file, struct xkb_keymap *keymap, + unsigned merge, SymbolsInfo *info); static bool HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap, - SymbolsInfo *info, FileHandler hndlr) + SymbolsInfo *info) { unsigned newMerge; XkbFile *rtrn; @@ -901,7 +885,7 @@ { included.explicit_group = info->explicit_group; } - (*hndlr) (rtrn, keymap, MergeOverride, &included); + HandleSymbolsFile(rtrn, keymap, MergeOverride, &included); if (stmt->stmt != NULL) { free(included.name); @@ -943,7 +927,7 @@ { next_incl.explicit_group = info->explicit_group; } - (*hndlr) (rtrn, keymap, MergeOverride, &next_incl); + HandleSymbolsFile(rtrn, keymap, MergeOverride, &next_incl); MergeIncludedSymbols(&included, &next_incl, op, keymap); FreeSymbolsInfo(&next_incl); FreeXKBFile(rtrn); @@ -1047,8 +1031,8 @@ ACTION("Ignoring duplicate definition\n"); return false; } - nSyms = value->value.list.nSyms; - nLevels = value->value.list.nLevels; + nSyms = darray_size(value->value.list.syms); + nLevels = darray_size(value->value.list.symsMapIndex); if (((key->numLevels[ndx] < nSyms) || (key->syms[ndx] == NULL)) && (!ResizeKeyGroup(key, ndx, nLevels, nSyms, false))) { @@ -1059,15 +1043,21 @@ } key->symsDefined |= (1 << ndx); for (i = 0; i < nLevels; i++) { - key->symsMapIndex[ndx][i] = value->value.list.symsMapIndex[i]; - key->symsMapNumEntries[ndx][i] = value->value.list.symsNumEntries[i]; + key->symsMapIndex[ndx][i] = + darray_item(value->value.list.symsMapIndex, i); + key->symsMapNumEntries[ndx][i] = + darray_item(value->value.list.symsNumEntries, i); + for (j = 0; j < key->symsMapNumEntries[ndx][i]; j++) { if (key->symsMapIndex[ndx][i] + j >= nSyms) abort(); - if (!LookupKeysym(value->value.list.syms[value->value.list.symsMapIndex[i] + j], + if (!LookupKeysym(darray_item(value->value.list.syms, + darray_item(value->value.list.symsMapIndex, i) + j), &key->syms[ndx][key->symsMapIndex[ndx][i] + j])) { WARN("Could not resolve keysym %s for key %s, group %d (%s), level %d\n", - value->value.list.syms[i], longText(key->name), ndx + 1, + darray_item(value->value.list.syms, i), + longText(key->name), + ndx + 1, xkb_atom_text(keymap->ctx, info->groupNames[ndx]), nSyms); while (--j >= 0) key->syms[ndx][key->symsMapIndex[ndx][i] + j] = XKB_KEY_NoSymbol; @@ -1611,8 +1601,7 @@ switch (stmt->stmtType) { case StmtInclude: - if (!HandleIncludeSymbols((IncludeStmt *) stmt, keymap, info, - HandleSymbolsFile)) + if (!HandleIncludeSymbols((IncludeStmt *) stmt, keymap, info)) info->errorCount++; break; case StmtSymbolsDef: @@ -1695,18 +1684,17 @@ static bool FindNamedType(struct xkb_keymap *keymap, xkb_atom_t atom, unsigned *type_rtrn) { - unsigned n; + unsigned n = 0; const char *name = xkb_atom_text(keymap->ctx, atom); + struct xkb_key_type *type; - if (keymap && keymap->map && keymap->map->types) - { - for (n = 0; n < keymap->map->num_types; n++) - { - if (strcmp(keymap->map->types[n].name, name) == 0) - { + if (keymap && keymap->map) { + darray_foreach(type, keymap->map->types) { + if (strcmp(type->name, name) == 0) { *type_rtrn = n; return true; } + n++; } } return false; @@ -1941,6 +1929,7 @@ unsigned types[XkbNumKbdGroups]; union xkb_action *outActs; unsigned int symIndex = 0; + struct xkb_sym_map *sym_map; useAlias = (start_from == 0); @@ -2004,7 +1993,7 @@ types[i] = XkbTwoLevelIndex; } /* if the type specifies fewer levels than the key has, shrink the key */ - type = &keymap->map->types[types[i]]; + type = &darray_item(keymap->map->types, types[i]); if (type->num_levels < key->numLevels[i]) { if (warningLevel > 0) @@ -2042,17 +2031,19 @@ } else outActs = NULL; + + sym_map = &darray_item(keymap->map->key_sym_map, kc); + if (key->defs.defined & _Key_GroupInfo) i = key->groupInfo; else - i = keymap->map->key_sym_map[kc].group_info; + i = sym_map->group_info; + + sym_map->group_info = XkbSetNumGroups(i, nGroups); + sym_map->width = width; + sym_map->sym_index = uTypedCalloc(nGroups * width, int); + sym_map->num_syms = uTypedCalloc(nGroups * width, unsigned int); - keymap->map->key_sym_map[kc].group_info = XkbSetNumGroups(i, nGroups); - keymap->map->key_sym_map[kc].width = width; - keymap->map->key_sym_map[kc].sym_index = uTypedCalloc(nGroups * width, - int); - keymap->map->key_sym_map[kc].num_syms = uTypedCalloc(nGroups * width, - unsigned int); for (i = 0; i < nGroups; i++) { /* assign kt_index[i] to the index of the type in map->types. @@ -2063,7 +2054,7 @@ * FIXME: There should be a better fix for this. */ if (key->numLevels[i]) - keymap->map->key_sym_map[kc].kt_index[i] = types[i]; + sym_map->kt_index[i] = types[i]; if (key->sizeSyms[i] != 0) { /* fill key to "width" symbols*/ @@ -2071,21 +2062,19 @@ { if (tmp < key->numLevels[i] && key->symsMapNumEntries[i][tmp]) { - memcpy(&keymap->map->key_sym_map[kc].syms[symIndex], + memcpy(&sym_map->syms[symIndex], &key->syms[i][key->symsMapIndex[i][tmp]], key->symsMapNumEntries[i][tmp] * sizeof(xkb_keysym_t)); - keymap->map->key_sym_map[kc].sym_index[(i * width) + tmp] = - symIndex; - keymap->map->key_sym_map[kc].num_syms[(i * width) + tmp] = + sym_map->sym_index[(i * width) + tmp] = symIndex; + sym_map->num_syms[(i * width) + tmp] = key->symsMapNumEntries[i][tmp]; - symIndex += - keymap->map->key_sym_map[kc].num_syms[(i * width) + tmp]; + symIndex += sym_map->num_syms[(i * width) + tmp]; } else { - keymap->map->key_sym_map[kc].sym_index[(i * width) + tmp] = -1; - keymap->map->key_sym_map[kc].num_syms[(i * width) + tmp] = 0; + sym_map->sym_index[(i * width) + tmp] = -1; + sym_map->num_syms[(i * width) + tmp] = 0; } if ((outActs != NULL) && (key->acts[i] != NULL)) { @@ -2182,7 +2171,7 @@ HandleSymbolsFile(file, keymap, merge, &info); - if (info.nKeys == 0) + if (darray_empty(info.keys)) goto err_info; if (info.errorCount != 0) @@ -2226,22 +2215,22 @@ } /* sanitize keys */ - for (key = info.keys, i = 0; i < info.nKeys; i++, key++) + darray_foreach(key, info.keys) PrepareKeyDef(key); /* copy! */ - for (key = info.keys, i = 0; i < info.nKeys; i++, key++) + darray_foreach(key, info.keys) if (!CopySymbolsDef(keymap, key, 0)) info.errorCount++; if (warningLevel > 3) { for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) { - if (keymap->names->keys[i].name[0] == '\0') + if (darray_item(keymap->names->keys, i).name[0] == '\0') continue; if (XkbKeyNumGroups(keymap, i) < 1) { char buf[5]; - memcpy(buf, keymap->names->keys[i].name, 4); + memcpy(buf, darray_item(keymap->names->keys, i).name, 4); buf[4] = '\0'; WARN("No symbols defined for <%s> (keycode %d)\n", buf, i); } diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/xkbcomp.c libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/xkbcomp.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/xkbcomp.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/xkbcomp.c 2012-05-30 06:41:46.000000000 +0000 @@ -64,68 +64,12 @@ &keycodes->common, 0); } -static struct xkb_component_names * -XkbComponentsFromRules(struct xkb_context *ctx, - const char *rules, - const XkbRF_VarDefsPtr defs) -{ - FILE *rulesFile = NULL; - char *rulesPath = NULL; - XkbRF_RulesPtr loaded = NULL; - struct xkb_component_names * names = NULL; - int i; - - rulesFile = XkbFindFileInPath(ctx, rules, XkmRulesFile, &rulesPath); - if (!rulesFile) { - ERROR("could not find \"%s\" rules in XKB path\n", rules); - ERROR("%d include paths searched:\n", - xkb_context_num_include_paths(ctx)); - for (i = 0; i < xkb_context_num_include_paths(ctx); i++) - ERROR("\t%s\n", xkb_context_include_path_get(ctx, i)); - return NULL; - } - - if (!(loaded = uTypedCalloc(1, XkbRF_RulesRec))) { - ERROR("failed to allocate XKB rules\n"); - goto unwind_file; - } - - if (!XkbcRF_LoadRules(rulesFile, loaded)) { - ERROR("failed to load XKB rules \"%s\"\n", rulesPath); - goto unwind_file; - } - - if (!(names = uTypedCalloc(1, struct xkb_component_names))) { - ERROR("failed to allocate XKB components\n"); - goto unwind_file; - } - - if (!XkbcRF_GetComponents(loaded, defs, names)) { - free(names->keymap); - free(names->keycodes); - free(names->types); - free(names->compat); - free(names->symbols); - free(names); - names = NULL; - ERROR("no components returned from XKB rules \"%s\"\n", rulesPath); - } - -unwind_file: - XkbcRF_Free(loaded); - if (rulesFile) - fclose(rulesFile); - free(rulesPath); - return names; -} - _X_EXPORT struct xkb_keymap * xkb_map_new_from_names(struct xkb_context *ctx, const struct xkb_rule_names *rmlvo, enum xkb_map_compile_flags flags) { - XkbRF_VarDefsRec defs; - struct xkb_component_names *names; + struct xkb_component_names *kkctgs; struct xkb_keymap *keymap; if (!rmlvo || ISEMPTY(rmlvo->rules) || ISEMPTY(rmlvo->layout)) { @@ -133,26 +77,21 @@ return NULL; } - defs.model = rmlvo->model; - defs.layout = rmlvo->layout; - defs.variant = rmlvo->variant; - defs.options = rmlvo->options; - - names = XkbComponentsFromRules(ctx, rmlvo->rules, &defs); - if (!names) { + kkctgs = xkb_components_from_rules(ctx, rmlvo); + if (!kkctgs) { ERROR("failed to generate XKB components from rules \"%s\"\n", rmlvo->rules); return NULL; } - keymap = xkb_map_new_from_kccgst(ctx, names, 0); + keymap = xkb_map_new_from_kccgst(ctx, kkctgs, 0); - free(names->keymap); - free(names->keycodes); - free(names->types); - free(names->compat); - free(names->symbols); - free(names); + free(kkctgs->keymap); + free(kkctgs->keycodes); + free(kkctgs->types); + free(kkctgs->compat); + free(kkctgs->symbols); + free(kkctgs); return keymap; } @@ -199,7 +138,10 @@ /* Find map to use */ mapToUse = XkbChooseMap(file, NULL); - if (!mapToUse || mapToUse->type != XkmKeymapFile) { + if (!mapToUse) + goto err; + + if (mapToUse->type != XkmKeymapFile) { ERROR("file type %d not handled\n", mapToUse->type); goto err; } @@ -280,36 +222,29 @@ } _X_EXPORT struct xkb_keymap * -xkb_map_new_from_fd(struct xkb_context *ctx, - int fd, - enum xkb_keymap_format format, - enum xkb_map_compile_flags flags) +xkb_map_new_from_file(struct xkb_context *ctx, + FILE *file, + enum xkb_keymap_format format, + enum xkb_map_compile_flags flags) { - XkbFile *file; - FILE *fptr; + XkbFile *xkb_file; if (format != XKB_KEYMAP_FORMAT_TEXT_V1) { ERROR("unsupported keymap format %d\n", format); return NULL; } - if (fd < 0) { + if (!file) { ERROR("no file specified to generate XKB keymap\n"); - return NULL; - } - - fptr = fdopen(fd, "r"); - if (!fptr) { - ERROR("couldn't associate fd with file pointer\n"); return NULL; } - if (!XKBParseFile(ctx, fptr, "(unknown file)", &file)) { + if (!XKBParseFile(ctx, file, "(unknown file)", &xkb_file)) { ERROR("failed to parse input xkb file\n"); return NULL; } - return compile_keymap(ctx, file); + return compile_keymap(ctx, xkb_file); } _X_EXPORT struct xkb_keymap * diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/xkbcomp.h libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/xkbcomp.h --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/xkbcomp.h 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/xkbcomp.h 2012-05-30 06:41:46.000000000 +0000 @@ -131,13 +131,9 @@ } action; struct { - int nSyms; - int szSyms; - char **syms; - int nLevels; - int szLevels; - int *symsMapIndex; - unsigned int *symsNumEntries; + darray(char *) syms; + darray(int) symsMapIndex; + darray(unsigned int) symsNumEntries; } list; struct _Expr *child; xkb_atom_t str; diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/xkbcomp-priv.h libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/xkbcomp-priv.h --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkbcomp/xkbcomp-priv.h 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkbcomp/xkbcomp-priv.h 2012-05-30 06:41:46.000000000 +0000 @@ -80,15 +80,4 @@ extern bool UpdateModifiersFromCompat(struct xkb_keymap *keymap); -extern const char * -XkbDirectoryForInclude(unsigned type); - -extern FILE * -XkbFindFileInPath(struct xkb_context *ctx, const char *name, - unsigned type, char **pathRtrn); - -extern bool -XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn, - char *nextop_rtrn, char **extra_data); - #endif /* XKBCOMP_PRIV_H */ diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkb-priv.h libxkbcommon-0.1.0~git20120530.c87468e9/src/xkb-priv.h --- libxkbcommon-0.1.0~git20120520.8ca8f05a/src/xkb-priv.h 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/src/xkb-priv.h 2012-05-30 06:41:46.000000000 +0000 @@ -87,6 +87,7 @@ #include "xkbcommon/xkbcommon.h" #include "utils.h" +#include "darray.h" /* From XKM.h */ #define XkmKeymapFile 22 @@ -167,23 +168,23 @@ uint8_t device; uint8_t v1_what; uint8_t v1_index; - uint8_t v1_value; + int8_t v1_value; uint8_t v2_what; uint8_t v2_index; - uint8_t v2_value; + int8_t v2_value; }; struct xkb_pointer_default_action { uint8_t type; uint8_t flags; uint8_t affect; - uint8_t value; + int8_t value; }; struct xkb_switch_screen_action { uint8_t type; uint8_t flags; - uint8_t screen; + int8_t screen; }; struct xkb_redirect_key_action { @@ -198,8 +199,8 @@ struct xkb_pointer_action { uint8_t type; uint8_t flags; - uint16_t x; - uint16_t y; + int16_t x; + int16_t y; }; struct xkb_message_action { @@ -212,7 +213,7 @@ uint8_t type; uint8_t flags; uint8_t count; - uint8_t button; + int8_t button; }; union xkb_action { @@ -247,8 +248,7 @@ struct xkb_key_type { struct xkb_mods mods; uint16_t num_levels; - unsigned char map_count; - struct xkb_kt_map_entry * map; + darray(struct xkb_kt_map_entry) map; struct xkb_mods * preserve; const char *name; const char **level_names; @@ -264,10 +264,8 @@ }; struct xkb_compat_map { - struct xkb_sym_interpret * sym_interpret; + darray(struct xkb_sym_interpret) sym_interpret; struct xkb_mods groups[XkbNumKbdGroups]; - unsigned short num_si; - unsigned short size_si; }; struct xkb_sym_map { @@ -281,11 +279,9 @@ }; struct xkb_client_map { - unsigned char size_types; - unsigned char num_types; - struct xkb_key_type * types; - struct xkb_sym_map * key_sym_map; - unsigned char *modmap; + darray(struct xkb_key_type) types; + darray(struct xkb_sym_map) key_sym_map; + unsigned char *modmap; }; struct xkb_behavior { @@ -294,14 +290,11 @@ }; struct xkb_server_map { - unsigned short num_acts; - unsigned short size_acts; - unsigned char * explicit; - union xkb_action *acts; + darray(union xkb_action) acts; + darray(size_t ) key_acts; /* acts[key_acts[keycode]] */ struct xkb_behavior *behaviors; - unsigned short *key_acts; uint32_t vmods[XkbNumVirtualMods]; /* vmod -> mod mapping */ uint32_t *vmodmap; /* key -> vmod mapping */ }; @@ -333,11 +326,9 @@ const char *vmods[XkbNumVirtualMods]; const char *indicators[XkbNumIndicators]; const char *groups[XkbNumKbdGroups]; - struct xkb_key_name * keys; - struct xkb_key_alias * key_aliases; - xkb_keycode_t num_keys; - xkb_keycode_t num_key_aliases; + darray(struct xkb_key_name) keys; + darray(struct xkb_key_alias) key_aliases; }; struct xkb_controls { @@ -376,39 +367,52 @@ struct xkb_compat_map * compat; }; -#define XkbNumGroups(g) ((g)&0x0f) -#define XkbOutOfRangeGroupInfo(g) ((g)&0xf0) -#define XkbOutOfRangeGroupAction(g) ((g)&0xc0) -#define XkbOutOfRangeGroupNumber(g) (((g)&0x30)>>4) -#define XkbSetGroupInfo(g,w,n) (((w)&0xc0)|(((n)&3)<<4)|((g)&0x0f)) -#define XkbSetNumGroups(g,n) (((g)&0xf0)|((n)&0x0f)) - -#define XkbKeyGroupInfo(d,k) ((d)->map->key_sym_map[k].group_info) -#define XkbKeyNumGroups(d,k) (XkbNumGroups((d)->map->key_sym_map[k].group_info)) -#define XkbKeyGroupWidth(d,k,g) (XkbKeyType(d,k,g)->num_levels) -#define XkbKeyGroupsWidth(d,k) ((d)->map->key_sym_map[k].width) -#define XkbKeyTypeIndex(d,k,g) ((d)->map->key_sym_map[k].kt_index[g&0x3]) -#define XkbKeyType(d,k,g) (&(d)->map->types[XkbKeyTypeIndex(d,k,g)]) -#define XkbKeyNumSyms(d,k,g,sl) \ - ((d)->map->key_sym_map[k].num_syms[(g*XkbKeyGroupsWidth(d,k))+sl]) -#define XkbKeySym(d,k,n) (&(d)->map->key_sym_map[k].syms[n]) -#define XkbKeySymOffset(d,k,g,sl) \ - ((d)->map->key_sym_map[k].sym_index[(g*XkbKeyGroupsWidth(d,k))+sl]) -#define XkbKeySymEntry(d,k,g,sl) \ - (XkbKeySym(d,k,XkbKeySymOffset(d,k,g,sl))) -#define XkbKeyHasActions(d,k) ((d)->server->key_acts[k]!=0) -#define XkbKeyNumActions(d,k) \ - (XkbKeyHasActions(d,k)?(XkbKeyGroupsWidth(d,k)*XkbKeyNumGroups(d,k)):1) -#define XkbKeyActionsPtr(d,k) (&(d)->server->acts[(d)->server->key_acts[k]]) -#define XkbKeyAction(d,k,n) \ - (XkbKeyHasActions(d,k)?&XkbKeyActionsPtr(d,k)[n]:NULL) -#define XkbKeyActionEntry(d,k,sl,g) \ - (XkbKeyHasActions(d,k)?\ - XkbKeyAction(d,k,((XkbKeyGroupsWidth(d,k)*(g))+(sl))):NULL) - -#define XkbKeycodeInRange(d,k) (((k)>=(d)->min_key_code)&&\ - ((k)<=(d)->max_key_code)) -#define XkbNumKeys(d) ((d)->max_key_code-(d)->min_key_code+1) +#define XkbNumGroups(g) ((g) & 0x0f) +#define XkbOutOfRangeGroupInfo(g) ((g) & 0xf0) +#define XkbOutOfRangeGroupAction(g) ((g) & 0xc0) +#define XkbOutOfRangeGroupNumber(g) (((g) & 0x30) >> 4) +#define XkbSetGroupInfo(g, w, n) (((w) & 0xc0) | (((n) & 3) << 4) | ((g) & 0x0f)) +#define XkbSetNumGroups(g, n) (((g) & 0xf0) | ((n) & 0x0f)) + +#define XkbKeyGroupInfo(d, k) \ + (darray_item((d)->map->key_sym_map, k).group_info) +#define XkbKeyNumGroups(d, k) \ + (XkbNumGroups(darray_item((d)->map->key_sym_map, k).group_info)) +#define XkbKeyGroupWidth(d, k, g) \ + (XkbKeyType(d, k, g)->num_levels) +#define XkbKeyGroupsWidth(d, k) \ + (darray_item((d)->map->key_sym_map, k).width) +#define XkbKeyTypeIndex(d, k, g) \ + (darray_item((d)->map->key_sym_map, k).kt_index[g & 0x3]) +#define XkbKeyType(d, k, g) \ + (&darray_item((d)->map->types, XkbKeyTypeIndex(d, k, g))) +#define XkbKeyNumSyms(d, k, g, sl) \ + (darray_item((d)->map->key_sym_map, k).num_syms[(g * XkbKeyGroupsWidth(d, k)) + sl]) +#define XkbKeySym(d, k, n) \ + (&darray_item((d)->map->key_sym_map, k).syms[n]) +#define XkbKeySymOffset(d, k, g, sl) \ + (darray_item((d)->map->key_sym_map, k).sym_index[(g * XkbKeyGroupsWidth(d, k)) + sl]) +#define XkbKeySymEntry(d, k, g, sl) \ + (XkbKeySym(d, k, XkbKeySymOffset(d, k, g, sl))) +#define XkbKeyHasActions(d, k) \ + (darray_item((d)->server->key_acts, k) != 0) +#define XkbKeyNumActions(d, k) \ + (XkbKeyHasActions(d, k) ? \ + (XkbKeyGroupsWidth(d, k) * XkbKeyNumGroups(d, k)) : \ + 1) +#define XkbKeyActionsPtr(d, k) \ + (&darray_item((d)->server->acts, darray_item((d)->server->key_acts, k))) +#define XkbKeyAction(d, k, n) \ + (XkbKeyHasActions(d, k) ? &XkbKeyActionsPtr(d, k)[n] : NULL) +#define XkbKeyActionEntry(d, k, sl, g) \ + (XkbKeyHasActions(d, k) ? \ + XkbKeyAction(d, k, ((XkbKeyGroupsWidth(d, k) * (g)) + (sl))) : \ + NULL) + +#define XkbKeycodeInRange(d, k) \ + (((k) >= (d)->min_key_code) && ((k) <= (d)->max_key_code)) +#define XkbNumKeys(d) \ + ((d)->max_key_code - (d)->min_key_code + 1) struct xkb_state { xkb_group_index_t base_group; /**< depressed */ @@ -501,6 +505,10 @@ extern unsigned _XkbcKSCheckCase(xkb_keysym_t sym); +extern xkb_keycode_t +XkbcFindKeycodeByName(struct xkb_keymap *keymap, const char *name, + bool use_aliases); + #define _XkbKSLower (1 << 0) #define _XkbKSUpper (1 << 1) diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/data/rules/groups libxkbcommon-0.1.0~git20120530.c87468e9/test/data/rules/groups --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/data/rules/groups 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/data/rules/groups 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,17 @@ +! $model_group = pc101 pc102 pc104 pc105 +! $layout_group = ar br cr us +! $variant_group = + +! model = keycodes + $model_group = something(%m) + * = default_keycodes + +! layout variant = symbols + $layout_group * = my_symbols+%(v) + * * = default_symbols + +! model = types + * = default_types + +! model = compat + * = default_compat diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/data/rules/index libxkbcommon-0.1.0~git20120530.c87468e9/test/data/rules/index --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/data/rules/index 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/data/rules/index 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,28 @@ +! $layouts = al az br cn us + +! layout option = symbols + $layouts some:opt = +extra + +! layout[1] option = symbols + $layouts some:opt = +extra:1 + +! layout[2] option = symbols + $layouts some:opt = +extra:2 + +! layout[3] option = symbols + $layouts some:opt = +extra:3 + +! layout[4] option = symbols + $layouts some:opt = +extra:4 + +! model = symbols + * = default_symbols + +! model = keycodes + * = default_keycodes + +! model = types + * = default_types + +! model = compat + * = default_compat diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/data/rules/simple libxkbcommon-0.1.0~git20120530.c87468e9/test/data/rules/simple --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/data/rules/simple 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/data/rules/simple 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,21 @@ +! model = keycodes + my_model = my_keycodes + * = default_keycodes + +! layout variant = symbols + my_layout my_variant = my_symbols+extra_variant + +! layout = symbols + my_layout = my_symbols + * = default_symbols + +! model = types + my_model = my_types + * = default_types + +! model = compat + my_model = my_compat + * = default_compat + +! option = compat + my_option = +some:compat diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/dump.c libxkbcommon-0.1.0~git20120530.c87468e9/test/dump.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/dump.c 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/dump.c 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,59 @@ +/* +Copyright 2009 Dan Nicholson + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors or their +institutions shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the authors. +*/ + +#include +#include +#include +#include + +#include "xkbcommon/xkbcommon.h" + +int main(int argc, char *argv[]) +{ + struct xkb_context *ctx = xkb_context_new(0); + struct xkb_keymap *keymap; + struct xkb_rule_names names = { + .rules = "evdev", + .model = "pc105", + .layout = "us", + .variant = NULL, + .options = NULL, + }; + char *as_string; + + assert(ctx); + keymap = xkb_map_new_from_names(ctx, &names, 0); + + as_string = xkb_map_get_as_string(keymap); + assert(as_string); + printf("%s\n", as_string); + + free(as_string); + xkb_map_unref(keymap); + xkb_context_unref(ctx); + + return 0; +} diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/filecomp.c libxkbcommon-0.1.0~git20120530.c87468e9/test/filecomp.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/filecomp.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/filecomp.c 2012-05-30 06:41:46.000000000 +0000 @@ -25,34 +25,31 @@ */ #include -#include #include #include #include -#include #include -#include -#include #include "xkbcommon/xkbcommon.h" static int test_file(const char *path) { - int fd; + FILE *file; struct xkb_context *context; struct xkb_keymap *keymap; - fd = open(path, O_RDONLY); - assert(fd >= 0); + file = fopen(path, "r"); + assert(file != NULL); context = xkb_context_new(0); assert(context); fprintf(stderr, "\nCompiling path: %s\n", path); - keymap = xkb_map_new_from_fd(context, fd, XKB_KEYMAP_FORMAT_TEXT_V1, 0); - close(fd); + keymap = xkb_map_new_from_file(context, file, + XKB_KEYMAP_FORMAT_TEXT_V1, 0); + fclose(file); if (!keymap) { fprintf(stderr, "Failed to compile keymap\n"); diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/.gitignore libxkbcommon-0.1.0~git20120530.c87468e9/test/.gitignore --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/.gitignore 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/.gitignore 2012-05-30 06:41:46.000000000 +0000 @@ -7,3 +7,4 @@ xkey state context +rules-file diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/rulescomp.c libxkbcommon-0.1.0~git20120530.c87468e9/test/rulescomp.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/rulescomp.c 2012-05-20 08:51:13.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/rulescomp.c 2012-05-30 06:41:46.000000000 +0000 @@ -26,6 +26,7 @@ #include #include +#include #include #include "xkbcommon/xkbcommon.h" @@ -112,5 +113,6 @@ assert(!test_rmlvo("base", "pc105", "", "", "")); assert(!test_rmlvo("badrules", "", "us", "", "")); - benchmark(); + if (argc > 1 && strcmp(argv[1], "bench") == 0) + benchmark(); } diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/rules-file.c libxkbcommon-0.1.0~git20120530.c87468e9/test/rules-file.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/rules-file.c 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/rules-file.c 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,184 @@ +/* + * Copyright © 2012 Ran Benita + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include + +#include "xkbcommon/xkbcommon.h" +#include "rules.h" + +struct test_data { + /* Rules file */ + const char *rules; + + /* Input */ + const char *model; + const char *layout; + const char *variant; + const char *options; + + /* Expected output */ + const char *keymap; + const char *keycodes; + const char *types; + const char *compat; + const char *symbols; + + /* Or set this if xkb_components_from_rules() should fail. */ + bool should_fail; +}; + +static inline bool +streq(const char *s1, const char *s2) +{ + if (s1 == NULL || s2 == NULL) + return s1 == s2; + return strcmp(s1, s2) == 0; +} + +static bool +test_rules(struct xkb_context *ctx, struct test_data *data) +{ + bool passed; + const struct xkb_rule_names rmlvo = { + data->rules, data->model, data->layout, data->variant, data->options + }; + struct xkb_component_names *kccgst; + + fprintf(stderr, "\n\nChecking : %s\t%s\t%s\t%s\t%s\n", data->rules, + data->model, data->layout, data->variant, data->options); + + if (data->should_fail) + fprintf(stderr, "Expecting: NULL\n"); + else + fprintf(stderr, "Expecting: %s\t%s\t%s\t%s\t%s\n", data->keymap, + data->keycodes, data->types, data->compat, data->symbols); + + kccgst = xkb_components_from_rules(ctx, &rmlvo); + if (!kccgst) { + fprintf(stderr, "Received: NULL\n"); + return data->should_fail; + } + + fprintf(stderr, "Received : %s\t%s\t%s\t%s\t%s\n", kccgst->keymap, + kccgst->keycodes, kccgst->types, kccgst->compat, kccgst->symbols); + + passed = streq(kccgst->keymap, data->keymap) && + streq(kccgst->keycodes, data->keycodes) && + streq(kccgst->types, data->types) && + streq(kccgst->compat, data->compat) && + streq(kccgst->symbols, data->symbols); + + free(kccgst->keymap); + free(kccgst->keycodes); + free(kccgst->types); + free(kccgst->compat); + free(kccgst->symbols); + free(kccgst); + + return passed; +} + +int +main(void) +{ + struct xkb_context *ctx; + const char *srcdir = getenv("srcdir"); + char *path; + + ctx = xkb_context_new(XKB_CONTEXT_NO_DEFAULT_INCLUDES); + assert(ctx); + + assert(asprintf(&path, "%s/test/data", srcdir ? srcdir : ".") > 0); + assert(xkb_context_include_path_append(ctx, path)); + free(path); + + struct test_data test1 = { + .rules = "simple", + + .model = "my_model", .layout = "my_layout", .variant = "my_variant", + .options = "my_option", + + .keycodes = "my_keycodes", .types = "my_types", + .compat = "my_compat+some:compat", + .symbols = "my_symbols+extra_variant", + }; + assert(test_rules(ctx, &test1)); + + struct test_data test2 = { + .rules = "simple", + + .model = "", .layout = "", .variant = "", .options = "", + + .keycodes = "default_keycodes", .types = "default_types", + .compat = "default_compat", .symbols = "default_symbols", + }; + assert(test_rules(ctx, &test2)); + + struct test_data test3 = { + .rules = "groups", + + .model = "pc104", .layout = "foo", .variant = "", .options = "", + + .keycodes = "something(pc104)", .types = "default_types", + .compat = "default_compat", .symbols = "default_symbols", + }; + assert(test_rules(ctx, &test3)); + + struct test_data test4 = { + .rules = "groups", + + .model = "foo", .layout = "ar", .variant = "bar", .options = "", + + .keycodes = "default_keycodes", .types = "default_types", + .compat = "default_compat", .symbols = "my_symbols+(bar)", + }; + assert(test_rules(ctx, &test4)); + + struct test_data test5 = { + .rules = "simple", + + .model = NULL, .layout = "my_layout,second_layout", .variant = "my_variant", + .options = "my_option", + + .should_fail = true + }; + assert(test_rules(ctx, &test5)); + + struct test_data test6 = { + .rules = "index", + + .model = "", .layout = "br,al,cn,az", .variant = "", + .options = "some:opt", + + .keycodes = "default_keycodes", .types = "default_types", + .compat = "default_compat", + .symbols = "default_symbols+extra:1+extra:2+extra:3+extra:4", + }; + assert(test_rules(ctx, &test6)); + + xkb_context_unref(ctx); + return 0; +} diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/stringcomp.c libxkbcommon-0.1.0~git20120530.c87468e9/test/stringcomp.c --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/stringcomp.c 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/stringcomp.c 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,82 @@ +/* +Copyright 2009 Dan Nicholson + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Except as contained in this notice, the names of the authors or their +institutions shall not be used in advertising or otherwise to promote the +sale, use or other dealings in this Software without prior written +authorization from the authors. +*/ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "xkbcommon/xkbcommon.h" + +int main(int argc, char *argv[]) +{ + struct xkb_context *ctx = xkb_context_new(0); + struct xkb_keymap *keymap; + struct stat info; + char *as_string, *buf; + char *path; + const char *srcdir; + int fd, count, remaining; + + assert(ctx); + + srcdir = getenv("srcdir"); + assert(srcdir); + assert(asprintf(&path, "%s/test/stringcomp.data", srcdir) > 0); + assert(path); + + fd = open(path, O_RDONLY); + assert(fd >= 0); + assert(fstat(fd, &info) == 0); + as_string = malloc(info.st_size + 1); + assert(as_string); + + remaining = info.st_size; + buf = as_string; + while ((count = read(fd, buf, remaining))) { + remaining -= count; + buf += count; + } + + assert(remaining == 0); + as_string[info.st_size] = '\0'; + + keymap = xkb_map_new_from_string(ctx, as_string, + XKB_KEYMAP_FORMAT_TEXT_V1, 0); + assert(keymap); + + free(path); + close(fd); + free(as_string); + xkb_map_unref(keymap); + xkb_context_unref(ctx); + + return 0; +} diff -Nru libxkbcommon-0.1.0~git20120520.8ca8f05a/test/stringcomp.data libxkbcommon-0.1.0~git20120530.c87468e9/test/stringcomp.data --- libxkbcommon-0.1.0~git20120520.8ca8f05a/test/stringcomp.data 1970-01-01 00:00:00.000000000 +0000 +++ libxkbcommon-0.1.0~git20120530.c87468e9/test/stringcomp.data 2012-05-30 06:41:46.000000000 +0000 @@ -0,0 +1,1460 @@ +xkb_keymap { + xkb_keycodes { + minimum = 8; + maximum = 255; + = 9; + = 10; + = 11; + = 12; + = 13; + = 14; + = 15; + = 16; + = 17; + = 18; + = 19; + = 20; + = 21; + = 22; + = 23; + = 24; + = 25; + = 26; + = 27; + = 28; + = 29; + = 30; + = 31; + = 32; + = 33; + = 34; + = 35; + = 36; + = 37; + = 38; + = 39; + = 40; + = 41; + = 42; + = 43; + = 44; + = 45; + = 46; + = 47; + = 48; + = 49; + = 50; + = 51; + = 52; + = 53; + = 54; + = 55; + = 56; + = 57; + = 58; + = 59; + = 60; + = 61; + = 62; + = 63; + = 64; + = 65; + = 66; + = 67; + = 68; + = 69; + = 70; + = 71; + = 72; + = 73; + = 74; + = 75; + = 76; + = 77; + = 78; + = 79; + = 80; + = 81; + = 82; + = 83; + = 84; + = 85; + = 86; + = 87; + = 88; + = 89; + = 90; + = 91; + = 92; + = 94; + = 95; + = 96; + = 97; + = 98; + = 99; + = 100; + = 101; + = 102; + = 103; + = 104; + = 105; + = 106; + = 107; + = 108; + = 109; + = 110; + = 111; + = 112; + = 113; + = 114; + = 115; + = 116; + = 117; + = 118; + = 119; + = 120; + = 121; + = 122; + = 123; + = 124; + = 125; + = 126; + = 127; + = 128; + = 129; + = 130; + = 131; + = 132; + = 133; + = 134; + = 135; + = 136; + = 137; + = 138; + = 139; + = 140; + = 141; + = 142; + = 143; + = 144; + = 145; + = 146; + = 147; + = 148; + = 149; + = 150; + = 151; + = 152; + = 153; + = 154; + = 155; + = 156; + = 157; + = 158; + = 159; + = 160; + = 161; + = 162; + = 163; + = 164; + = 165; + = 166; + = 167; + = 168; + = 169; + = 170; + = 171; + = 172; + = 173; + = 174; + = 175; + = 176; + = 177; + = 178; + = 179; + = 180; + = 181; + = 182; + = 183; + = 184; + = 185; + = 186; + = 187; + = 188; + = 189; + = 190; + = 191; + = 192; + = 193; + = 194; + = 195; + = 196; + = 197; + = 198; + = 199; + = 200; + = 201; + = 202; + = 203; + = 204; + = 205; + = 206; + = 207; + = 208; + = 209; + = 210; + = 211; + = 212; + = 213; + = 214; + = 215; + = 216; + = 217; + = 218; + = 219; + = 220; + = 221; + = 222; + = 223; + = 224; + = 225; + = 226; + = 227; + = 228; + = 229; + = 230; + = 231; + = 232; + = 233; + = 234; + = 235; + = 236; + = 237; + = 238; + = 239; + = 240; + = 241; + = 242; + = 243; + = 244; + = 245; + = 246; + = 247; + = 248; + = 249; + = 250; + = 251; + = 252; + = 253; + indicator 1 = "Caps Lock"; + indicator 2 = "Num Lock"; + indicator 3 = "Scroll Lock"; + indicator 4 = "Compose"; + indicator 5 = "Kana"; + indicator 6 = "Sleep"; + indicator 7 = "Suspend"; + indicator 8 = "Mute"; + indicator 9 = "Misc"; + indicator 10 = "Mail"; + indicator 11 = "Charging"; + indicator 12 = "Shift Lock"; + indicator 13 = "Group 2"; + indicator 14 = "Mouse Keys"; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + alias = ; + }; + + xkb_types { + + virtual_modifiers NumLock,Alt,LevelThree,LAlt,RAlt,RControl,LControl,ScrollLock,LevelFive,AltGr,Meta,Super,Hyper; + + type "ONE_LEVEL" { + modifiers= none; + level_name[Level1]= "Any"; + }; + type "TWO_LEVEL" { + modifiers= Shift; + map[Shift]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + }; + type "ALPHABETIC" { + modifiers= Shift+Lock; + map[Shift]= Level2; + map[Lock]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "Caps"; + }; + type "KEYPAD" { + modifiers= Shift+NumLock; + map[Shift]= Level2; + map[NumLock]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "Number"; + }; + type "SHIFT+ALT" { + modifiers= Shift+Alt; + map[Shift+Alt]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift+Alt"; + }; + type "PC_CONTROL_LEVEL2" { + modifiers= Control; + map[Control]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "Control"; + }; + type "PC_LCONTROL_LEVEL2" { + modifiers= LControl; + map[LControl]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "LControl"; + }; + type "PC_RCONTROL_LEVEL2" { + modifiers= RControl; + map[RControl]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "RControl"; + }; + type "PC_ALT_LEVEL2" { + modifiers= Alt; + map[Alt]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "Alt"; + }; + type "PC_LALT_LEVEL2" { + modifiers= LAlt; + map[LAlt]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "LAlt"; + }; + type "PC_RALT_LEVEL2" { + modifiers= RAlt; + map[RAlt]= Level2; + level_name[Level1]= "Base"; + level_name[Level2]= "RAlt"; + }; + type "CTRL+ALT" { + modifiers= Shift+Control+Alt+LevelThree; + map[Shift]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[Control+Alt]= Level5; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Shift Alt"; + level_name[Level5]= "Ctrl+Alt"; + }; + type "LOCAL_EIGHT_LEVEL" { + modifiers= Shift+Lock+Control+LevelThree; + map[Shift+Lock]= Level1; + map[Shift]= Level2; + map[Lock]= Level2; + map[LevelThree]= Level3; + map[Shift+Lock+LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[Lock+LevelThree]= Level4; + map[Control]= Level5; + map[Shift+Lock+Control]= Level5; + map[Shift+Control]= Level6; + map[Lock+Control]= Level6; + map[Control+LevelThree]= Level7; + map[Shift+Lock+Control+LevelThree]= Level7; + map[Shift+Control+LevelThree]= Level8; + map[Lock+Control+LevelThree]= Level8; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Level3"; + level_name[Level4]= "Shift Level3"; + level_name[Level5]= "Ctrl"; + level_name[Level6]= "Shift Ctrl"; + level_name[Level7]= "Level3 Ctrl"; + level_name[Level8]= "Shift Level3 Ctrl"; + }; + type "THREE_LEVEL" { + modifiers= Shift+LevelThree; + map[Shift]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level3; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Level3"; + }; + type "EIGHT_LEVEL" { + modifiers= Shift+LevelThree+LevelFive; + map[Shift]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[LevelFive]= Level5; + map[Shift+LevelFive]= Level6; + map[LevelThree+LevelFive]= Level7; + map[Shift+LevelThree+LevelFive]= Level8; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Shift Alt"; + level_name[Level5]= "X"; + level_name[Level6]= "X Shift"; + level_name[Level7]= "X Alt Base"; + level_name[Level8]= "X Shift Alt"; + }; + type "EIGHT_LEVEL_ALPHABETIC" { + modifiers= Shift+Lock+LevelThree+LevelFive; + map[Shift]= Level2; + map[Lock]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[Lock+LevelThree]= Level4; + map[Shift+Lock+LevelThree]= Level3; + map[LevelFive]= Level5; + map[Shift+LevelFive]= Level6; + map[Lock+LevelFive]= Level6; + map[LevelThree+LevelFive]= Level7; + map[Shift+LevelThree+LevelFive]= Level8; + map[Lock+LevelThree+LevelFive]= Level8; + map[Shift+Lock+LevelThree+LevelFive]= Level7; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Shift Alt"; + level_name[Level5]= "X"; + level_name[Level6]= "X Shift"; + level_name[Level7]= "X Alt Base"; + level_name[Level8]= "X Shift Alt"; + }; + type "EIGHT_LEVEL_SEMIALPHABETIC" { + modifiers= Shift+Lock+LevelThree+LevelFive; + map[Shift]= Level2; + map[Lock]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[Lock+LevelThree]= Level3; + preserve[Lock+LevelThree]= Lock; + map[Shift+Lock+LevelThree]= Level4; + preserve[Shift+Lock+LevelThree]= Lock; + map[LevelFive]= Level5; + map[Shift+LevelFive]= Level6; + map[Lock+LevelFive]= Level6; + preserve[Lock+LevelFive]= Lock; + map[LevelThree+LevelFive]= Level7; + map[Shift+LevelThree+LevelFive]= Level8; + map[Lock+LevelThree+LevelFive]= Level7; + preserve[Lock+LevelThree+LevelFive]= Lock; + map[Shift+Lock+LevelThree+LevelFive]= Level8; + preserve[Shift+Lock+LevelThree+LevelFive]= Lock; + map[Shift+Lock+LevelFive]= Level1; + preserve[Shift+Lock+LevelFive]= Lock; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Shift Alt"; + level_name[Level5]= "X"; + level_name[Level6]= "X Shift"; + level_name[Level7]= "X Alt Base"; + level_name[Level8]= "X Shift Alt"; + }; + type "FOUR_LEVEL" { + modifiers= Shift+LevelThree; + map[Shift]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Shift Alt"; + }; + type "FOUR_LEVEL_ALPHABETIC" { + modifiers= Shift+Lock+LevelThree; + map[Shift]= Level2; + map[Lock]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[Lock+LevelThree]= Level4; + map[Shift+Lock+LevelThree]= Level3; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Shift Alt"; + }; + type "FOUR_LEVEL_SEMIALPHABETIC" { + modifiers= Shift+Lock+LevelThree; + map[Shift]= Level2; + map[Lock]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[Lock+LevelThree]= Level3; + preserve[Lock+LevelThree]= Lock; + map[Shift+Lock+LevelThree]= Level4; + preserve[Shift+Lock+LevelThree]= Lock; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Shift Alt"; + }; + type "FOUR_LEVEL_MIXED_KEYPAD" { + modifiers= Shift+NumLock+LevelThree; + map[Shift+NumLock]= Level1; + map[NumLock]= Level2; + map[Shift]= Level2; + map[LevelThree]= Level3; + map[NumLock+LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[Shift+NumLock+LevelThree]= Level4; + level_name[Level1]= "Base"; + level_name[Level2]= "Number"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Shift Alt"; + }; + type "FOUR_LEVEL_X" { + modifiers= Shift+Control+Alt+LevelThree; + map[LevelThree]= Level2; + map[Shift+LevelThree]= Level3; + map[Control+Alt]= Level4; + level_name[Level1]= "Base"; + level_name[Level2]= "Alt Base"; + level_name[Level3]= "Shift Alt"; + level_name[Level4]= "Ctrl+Alt"; + }; + type "SEPARATE_CAPS_AND_SHIFT_ALPHABETIC" { + modifiers= Shift+Lock+LevelThree; + map[Shift]= Level2; + map[Lock]= Level4; + preserve[Lock]= Lock; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[Lock+LevelThree]= Level3; + preserve[Lock+LevelThree]= Lock; + map[Shift+Lock+LevelThree]= Level3; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "AltGr Base"; + level_name[Level4]= "Shift AltGr"; + }; + type "FOUR_LEVEL_PLUS_LOCK" { + modifiers= Shift+Lock+LevelThree; + map[Shift]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[Lock]= Level5; + map[Shift+Lock]= Level2; + map[Lock+LevelThree]= Level3; + map[Shift+Lock+LevelThree]= Level4; + level_name[Level1]= "Base"; + level_name[Level2]= "Shift"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Shift Alt"; + level_name[Level5]= "Lock"; + }; + type "FOUR_LEVEL_KEYPAD" { + modifiers= Shift+NumLock+LevelThree; + map[Shift]= Level2; + map[NumLock]= Level2; + map[LevelThree]= Level3; + map[Shift+LevelThree]= Level4; + map[NumLock+LevelThree]= Level4; + map[Shift+NumLock+LevelThree]= Level3; + level_name[Level1]= "Base"; + level_name[Level2]= "Number"; + level_name[Level3]= "Alt Base"; + level_name[Level4]= "Alt Number"; + }; + }; + + xkb_compatibility { + + virtual_modifiers NumLock,Alt,LevelThree,LAlt,RAlt,RControl,LControl,ScrollLock,LevelFive,AltGr,Meta,Super,Hyper; + + interpret.useModMapMods= AnyLevel; + interpret.repeat= false; + interpret.locking= false; + interpret ISO_Level2_Latch+Exactly(Shift) { + useModMapMods=level1; + action= LatchMods(modifiers=Shift,clearLocks,latchToLock); + }; + interpret Shift_Lock+AnyOf(Shift+Lock) { + action= LockMods(modifiers=Shift); + }; + interpret Num_Lock+AnyOf(all) { + virtualModifier= NumLock; + action= LockMods(modifiers=NumLock); + }; + interpret ISO_Lock+AnyOf(all) { + action= NoAction(); + }; + interpret ISO_Level3_Shift+AnyOf(all) { + virtualModifier= LevelThree; + useModMapMods=level1; + action= SetMods(modifiers=LevelThree,clearLocks); + }; + interpret ISO_Level3_Latch+AnyOf(all) { + virtualModifier= LevelThree; + useModMapMods=level1; + action= LatchMods(modifiers=LevelThree,clearLocks,latchToLock); + }; + interpret ISO_Level3_Lock+AnyOf(all) { + virtualModifier= LevelThree; + useModMapMods=level1; + action= LockMods(modifiers=LevelThree); + }; + interpret Alt_L+AnyOf(all) { + virtualModifier= Alt; + action= SetMods(modifiers=modMapMods,clearLocks); + }; + interpret Alt_R+AnyOf(all) { + virtualModifier= Alt; + action= SetMods(modifiers=modMapMods,clearLocks); + }; + interpret Meta_L+AnyOf(all) { + virtualModifier= Meta; + action= SetMods(modifiers=modMapMods,clearLocks); + }; + interpret Meta_R+AnyOf(all) { + virtualModifier= Meta; + action= SetMods(modifiers=modMapMods,clearLocks); + }; + interpret Super_L+AnyOf(all) { + virtualModifier= Super; + action= SetMods(modifiers=modMapMods,clearLocks); + }; + interpret Super_R+AnyOf(all) { + virtualModifier= Super; + action= SetMods(modifiers=modMapMods,clearLocks); + }; + interpret Hyper_L+AnyOf(all) { + virtualModifier= Hyper; + action= SetMods(modifiers=modMapMods,clearLocks); + }; + interpret Hyper_R+AnyOf(all) { + virtualModifier= Hyper; + action= SetMods(modifiers=modMapMods,clearLocks); + }; + interpret Scroll_Lock+AnyOf(all) { + virtualModifier= ScrollLock; + action= LockMods(modifiers=modMapMods); + }; + interpret ISO_Level5_Shift+AnyOf(all) { + virtualModifier= LevelFive; + useModMapMods=level1; + action= SetMods(modifiers=LevelFive,clearLocks); + }; + interpret ISO_Level5_Latch+AnyOf(all) { + virtualModifier= LevelFive; + action= LatchMods(modifiers=LevelFive,clearLocks,latchToLock); + }; + interpret ISO_Level5_Lock+AnyOf(all) { + virtualModifier= LevelFive; + action= LockMods(modifiers=LevelFive); + }; + interpret Mode_switch+AnyOfOrNone(all) { + virtualModifier= AltGr; + useModMapMods=level1; + action= SetGroup(group=+1); + }; + interpret ISO_Level3_Shift+AnyOfOrNone(all) { + action= SetMods(modifiers=LevelThree,clearLocks); + }; + interpret ISO_Level3_Latch+AnyOfOrNone(all) { + action= LatchMods(modifiers=LevelThree,clearLocks,latchToLock); + }; + interpret ISO_Level3_Lock+AnyOfOrNone(all) { + action= LockMods(modifiers=LevelThree); + }; + interpret ISO_Group_Latch+AnyOfOrNone(all) { + virtualModifier= AltGr; + useModMapMods=level1; + action= LatchGroup(group=2); + }; + interpret ISO_Next_Group+AnyOfOrNone(all) { + virtualModifier= AltGr; + useModMapMods=level1; + action= LockGroup(group=+1); + }; + interpret ISO_Prev_Group+AnyOfOrNone(all) { + virtualModifier= AltGr; + useModMapMods=level1; + action= LockGroup(group=-1); + }; + interpret ISO_First_Group+AnyOfOrNone(all) { + action= LockGroup(group=1); + }; + interpret ISO_Last_Group+AnyOfOrNone(all) { + action= LockGroup(group=2); + }; + interpret KP_1+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=-1,y=+1); + }; + interpret KP_End+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=-1,y=+1); + }; + interpret KP_2+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+0,y=+1); + }; + interpret KP_Down+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+0,y=+1); + }; + interpret KP_3+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+1,y=+1); + }; + interpret KP_Next+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+1,y=+1); + }; + interpret KP_4+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=-1,y=+0); + }; + interpret KP_Left+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=-1,y=+0); + }; + interpret KP_6+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+1,y=+0); + }; + interpret KP_Right+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+1,y=+0); + }; + interpret KP_7+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=-1,y=-1); + }; + interpret KP_Home+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=-1,y=-1); + }; + interpret KP_8+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+0,y=-1); + }; + interpret KP_Up+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+0,y=-1); + }; + interpret KP_9+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+1,y=-1); + }; + interpret KP_Prior+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+1,y=-1); + }; + interpret KP_5+AnyOfOrNone(all) { + repeat= true; + action= PtrBtn(button=default); + }; + interpret KP_Begin+AnyOfOrNone(all) { + repeat= true; + action= PtrBtn(button=default); + }; + interpret KP_F2+AnyOfOrNone(all) { + repeat= true; + action= SetPtrDflt(affect=button,button=1); + }; + interpret KP_Divide+AnyOfOrNone(all) { + repeat= true; + action= SetPtrDflt(affect=button,button=1); + }; + interpret KP_F3+AnyOfOrNone(all) { + repeat= true; + action= SetPtrDflt(affect=button,button=2); + }; + interpret KP_Multiply+AnyOfOrNone(all) { + repeat= true; + action= SetPtrDflt(affect=button,button=2); + }; + interpret KP_F4+AnyOfOrNone(all) { + repeat= true; + action= SetPtrDflt(affect=button,button=3); + }; + interpret KP_Subtract+AnyOfOrNone(all) { + repeat= true; + action= SetPtrDflt(affect=button,button=3); + }; + interpret KP_Separator+AnyOfOrNone(all) { + repeat= true; + action= PtrBtn(button=default,count=2); + }; + interpret KP_Add+AnyOfOrNone(all) { + repeat= true; + action= PtrBtn(button=default,count=2); + }; + interpret KP_0+AnyOfOrNone(all) { + repeat= true; + action= LockPtrBtn(button=default,affect=lock); + }; + interpret KP_Insert+AnyOfOrNone(all) { + repeat= true; + action= LockPtrBtn(button=default,affect=lock); + }; + interpret KP_Decimal+AnyOfOrNone(all) { + repeat= true; + action= LockPtrBtn(button=default,affect=unlock); + }; + interpret KP_Delete+AnyOfOrNone(all) { + repeat= true; + action= LockPtrBtn(button=default,affect=unlock); + }; + interpret F25+AnyOfOrNone(all) { + repeat= true; + action= SetPtrDflt(affect=button,button=1); + }; + interpret F26+AnyOfOrNone(all) { + repeat= true; + action= SetPtrDflt(affect=button,button=2); + }; + interpret F27+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=-1,y=-1); + }; + interpret F29+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+1,y=-1); + }; + interpret F31+AnyOfOrNone(all) { + repeat= true; + action= PtrBtn(button=default); + }; + interpret F33+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=-1,y=+1); + }; + interpret F35+AnyOfOrNone(all) { + repeat= true; + action= MovePtr(x=+1,y=+1); + }; + interpret Pointer_Button_Dflt+AnyOfOrNone(all) { + action= PtrBtn(button=default); + }; + interpret Pointer_Button1+AnyOfOrNone(all) { + action= PtrBtn(button=1); + }; + interpret Pointer_Button2+AnyOfOrNone(all) { + action= PtrBtn(button=2); + }; + interpret Pointer_Button3+AnyOfOrNone(all) { + action= PtrBtn(button=3); + }; + interpret Pointer_DblClick_Dflt+AnyOfOrNone(all) { + action= PtrBtn(button=default,count=2); + }; + interpret Pointer_DblClick1+AnyOfOrNone(all) { + action= PtrBtn(button=1,count=2); + }; + interpret Pointer_DblClick2+AnyOfOrNone(all) { + action= PtrBtn(button=2,count=2); + }; + interpret Pointer_DblClick3+AnyOfOrNone(all) { + action= PtrBtn(button=3,count=2); + }; + interpret Pointer_Drag_Dflt+AnyOfOrNone(all) { + action= LockPtrBtn(button=default,affect=both); + }; + interpret Pointer_Drag1+AnyOfOrNone(all) { + action= LockPtrBtn(button=1,affect=both); + }; + interpret Pointer_Drag2+AnyOfOrNone(all) { + action= LockPtrBtn(button=2,affect=both); + }; + interpret Pointer_Drag3+AnyOfOrNone(all) { + action= LockPtrBtn(button=3,affect=both); + }; + interpret Pointer_EnableKeys+AnyOfOrNone(all) { + action= LockControls(controls=mouseKeys); + }; + interpret Pointer_Accelerate+AnyOfOrNone(all) { + action= LockControls(controls=mouseKeysAccel); + }; + interpret Pointer_DfltBtnNext+AnyOfOrNone(all) { + action= SetPtrDflt(affect=button,button=+1); + }; + interpret Pointer_DfltBtnPrev+AnyOfOrNone(all) { + action= SetPtrDflt(affect=button,button=-1); + }; + interpret AccessX_Enable+AnyOfOrNone(all) { + action= LockControls(controls=accessXKeys); + }; + interpret AccessX_Feedback_Enable+AnyOfOrNone(all) { + action= LockControls(controls=accessXFeedback); + }; + interpret RepeatKeys_Enable+AnyOfOrNone(all) { + action= LockControls(controls=repeatKeys); + }; + interpret SlowKeys_Enable+AnyOfOrNone(all) { + action= LockControls(controls=slowKeys); + }; + interpret BounceKeys_Enable+AnyOfOrNone(all) { + action= LockControls(controls=bounceKeys); + }; + interpret StickyKeys_Enable+AnyOfOrNone(all) { + action= LockControls(controls=stickyKeys); + }; + interpret MouseKeys_Enable+AnyOfOrNone(all) { + action= LockControls(controls=mouseKeys); + }; + interpret MouseKeys_Accel_Enable+AnyOfOrNone(all) { + action= LockControls(controls=mouseKeysAccel); + }; + interpret Overlay1_Enable+AnyOfOrNone(all) { + action= LockControls(controls=none); + }; + interpret Overlay2_Enable+AnyOfOrNone(all) { + action= LockControls(controls=none); + }; + interpret AudibleBell_Enable+AnyOfOrNone(all) { + action= LockControls(controls=audibleBell); + }; + interpret Terminate_Server+AnyOfOrNone(all) { + action= Terminate(); + }; + interpret Alt_L+AnyOfOrNone(all) { + action= SetMods(modifiers=Alt,clearLocks); + }; + interpret Alt_R+AnyOfOrNone(all) { + action= SetMods(modifiers=Alt,clearLocks); + }; + interpret Meta_L+AnyOfOrNone(all) { + action= SetMods(modifiers=Meta,clearLocks); + }; + interpret Meta_R+AnyOfOrNone(all) { + action= SetMods(modifiers=Meta,clearLocks); + }; + interpret Super_L+AnyOfOrNone(all) { + action= SetMods(modifiers=Super,clearLocks); + }; + interpret Super_R+AnyOfOrNone(all) { + action= SetMods(modifiers=Super,clearLocks); + }; + interpret Hyper_L+AnyOfOrNone(all) { + action= SetMods(modifiers=Hyper,clearLocks); + }; + interpret Hyper_R+AnyOfOrNone(all) { + action= SetMods(modifiers=Hyper,clearLocks); + }; + interpret Shift_L+AnyOfOrNone(all) { + action= SetMods(modifiers=Shift,clearLocks); + }; + interpret XF86Switch_VT_1+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=1,!same); + }; + interpret XF86Switch_VT_2+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=2,!same); + }; + interpret XF86Switch_VT_3+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=3,!same); + }; + interpret XF86Switch_VT_4+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=4,!same); + }; + interpret XF86Switch_VT_5+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=5,!same); + }; + interpret XF86Switch_VT_6+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=6,!same); + }; + interpret XF86Switch_VT_7+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=7,!same); + }; + interpret XF86Switch_VT_8+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=8,!same); + }; + interpret XF86Switch_VT_9+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=9,!same); + }; + interpret XF86Switch_VT_10+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=10,!same); + }; + interpret XF86Switch_VT_11+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=11,!same); + }; + interpret XF86Switch_VT_12+AnyOfOrNone(all) { + repeat= true; + action= SwitchScreen(screen=12,!same); + }; + interpret XF86LogGrabInfo+AnyOfOrNone(all) { + repeat= true; + action= Private(type=0x86,data[0]=0x50,data[1]=0x72,data[2]=0x47,data[3]=0x72,data[4]=0x62,data[5]=0x73,data[6]=0x00); + }; + interpret XF86LogWindowTree+AnyOfOrNone(all) { + repeat= true; + action= Private(type=0x86,data[0]=0x50,data[1]=0x72,data[2]=0x57,data[3]=0x69,data[4]=0x6e,data[5]=0x73,data[6]=0x00); + }; + interpret XF86Next_VMode+AnyOfOrNone(all) { + repeat= true; + action= Private(type=0x86,data[0]=0x2b,data[1]=0x56,data[2]=0x4d,data[3]=0x6f,data[4]=0x64,data[5]=0x65,data[6]=0x00); + }; + interpret XF86Prev_VMode+AnyOfOrNone(all) { + repeat= true; + action= Private(type=0x86,data[0]=0x2d,data[1]=0x56,data[2]=0x4d,data[3]=0x6f,data[4]=0x64,data[5]=0x65,data[6]=0x00); + }; + interpret ISO_Level5_Shift+AnyOfOrNone(all) { + action= SetMods(modifiers=LevelFive,clearLocks); + }; + interpret ISO_Level5_Latch+AnyOfOrNone(all) { + action= LatchMods(modifiers=LevelFive,clearLocks,latchToLock); + }; + interpret ISO_Level5_Lock+AnyOfOrNone(all) { + action= LockMods(modifiers=LevelFive); + }; + interpret Caps_Lock+AnyOfOrNone(all) { + action= LockMods(modifiers=Lock); + }; + interpret Any+Exactly(Lock) { + action= LockMods(modifiers=Lock); + }; + interpret Any+AnyOf(all) { + action= SetMods(modifiers=modMapMods,clearLocks); + }; + group 2 = AltGr; + group 3 = AltGr; + group 4 = AltGr; + indicator "Caps Lock" { + whichModState= locked; + modifiers= Lock; + }; + indicator "Num Lock" { + whichModState= locked; + modifiers= NumLock; + }; + indicator "Scroll Lock" { + whichModState= locked; + modifiers= ScrollLock; + }; + indicator "Shift Lock" { + whichModState= locked; + modifiers= Shift; + }; + indicator "Group 2" { + groups= 0xfe; + }; + indicator "Mouse Keys" { + controls= mouseKeys; + }; + }; + + xkb_symbols { + + name[group1]="English (US)"; + + key { [ Escape ] }; + key { [ 1, exclam ] }; + key { [ 2, at ] }; + key { [ 3, numbersign ] }; + key { [ 4, dollar ] }; + key { [ 5, percent ] }; + key { [ 6, asciicircum ] }; + key { [ 7, ampersand ] }; + key { [ 8, asterisk ] }; + key { [ 9, parenleft ] }; + key { [ 0, parenright ] }; + key { [ minus, underscore ] }; + key { [ equal, plus ] }; + key { [ BackSpace, BackSpace ] }; + key { [ Tab, ISO_Left_Tab ] }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ q, Q ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ w, W ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ e, E ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ r, R ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ t, T ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ y, Y ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ u, U ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ i, I ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ o, O ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ p, P ] + }; + key { [ bracketleft, braceleft ] }; + key { [ bracketright, braceright ] }; + key { [ Return ] }; + key { [ Control_L ] }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ a, A ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ s, S ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ d, D ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ f, F ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ g, G ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ h, H ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ j, J ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ k, K ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ l, L ] + }; + key { [ semicolon, colon ] }; + key { [ apostrophe, quotedbl ] }; + key { [ grave, asciitilde ] }; + key { [ Shift_L ] }; + key { [ NoSymbol, NoSymbol ] }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ z, Z ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ x, X ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ c, C ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ v, V ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ b, B ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ n, N ] + }; + key { + type= "ALPHABETIC", + symbols[Group1]= [ m, M ] + }; + key { [ comma, less ] }; + key { [ period, greater ] }; + key { [ slash, question ] }; + key { [ Shift_R ] }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ KP_Multiply, KP_Multiply, KP_Multiply, KP_Multiply, XF86ClearGrab ] + }; + key { [ Alt_L, Meta_L ] }; + key { [ space ] }; + key { [ Caps_Lock ] }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F1, F1, F1, F1, XF86Switch_VT_1 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F2, F2, F2, F2, XF86Switch_VT_2 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F3, F3, F3, F3, XF86Switch_VT_3 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F4, F4, F4, F4, XF86Switch_VT_4 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F5, F5, F5, F5, XF86Switch_VT_5 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F6, F6, F6, F6, XF86Switch_VT_6 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F7, F7, F7, F7, XF86Switch_VT_7 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F8, F8, F8, F8, XF86Switch_VT_8 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F9, F9, F9, F9, XF86Switch_VT_9 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F10, F10, F10, F10, XF86Switch_VT_10 ] + }; + key { [ Num_Lock ] }; + key { [ Scroll_Lock ] }; + key { [ KP_Home, KP_7 ] }; + key { [ KP_Up, KP_8 ] }; + key { [ KP_Prior, KP_9 ] }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ KP_Subtract, KP_Subtract, KP_Subtract, KP_Subtract, XF86Prev_VMode ] + }; + key { [ KP_Left, KP_4 ] }; + key { [ KP_Begin, KP_5 ] }; + key { [ KP_Right, KP_6 ] }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ KP_Add, KP_Add, KP_Add, KP_Add, XF86Next_VMode ] + }; + key { [ KP_End, KP_1 ] }; + key { [ KP_Down, KP_2 ] }; + key { [ KP_Next, KP_3 ] }; + key { [ KP_Insert, KP_0 ] }; + key { [ KP_Delete, KP_Decimal ] }; + key { [ ISO_Level3_Shift ] }; + key { + type= "FOUR_LEVEL", + symbols[Group1]= [ less, greater, bar, brokenbar ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F11, F11, F11, F11, XF86Switch_VT_11 ] + }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ F12, F12, F12, F12, XF86Switch_VT_12 ] + }; + key { [ Katakana ] }; + key { [ Hiragana ] }; + key { [ Henkan_Mode ] }; + key { [ Hiragana_Katakana ] }; + key { [ Muhenkan ] }; + key { [ KP_Enter ] }; + key { [ Control_R ] }; + key { + type= "CTRL+ALT", + symbols[Group1]= [ KP_Divide, KP_Divide, KP_Divide, KP_Divide, XF86Ungrab ] + }; + key { + type= "PC_ALT_LEVEL2", + symbols[Group1]= [ Print, Sys_Req ] + }; + key { + type= "TWO_LEVEL", + symbols[Group1]= [ Alt_R, Meta_R ] + }; + key { [ Linefeed ] }; + key { [ Home ] }; + key { [ Up ] }; + key { [ Prior ] }; + key { [ Left ] }; + key { [ Right ] }; + key { [ End ] }; + key { [ Down ] }; + key { [ Next ] }; + key { [ Insert ] }; + key { [ Delete ] }; + key { [ XF86AudioMute ] }; + key { [ XF86AudioLowerVolume ] }; + key { [ XF86AudioRaiseVolume ] }; + key { [ XF86PowerOff ] }; + key { [ KP_Equal ] }; + key { [ plusminus ] }; + key { + type= "PC_CONTROL_LEVEL2", + symbols[Group1]= [ Pause, Break ] + }; + key { [ XF86LaunchA ] }; + key { [ KP_Decimal, KP_Decimal ] }; + key { [ Hangul ] }; + key { [ Hangul_Hanja ] }; + key { [ Super_L ] }; + key { [ Super_R ] }; + key { [ Menu ] }; + key { [ Cancel ] }; + key { [ Redo ] }; + key { [ SunProps ] }; + key { [ Undo ] }; + key { [ SunFront ] }; + key { [ XF86Copy ] }; + key { [ SunOpen ] }; + key { [ XF86Paste ] }; + key { [ Find ] }; + key { [ XF86Cut ] }; + key { [ Help ] }; + key { [ XF86MenuKB ] }; + key { [ XF86Calculator ] }; + key { [ XF86Sleep ] }; + key { [ XF86WakeUp ] }; + key { [ XF86Explorer ] }; + key { [ XF86Send ] }; + key { [ XF86Xfer ] }; + key { [ XF86Launch1 ] }; + key { [ XF86Launch2 ] }; + key { [ XF86WWW ] }; + key { [ XF86DOS ] }; + key { [ XF86ScreenSaver ] }; + key { [ XF86RotateWindows ] }; + key { [ XF86Mail ] }; + key { [ XF86Favorites ] }; + key { [ XF86MyComputer ] }; + key { [ XF86Back ] }; + key { [ XF86Forward ] }; + key { [ XF86Eject ] }; + key { [ XF86Eject, XF86Eject ] }; + key { [ XF86AudioNext ] }; + key { [ XF86AudioPlay, XF86AudioPause ] }; + key { [ XF86AudioPrev ] }; + key { [ XF86AudioStop, XF86Eject ] }; + key { [ XF86AudioRecord ] }; + key { [ XF86AudioRewind ] }; + key { [ XF86Phone ] }; + key { [ XF86Tools ] }; + key { [ XF86HomePage ] }; + key { [ XF86Reload ] }; + key { [ XF86Close ] }; + key { [ XF86ScrollUp ] }; + key { [ XF86ScrollDown ] }; + key { [ parenleft ] }; + key { [ parenright ] }; + key { [ XF86New ] }; + key { [ Redo ] }; + key { [ XF86Tools ] }; + key { [ XF86Launch5 ] }; + key { [ XF86Launch6 ] }; + key { [ XF86Launch7 ] }; + key { [ XF86Launch8 ] }; + key { [ XF86Launch9 ] }; + key { [ XF86TouchpadToggle ] }; + key { [ XF86TouchpadOn ] }; + key { [ XF86TouchpadOff ] }; + key { [ Mode_switch ] }; + key { [ NoSymbol, Alt_L ] }; + key { [ NoSymbol, Meta_L ] }; + key { [ NoSymbol, Super_L ] }; + key { [ NoSymbol, Hyper_L ] }; + key { [ XF86AudioPlay ] }; + key { [ XF86AudioPause ] }; + key { [ XF86Launch3 ] }; + key { [ XF86Launch4 ] }; + key { [ XF86LaunchB ] }; + key { [ XF86Suspend ] }; + key { [ XF86Close ] }; + key { [ XF86AudioPlay ] }; + key { [ XF86AudioForward ] }; + key { [ Print ] }; + key { [ XF86WebCam ] }; + key { [ XF86Mail ] }; + key { [ XF86Messenger ] }; + key { [ XF86Search ] }; + key { [ XF86Go ] }; + key { [ XF86Finance ] }; + key { [ XF86Game ] }; + key { [ XF86Shop ] }; + key { [ Cancel ] }; + key { [ XF86MonBrightnessDown ] }; + key { [ XF86MonBrightnessUp ] }; + key { [ XF86AudioMedia ] }; + key { [ XF86Display ] }; + key { [ XF86KbdLightOnOff ] }; + key { [ XF86KbdBrightnessDown ] }; + key { [ XF86KbdBrightnessUp ] }; + key { [ XF86Send ] }; + key { [ XF86Reply ] }; + key { [ XF86MailForward ] }; + key { [ XF86Save ] }; + key { [ XF86Documents ] }; + key { [ XF86Battery ] }; + key { [ XF86Bluetooth ] }; + key { [ XF86WLAN ] }; + modifier_map Control { }; + modifier_map Shift { }; + modifier_map Shift { }; + modifier_map Mod1 { }; + modifier_map Lock { }; + modifier_map Mod2 { }; + modifier_map Mod5 { }; + modifier_map Control { }; + modifier_map Mod1 { }; + modifier_map Mod4 { }; + modifier_map Mod4 { }; + modifier_map Mod5 { }; + modifier_map Mod1 { }; + modifier_map Mod4 { }; + modifier_map Mod4 { }; + }; + +};