Run source tree through uncrustify

.uncrustify.cfg committed for future reference also, but had to manually
fix up a few things: it really likes justifying struct initialisers.

Signed-off-by: Daniel Stone <daniel@fooishbar.org>
master
Daniel Stone 2012-07-17 10:20:15 +01:00
parent c6c937abc2
commit 9308a46039
51 changed files with 3484 additions and 3756 deletions

228
.uncrustify.cfg Normal file
View File

@ -0,0 +1,228 @@
tok_split_gte=false
utf8_byte=true
utf8_force=true
indent_cmt_with_tabs=false
indent_align_string=false
indent_braces=false
indent_braces_no_func=false
indent_braces_no_class=false
indent_braces_no_struct=false
indent_brace_parent=false
indent_namespace=false
indent_extern=false
indent_class=false
indent_class_colon=false
indent_else_if=false
indent_var_def_cont=false
indent_func_call_param=false
indent_func_def_param=false
indent_func_proto_param=false
indent_func_class_param=false
indent_func_ctor_var_param=false
indent_template_param=false
indent_func_param_double=false
indent_relative_single_line_comments=false
indent_col1_comment=false
indent_access_spec_body=false
indent_paren_nl=false
indent_comma_paren=false
indent_bool_paren=false
indent_first_bool_expr=false
indent_square_nl=false
indent_preserve_sql=false
indent_align_assign=true
sp_balance_nested_parens=false
align_keep_tabs=false
align_with_tabs=false
align_on_tabstop=false
align_number_left=false
align_func_params=false
align_same_func_call_params=false
align_var_def_colon=true
align_var_def_attribute=true
align_var_def_inline=true
align_right_cmt_mix=false
align_on_operator=false
align_mix_var_proto=false
align_single_line_func=false
align_single_line_brace=false
align_nl_cont=false
align_left_shift=true
align_oc_decl_colon=true
nl_collapse_empty_body=true
nl_assign_leave_one_liners=true
nl_class_leave_one_liners=true
nl_enum_leave_one_liners=true
nl_getset_leave_one_liners=true
nl_func_leave_one_liners=true
nl_if_leave_one_liners=true
nl_multi_line_cond=false
nl_multi_line_define=false
nl_before_case=true
nl_after_case=true
nl_after_return=false
nl_after_semicolon=true
nl_after_brace_open=true
nl_after_brace_open_cmt=false
nl_after_vbrace_open=false
nl_after_vbrace_open_empty=false
nl_after_brace_close=false
nl_after_vbrace_close=false
nl_define_macro=false
nl_squeeze_ifdef=false
nl_ds_struct_enum_cmt=false
nl_ds_struct_enum_close_brace=false
nl_create_if_one_liner=false
nl_create_for_one_liner=false
nl_create_while_one_liner=false
ls_for_split_full=false
ls_func_split_full=false
nl_after_multiline_comment=false
eat_blanks_after_open_brace=false
eat_blanks_before_close_brace=false
mod_full_brace_if_chain=false
mod_pawn_semicolon=false
mod_full_paren_if_bool=false
mod_remove_extra_semicolon=false
mod_sort_import=false
mod_sort_using=false
mod_sort_include=false
mod_move_case_break=false
mod_remove_empty_return=false
cmt_indent_multi=true
cmt_c_group=false
cmt_c_nl_start=false
cmt_c_nl_end=false
cmt_cpp_group=false
cmt_cpp_nl_start=false
cmt_cpp_nl_end=false
cmt_cpp_to_c=true
cmt_star_cont=true
cmt_multi_check_last=true
cmt_insert_before_preproc=false
pp_indent_at_level=false
pp_region_indent_code=false
pp_if_indent_code=false
pp_define_at_level=false
indent_columns=4
indent_brace=0
indent_switch_case=0
align_struct_init_span=2
align_pp_define_gap=0
align_pp_define_span=2
align_oc_msg_colon_span=16
nl_end_of_file_min=1
nl_func_var_def_blk=0
code_width=78
nl_max=2
newlines=auto
indent_with_tabs=0
sp_arith=force
sp_assign=force
sp_assign_default=force
sp_before_assign=force
sp_after_assign=force
sp_enum_assign=force
sp_enum_before_assign=force
sp_enum_after_assign=force
sp_pp_stringify=add
sp_bool=force
sp_compare=force
sp_inside_paren=remove
sp_paren_paren=remove
sp_paren_brace=force
sp_before_ptr_star=ignore
sp_before_unnamed_ptr_star=force
sp_before_byref=force
sp_before_unnamed_byref=force
sp_after_byref=remove
sp_after_type=force
sp_before_sparen=force
sp_inside_sparen=remove
sp_inside_sparen_close=remove
sp_after_sparen=force
sp_sparen_brace=force
sp_special_semi=force
sp_before_semi=remove
sp_after_semi=force
sp_after_semi_for=force
sp_after_semi_for_empty=force
sp_before_square=remove
sp_inside_square=remove
sp_after_comma=force
sp_before_comma=remove
sp_paren_comma=force
sp_before_ellipsis=force
sp_after_class_colon=force
sp_before_class_colon=force
sp_before_case_colon=remove
sp_after_cast=force
sp_inside_paren_cast=remove
sp_sizeof_paren=remove
sp_inside_braces_enum=force
sp_inside_braces_struct=force
sp_inside_braces=force
sp_inside_braces_empty=force
sp_func_proto_paren=remove
sp_func_def_paren=remove
sp_inside_fparens=remove
sp_inside_fparen=remove
sp_square_fparen=remove
sp_fparen_brace=force
sp_func_call_paren=remove
sp_func_call_paren_empty=remove
sp_return_paren=force
sp_attribute_paren=remove
sp_defined_paren=remove
sp_macro=force
sp_macro_func=force
sp_else_brace=force
sp_brace_else=force
sp_brace_typedef=force
sp_not=remove
sp_inv=remove
nl_start_of_file=remove
nl_end_of_file=force
nl_assign_square=remove
nl_after_square_assign=remove
nl_fcall_brace=remove
nl_enum_brace=remove
nl_struct_brace=remove
nl_union_brace=remove
nl_if_brace=remove
nl_brace_else=force
nl_elseif_brace=remove
nl_else_brace=remove
nl_else_if=remove
nl_for_brace=remove
nl_do_brace=remove
nl_brace_while=remove
nl_switch_brace=remove
nl_case_colon_brace=force
nl_func_type_name=force
nl_func_type_name_class=force
nl_func_proto_type_name=force
nl_func_paren=remove
nl_func_def_paren=remove
nl_func_decl_start=remove
nl_func_def_start=remove
nl_func_decl_args=remove
nl_func_decl_end=remove
nl_func_def_end=remove
nl_func_decl_end_single=remove
nl_func_def_end_single=remove
nl_func_decl_empty=remove
nl_func_def_empty=remove
nl_fdef_brace=force
nl_return_expr=remove
nl_before_if=ignore
nl_after_if=ignore
nl_before_for=ignore
nl_after_for=ignore
nl_before_while=ignore
nl_after_while=ignore
nl_before_switch=ignore
nl_after_switch=ignore
nl_before_do=ignore
nl_after_do=ignore
pp_space=remove

View File

@ -1,55 +1,55 @@
/* /*
Copyright 1985, 1987, 1990, 1998 The Open Group * Copyright 1985, 1987, 1990, 1998 The Open Group
Copyright 2008 Dan Nicholson * Copyright 2008 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
/************************************************************ /************************************************************
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
/* /*
* Copyright © 2009 Daniel Stone * Copyright © 2009 Daniel Stone
@ -76,7 +76,6 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
* Author: Daniel Stone <daniel@fooishbar.org> * Author: Daniel Stone <daniel@fooishbar.org>
*/ */
#ifndef _XKBCOMMON_H_ #ifndef _XKBCOMMON_H_
#define _XKBCOMMON_H_ #define _XKBCOMMON_H_
@ -94,14 +93,14 @@ typedef uint32_t xkb_mod_mask_t;
typedef uint32_t xkb_group_index_t; typedef uint32_t xkb_group_index_t;
typedef uint32_t xkb_led_index_t; typedef uint32_t xkb_led_index_t;
#define XKB_MOD_INVALID (0xffffffff) #define XKB_MOD_INVALID (0xffffffff)
#define XKB_GROUP_INVALID (0xffffffff) #define XKB_GROUP_INVALID (0xffffffff)
#define XKB_KEYCODE_INVALID (0xffffffff) #define XKB_KEYCODE_INVALID (0xffffffff)
#define XKB_LED_INVALID (0xffffffff) #define XKB_LED_INVALID (0xffffffff)
#define XKB_KEYCODE_MAX (0xffffffff - 1) #define XKB_KEYCODE_MAX (0xffffffff - 1)
#define xkb_keycode_is_legal_ext(kc) (kc <= XKB_KEYCODE_MAX) #define xkb_keycode_is_legal_ext(kc) (kc <= XKB_KEYCODE_MAX)
#define xkb_keycode_is_legal_x11(kc) (kc >= 8 && kc <= 255) #define xkb_keycode_is_legal_x11(kc) (kc >= 8 && kc <= 255)
/** /**
* Names to compile a keymap with, also known as RMLVO. These names together * Names to compile a keymap with, also known as RMLVO. These names together
@ -168,7 +167,7 @@ xkb_keysym_to_utf8(xkb_keysym_t keysym, char *buffer, size_t size);
* Returns the Unicode/UTF-32 representation of the provided keysym, which is * Returns the Unicode/UTF-32 representation of the provided keysym, which is
* also compatible with UCS-4. A return value of zero means the keysym does * also compatible with UCS-4. A return value of zero means the keysym does
* not have a known printable Unicode representation. * not have a known printable Unicode representation.
*/ */
uint32_t uint32_t
xkb_keysym_to_utf32(xkb_keysym_t keysym); xkb_keysym_to_utf32(xkb_keysym_t keysym);
@ -283,17 +282,16 @@ enum xkb_keymap_format {
* file. * file.
*/ */
struct xkb_keymap * struct xkb_keymap *
xkb_map_new_from_file(struct xkb_context *context, xkb_map_new_from_file(struct xkb_context *context, FILE *file,
FILE *file, enum xkb_keymap_format format, enum xkb_keymap_format format,
enum xkb_map_compile_flags flags); enum xkb_map_compile_flags flags);
/** /**
* Creates an XKB keymap from a full text XKB keymap serialized into one * Creates an XKB keymap from a full text XKB keymap serialized into one
* enormous string. * enormous string.
*/ */
struct xkb_keymap * struct xkb_keymap *
xkb_map_new_from_string(struct xkb_context *context, xkb_map_new_from_string(struct xkb_context *context, const char *string,
const char *string,
enum xkb_keymap_format format, enum xkb_keymap_format format,
enum xkb_map_compile_flags flags); enum xkb_map_compile_flags flags);
@ -507,10 +505,8 @@ enum xkb_state_match {
* Please do not use this unless you fit the description above. * Please do not use this unless you fit the description above.
*/ */
void void
xkb_state_update_mask(struct xkb_state *state, xkb_state_update_mask(struct xkb_state *state, xkb_mod_mask_t base_mods,
xkb_mod_mask_t base_mods, xkb_mod_mask_t latched_mods, xkb_mod_mask_t locked_mods,
xkb_mod_mask_t latched_mods,
xkb_mod_mask_t locked_mods,
xkb_group_index_t base_group, xkb_group_index_t base_group,
xkb_group_index_t latched_group, xkb_group_index_t latched_group,
xkb_group_index_t locked_group); xkb_group_index_t locked_group);
@ -594,7 +590,8 @@ xkb_state_group_name_is_active(struct xkb_state *state, const char *name,
* exist in the current map. * exist in the current map.
*/ */
int int
xkb_state_group_index_is_active(struct xkb_state *state, xkb_group_index_t idx, xkb_state_group_index_is_active(struct xkb_state *state,
xkb_group_index_t idx,
enum xkb_state_component type); enum xkb_state_component type);
/** /**

View File

@ -1,30 +1,30 @@
/* /*
*
Copyright 1990, 1998 The Open Group * Copyright 1990, 1998 The Open Group
*
Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that * the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting * copyright notice and this permission notice appear in supporting
documentation. * documentation.
*
The above copyright notice and this permission notice shall be included * The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software. * in all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR * IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * 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 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE. * OTHER DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name of The Open Group shall * Except as contained in this notice, the name of The Open Group shall
not be used in advertising or otherwise to promote the sale, use or * not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization * other dealings in this Software without prior written authorization
from The Open Group. * from The Open Group.
*
*/ */
/* /*
* Constructs hash tables for xkb_keysym_to_string and * Constructs hash tables for xkb_keysym_to_string and
@ -48,7 +48,7 @@ static struct info {
} info[KTNUM]; } info[KTNUM];
#define MIN_REHASH 15 #define MIN_REHASH 15
#define MATCHES 10 #define MATCHES 10
static char tab[KTNUM]; static char tab[KTNUM];
static unsigned short offsets[KTNUM]; static unsigned short offsets[KTNUM];
@ -64,7 +64,7 @@ parse_line(const char *buf, char *key, xkb_keysym_t *val, char *prefix)
/* See if we can catch a straight XK_foo 0x1234-style definition first; /* See if we can catch a straight XK_foo 0x1234-style definition first;
* the trickery around tmp is to account for prefices. */ * the trickery around tmp is to account for prefices. */
i = sscanf(buf, "#define %127s 0x%"SCNx32, key, val); i = sscanf(buf, "#define %127s 0x%" SCNx32, key, val);
if (i == 2 && strncmp(key, "XKB_KEY_", 8) == 0) { if (i == 2 && strncmp(key, "XKB_KEY_", 8) == 0) {
prefix[0] = '\0'; prefix[0] = '\0';
memmove(key, key + 8, strlen(key + 8) + 1); memmove(key, key + 8, strlen(key + 8) + 1);
@ -73,7 +73,7 @@ parse_line(const char *buf, char *key, xkb_keysym_t *val, char *prefix)
i = sscanf(buf, "#define %127s %127s", key, alias); i = sscanf(buf, "#define %127s %127s", key, alias);
if (i == 2) if (i == 2)
fprintf(stderr, "can't parse keysym definition: %s", buf); fprintf(stderr, "can't parse keysym definition: %s", buf);
return 0; return 0;
} }
@ -109,7 +109,8 @@ main(int argc, char *argv[])
if (val == XKB_KEY_VoidSymbol) if (val == XKB_KEY_VoidSymbol)
val = 0; val = 0;
if (val > 0x1fffffff) { if (val > 0x1fffffff) {
fprintf(stderr, "ignoring illegal keysym (%s, %"PRIx32")\n", key, fprintf(stderr, "ignoring illegal keysym (%s, %" PRIx32 ")\n",
key,
val); val);
continue; continue;
} }
@ -140,7 +141,7 @@ main(int argc, char *argv[])
num_found = 0; num_found = 0;
for (z = ksnum; z < KTNUM; z++) { for (z = ksnum; z < KTNUM; z++) {
max_rehash = 0; max_rehash = 0;
for (name = tab, i = z; --i >= 0;) for (name = tab, i = z; --i >= 0; )
*name++ = 0; *name++ = 0;
for (i = 0; i < ksnum; i++) { for (i = 0; i < ksnum; i++) {
name = info[i].name; name = info[i].name;
@ -168,7 +169,7 @@ main(int argc, char *argv[])
if (num_found >= MATCHES) if (num_found >= MATCHES)
break; break;
} }
next1: ; next1:;
} }
z = best_z; z = best_z;
@ -196,13 +197,13 @@ next1: ;
offsets[j] = k; offsets[j] = k;
indexes[i] = k; indexes[i] = k;
val = info[i].val; val = info[i].val;
printf("0x%.2"PRIx32", 0x%.2"PRIx32", 0x%.2"PRIx32", " printf("0x%.2" PRIx32 ", 0x%.2" PRIx32 ", 0x%.2" PRIx32 ", "
"0x%.2"PRIx32", 0x%.2"PRIx32", 0x%.2"PRIx32", ", "0x%.2" PRIx32 ", 0x%.2" PRIx32 ", 0x%.2" PRIx32 ", ",
(sig >> 8) & 0xff, sig & 0xff, (val >> 24) & 0xff, (sig >> 8) & 0xff, sig & 0xff, (val >> 24) & 0xff,
(val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff); (val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff);
for (name = info[i].name, k += 7; (c = *name++); k++) for (name = info[i].name, k += 7; (c = *name++); k++)
printf("'%c',", c); printf("'%c',", c);
printf((i == (ksnum-1)) ? "0\n" : "0,\n"); printf((i == (ksnum - 1)) ? "0\n" : "0,\n");
} }
printf("};\n"); printf("};\n");
printf("\n"); printf("\n");
@ -210,7 +211,7 @@ next1: ;
printf("#define KMAXHASH %d\n", best_max_rehash + 1); printf("#define KMAXHASH %d\n", best_max_rehash + 1);
printf("\n"); printf("\n");
printf("static const unsigned short hashString[KTABLESIZE] = {\n"); printf("static const unsigned short hashString[KTABLESIZE] = {\n");
for (i = 0; i < z;) { for (i = 0; i < z; ) {
printf("0x%.4x", offsets[i]); printf("0x%.4x", offsets[i]);
i++; i++;
if (i == z) if (i == z)
@ -224,7 +225,7 @@ next1: ;
num_found = 0; num_found = 0;
for (z = ksnum; z < KTNUM; z++) { for (z = ksnum; z < KTNUM; z++) {
max_rehash = 0; max_rehash = 0;
for (name = tab, i = z; --i >= 0;) for (name = tab, i = z; --i >= 0; )
*name++ = 0; *name++ = 0;
for (i = 0; i < ksnum; i++) { for (i = 0; i < ksnum; i++) {
val = info[i].val; val = info[i].val;
@ -242,7 +243,7 @@ next1: ;
values[j] = val; values[j] = val;
if (k > max_rehash) if (k > max_rehash)
max_rehash = k; max_rehash = k;
skip1: ; skip1:;
} }
if (max_rehash < MIN_REHASH) { if (max_rehash < MIN_REHASH) {
if (max_rehash < best_max_rehash) { if (max_rehash < best_max_rehash) {
@ -253,7 +254,7 @@ skip1: ;
if (num_found >= MATCHES) if (num_found >= MATCHES)
break; break;
} }
next2: ; next2:;
} }
z = best_z; z = best_z;
@ -262,7 +263,7 @@ next2: ;
"Try increasing KTNUM in makekeys.c\n"); "Try increasing KTNUM in makekeys.c\n");
exit(1); exit(1);
} }
for (i = z; --i >= 0;) for (i = z; --i >= 0; )
offsets[i] = 0; offsets[i] = 0;
for (i = 0; i < ksnum; i++) { for (i = 0; i < ksnum; i++) {
val = info[i].val; val = info[i].val;
@ -276,14 +277,14 @@ next2: ;
} }
offsets[j] = indexes[i] + 2; offsets[j] = indexes[i] + 2;
values[j] = val; values[j] = val;
skip2: ; skip2:;
} }
printf("\n"); printf("\n");
printf("#define VTABLESIZE %d\n", z); printf("#define VTABLESIZE %d\n", z);
printf("#define VMAXHASH %d\n", best_max_rehash + 1); printf("#define VMAXHASH %d\n", best_max_rehash + 1);
printf("\n"); printf("\n");
printf("static const unsigned short hashKeysym[VTABLESIZE] = {\n"); printf("static const unsigned short hashKeysym[VTABLESIZE] = {\n");
for (i = 0; i < z;) { for (i = 0; i < z; ) {
printf("0x%.4x", offsets[i]); printf("0x%.4x", offsets[i]);
i++; i++;
if (i == z) if (i == z)

View File

@ -1,27 +1,27 @@
/* /*
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#include "xkb-priv.h" #include "xkb-priv.h"
#include "alloc.h" #include "alloc.h"
@ -279,7 +279,6 @@ XkbcAllocCompatMap(struct xkb_keymap *keymap, unsigned nSI)
return Success; return Success;
} }
static void static void
XkbcFreeCompatMap(struct xkb_keymap *keymap) XkbcFreeCompatMap(struct xkb_keymap *keymap)
{ {
@ -292,7 +291,8 @@ XkbcFreeCompatMap(struct xkb_keymap *keymap)
} }
int int
XkbcAllocNames(struct xkb_keymap *keymap, unsigned which, size_t nTotalAliases) XkbcAllocNames(struct xkb_keymap *keymap, unsigned which,
size_t nTotalAliases)
{ {
if (!keymap) if (!keymap)
return BadMatch; return BadMatch;

View File

@ -1,28 +1,28 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#ifndef ALLOC_H #ifndef ALLOC_H
#define ALLOC_H #define ALLOC_H

View File

@ -1,73 +1,73 @@
/*********************************************************** /***********************************************************
Copyright 1987, 1998 The Open Group * Copyright 1987, 1998 The Open Group
*
Permission to use, copy, modify, distribute, and sell this software and its * Permission to use, copy, modify, distribute, and sell this software and its
documentation for any purpose is hereby granted without fee, provided that * documentation for any purpose is hereby granted without fee, provided that
the above copyright notice appear in all copies and that both that * the above copyright notice appear in all copies and that both that
copyright notice and this permission notice appear in supporting * copyright notice and this permission notice appear in supporting
documentation. * documentation.
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 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. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
Except as contained in this notice, the name of The Open Group shall not be * Except as contained in this notice, the name of The Open Group shall not be
used in advertising or otherwise to promote the sale, use or other dealings * used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from The Open Group. * in this Software without prior written authorization from The Open Group.
*
*
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
*
All Rights Reserved * All Rights Reserved
*
Permission to use, copy, modify, and distribute this software and its * Permission to use, copy, modify, and distribute this software and its
documentation for any purpose and without fee is hereby granted, * documentation for any purpose and without fee is hereby granted,
provided that the above copyright notice appear in all copies and that * provided that the above copyright notice appear in all copies and that
both that copyright notice and this permission notice appear in * both that copyright notice and this permission notice appear in
supporting documentation, and that the name of Digital not be * supporting documentation, and that the name of Digital not be
used in advertising or publicity pertaining to distribution of the * used in advertising or publicity pertaining to distribution of the
software without specific, written prior permission. * software without specific, written prior permission.
*
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
SOFTWARE. * SOFTWARE.
*
******************************************************************/ ******************************************************************/
/************************************************************ /************************************************************
Copyright 1994 by Silicon Graphics Computer Systems, Inc. * Copyright 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "atom.h" #include "atom.h"
@ -173,8 +173,8 @@ atom_intern(struct atom_table *table, const char *string)
else if (comp > 0) else if (comp > 0)
np = &((*np)->right); np = &((*np)->right);
else else
return(*np)->a; return (*np)->a;
} }
} }
nd = malloc(sizeof(*nd)); nd = malloc(sizeof(*nd));

View File

@ -1,28 +1,28 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#ifndef ATOM_H #ifndef ATOM_H
#define ATOM_H #define ATOM_H

View File

@ -107,7 +107,7 @@ xkb_context_include_path_clear(struct xkb_context *ctx)
char **path; char **path;
darray_foreach(path, ctx->includes) darray_foreach(path, ctx->includes)
free(*path); free(*path);
darray_free(ctx->includes); darray_free(ctx->includes);
} }

View File

@ -122,14 +122,16 @@
/*** Life cycle ***/ /*** Life cycle ***/
#define darray(type) struct {type *item; size_t size; size_t alloc;} #define darray(type) struct { type *item; size_t size; size_t alloc; }
#define darray_new() {0,0,0} #define darray_new() { 0, 0, 0 }
#define darray_init(arr) do {(arr).item=0; (arr).size=0; (arr).alloc=0;} while(0) #define darray_init(arr) do { (arr).item = 0; (arr).size = 0; (arr).alloc = 0; \
#define darray_free(arr) do {free((arr).item); darray_init(arr);} while(0) } while (0)
#define darray_free(arr) do { free((arr).item); darray_init(arr); } while (0)
/* Only use for immutable darray - e.g. for static const initialzers. */ /* Only use for immutable darray - e.g. for static const initialzers. */
#define darray_lit(c_array) {(c_array), sizeof(c_array) / sizeof(*(c_array)), 0} #define darray_lit(c_array) { (c_array), sizeof(c_array) / sizeof(*(c_array)), \
0 }
/* /*
* Typedefs for darrays of common types. These are useful * Typedefs for darrays of common types. These are useful
@ -148,153 +150,186 @@
* foo(&arr); * foo(&arr);
*/ */
typedef darray(char) darray_char; typedef darray (char) darray_char;
typedef darray(signed char) darray_schar; typedef darray (signed char) darray_schar;
typedef darray(unsigned char) darray_uchar; typedef darray (unsigned char) darray_uchar;
typedef darray(short) darray_short; typedef darray (short) darray_short;
typedef darray(int) darray_int; typedef darray (int) darray_int;
typedef darray(long) darray_long; typedef darray (long) darray_long;
typedef darray(unsigned short) darray_ushort;
typedef darray(unsigned int) darray_uint;
typedef darray(unsigned long) darray_ulong;
typedef darray (unsigned short) darray_ushort;
typedef darray (unsigned int) darray_uint;
typedef darray (unsigned long) darray_ulong;
/*** Access ***/ /*** Access ***/
#define darray_item(arr, i) ((arr).item[i]) #define darray_item(arr, i) ((arr).item[i])
#define darray_size(arr) ((arr).size) #define darray_size(arr) ((arr).size)
#define darray_alloc(arr) ((arr).alloc) #define darray_alloc(arr) ((arr).alloc)
#define darray_empty(arr) ((arr).size == 0) #define darray_empty(arr) ((arr).size == 0)
#define darray_mem(arr, offset) ((arr).item + (offset)) #define darray_mem(arr, offset) ((arr).item + (offset))
#define darray_same(arr1, arr2) ((arr1).item == (arr2).item) #define darray_same(arr1, arr2) ((arr1).item == (arr2).item)
/*** Insertion (single item) ***/ /*** Insertion (single item) ***/
#define darray_append(arr, ...) do { \ #define darray_append(arr, ...) do { \
darray_resize(arr, (arr).size+1); \ darray_resize(arr, (arr).size + 1); \
(arr).item[(arr).size-1] = (__VA_ARGS__); \ (arr).item[(arr).size - 1] = (__VA_ARGS__); \
} while(0) } while (0)
#define darray_prepend(arr, ...) do { \ #define darray_prepend(arr, ...) do { \
darray_resize(arr, (arr).size+1); \ darray_resize(arr, (arr).size + 1); \
memmove((arr).item+1, (arr).item, ((arr).size-1)*sizeof(*(arr).item)); \ memmove((arr).item + 1, (arr).item, \
(arr).item[0] = (__VA_ARGS__); \ ((arr).size - 1) * sizeof(*(arr).item)); \
} while(0) (arr).item[0] = (__VA_ARGS__); \
#define darray_push(arr, ...) darray_append(arr, __VA_ARGS__) } while (0)
#define darray_push(arr, ...) darray_append(arr, __VA_ARGS__)
/*** Insertion (multiple items) ***/ /*** Insertion (multiple items) ***/
#define darray_append_items(arr, items, count) do { \ #define darray_append_items(arr, items, count) do { \
size_t __count = (count), __oldSize = (arr).size; \ size_t __count = (count), __oldSize = (arr).size; \
darray_resize(arr, __oldSize + __count); \ darray_resize(arr, __oldSize + __count); \
memcpy((arr).item + __oldSize, items, __count * sizeof(*(arr).item)); \ memcpy((arr).item + __oldSize, items, __count * sizeof(*(arr).item)); \
} while(0) } while (0)
#define darray_prepend_items(arr, items, count) do { \ #define darray_prepend_items(arr, items, count) do { \
size_t __count = (count), __oldSize = (arr).size; \ size_t __count = (count), __oldSize = (arr).size; \
darray_resize(arr, __count + __oldSize); \ darray_resize(arr, __count + __oldSize); \
memmove((arr).item + __count, (arr).item, __oldSize * sizeof(*(arr).item)); \ memmove((arr).item + __count, (arr).item, __oldSize * \
memcpy((arr).item, items, __count * sizeof(*(arr).item)); \ sizeof(*(arr).item)); \
} while(0) memcpy((arr).item, items, __count * sizeof(*(arr).item)); \
} while (0)
#define darray_append_items_nullterminate(arr, items, count) do { \ #define darray_append_items_nullterminate(arr, items, count) do { \
size_t __count = (count), __oldSize = (arr).size; \ size_t __count = (count), __oldSize = (arr).size; \
darray_resize(arr, __oldSize + __count + 1); \ darray_resize(arr, __oldSize + __count + 1); \
memcpy((arr).item + __oldSize, items, __count * sizeof(*(arr).item)); \ memcpy((arr).item + __oldSize, items, __count * sizeof(*(arr).item)); \
(arr).item[--(arr).size] = 0; \ (arr).item[--(arr).size] = 0; \
} while(0) } while (0)
#define darray_prepend_items_nullterminate(arr, items, count) do { \ #define darray_prepend_items_nullterminate(arr, items, count) do { \
size_t __count = (count), __oldSize = (arr).size; \ size_t __count = (count), __oldSize = (arr).size; \
darray_resize(arr, __count + __oldSize + 1); \ darray_resize(arr, __count + __oldSize + 1); \
memmove((arr).item + __count, (arr).item, __oldSize * sizeof(*(arr).item)); \ memmove((arr).item + __count, (arr).item, __oldSize * \
memcpy((arr).item, items, __count * sizeof(*(arr).item)); \ sizeof(*(arr).item)); \
(arr).item[--(arr).size] = 0; \ memcpy((arr).item, items, __count * sizeof(*(arr).item)); \
} while(0) (arr).item[--(arr).size] = 0; \
} while (0)
#if HAVE_TYPEOF #if HAVE_TYPEOF
#define darray_appends(arr, ...) darray_appends_t(arr, typeof((*(arr).item)), __VA_ARGS__) #define darray_appends(arr, ...) darray_appends_t(arr, typeof((*(arr).item)), \
#define darray_prepends(arr, ...) darray_prepends_t(arr, typeof((*(arr).item)), __VA_ARGS__) __VA_ARGS__)
#define darray_prepends(arr, ...) darray_prepends_t(arr, typeof((*(arr).item)), \
__VA_ARGS__)
#endif #endif
#define darray_appends_t(arr, type, ...) do { \ #define darray_appends_t(arr, type, ...) do { \
type __src[] = {__VA_ARGS__}; \ type __src[] = { __VA_ARGS__ }; \
darray_append_items(arr, __src, sizeof(__src)/sizeof(*__src)); \ darray_append_items(arr, __src, sizeof(__src) / sizeof(*__src)); \
} while(0) } while (0)
#define darray_prepends_t(arr, type, ...) do { \ #define darray_prepends_t(arr, type, ...) do { \
type __src[] = {__VA_ARGS__}; \ type __src[] = { __VA_ARGS__ }; \
darray_prepend_items(arr, __src, sizeof(__src)/sizeof(*__src)); \ darray_prepend_items(arr, __src, sizeof(__src) / sizeof(*__src)); \
} while(0) } while (0)
/*** Removal ***/ /*** Removal ***/
/* Warning: Do not call darray_pop on an empty darray. */ /* Warning: Do not call darray_pop on an empty darray. */
#define darray_pop(arr) ((arr).item[--(arr).size]) #define darray_pop(arr) ((arr).item[--(arr).size])
#define darray_pop_check(arr) ((arr).size ? darray_pop(arr) : NULL) #define darray_pop_check(arr) ((arr).size ? darray_pop(arr) : NULL)
/*** Replacement ***/ /*** 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_items(arr, items, count) do { size_t __count = (count); \
#define darray_from_c(arr, c_array) darray_from_items(arr, c_array, sizeof(c_array)/sizeof(*(c_array))) darray_resize(arr, __count); \
#define darray_copy(arr_to, arr_from) darray_from_items(arr_to, (arr_from).item, (arr_from).size) 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)))
#define darray_copy(arr_to, arr_from) darray_from_items( \
arr_to, \
(arr_from). \
item, (arr_from).size)
/*** String buffer ***/ /*** 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_string(arr, str) do { const char *__str = (str); \
#define darray_append_lit(arr, stringLiteral) do {darray_append_items(arr, stringLiteral, sizeof(stringLiteral)); (arr).size--;} while(0) 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 { \ #define darray_prepend_string(arr, str) do { \
const char *__str = (str); \ const char *__str = (str); \
darray_prepend_items_nullterminate(arr, __str, strlen(__str)); \ darray_prepend_items_nullterminate(arr, __str, strlen(__str)); \
} while(0) } while (0)
#define darray_prepend_lit(arr, stringLiteral) \ #define darray_prepend_lit(arr, stringLiteral) \
darray_prepend_items_nullterminate(arr, stringLiteral, sizeof(stringLiteral) - 1) 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)
#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 ***/ /*** Size management ***/
#define darray_resize(arr, newSize) darray_growalloc(arr, (arr).size = (newSize)) #define darray_resize(arr, newSize) darray_growalloc(arr, (arr).size = \
#define darray_resize0(arr, newSize) do { \ (newSize))
size_t __oldSize = (arr).size, __newSize = (newSize); \ #define darray_resize0(arr, newSize) do { \
(arr).size = __newSize; \ size_t __oldSize = (arr).size, __newSize = (newSize); \
if (__newSize > __oldSize) { \ (arr).size = __newSize; \
darray_growalloc(arr, __newSize); \ if (__newSize > __oldSize) { \
memset(&(arr).item[__oldSize], 0, (__newSize - __oldSize) * sizeof(*(arr).item)); \ darray_growalloc(arr, __newSize); \
} \ memset(&(arr).item[__oldSize], 0, \
} while(0) (__newSize - __oldSize) * sizeof(*(arr).item)); \
} \
} while (0)
#define darray_realloc(arr, newAlloc) do { \ #define darray_realloc(arr, newAlloc) do { \
(arr).item = realloc((arr).item, ((arr).alloc = (newAlloc)) * sizeof(*(arr).item)); \ (arr).item = \
} while(0) realloc((arr).item, ((arr).alloc = (newAlloc)) * \
#define darray_growalloc(arr, need) do { \ sizeof(*(arr).item)); \
size_t __need = (need); \ } while (0)
if (__need > (arr).alloc) \ #define darray_growalloc(arr, need) do { \
darray_realloc(arr, darray_next_alloc((arr).alloc, __need)); \ size_t __need = (need); \
} while(0) if (__need > (arr).alloc) \
darray_realloc(arr, darray_next_alloc((arr).alloc, __need)); \
} while (0)
#if HAVE_STATEMENT_EXPR==1 #if HAVE_STATEMENT_EXPR == 1
#define darray_make_room(arr, room) ({size_t newAlloc = (arr).size+(room); if ((arr).alloc<newAlloc) darray_realloc(arr, newAlloc); (arr).item+(arr).size; }) #define darray_make_room(arr, \
room) ({ size_t newAlloc = (arr).size + (room); \
if ((arr).alloc < \
newAlloc) darray_realloc(arr, newAlloc); \
(arr).item + (arr).size; })
#endif #endif
static inline size_t darray_next_alloc(size_t alloc, size_t need) static inline size_t
darray_next_alloc(size_t alloc, size_t need)
{ {
if (alloc == 0) if (alloc == 0)
alloc = 4; alloc = 4;
while (alloc < need) while (alloc < need)
alloc *= 2; alloc *= 2;
return alloc; return alloc;
} }
/*** Traversal ***/ /*** Traversal ***/
/* /*
@ -303,7 +338,7 @@ static inline size_t darray_next_alloc(size_t alloc, size_t need)
* Traverse a darray. `i` must be declared in advance as a pointer to an item. * Traverse a darray. `i` must be declared in advance as a pointer to an item.
*/ */
#define darray_foreach(i, arr) \ #define darray_foreach(i, arr) \
for ((i) = &(arr).item[0]; (i) < &(arr).item[(arr).size]; (i)++) for ((i) = &(arr).item[0]; (i) < &(arr).item[(arr).size]; (i)++)
/* /*
* darray_foreach_reverse(T *&i, darray(T) arr) {...} * darray_foreach_reverse(T *&i, darray(T) arr) {...}
@ -311,53 +346,52 @@ static inline size_t darray_next_alloc(size_t alloc, size_t need)
* Like darray_foreach, but traverse in reverse order. * Like darray_foreach, but traverse in reverse order.
*/ */
#define darray_foreach_reverse(i, arr) \ #define darray_foreach_reverse(i, arr) \
for ((i) = &(arr).item[(arr).size]; (i)-- > &(arr).item[0]; ) for ((i) = &(arr).item[(arr).size]; (i)-- > &(arr).item[0]; )
#endif /* CCAN_DARRAY_H */ #endif /* CCAN_DARRAY_H */
/* /*
*
darray_growalloc(arr, newAlloc) sees if the darray can currently hold newAlloc items; * 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 * if not, it increases the alloc to satisfy this requirement, allocating slack
space to avoid having to reallocate for every size increment. * space to avoid having to reallocate for every size increment.
*
darray_from_string(arr, str) copies a string to an darray_char. * 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_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(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_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. * 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. * Currently requires HAVE_STATEMENT_EXPR, but I plan to remove this dependency by creating an inline function.
*
The following require HAVE_TYPEOF==1 : * The following require HAVE_TYPEOF==1 :
*
darray_appends(arr, item0, item1...) appends a collection of comma-delimited items to the darray. * 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.\ * darray_prepends(arr, item0, item1...) prepends a collection of comma-delimited items to the darray.\
*
*
Examples: * Examples:
*
darray(int) arr; * darray(int) arr;
int *i; * int *i;
*
darray_appends(arr, 0,1,2,3,4); * darray_appends(arr, 0,1,2,3,4);
darray_appends(arr, -5,-4,-3,-2,-1); * darray_appends(arr, -5,-4,-3,-2,-1);
darray_foreach(i, arr) * darray_foreach(i, arr)
printf("%d ", *i); * printf("%d ", *i);
printf("\n"); * printf("\n");
*
darray_free(arr); * darray_free(arr);
*
*
typedef struct {int n,d;} Fraction; * typedef struct {int n,d;} Fraction;
darray(Fraction) fractions; * darray(Fraction) fractions;
Fraction *i; * Fraction *i;
*
darray_appends(fractions, {3,4}, {3,5}, {2,1}); * darray_appends(fractions, {3,4}, {3,5}, {2,1});
darray_foreach(i, fractions) * darray_foreach(i, fractions)
printf("%d/%d\n", i->n, i->d); * printf("%d/%d\n", i->n, i->d);
*
darray_free(fractions); * darray_free(fractions);
*/ */

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
/* /*
@ -58,11 +58,11 @@
#include "xkb-priv.h" #include "xkb-priv.h"
#include "text.h" #include "text.h"
#define VMOD_HIDE_VALUE 0 #define VMOD_HIDE_VALUE 0
#define VMOD_SHOW_VALUE 1 #define VMOD_SHOW_VALUE 1
#define VMOD_COMMENT_VALUE 2 #define VMOD_COMMENT_VALUE 2
#define BUF_CHUNK_SIZE 4096 #define BUF_CHUNK_SIZE 4096
static bool static bool
do_realloc(char **buf, size_t *size, size_t offset, size_t at_least) do_realloc(char **buf, size_t *size, size_t offset, size_t at_least)
@ -86,45 +86,46 @@ do_realloc(char **buf, size_t *size, size_t offset, size_t at_least)
/* This whole thing should be a function, but you can't call vsnprintf /* This whole thing should be a function, but you can't call vsnprintf
* multiple times. */ * multiple times. */
#define check_write_buf(keymap, buf, size, offset, ...) \ #define check_write_buf(keymap, buf, size, offset, ...) \
do { \ do { \
size_t _printed; \ size_t _printed; \
bool _ret = true; \ bool _ret = true; \
\ \
/* Concatenate the strings, and check whether or not the output was \ /* Concatenate the strings, and check whether or not the output was \
* truncated. */ \ * truncated. */ \
while ((_printed = snprintf(*buf + *offset, *size - *offset, \ while ((_printed = snprintf(*buf + *offset, *size - *offset, \
__VA_ARGS__)) >= \ __VA_ARGS__)) >= \
(*size - *offset)) {\ (*size - *offset)) { \
/* If it was truncated, embiggen the string and roll from the top. */ \ /* If it was truncated, embiggen the string and roll from the top. */ \
if (!do_realloc(buf, size, *offset, _printed)) { \ if (!do_realloc(buf, size, *offset, _printed)) { \
fprintf(stderr, \ fprintf(stderr, \
"xkbcommon: failed to allocate %zu bytes for keymap\n", \ "xkbcommon: couldn't allocate %zu bytes for keymap\n", \
*size); \ *size); \
free(*buf); \ free(*buf); \
*buf = NULL; \ *buf = NULL; \
_ret = false; \ _ret = false; \
break; \ break; \
} \
} \ } \
} \ if (_ret == true) \
if (_ret == true) \ *offset += _printed; \
*offset += _printed; \ } while (0)
} while (0)
#define write_buf(keymap, buf, size, offset, ...) \ #define write_buf(keymap, buf, size, offset, ...) \
do { \ do { \
check_write_buf(keymap, buf, size, offset, __VA_ARGS__); \ check_write_buf(keymap, buf, size, offset, __VA_ARGS__); \
if (*buf == NULL) \ if (*buf == NULL) \
return false; \ return false; \
} while (0) } while (0)
static bool static bool
write_vmods(struct xkb_keymap *keymap, char **buf, size_t *size, size_t *offset) write_vmods(struct xkb_keymap *keymap, char **buf, size_t *size,
size_t *offset)
{ {
int num_vmods = 0; int num_vmods = 0;
int i; int i;
for (i = 0; i < XkbNumVirtualMods; i++) { for (i = 0; i < XkbNumVirtualMods; i++) {
if (!keymap->names->vmods[i]) if (!keymap->names->vmods[i])
continue; continue;
if (num_vmods == 0) if (num_vmods == 0)
write_buf(keymap, buf, size, offset, "\t\tvirtual_modifiers "); write_buf(keymap, buf, size, offset, "\t\tvirtual_modifiers ");
@ -135,7 +136,7 @@ write_vmods(struct xkb_keymap *keymap, char **buf, size_t *size, size_t *offset)
} }
if (num_vmods > 0) if (num_vmods > 0)
write_buf(keymap, buf, size, offset, ";\n\n"); write_buf(keymap, buf, size, offset, ";\n\n");
return true; return true;
} }
@ -143,10 +144,10 @@ write_vmods(struct xkb_keymap *keymap, char **buf, size_t *size, size_t *offset)
#define GET_TEXT_BUF_SIZE 512 #define GET_TEXT_BUF_SIZE 512
#define append_get_text(...) do { \ #define append_get_text(...) do { \
int _size = snprintf(ret, GET_TEXT_BUF_SIZE, __VA_ARGS__); \ int _size = snprintf(ret, GET_TEXT_BUF_SIZE, __VA_ARGS__); \
if (_size >= GET_TEXT_BUF_SIZE) \ if (_size >= GET_TEXT_BUF_SIZE) \
return NULL; \ return NULL; \
} while(0) } while (0)
/* FIXME: Merge with src/xkbcomp/expr.c::modIndexNames. */ /* FIXME: Merge with src/xkbcomp/expr.c::modIndexNames. */
static const char *core_mod_names[] = { static const char *core_mod_names[] = {
@ -167,7 +168,8 @@ get_mod_index_text(uint8_t real_mod)
} }
static char * static char *
get_mod_mask_text(struct xkb_keymap *keymap, uint8_t real_mods, uint32_t vmods) 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]; static char ret[GET_TEXT_BUF_SIZE], ret2[GET_TEXT_BUF_SIZE];
int i; int i;
@ -323,26 +325,25 @@ write_keycodes(struct xkb_keymap *keymap, char **buf, size_t *size,
keymap->max_key_code); keymap->max_key_code);
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) { for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
if (darray_item(keymap->names->keys, key).name[0] == '\0') if (darray_item(keymap->names->keys, key).name[0] == '\0')
continue; continue;
write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n", write_buf(keymap, buf, size, offset, "\t\t%6s = %d;\n",
XkbcKeyNameText(darray_item(keymap->names->keys, key).name), XkbcKeyNameText(darray_item(keymap->names->keys, key).name),
key); key);
} }
for (i = 0; i < XkbNumIndicators; i++) { for (i = 0; i < XkbNumIndicators; i++) {
if (!keymap->names->indicators[i]) if (!keymap->names->indicators[i])
continue; continue;
write_buf(keymap, buf, size, offset, "\t\tindicator %d = \"%s\";\n", write_buf(keymap, buf, size, offset, "\t\tindicator %d = \"%s\";\n",
i + 1, keymap->names->indicators[i]); i + 1, keymap->names->indicators[i]);
} }
darray_foreach(alias, keymap->names->key_aliases) darray_foreach(alias, keymap->names->key_aliases)
write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n", write_buf(keymap, buf, size, offset, "\t\talias %6s = %6s;\n",
XkbcKeyNameText(alias->alias), XkbcKeyNameText(alias->alias),
XkbcKeyNameText(alias->real)); XkbcKeyNameText(alias->real));
write_buf(keymap, buf, size, offset, "\t};\n\n"); write_buf(keymap, buf, size, offset, "\t};\n\n");
return true; return true;
@ -364,19 +365,19 @@ write_types(struct xkb_keymap *keymap, char **buf, size_t *size,
write_vmods(keymap, buf, size, offset); write_vmods(keymap, buf, size, offset);
darray_foreach(type, keymap->map->types) { darray_foreach(type, keymap->map->types) {
write_buf(keymap, buf, size, offset, "\t\ttype \"%s\" {\n", write_buf(keymap, buf, size, offset, "\t\ttype \"%s\" {\n",
type->name); type->name);
write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n", write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n",
get_mod_mask_text(keymap, type->mods.real_mods, get_mod_mask_text(keymap, type->mods.real_mods,
type->mods.vmods)); type->mods.vmods));
for (n = 0; n < darray_size(type->map); n++) { for (n = 0; n < darray_size(type->map); n++) {
struct xkb_kt_map_entry *entry = &darray_item(type->map, n); struct xkb_kt_map_entry *entry = &darray_item(type->map, n);
char *str; char *str;
str = get_mod_mask_text(keymap, entry->mods.real_mods, str = get_mod_mask_text(keymap, entry->mods.real_mods,
entry->mods.vmods); entry->mods.vmods);
write_buf(keymap, buf, size, offset, "\t\t\tmap[%s]= Level%d;\n", write_buf(keymap, buf, size, offset, "\t\t\tmap[%s]= Level%d;\n",
str, entry->level + 1); str, entry->level + 1);
if (!type->preserve || (!type->preserve[n].real_mods && if (!type->preserve || (!type->preserve[n].real_mods &&
@ -386,18 +387,18 @@ write_types(struct xkb_keymap *keymap, char **buf, size_t *size,
write_buf(keymap, buf, size, offset, "%s;\n", write_buf(keymap, buf, size, offset, "%s;\n",
get_mod_mask_text(keymap, type->preserve[n].real_mods, get_mod_mask_text(keymap, type->preserve[n].real_mods,
type->preserve[n].vmods)); type->preserve[n].vmods));
} }
if (type->level_names) { if (type->level_names) {
for (n = 0; n < type->num_levels; n++) { for (n = 0; n < type->num_levels; n++) {
if (!type->level_names[n]) if (!type->level_names[n])
continue; continue;
write_buf(keymap, buf, size, offset, write_buf(keymap, buf, size, offset,
"\t\t\tlevel_name[Level%d]= \"%s\";\n", n + 1, "\t\t\tlevel_name[Level%d]= \"%s\";\n", n + 1,
type->level_names[n]); type->level_names[n]);
} }
} }
write_buf(keymap, buf, size, offset, "\t\t};\n"); write_buf(keymap, buf, size, offset, "\t\t};\n");
} }
write_buf(keymap, buf, size, offset, "\t};\n\n"); write_buf(keymap, buf, size, offset, "\t};\n\n");
@ -414,27 +415,29 @@ write_indicator_map(struct xkb_keymap *keymap, char **buf, size_t *size,
keymap->names->indicators[num]); keymap->names->indicators[num]);
if (led->which_groups) { if (led->which_groups) {
if (led->which_groups != XkbIM_UseEffective) { if (led->which_groups != XkbIM_UseEffective) {
write_buf(keymap, buf, size, offset, "\t\t\twhichGroupState= %s;\n", write_buf(keymap, buf, size, offset,
get_indicator_state_text(led->which_groups)); "\t\t\twhichGroupState= %s;\n",
} get_indicator_state_text(
write_buf(keymap, buf, size, offset, "\t\t\tgroups= 0x%02x;\n", led->which_groups));
}
write_buf(keymap, buf, size, offset, "\t\t\tgroups= 0x%02x;\n",
led->groups); led->groups);
} }
if (led->which_mods) { if (led->which_mods) {
if (led->which_mods != XkbIM_UseEffective) { if (led->which_mods != XkbIM_UseEffective) {
write_buf(keymap, buf, size, offset, "\t\t\twhichModState= %s;\n", write_buf(keymap, buf, size, offset, "\t\t\twhichModState= %s;\n",
get_indicator_state_text(led->which_mods)); get_indicator_state_text(led->which_mods));
} }
write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n", write_buf(keymap, buf, size, offset, "\t\t\tmodifiers= %s;\n",
get_mod_mask_text(keymap, led->mods.real_mods, get_mod_mask_text(keymap, led->mods.real_mods,
led->mods.vmods)); led->mods.vmods));
} }
if (led->ctrls) { if (led->ctrls) {
write_buf(keymap, buf, size, offset, "\t\t\tcontrols= %s;\n", write_buf(keymap, buf, size, offset, "\t\t\tcontrols= %s;\n",
get_control_mask_text(led->ctrls)); get_control_mask_text(led->ctrls));
} }
write_buf(keymap, buf, size, offset, "\t\t};\n"); write_buf(keymap, buf, size, offset, "\t\t};\n");
@ -447,24 +450,29 @@ get_interp_match_text(uint8_t type)
static char ret[16]; static char ret[16];
switch (type & XkbSI_OpMask) { switch (type & XkbSI_OpMask) {
case XkbSI_NoneOf: case XkbSI_NoneOf:
sprintf(ret, "NoneOf"); sprintf(ret, "NoneOf");
break; break;
case XkbSI_AnyOfOrNone:
sprintf(ret, "AnyOfOrNone"); case XkbSI_AnyOfOrNone:
break; sprintf(ret, "AnyOfOrNone");
case XkbSI_AnyOf: break;
sprintf(ret, "AnyOf");
break; case XkbSI_AnyOf:
case XkbSI_AllOf: sprintf(ret, "AnyOf");
sprintf(ret, "AllOf"); break;
break;
case XkbSI_Exactly: case XkbSI_AllOf:
sprintf(ret, "Exactly"); sprintf(ret, "AllOf");
break; break;
default:
sprintf(ret, "0x%x", type & XkbSI_OpMask); case XkbSI_Exactly:
break; sprintf(ret, "Exactly");
break;
default:
sprintf(ret, "0x%x", type & XkbSI_OpMask);
break;
} }
return ret; return ret;
@ -501,11 +509,14 @@ write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
write_buf(keymap, buf, size, offset, "%s%s(modifiers=%s%s%s)%s", write_buf(keymap, buf, size, offset, "%s%s(modifiers=%s%s%s)%s",
prefix, type, args, prefix, type, args,
(action->any.type != XkbSA_LockGroup && (action->any.type != XkbSA_LockGroup &&
action->mods.flags & XkbSA_ClearLocks) ? ",clearLocks" : "", (action->mods.flags & XkbSA_ClearLocks)) ?
",clearLocks" : "",
(action->any.type != XkbSA_LockGroup && (action->any.type != XkbSA_LockGroup &&
action->mods.flags & XkbSA_LatchToLock) ? ",latchToLock" : "", (action->mods.flags & XkbSA_LatchToLock)) ?
",latchToLock" : "",
suffix); suffix);
break; break;
case XkbSA_SetGroup: case XkbSA_SetGroup:
if (!type) if (!type)
type = "SetGroup"; type = "SetGroup";
@ -515,21 +526,27 @@ write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
case XkbSA_LockGroup: case XkbSA_LockGroup:
if (!type) if (!type)
type = "LockGroup"; type = "LockGroup";
write_buf(keymap, buf, size, offset, "%s%s(group=%s%d%s%s)%s", write_buf(
prefix, type, keymap, buf, size, offset, "%s%s(group=%s%d%s%s)%s",
(!(action->group.flags & XkbSA_GroupAbsolute) && prefix, type,
action->group.group > 0) ? "+" : "", (!(action->group.flags & XkbSA_GroupAbsolute) &&
(action->group.flags & XkbSA_GroupAbsolute) ? action->group.group > 0) ? "+" : "",
action->group.group + 1 : action->group.group, (action->group.flags & XkbSA_GroupAbsolute) ?
(action->any.type != XkbSA_LockGroup && action->group.group + 1 : action->group.group,
action->group.flags & XkbSA_ClearLocks) ? ",clearLocks" : "", (action->any.type != XkbSA_LockGroup &&
(action->any.type != XkbSA_LockGroup && (action->group.flags & XkbSA_ClearLocks)) ?
action->group.flags & XkbSA_LatchToLock) ? ",latchToLock" : "", ",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); suffix);
break; break;
case XkbSA_Terminate:
write_buf(keymap, buf, size, offset, "%sTerminate()%s", prefix, suffix);
break;
case XkbSA_MovePtr: case XkbSA_MovePtr:
write_buf(keymap, buf, size, offset, "%sMovePtr(x=%s%d,y=%s%d%s)%s", write_buf(keymap, buf, size, offset, "%sMovePtr(x=%s%d,y=%s%d%s)%s",
prefix, prefix,
@ -542,22 +559,27 @@ write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
(action->ptr.flags & XkbSA_NoAcceleration) ? ",!accel" : "", (action->ptr.flags & XkbSA_NoAcceleration) ? ",!accel" : "",
suffix); suffix);
break; break;
case XkbSA_PtrBtn: case XkbSA_PtrBtn:
if (!type) if (!type)
type = "PtrBtn"; type = "PtrBtn";
case XkbSA_LockPtrBtn: case XkbSA_LockPtrBtn:
if (!type) { if (!type) {
type = "LockPtrBtn"; type = "LockPtrBtn";
switch (action->btn.flags & (XkbSA_LockNoUnlock | XkbSA_LockNoLock)) { switch (action->btn.flags &
(XkbSA_LockNoUnlock | XkbSA_LockNoLock)) {
case XkbSA_LockNoUnlock: case XkbSA_LockNoUnlock:
args = ",affect=lock"; args = ",affect=lock";
break; break;
case XkbSA_LockNoLock: case XkbSA_LockNoLock:
args = ",affect=unlock"; args = ",affect=unlock";
break; break;
case XkbSA_LockNoLock | XkbSA_LockNoUnlock: case XkbSA_LockNoLock | XkbSA_LockNoUnlock:
args = ",affect=neither"; args = ",affect=neither";
break; break;
default: default:
args = ",affect=both"; args = ",affect=both";
break; break;
@ -578,6 +600,7 @@ write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
write_buf(keymap, buf, size, offset, "%s", args); write_buf(keymap, buf, size, offset, "%s", args);
write_buf(keymap, buf, size, offset, ")%s", suffix); write_buf(keymap, buf, size, offset, ")%s", suffix);
break; break;
case XkbSA_SetPtrDflt: case XkbSA_SetPtrDflt:
write_buf(keymap, buf, size, offset, "%sSetPtrDflt(", prefix); write_buf(keymap, buf, size, offset, "%sSetPtrDflt(", prefix);
if (action->dflt.affect == XkbSA_AffectDfltBtn) if (action->dflt.affect == XkbSA_AffectDfltBtn)
@ -587,6 +610,7 @@ write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
action->dflt.value); action->dflt.value);
write_buf(keymap, buf, size, offset, ")%s", suffix); write_buf(keymap, buf, size, offset, ")%s", suffix);
break; break;
case XkbSA_SwitchScreen: case XkbSA_SwitchScreen:
write_buf(keymap, buf, size, offset, write_buf(keymap, buf, size, offset,
"%sSwitchScreen(screen=%s%d,%ssame)%s", prefix, "%sSwitchScreen(screen=%s%d,%ssame)%s", prefix,
@ -596,6 +620,7 @@ write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
(action->screen.flags & XkbSA_SwitchApplication) ? "!" : "", (action->screen.flags & XkbSA_SwitchApplication) ? "!" : "",
suffix); suffix);
break; break;
/* Deprecated actions below here */ /* Deprecated actions below here */
case XkbSA_SetControls: case XkbSA_SetControls:
if (!type) if (!type)
@ -607,6 +632,7 @@ write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
prefix, type, get_control_mask_text(action->ctrls.ctrls), prefix, type, get_control_mask_text(action->ctrls.ctrls),
suffix); suffix);
break; break;
case XkbSA_ISOLock: case XkbSA_ISOLock:
case XkbSA_ActionMessage: case XkbSA_ActionMessage:
case XkbSA_RedirectKey: case XkbSA_RedirectKey:
@ -616,6 +642,7 @@ write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
/* XXX TODO */ /* XXX TODO */
write_buf(keymap, buf, size, offset, "%sNoAction()%s", prefix, suffix); write_buf(keymap, buf, size, offset, "%sNoAction()%s", prefix, suffix);
break; break;
case XkbSA_XFree86Private: case XkbSA_XFree86Private:
default: default:
write_buf(keymap, buf, size, offset, write_buf(keymap, buf, size, offset,
@ -623,7 +650,8 @@ write_action(struct xkb_keymap *keymap, char **buf, size_t *size,
prefix, action->any.type, action->any.data[0], prefix, action->any.type, action->any.data[0],
action->any.data[1], action->any.data[2], action->any.data[1], action->any.data[2],
action->any.data[3], action->any.data[4], action->any.data[3], action->any.data[4],
action->any.data[5], action->any.data[6], suffix); action->any.data[5], action->any.data[6],
suffix);
break; break;
} }
@ -638,14 +666,16 @@ write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
struct xkb_sym_interpret *interp; struct xkb_sym_interpret *interp;
if (keymap->names->compat) if (keymap->names->compat)
write_buf(keymap, buf, size, offset, "\txkb_compatibility \"%s\" {\n\n", write_buf(keymap, buf, size, offset,
"\txkb_compatibility \"%s\" {\n\n",
keymap->names->compat); keymap->names->compat);
else else
write_buf(keymap, buf, size, offset, "\txkb_compatibility {\n\n"); write_buf(keymap, buf, size, offset, "\txkb_compatibility {\n\n");
write_vmods(keymap, buf, size, offset); 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.useModMapMods= AnyLevel;\n");
write_buf(keymap, buf, size, offset, "\t\tinterpret.repeat= False;\n"); write_buf(keymap, buf, size, offset, "\t\tinterpret.repeat= False;\n");
write_buf(keymap, buf, size, offset, "\t\tinterpret.locking= False;\n"); write_buf(keymap, buf, size, offset, "\t\tinterpret.locking= False;\n");
@ -659,39 +689,41 @@ write_compat(struct xkb_keymap *keymap, char **buf, size_t *size,
write_buf(keymap, buf, size, offset, "\t\tinterpret %s+%s(%s) {\n", write_buf(keymap, buf, size, offset, "\t\tinterpret %s+%s(%s) {\n",
keysym_name, keysym_name,
get_interp_match_text(interp->match), get_interp_match_text(interp->match),
get_mod_mask_text(keymap, interp->mods, 0)); get_mod_mask_text(keymap, interp->mods, 0));
if (interp->virtual_mod != XkbNoModifier) { if (interp->virtual_mod != XkbNoModifier) {
write_buf(keymap, buf, size, offset, "\t\t\tvirtualModifier= %s;\n", write_buf(keymap, buf, size, offset,
"\t\t\tvirtualModifier= %s;\n",
keymap->names->vmods[interp->virtual_mod]); keymap->names->vmods[interp->virtual_mod]);
} }
if (interp->match & XkbSI_LevelOneOnly) if (interp->match & XkbSI_LevelOneOnly)
write_buf(keymap, buf, size, offset, "\t\t\tuseModMapMods=level1;\n"); write_buf(keymap, buf, size, offset,
if (interp->flags & XkbSI_LockingKey) "\t\t\tuseModMapMods=level1;\n");
write_buf(keymap, buf, size, offset, "\t\t\tlocking= True;\n"); if (interp->flags & XkbSI_LockingKey)
if (interp->flags & XkbSI_AutoRepeat) write_buf(keymap, buf, size, offset, "\t\t\tlocking= True;\n");
write_buf(keymap, buf, size, offset, "\t\t\trepeat= 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, write_action(keymap, buf, size, offset, &interp->act,
"\t\t\taction= ", ";\n"); "\t\t\taction= ", ";\n");
write_buf(keymap, buf, size, offset, "\t\t};\n"); write_buf(keymap, buf, size, offset, "\t\t};\n");
} }
for (i = 0; i < XkbNumKbdGroups; i++) { for (i = 0; i < XkbNumKbdGroups; i++) {
struct xkb_mods *gc; struct xkb_mods *gc;
gc = &keymap->compat->groups[i]; gc = &keymap->compat->groups[i];
if (gc->real_mods == 0 && gc->vmods ==0) if (gc->real_mods == 0 && gc->vmods == 0)
continue; continue;
write_buf(keymap, buf, size, offset, write_buf(keymap, buf, size, offset,
"\t\tgroup %d = %s;\n", i + 1, "\t\tgroup %d = %s;\n", i + 1,
get_mod_mask_text(keymap, gc->real_mods, gc->vmods)); get_mod_mask_text(keymap, gc->real_mods, gc->vmods));
} }
for (i = 0; i < XkbNumIndicators; i++) { for (i = 0; i < XkbNumIndicators; i++) {
struct xkb_indicator_map *map = &keymap->indicators->maps[i]; struct xkb_indicator_map *map = &keymap->indicators->maps[i];
if (map->flags == 0 && map->which_groups == 0 && if (map->flags == 0 && map->which_groups == 0 &&
map->groups == 0 && map->which_mods == 0 && map->groups == 0 && map->which_mods == 0 &&
map->mods.real_mods == 0 && map->mods.vmods == 0 && map->mods.real_mods == 0 && map->mods.vmods == 0 &&
@ -760,32 +792,33 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
write_buf(keymap, buf, size, offset, "\txkb_symbols {\n\n"); write_buf(keymap, buf, size, offset, "\txkb_symbols {\n\n");
for (tmp = group = 0; group < XkbNumKbdGroups; group++) { for (tmp = group = 0; group < XkbNumKbdGroups; group++) {
if (!keymap->names->groups[group]) if (!keymap->names->groups[group])
continue; continue;
write_buf(keymap, buf, size, offset, write_buf(keymap, buf, size, offset,
"\t\tname[group%d]=\"%s\";\n", group + 1, "\t\tname[group%d]=\"%s\";\n", group + 1,
keymap->names->groups[group]); keymap->names->groups[group]);
tmp++; tmp++;
} }
if (tmp > 0) if (tmp > 0)
write_buf(keymap, buf, size, offset, "\n"); write_buf(keymap, buf, size, offset, "\n");
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) { for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
bool simple = true; bool simple = true;
if (xkb_key_num_groups(keymap, key) == 0) if (xkb_key_num_groups(keymap, key) == 0)
continue; continue;
write_buf(keymap, buf, size, offset, "\t\tkey %6s {", write_buf(keymap, buf, size, offset, "\t\tkey %6s {",
XkbcKeyNameText(darray_item(keymap->names->keys, key).name)); XkbcKeyNameText(darray_item(keymap->names->keys, key).name));
if (srv->explicit) { if (srv->explicit) {
if ((srv->explicit[key] & XkbExplicitKeyTypesMask)) { if ((srv->explicit[key] & XkbExplicitKeyTypesMask)) {
bool multi_type = false; bool multi_type = false;
int type = XkbKeyTypeIndex(keymap, key, 0); int type = XkbKeyTypeIndex(keymap, key, 0);
simple = false; simple = false;
for (group = 0; group < xkb_key_num_groups(keymap, key); group++) { for (group = 0; group < xkb_key_num_groups(keymap, key);
group++) {
if (XkbKeyTypeIndex(keymap, key, group) != type) { if (XkbKeyTypeIndex(keymap, key, group) != type) {
multi_type = true; multi_type = true;
break; break;
@ -810,81 +843,88 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
darray_item(map->types, type).name); darray_item(map->types, type).name);
} }
} }
if (keymap->ctrls && (srv->explicit[key] & XkbExplicitAutoRepeatMask)) { if (keymap->ctrls &&
if (keymap->ctrls->per_key_repeat[key / 8] & (1 << (key % 8))) (srv->explicit[key] & XkbExplicitAutoRepeatMask)) {
write_buf(keymap, buf, size, offset, if (keymap->ctrls->per_key_repeat[key / 8] & (1 << (key % 8)))
"\n\t\t\trepeat= Yes,"); write_buf(keymap, buf, size, offset,
else "\n\t\t\trepeat= Yes,");
else
write_buf(keymap, buf, size, offset, write_buf(keymap, buf, size, offset,
"\n\t\t\trepeat= No,"); "\n\t\t\trepeat= No,");
simple = false; simple = false;
} }
if (keymap->server->vmodmap[key] && if (keymap->server->vmodmap[key] &&
(srv->explicit[key] & XkbExplicitVModMapMask)) { (srv->explicit[key] & XkbExplicitVModMapMask)) {
write_buf(keymap, buf, size, offset, "\n\t\t\tvirtualMods= %s,", write_buf(keymap, buf, size, offset,
get_mod_mask_text(keymap, 0, keymap->server->vmodmap[key])); "\n\t\t\tvirtualMods= %s,",
} get_mod_mask_text(keymap, 0,
} keymap->server->vmodmap[key]));
}
}
switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(keymap, key))) { switch (XkbOutOfRangeGroupAction(XkbKeyGroupInfo(keymap, key))) {
case XkbClampIntoRange: case XkbClampIntoRange:
write_buf(keymap, buf, size, offset, "\n\t\t\tgroupsClamp,"); write_buf(keymap, buf, size, offset, "\n\t\t\tgroupsClamp,");
break; 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 || 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)) (srv->explicit[key] & XkbExplicitInterpretMask))
showActions = XkbKeyHasActions(keymap, key); showActions = XkbKeyHasActions(keymap, key);
else else
showActions = false; showActions = false;
if (xkb_key_num_groups(keymap, key) > 1 || showActions) if (xkb_key_num_groups(keymap, key) > 1 || showActions)
simple = false; simple = false;
if (simple) { if (simple) {
write_buf(keymap, buf, size, offset, "\t[ "); write_buf(keymap, buf, size, offset, "\t[ ");
if (!write_keysyms(keymap, buf, size, offset, key, 0)) if (!write_keysyms(keymap, buf, size, offset, key, 0))
return false; return false;
write_buf(keymap, buf, size, offset, " ] };\n"); write_buf(keymap, buf, size, offset, " ] };\n");
} }
else { else {
union xkb_action *acts; union xkb_action *acts;
int level; int level;
acts = XkbKeyActionsPtr(keymap, key); acts = XkbKeyActionsPtr(keymap, key);
for (group = 0; group < xkb_key_num_groups(keymap, key); group++) { for (group = 0; group < xkb_key_num_groups(keymap, key);
if (group != 0) group++) {
write_buf(keymap, buf, size, offset, ","); if (group != 0)
write_buf(keymap, buf, size, offset, write_buf(keymap, buf, size, offset, ",");
write_buf(keymap, buf, size, offset,
"\n\t\t\tsymbols[Group%d]= [ ", group + 1); "\n\t\t\tsymbols[Group%d]= [ ", group + 1);
if (!write_keysyms(keymap, buf, size, offset, key, group)) if (!write_keysyms(keymap, buf, size, offset, key, group))
return false; return false;
write_buf(keymap, buf, size, offset, " ]"); write_buf(keymap, buf, size, offset, " ]");
if (showActions) { if (showActions) {
write_buf(keymap, buf, size, offset, write_buf(keymap, buf, size, offset,
",\n\t\t\tactions[Group%d]= [ ", group + 1); ",\n\t\t\tactions[Group%d]= [ ", group + 1);
for (level = 0; for (level = 0;
level < XkbKeyGroupWidth(keymap, key, group); level < XkbKeyGroupWidth(keymap, key, group);
level++) { level++) {
if (level != 0) if (level != 0)
write_buf(keymap, buf, size, offset, ", "); write_buf(keymap, buf, size, offset, ", ");
write_action(keymap, buf, size, offset, &acts[level], write_action(keymap, buf, size, offset, &acts[level],
NULL, NULL); NULL, NULL);
} }
write_buf(keymap, buf, size, offset, " ]"); write_buf(keymap, buf, size, offset, " ]");
acts += XkbKeyGroupsWidth(keymap, key); acts += XkbKeyGroupsWidth(keymap, key);
} }
} }
write_buf(keymap, buf, size, offset, "\n\t\t};\n"); write_buf(keymap, buf, size, offset, "\n\t\t};\n");
} }
} }
if (map && map->modmap) { if (map && map->modmap) {
for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) { for (key = keymap->min_key_code; key <= keymap->max_key_code;
key++) {
int mod; int mod;
if (map->modmap[key] == 0) if (map->modmap[key] == 0)
@ -900,7 +940,7 @@ write_symbols(struct xkb_keymap *keymap, char **buf, size_t *size,
XkbcKeyNameText(darray_item(keymap->names->keys, XkbcKeyNameText(darray_item(keymap->names->keys,
key).name)); key).name));
} }
} }
} }
write_buf(keymap, buf, size, offset, "\t};\n\n"); write_buf(keymap, buf, size, offset, "\t};\n\n");

View File

@ -877,8 +877,6 @@ xkb_keysym_to_utf32(xkb_keysym_t keysym)
return 0; return 0;
} }
/* /*
* Copyright © 2012 Intel Corporation * Copyright © 2012 Intel Corporation
* *
@ -914,19 +912,24 @@ utf32_to_utf8(uint32_t unichar, char *buffer)
buffer[0] = unichar; buffer[0] = unichar;
buffer[1] = '\0'; buffer[1] = '\0';
return 2; return 2;
} else if (unichar <= 0x07FF) { }
else if (unichar <= 0x07FF) {
length = 2; length = 2;
head = 0xc0; head = 0xc0;
} else if (unichar <= 0xffff) { }
else if (unichar <= 0xffff) {
length = 3; length = 3;
head = 0xe0; head = 0xe0;
} else if (unichar <= 0x1fffff) { }
else if (unichar <= 0x1fffff) {
length = 4; length = 4;
head = 0xf0; head = 0xf0;
} else if (unichar <= 0x3ffffff) { }
else if (unichar <= 0x3ffffff) {
length = 5; length = 5;
head = 0xf8; head = 0xf8;
} else { }
else {
length = 6; length = 6;
head = 0xfc; head = 0xfc;
} }

View File

@ -1,29 +1,29 @@
/* /*
Copyright 1985, 1987, 1990, 1998 The Open Group * Copyright 1985, 1987, 1990, 1998 The Open Group
Copyright 2008 Dan Nicholson * Copyright 2008 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
@ -59,9 +59,9 @@ xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size)
if ((entry[0] == val1) && (entry[1] == val2) && if ((entry[0] == val1) && (entry[1] == val2) &&
(entry[2] == val3) && (entry[3] == val4)) { (entry[2] == val3) && (entry[3] == val4)) {
snprintf(buffer, size, "%s", entry + 4); snprintf(buffer, size, "%s", entry + 4);
return; return;
} }
if (!--n) if (!--n)
break; break;
@ -73,11 +73,11 @@ xkb_keysym_get_name(xkb_keysym_t ks, char *buffer, size_t size)
} }
if (ks >= 0x01000100 && ks <= 0x0110ffff) if (ks >= 0x01000100 && ks <= 0x0110ffff)
/* Unnamed Unicode codepoint. */ /* Unnamed Unicode codepoint. */
snprintf(buffer, size, "U%lx", ks & 0xffffffUL); snprintf(buffer, size, "U%lx", ks & 0xffffffUL);
else else
/* Unnamed, non-Unicode, symbol (shouldn't generally happen). */ /* Unnamed, non-Unicode, symbol (shouldn't generally happen). */
snprintf(buffer, size, "0x%08x", ks); snprintf(buffer, size, "0x%08x", ks);
} }
_X_EXPORT xkb_keysym_t _X_EXPORT xkb_keysym_t
@ -104,10 +104,9 @@ xkb_keysym_from_name(const char *s)
entry = &_XkeyTable[idx]; entry = &_XkeyTable[idx];
if ((entry[0] == sig1) && (entry[1] == sig2) && if ((entry[0] == sig1) && (entry[1] == sig2) &&
!strcmp(s, (const char *)entry + 6)) !strcmp(s, (const char *) entry + 6)) {
{
val = (entry[2] << 24) | (entry[3] << 16) | val = (entry[2] << 24) | (entry[3] << 16) |
(entry[4] << 8) | entry[5]; (entry[4] << 8) | entry[5];
if (!val) if (!val)
val = XKB_KEY_VoidSymbol; val = XKB_KEY_VoidSymbol;
return val; return val;
@ -173,20 +172,25 @@ keysym_get_case(xkb_keysym_t ks)
switch (set) { switch (set) {
case 0: /* latin 1 */ case 0: /* latin 1 */
if ((ks >= XKB_KEY_A && ks <= XKB_KEY_Z) || if ((ks >= XKB_KEY_A && ks <= XKB_KEY_Z) ||
(ks >= XKB_KEY_Agrave && ks <= XKB_KEY_THORN && ks != XKB_KEY_multiply)) (ks >= XKB_KEY_Agrave && ks <= XKB_KEY_THORN && ks !=
XKB_KEY_multiply))
return UPPERCASE; return UPPERCASE;
if ((ks >= XKB_KEY_a && ks <= XKB_KEY_z) || if ((ks >= XKB_KEY_a && ks <= XKB_KEY_z) ||
(ks >= XKB_KEY_agrave && ks <= XKB_KEY_ydiaeresis)) (ks >= XKB_KEY_agrave && ks <= XKB_KEY_ydiaeresis))
return LOWERCASE; return LOWERCASE;
break; break;
case 1: /* latin 2 */ case 1: /* latin 2 */
if ((ks >= XKB_KEY_Aogonek && ks <= XKB_KEY_Zabovedot && ks != XKB_KEY_breve) || if ((ks >= XKB_KEY_Aogonek && ks <= XKB_KEY_Zabovedot && ks !=
(ks >= XKB_KEY_Racute && ks<=XKB_KEY_Tcedilla)) XKB_KEY_breve) ||
(ks >= XKB_KEY_Racute && ks <= XKB_KEY_Tcedilla))
return UPPERCASE; return UPPERCASE;
if ((ks >= XKB_KEY_aogonek && ks <= XKB_KEY_zabovedot && ks != XKB_KEY_caron) || if ((ks >= XKB_KEY_aogonek && ks <= XKB_KEY_zabovedot && ks !=
XKB_KEY_caron) ||
(ks >= XKB_KEY_racute && ks <= XKB_KEY_tcedilla)) (ks >= XKB_KEY_racute && ks <= XKB_KEY_tcedilla))
return LOWERCASE; return LOWERCASE;
break; break;
case 2: /* latin 3 */ case 2: /* latin 3 */
if ((ks >= XKB_KEY_Hstroke && ks <= XKB_KEY_Jcircumflex) || if ((ks >= XKB_KEY_Hstroke && ks <= XKB_KEY_Jcircumflex) ||
(ks >= XKB_KEY_Cabovedot && ks <= XKB_KEY_Scircumflex)) (ks >= XKB_KEY_Cabovedot && ks <= XKB_KEY_Scircumflex))
@ -195,6 +199,7 @@ keysym_get_case(xkb_keysym_t ks)
(ks >= XKB_KEY_cabovedot && ks <= XKB_KEY_scircumflex)) (ks >= XKB_KEY_cabovedot && ks <= XKB_KEY_scircumflex))
return LOWERCASE; return LOWERCASE;
break; break;
case 3: /* latin 4 */ case 3: /* latin 4 */
if ((ks >= XKB_KEY_Rcedilla && ks <= XKB_KEY_Tslash) || if ((ks >= XKB_KEY_Rcedilla && ks <= XKB_KEY_Tslash) ||
(ks == XKB_KEY_ENG) || (ks == XKB_KEY_ENG) ||
@ -205,6 +210,7 @@ keysym_get_case(xkb_keysym_t ks)
(ks >= XKB_KEY_amacron && ks <= XKB_KEY_umacron)) (ks >= XKB_KEY_amacron && ks <= XKB_KEY_umacron))
return LOWERCASE; return LOWERCASE;
break; break;
case 6: /* Cyrillic */ case 6: /* Cyrillic */
if ((ks >= XKB_KEY_Serbian_DJE && ks <= XKB_KEY_Serbian_DZE) || if ((ks >= XKB_KEY_Serbian_DJE && ks <= XKB_KEY_Serbian_DZE) ||
(ks >= XKB_KEY_Cyrillic_YU && ks <= XKB_KEY_Cyrillic_HARDSIGN)) (ks >= XKB_KEY_Cyrillic_YU && ks <= XKB_KEY_Cyrillic_HARDSIGN))
@ -213,6 +219,7 @@ keysym_get_case(xkb_keysym_t ks)
(ks >= XKB_KEY_Cyrillic_yu && ks <= XKB_KEY_Cyrillic_hardsign)) (ks >= XKB_KEY_Cyrillic_yu && ks <= XKB_KEY_Cyrillic_hardsign))
return LOWERCASE; return LOWERCASE;
break; break;
case 7: /* Greek */ case 7: /* Greek */
if ((ks >= XKB_KEY_Greek_ALPHAaccent && if ((ks >= XKB_KEY_Greek_ALPHAaccent &&
ks <= XKB_KEY_Greek_OMEGAaccent) || ks <= XKB_KEY_Greek_OMEGAaccent) ||
@ -223,6 +230,7 @@ keysym_get_case(xkb_keysym_t ks)
(ks >= XKB_KEY_Greek_alpha && ks <= XKB_KEY_Greek_OMEGA)) (ks >= XKB_KEY_Greek_alpha && ks <= XKB_KEY_Greek_OMEGA))
return LOWERCASE; return LOWERCASE;
break; break;
case 18: /* latin 8 */ case 18: /* latin 8 */
if ((ks == XKB_KEY_Wcircumflex) || if ((ks == XKB_KEY_Wcircumflex) ||
(ks == XKB_KEY_Ycircumflex) || (ks == XKB_KEY_Ycircumflex) ||
@ -249,6 +257,7 @@ keysym_get_case(xkb_keysym_t ks)
(ks == XKB_KEY_ygrave)) (ks == XKB_KEY_ygrave))
return LOWERCASE; return LOWERCASE;
break; break;
case 19: /* latin 9 */ case 19: /* latin 9 */
if (ks == XKB_KEY_OE || ks == XKB_KEY_Ydiaeresis) if (ks == XKB_KEY_OE || ks == XKB_KEY_Ydiaeresis)
return UPPERCASE; return UPPERCASE;

View File

@ -281,9 +281,11 @@ xkb_key_get_group(struct xkb_state *state, xkb_keycode_t key)
if (ret >= num_groups) if (ret >= num_groups)
ret = 0; ret = 0;
break; break;
case XkbClampIntoRange: case XkbClampIntoRange:
ret = num_groups - 1; ret = num_groups - 1;
break; break;
case XkbWrapIntoRange: case XkbWrapIntoRange:
default: default:
ret %= num_groups; ret %= num_groups;

View File

@ -1,28 +1,28 @@
/************************************************************ /************************************************************
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
/* /*
* Copyright © 2012 Intel Corporation * Copyright © 2012 Intel Corporation
@ -575,7 +575,8 @@ xkb_state_led_update_all(struct xkb_state *state)
static void static void
xkb_state_update_derived(struct xkb_state *state) xkb_state_update_derived(struct xkb_state *state)
{ {
state->mods = (state->base_mods | state->latched_mods | state->locked_mods); state->mods =
(state->base_mods | state->latched_mods | state->locked_mods);
/* FIXME: Clamp/wrap locked_group */ /* FIXME: Clamp/wrap locked_group */
state->group = state->locked_group + state->base_group + state->group = state->locked_group + state->base_group +
state->latched_group; state->latched_group;

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "text.h" #include "text.h"
@ -56,9 +56,9 @@ XkbcVModIndexText(struct xkb_keymap *keymap, unsigned ndx)
char buf[20]; char buf[20];
if (ndx >= XkbNumVirtualMods) if (ndx >= XkbNumVirtualMods)
tmp = "illegal"; tmp = "illegal";
else if (keymap && keymap->names) else if (keymap && keymap->names)
tmp = keymap->names->vmods[ndx]; tmp = keymap->names->vmods[ndx];
if (!tmp) { if (!tmp) {
snprintf(buf, sizeof(buf) - 1, "%d", ndx); snprintf(buf, sizeof(buf) - 1, "%d", ndx);
@ -90,12 +90,12 @@ XkbcVModMaskText(struct xkb_keymap *keymap, unsigned modMask, unsigned mask)
mm = XkbcModMaskText(modMask, false); mm = XkbcModMaskText(modMask, false);
str = buf; str = buf;
buf[0]= '\0'; buf[0] = '\0';
rem = BUFFER_SIZE; rem = BUFFER_SIZE;
if (mask) { if (mask) {
for (i = 0, bit = 1; i < XkbNumVirtualMods && rem > 1; i++, bit <<= 1) for (i = 0, bit = 1; i < XkbNumVirtualMods && rem > 1; i++, bit <<=
{ 1) {
if (!(mask & bit)) if (!(mask & bit))
continue; continue;
@ -206,7 +206,7 @@ XkbcFileTypeText(enum xkb_file_type type)
} }
} }
static const char *actionTypeNames[XkbSA_NumActions]= { static const char *actionTypeNames[XkbSA_NumActions] = {
"NoAction", /* XkbSA_NoAction */ "NoAction", /* XkbSA_NoAction */
"SetMods", /* XkbSA_SetMods */ "SetMods", /* XkbSA_SetMods */
"LatchMods", /* XkbSA_LatchMods */ "LatchMods", /* XkbSA_LatchMods */

View File

@ -1,28 +1,28 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#ifndef TEXT_H #ifndef TEXT_H
#define TEXT_H #define TEXT_H

View File

@ -1,29 +1,28 @@
/*\
/*\ *
* * COPYRIGHT 1990
* COPYRIGHT 1990 * DIGITAL EQUIPMENT CORPORATION
* DIGITAL EQUIPMENT CORPORATION * MAYNARD, MASSACHUSETTS
* MAYNARD, MASSACHUSETTS * ALL RIGHTS RESERVED.
* ALL RIGHTS RESERVED. *
* * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
* SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION. * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
* DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE * FOR ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
* FOR ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED * WARRANTY.
* WARRANTY. *
* * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
* IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
* RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN * ADDITION TO THAT SET FORTH ABOVE.
* ADDITION TO THAT SET FORTH ABOVE. *
* * Permission to use, copy, modify, and distribute this software and its
* Permission to use, copy, modify, and distribute this software and its * documentation for any purpose and without fee is hereby granted, provided
* documentation for any purpose and without fee is hereby granted, provided * that the above copyright notice appear in all copies and that both that
* that the above copyright notice appear in all copies and that both that * copyright notice and this permission notice appear in supporting
* copyright notice and this permission notice appear in supporting * documentation, and that the name of Digital Equipment Corporation not be
* documentation, and that the name of Digital Equipment Corporation not be * used in advertising or publicity pertaining to distribution of the
* used in advertising or publicity pertaining to distribution of the * software without specific, written prior permission.
* software without specific, written prior permission. \*/
\*/
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
@ -40,8 +39,7 @@ static char *prefix = NULL;
bool bool
uSetErrorFile(char *name) uSetErrorFile(char *name)
{ {
if ((errorFile != NULL) && (errorFile != stderr)) if ((errorFile != NULL) && (errorFile != stderr)) {
{
fprintf(errorFile, "switching to %s\n", name ? name : "stderr"); fprintf(errorFile, "switching to %s\n", name ? name : "stderr");
fclose(errorFile); fclose(errorFile);
} }
@ -49,8 +47,7 @@ uSetErrorFile(char *name)
errorFile = fopen(name, "w"); errorFile = fopen(name, "w");
else else
errorFile = stderr; errorFile = stderr;
if (errorFile == NULL) if (errorFile == NULL) {
{
errorFile = stderr; errorFile = stderr;
return false; return false;
} }

View File

@ -1,31 +1,31 @@
#ifndef UTILS_H #ifndef UTILS_H
#define UTILS_H 1 #define UTILS_H 1
/*\ /*\
* *
* COPYRIGHT 1990 * COPYRIGHT 1990
* DIGITAL EQUIPMENT CORPORATION * DIGITAL EQUIPMENT CORPORATION
* MAYNARD, MASSACHUSETTS * MAYNARD, MASSACHUSETTS
* ALL RIGHTS RESERVED. * ALL RIGHTS RESERVED.
* *
* THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
* SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION. * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
* DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
* FOR ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED * FOR ANY PURPOSE. IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
* WARRANTY. * WARRANTY.
* *
* IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
* RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
* ADDITION TO THAT SET FORTH ABOVE. * ADDITION TO THAT SET FORTH ABOVE.
* *
* Permission to use, copy, modify, and distribute this software and its * Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided * documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that * that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting * copyright notice and this permission notice appear in supporting
* documentation, and that the name of Digital Equipment Corporation not be * documentation, and that the name of Digital Equipment Corporation not be
* used in advertising or publicity pertaining to distribution of the * used in advertising or publicity pertaining to distribution of the
* software without specific, written prior permission. * software without specific, written prior permission.
\*/ \*/
/***====================================================================***/ /***====================================================================***/
@ -40,10 +40,10 @@
* macro is used when we free these strings in order to avoid -Wcast-qual * macro is used when we free these strings in order to avoid -Wcast-qual
* errors. * errors.
*/ */
#define UNCONSTIFY(const_ptr) ((void *)(uintptr_t)(const_ptr)) #define UNCONSTIFY(const_ptr) ((void *) (uintptr_t) (const_ptr))
#define uTypedAlloc(t) ((t*)malloc(sizeof(t))) #define uTypedAlloc(t) ((t *) malloc(sizeof(t)))
#define uTypedCalloc(n, t) ((t*)calloc((n), sizeof(t))) #define uTypedCalloc(n, t) ((t *) calloc((n), sizeof(t)))
#define uDupString(s) ((s) ? strdup(s) : NULL) #define uDupString(s) ((s) ? strdup(s) : NULL)
#define uStringText(s) ((s) == NULL ? "<NullString>" : (s)) #define uStringText(s) ((s) == NULL ? "<NullString>" : (s))
@ -54,33 +54,33 @@
extern bool extern bool
uSetErrorFile(char *name); uSetErrorFile(char *name);
#define INFO uInformation #define INFO uInformation
extern _X_ATTRIBUTE_PRINTF(1, 2) void extern _X_ATTRIBUTE_PRINTF(1, 2) void
uInformation(const char *s, ...); uInformation(const char *s, ...);
#define ACTION uAction #define ACTION uAction
extern _X_ATTRIBUTE_PRINTF(1, 2) void extern _X_ATTRIBUTE_PRINTF(1, 2) void
uAction(const char *s, ...); uAction(const char *s, ...);
#define WARN uWarning #define WARN uWarning
extern _X_ATTRIBUTE_PRINTF(1, 2) void extern _X_ATTRIBUTE_PRINTF(1, 2) void
uWarning(const char *s, ...); uWarning(const char *s, ...);
#define ERROR uError #define ERROR uError
extern _X_ATTRIBUTE_PRINTF(1, 2) void extern _X_ATTRIBUTE_PRINTF(1, 2) void
uError(const char *s, ...); uError(const char *s, ...);
#define FATAL uFatalError #define FATAL uFatalError
extern _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN void extern _X_ATTRIBUTE_PRINTF(1, 2) _X_NORETURN void
uFatalError(const char *s, ...); uFatalError(const char *s, ...);
/* WSGO stands for "Weird Stuff Going On" (wtf???) */ /* WSGO stands for "Weird Stuff Going On" (wtf???) */
#define WSGO uInternalError #define WSGO uInternalError
extern _X_ATTRIBUTE_PRINTF(1, 2) void extern _X_ATTRIBUTE_PRINTF(1, 2) void
uInternalError(const char *s, ...); uInternalError(const char *s, ...);

View File

@ -1,55 +1,55 @@
/* /*
Copyright 1985, 1987, 1990, 1998 The Open Group * Copyright 1985, 1987, 1990, 1998 The Open Group
Copyright 2008 Dan Nicholson * Copyright 2008 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
/************************************************************ /************************************************************
Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
/* /*
* Copyright © 2012 Intel Corporation * Copyright © 2012 Intel Corporation
@ -91,21 +91,22 @@ THE USE OR PERFORMANCE OF THIS SOFTWARE.
enum xkb_file_type { enum xkb_file_type {
/* The top level file which includes the other component files. */ /* The top level file which includes the other component files. */
FILE_TYPE_KEYMAP = (1 << 0), FILE_TYPE_KEYMAP = (1 << 0),
/* Component files. */ /* Component files. */
FILE_TYPE_TYPES = (1 << 1), FILE_TYPE_TYPES = (1 << 1),
FILE_TYPE_COMPAT = (1 << 2), FILE_TYPE_COMPAT = (1 << 2),
FILE_TYPE_SYMBOLS = (1 << 3), FILE_TYPE_SYMBOLS = (1 << 3),
FILE_TYPE_KEYCODES = (1 << 4), FILE_TYPE_KEYCODES = (1 << 4),
FILE_TYPE_GEOMETRY = (1 << 5), FILE_TYPE_GEOMETRY = (1 << 5),
/* This one doesn't mix with the others, but useful here as well. */ /* This one doesn't mix with the others, but useful here as well. */
FILE_TYPE_RULES = (1 << 6), FILE_TYPE_RULES = (1 << 6),
}; };
/* Files needed for a complete keymap. */ /* Files needed for a complete keymap. */
#define REQUIRED_FILE_TYPES (FILE_TYPE_TYPES | FILE_TYPE_COMPAT | FILE_TYPE_SYMBOLS | FILE_TYPE_KEYCODES) #define REQUIRED_FILE_TYPES (FILE_TYPE_TYPES | FILE_TYPE_COMPAT | \
FILE_TYPE_SYMBOLS | FILE_TYPE_KEYCODES)
#define LEGAL_FILE_TYPES REQUIRED_FILE_TYPES #define LEGAL_FILE_TYPES REQUIRED_FILE_TYPES
/** /**
@ -119,132 +120,132 @@ struct xkb_component_names {
}; };
struct xkb_any_action { struct xkb_any_action {
uint8_t type; uint8_t type;
uint8_t data[7]; uint8_t data[7];
}; };
struct xkb_mod_action { struct xkb_mod_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
uint8_t mask; uint8_t mask;
uint8_t real_mods; uint8_t real_mods;
uint16_t vmods; uint16_t vmods;
}; };
struct xkb_group_action { struct xkb_group_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
int16_t group; int16_t group;
}; };
struct xkb_iso_action { struct xkb_iso_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
uint8_t mask; uint8_t mask;
uint8_t real_mods; uint8_t real_mods;
uint8_t group; uint8_t group;
uint8_t affect; uint8_t affect;
uint16_t vmods; uint16_t vmods;
}; };
struct xkb_controls_action { struct xkb_controls_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
uint32_t ctrls; uint32_t ctrls;
}; };
struct xkb_device_button_action { struct xkb_device_button_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
uint8_t count; uint8_t count;
uint8_t button; uint8_t button;
uint8_t device; uint8_t device;
}; };
struct xkb_device_valuator_action { struct xkb_device_valuator_action {
uint8_t type; uint8_t type;
uint8_t device; uint8_t device;
uint8_t v1_what; uint8_t v1_what;
uint8_t v1_index; uint8_t v1_index;
int8_t v1_value; int8_t v1_value;
uint8_t v2_what; uint8_t v2_what;
uint8_t v2_index; uint8_t v2_index;
int8_t v2_value; int8_t v2_value;
}; };
struct xkb_pointer_default_action { struct xkb_pointer_default_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
uint8_t affect; uint8_t affect;
int8_t value; int8_t value;
}; };
struct xkb_switch_screen_action { struct xkb_switch_screen_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
int8_t screen; int8_t screen;
}; };
struct xkb_redirect_key_action { struct xkb_redirect_key_action {
uint8_t type; uint8_t type;
xkb_keycode_t new_key; xkb_keycode_t new_key;
uint8_t mods_mask; uint8_t mods_mask;
uint8_t mods; uint8_t mods;
uint16_t vmods_mask; uint16_t vmods_mask;
uint16_t vmods; uint16_t vmods;
}; };
struct xkb_pointer_action { struct xkb_pointer_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
int16_t x; int16_t x;
int16_t y; int16_t y;
}; };
struct xkb_message_action { struct xkb_message_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
uint8_t message[6]; uint8_t message[6];
}; };
struct xkb_pointer_button_action { struct xkb_pointer_button_action {
uint8_t type; uint8_t type;
uint8_t flags; uint8_t flags;
uint8_t count; uint8_t count;
int8_t button; int8_t button;
}; };
union xkb_action { union xkb_action {
struct xkb_any_action any; struct xkb_any_action any;
struct xkb_mod_action mods; struct xkb_mod_action mods;
struct xkb_group_action group; struct xkb_group_action group;
struct xkb_iso_action iso; struct xkb_iso_action iso;
struct xkb_controls_action ctrls; struct xkb_controls_action ctrls;
struct xkb_device_button_action devbtn; struct xkb_device_button_action devbtn;
struct xkb_device_valuator_action devval; struct xkb_device_valuator_action devval;
struct xkb_pointer_default_action dflt; struct xkb_pointer_default_action dflt;
struct xkb_switch_screen_action screen; struct xkb_switch_screen_action screen;
struct xkb_redirect_key_action redirect; /* XXX wholly unnecessary? */ struct xkb_redirect_key_action redirect; /* XXX wholly unnecessary? */
struct xkb_pointer_action ptr; /* XXX delete for DeviceValuator */ struct xkb_pointer_action ptr; /* XXX delete for DeviceValuator */
struct xkb_pointer_button_action btn; /* XXX delete for DeviceBtn */ struct xkb_pointer_button_action btn; /* XXX delete for DeviceBtn */
struct xkb_message_action msg; /* XXX just delete */ struct xkb_message_action msg; /* XXX just delete */
unsigned char type; unsigned char type;
}; };
struct xkb_mods { struct xkb_mods {
uint32_t mask; /* effective mods */ uint32_t mask; /* effective mods */
uint32_t vmods; uint32_t vmods;
uint8_t real_mods; uint8_t real_mods;
}; };
struct xkb_kt_map_entry { struct xkb_kt_map_entry {
uint16_t level; uint16_t level;
struct xkb_mods mods; struct xkb_mods mods;
}; };
struct xkb_key_type { struct xkb_key_type {
struct xkb_mods mods; struct xkb_mods mods;
uint16_t num_levels; uint16_t num_levels;
darray(struct xkb_kt_map_entry) map; darray(struct xkb_kt_map_entry) map;
struct xkb_mods * preserve; struct xkb_mods * preserve;
char *name; char *name;
@ -252,26 +253,26 @@ struct xkb_key_type {
}; };
struct xkb_sym_interpret { struct xkb_sym_interpret {
xkb_keysym_t sym; xkb_keysym_t sym;
unsigned char flags; unsigned char flags;
unsigned char match; unsigned char match;
uint8_t mods; uint8_t mods;
uint32_t virtual_mod; uint32_t virtual_mod;
union xkb_action act; union xkb_action act;
}; };
struct xkb_compat_map { struct xkb_compat_map {
darray(struct xkb_sym_interpret) sym_interpret; darray(struct xkb_sym_interpret) sym_interpret;
struct xkb_mods groups[XkbNumKbdGroups]; struct xkb_mods groups[XkbNumKbdGroups];
}; };
struct xkb_sym_map { struct xkb_sym_map {
unsigned char kt_index[XkbNumKbdGroups]; unsigned char kt_index[XkbNumKbdGroups];
unsigned char group_info; unsigned char group_info;
unsigned char width; unsigned char width;
int *sym_index; /* per level/group index into 'syms' */ int *sym_index; /* per level/group index into 'syms' */
unsigned int *num_syms; /* per level/group */ unsigned int *num_syms; /* per level/group */
darray(xkb_keysym_t) syms; darray(xkb_keysym_t) syms;
}; };
struct xkb_client_map { struct xkb_client_map {
@ -281,41 +282,40 @@ struct xkb_client_map {
}; };
struct xkb_behavior { struct xkb_behavior {
unsigned char type; unsigned char type;
unsigned char data; unsigned char data;
}; };
struct xkb_server_map { struct xkb_server_map {
unsigned char * explicit; unsigned char * explicit;
darray(union xkb_action) acts; darray(union xkb_action) acts;
darray(size_t ) key_acts; /* acts[key_acts[keycode]] */ darray(size_t) key_acts; /* acts[key_acts[keycode]] */
struct xkb_behavior *behaviors; struct xkb_behavior *behaviors;
uint32_t vmods[XkbNumVirtualMods]; /* vmod -> mod mapping */ uint32_t vmods[XkbNumVirtualMods]; /* vmod -> mod mapping */
uint32_t *vmodmap; /* key -> vmod mapping */ uint32_t *vmodmap; /* key -> vmod mapping */
}; };
struct xkb_indicator_map { struct xkb_indicator_map {
unsigned char flags; unsigned char flags;
unsigned char which_groups; unsigned char which_groups;
unsigned char groups; unsigned char groups;
unsigned char which_mods; unsigned char which_mods;
struct xkb_mods mods; struct xkb_mods mods;
unsigned int ctrls; unsigned int ctrls;
}; };
struct xkb_indicator { struct xkb_indicator {
struct xkb_indicator_map maps[XkbNumIndicators]; struct xkb_indicator_map maps[XkbNumIndicators];
}; };
struct xkb_key_name { struct xkb_key_name {
char name[XkbKeyNameLength]; char name[XkbKeyNameLength];
}; };
struct xkb_key_alias { struct xkb_key_alias {
char real[XkbKeyNameLength]; char real[XkbKeyNameLength];
char alias[XkbKeyNameLength]; char alias[XkbKeyNameLength];
}; };
struct xkb_names { struct xkb_names {
@ -354,10 +354,10 @@ struct xkb_controls {
struct xkb_keymap { struct xkb_keymap {
struct xkb_context *ctx; struct xkb_context *ctx;
unsigned int refcnt; unsigned int refcnt;
unsigned short flags; unsigned short flags;
xkb_keycode_t min_key_code; xkb_keycode_t min_key_code;
xkb_keycode_t max_key_code; xkb_keycode_t max_key_code;
struct xkb_controls * ctrls; struct xkb_controls * ctrls;
struct xkb_server_map * server; struct xkb_server_map * server;
@ -371,7 +371,9 @@ struct xkb_keymap {
#define XkbOutOfRangeGroupInfo(g) ((g) & 0xf0) #define XkbOutOfRangeGroupInfo(g) ((g) & 0xf0)
#define XkbOutOfRangeGroupAction(g) ((g) & 0xc0) #define XkbOutOfRangeGroupAction(g) ((g) & 0xc0)
#define XkbOutOfRangeGroupNumber(g) (((g) & 0x30) >> 4) #define XkbOutOfRangeGroupNumber(g) (((g) & 0x30) >> 4)
#define XkbSetGroupInfo(g, w, n) (((w) & 0xc0) | (((n) & 3) << 4) | ((g) & 0x0f)) #define XkbSetGroupInfo(g, w, \
n) (((w) & \
0xc0) | (((n) & 3) << 4) | ((g) & 0x0f))
#define XkbSetNumGroups(g, n) (((g) & 0xf0) | ((n) & 0x0f)) #define XkbSetNumGroups(g, n) (((g) & 0xf0) | ((n) & 0x0f))
#define XkbKeyGroupInfo(d, k) \ #define XkbKeyGroupInfo(d, k) \
@ -387,11 +389,13 @@ struct xkb_keymap {
#define XkbKeyType(d, k, g) \ #define XkbKeyType(d, k, g) \
(&darray_item((d)->map->types, XkbKeyTypeIndex(d, k, g))) (&darray_item((d)->map->types, XkbKeyTypeIndex(d, k, g)))
#define XkbKeyNumSyms(d, k, g, sl) \ #define XkbKeyNumSyms(d, k, g, sl) \
(darray_item((d)->map->key_sym_map, k).num_syms[(g * XkbKeyGroupsWidth(d, k)) + sl]) (darray_item((d)->map->key_sym_map, \
k).num_syms[(g * XkbKeyGroupsWidth(d, k)) + sl])
#define XkbKeySym(d, k, n) \ #define XkbKeySym(d, k, n) \
(&darray_item(darray_item((d)->map->key_sym_map, k).syms, n)) (&darray_item(darray_item((d)->map->key_sym_map, k).syms, n))
#define XkbKeySymOffset(d, k, g, sl) \ #define XkbKeySymOffset(d, k, g, sl) \
(darray_item((d)->map->key_sym_map, k).sym_index[(g * XkbKeyGroupsWidth(d, k)) + sl]) (darray_item((d)->map->key_sym_map, \
k).sym_index[(g * XkbKeyGroupsWidth(d, k)) + sl])
#define XkbKeySymEntry(d, k, g, sl) \ #define XkbKeySymEntry(d, k, g, sl) \
(XkbKeySym(d, k, XkbKeySymOffset(d, k, g, sl))) (XkbKeySym(d, k, XkbKeySymOffset(d, k, g, sl)))
#define XkbKeyHasActions(d, k) \ #define XkbKeyHasActions(d, k) \

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "action.h" #include "action.h"
@ -178,7 +178,7 @@ static bool
ReportIllegal(unsigned action, unsigned field) ReportIllegal(unsigned action, unsigned field)
{ {
ERROR("Field %s is not defined for an action of type %s\n", ERROR("Field %s is not defined for an action of type %s\n",
fieldText(field), XkbcActionTypeText(action)); fieldText(field), XkbcActionTypeText(action));
ACTION("Action definition ignored\n"); ACTION("Action definition ignored\n");
return false; return false;
} }
@ -187,7 +187,7 @@ static bool
ReportActionNotArray(unsigned action, unsigned field) ReportActionNotArray(unsigned action, unsigned field)
{ {
ERROR("The %s field in the %s action is not an array\n", ERROR("The %s field in the %s action is not an array\n",
fieldText(field), XkbcActionTypeText(action)); fieldText(field), XkbcActionTypeText(action));
ACTION("Action definition ignored\n"); ACTION("Action definition ignored\n");
return false; return false;
} }
@ -198,7 +198,7 @@ ReportNotFound(unsigned action, unsigned field, const char *what,
{ {
ERROR("%s named %s not found\n", what, bad); ERROR("%s named %s not found\n", what, bad);
ACTION("Ignoring the %s field of an %s action\n", fieldText(field), ACTION("Ignoring the %s field of an %s action\n", fieldText(field),
XkbcActionTypeText(action)); XkbcActionTypeText(action));
return false; return false;
} }
@ -237,13 +237,11 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
{ {
ExprResult rtrn; ExprResult rtrn;
if (value->op == ExprIdent) if (value->op == ExprIdent) {
{
const char *valStr; const char *valStr;
valStr = xkb_atom_text(keymap->ctx, value->value.str); valStr = xkb_atom_text(keymap->ctx, value->value.str);
if (valStr && ((strcasecmp(valStr, "usemodmapmods") == 0) || if (valStr && ((strcasecmp(valStr, "usemodmapmods") == 0) ||
(strcasecmp(valStr, "modmapmods") == 0))) (strcasecmp(valStr, "modmapmods") == 0))) {
{
*mods_rtrn = 0; *mods_rtrn = 0;
*flags_inout |= XkbSA_UseModMapMods; *flags_inout |= XkbSA_UseModMapMods;
@ -266,31 +264,27 @@ HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned t1, t2; unsigned t1, t2;
act = (struct xkb_mod_action *) action; act = (struct xkb_mod_action *) action;
if (array_ndx != NULL) if (array_ndx != NULL) {
{ switch (field) {
switch (field)
{
case F_ClearLocks: case F_ClearLocks:
case F_LatchToLock: case F_LatchToLock:
case F_Modifiers: case F_Modifiers:
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
} }
} }
switch (field) switch (field) {
{
case F_ClearLocks: case F_ClearLocks:
case F_LatchToLock: case F_LatchToLock:
rtrn = act->flags; rtrn = act->flags;
if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
{
act->flags = rtrn; act->flags = rtrn;
return true; return true;
} }
return false; return false;
case F_Modifiers: case F_Modifiers:
t1 = act->flags; t1 = act->flags;
if (CheckModifierField(keymap, action->type, value, &t1, &t2)) if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
{
act->flags = t1; act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff); act->real_mods = act->mask = (t2 & 0xff);
act->vmods = (t2 >> 8) & 0xffff; act->vmods = (t2 >> 8) & 0xffff;
@ -311,12 +305,10 @@ HandleLockMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
act = (struct xkb_mod_action *) action; act = (struct xkb_mod_action *) action;
if ((array_ndx != NULL) && (field == F_Modifiers)) if ((array_ndx != NULL) && (field == F_Modifiers))
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
switch (field) switch (field) {
{
case F_Modifiers: case F_Modifiers:
t1 = act->flags; t1 = act->flags;
if (CheckModifierField(keymap, action->type, value, &t1, &t2)) if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
{
act->flags = t1; act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff); act->real_mods = act->mask = (t2 & 0xff);
act->vmods = (t2 >> 8) & 0xffff; act->vmods = (t2 >> 8) & 0xffff;
@ -334,13 +326,11 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action,
ExprDef *spec; ExprDef *spec;
ExprResult rtrn; ExprResult rtrn;
if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
{
*flags_inout &= ~XkbSA_GroupAbsolute; *flags_inout &= ~XkbSA_GroupAbsolute;
spec = value->value.child; spec = value->value.child;
} }
else else {
{
*flags_inout |= XkbSA_GroupAbsolute; *flags_inout |= XkbSA_GroupAbsolute;
spec = value; spec = value;
} }
@ -366,33 +356,29 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
int t2; int t2;
act = (struct xkb_group_action *) action; act = (struct xkb_group_action *) action;
if (array_ndx != NULL) if (array_ndx != NULL) {
{ switch (field) {
switch (field)
{
case F_ClearLocks: case F_ClearLocks:
case F_LatchToLock: case F_LatchToLock:
case F_Group: case F_Group:
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
} }
} }
switch (field) switch (field) {
{
case F_ClearLocks: case F_ClearLocks:
case F_LatchToLock: case F_LatchToLock:
rtrn = act->flags; rtrn = act->flags;
if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
{
act->flags = rtrn; act->flags = rtrn;
return true; return true;
} }
return false; return false;
case F_Group: case F_Group:
t1 = act->flags; t1 = act->flags;
if (CheckGroupField(keymap, action->type, value, &t1, &t2)) if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
{
act->flags = t1; act->flags = t1;
act->group = t2; act->group = t2;
return true; return true;
} }
return false; return false;
@ -411,13 +397,11 @@ HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
act = (struct xkb_group_action *) action; act = (struct xkb_group_action *) action;
if ((array_ndx != NULL) && (field == F_Group)) if ((array_ndx != NULL) && (field == F_Group))
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (field == F_Group) if (field == F_Group) {
{
t1 = act->flags; t1 = act->flags;
if (CheckGroupField(keymap, action->type, value, &t1, &t2)) if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
{
act->flags = t1; act->flags = t1;
act->group = t2; act->group = t2;
return true; return true;
} }
return false; return false;
@ -437,30 +421,26 @@ HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y))) if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if ((field == F_X) || (field == F_Y)) if ((field == F_X) || (field == F_Y)) {
{
if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
absolute = false; absolute = false;
else else
absolute = true; absolute = true;
if (!ExprResolveInteger(keymap->ctx, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if (field == F_X) if (field == F_X) {
{
if (absolute) if (absolute)
act->flags |= XkbSA_MoveAbsoluteX; act->flags |= XkbSA_MoveAbsoluteX;
act->x = rtrn.ival; act->x = rtrn.ival;
} }
else else {
{
if (absolute) if (absolute)
act->flags |= XkbSA_MoveAbsoluteY; act->flags |= XkbSA_MoveAbsoluteY;
act->y = rtrn.ival; act->y = rtrn.ival;
} }
return true; return true;
} }
else if (field == F_Accel) else if (field == F_Accel) {
{
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn)) if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "boolean"); return ReportMismatch(action->type, field, "boolean");
if (rtrn.uval) if (rtrn.uval)
@ -472,11 +452,11 @@ HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
} }
static const LookupEntry lockWhich[] = { static const LookupEntry lockWhich[] = {
{"both", 0}, { "both", 0 },
{"lock", XkbSA_LockNoUnlock}, { "lock", XkbSA_LockNoUnlock },
{"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)}, { "neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock) },
{"unlock", XkbSA_LockNoLock}, { "unlock", XkbSA_LockNoLock },
{NULL, 0} { NULL, 0 }
}; };
static bool static bool
@ -487,15 +467,13 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
struct xkb_pointer_button_action *act; struct xkb_pointer_button_action *act;
act = (struct xkb_pointer_button_action *) action; act = (struct xkb_pointer_button_action *) action;
if (field == F_Button) if (field == F_Button) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &rtrn)) if (!ExprResolveButton(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, return ReportMismatch(action->type, field,
"integer (range 1..5)"); "integer (range 1..5)");
if ((rtrn.ival < 0) || (rtrn.ival > 5)) if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
{
ERROR("Button must specify default or be in the range 1..5\n"); ERROR("Button must specify default or be in the range 1..5\n");
ACTION("Illegal button value %d ignored\n", rtrn.ival); ACTION("Illegal button value %d ignored\n", rtrn.ival);
return false; return false;
@ -503,8 +481,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->button = rtrn.ival; act->button = rtrn.ival;
return true; return true;
} }
else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich)) if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
@ -513,14 +490,12 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->flags |= rtrn.ival; act->flags |= rtrn.ival;
return true; return true;
} }
else if (field == F_Count) else if (field == F_Count) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &rtrn)) if (!ExprResolveButton(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
{
ERROR("The count field must have a value in the range 0..255\n"); ERROR("The count field must have a value in the range 0..255\n");
ACTION("Illegal count %d ignored\n", rtrn.ival); ACTION("Illegal count %d ignored\n", rtrn.ival);
return false; return false;
@ -532,10 +507,10 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
} }
static const LookupEntry ptrDflts[] = { static const LookupEntry ptrDflts[] = {
{"dfltbtn", XkbSA_AffectDfltBtn}, { "dfltbtn", XkbSA_AffectDfltBtn },
{"defaultbutton", XkbSA_AffectDfltBtn}, { "defaultbutton", XkbSA_AffectDfltBtn },
{"button", XkbSA_AffectDfltBtn}, { "button", XkbSA_AffectDfltBtn },
{NULL, 0} { NULL, 0 }
}; };
static bool static bool
@ -546,8 +521,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
struct xkb_pointer_default_action *act; struct xkb_pointer_default_action *act;
act = (struct xkb_pointer_default_action *) action; act = (struct xkb_pointer_default_action *) action;
if (field == F_Affect) if (field == F_Affect) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveEnum(keymap->ctx, value, &rtrn, ptrDflts)) if (!ExprResolveEnum(keymap->ctx, value, &rtrn, ptrDflts))
@ -555,18 +529,15 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->affect = rtrn.uval; act->affect = rtrn.uval;
return true; return true;
} }
else if ((field == F_Button) || (field == F_Value)) else if ((field == F_Button) || (field == F_Value)) {
{
ExprDef *btn; ExprDef *btn;
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
{
act->flags &= ~XkbSA_DfltBtnAbsolute; act->flags &= ~XkbSA_DfltBtnAbsolute;
btn = value->value.child; btn = value->value.child;
} }
else else {
{
act->flags |= XkbSA_DfltBtnAbsolute; act->flags |= XkbSA_DfltBtnAbsolute;
btn = value; btn = value;
} }
@ -574,39 +545,37 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
if (!ExprResolveButton(keymap->ctx, btn, &rtrn)) if (!ExprResolveButton(keymap->ctx, btn, &rtrn))
return ReportMismatch(action->type, field, return ReportMismatch(action->type, field,
"integer (range 1..5)"); "integer (range 1..5)");
if ((rtrn.ival < 0) || (rtrn.ival > 5)) if ((rtrn.ival < 0) || (rtrn.ival > 5)) {
{
ERROR("New default button value must be in the range 1..5\n"); ERROR("New default button value must be in the range 1..5\n");
ACTION("Illegal default button value %d ignored\n", rtrn.ival); ACTION("Illegal default button value %d ignored\n", rtrn.ival);
return false; return false;
} }
if (rtrn.ival == 0) if (rtrn.ival == 0) {
{
ERROR("Cannot set default pointer button to \"default\"\n"); ERROR("Cannot set default pointer button to \"default\"\n");
ACTION("Illegal default button setting ignored\n"); ACTION("Illegal default button setting ignored\n");
return false; return false;
} }
if (value->op == OpNegate) if (value->op == OpNegate)
act->value = -rtrn.ival; act->value = -rtrn.ival;
else else
act->value = rtrn.ival; act->value = rtrn.ival;
return true; return true;
} }
return ReportIllegal(action->type, field); return ReportIllegal(action->type, field);
} }
static const LookupEntry isoNames[] = { static const LookupEntry isoNames[] = {
{"mods", XkbSA_ISONoAffectMods}, { "mods", XkbSA_ISONoAffectMods },
{"modifiers", XkbSA_ISONoAffectMods}, { "modifiers", XkbSA_ISONoAffectMods },
{"group", XkbSA_ISONoAffectGroup}, { "group", XkbSA_ISONoAffectGroup },
{"groups", XkbSA_ISONoAffectGroup}, { "groups", XkbSA_ISONoAffectGroup },
{"ptr", XkbSA_ISONoAffectPtr}, { "ptr", XkbSA_ISONoAffectPtr },
{"pointer", XkbSA_ISONoAffectPtr}, { "pointer", XkbSA_ISONoAffectPtr },
{"ctrls", XkbSA_ISONoAffectCtrls}, { "ctrls", XkbSA_ISONoAffectCtrls },
{"controls", XkbSA_ISONoAffectCtrls}, { "controls", XkbSA_ISONoAffectCtrls },
{"all", ~((unsigned) 0)}, { "all", ~((unsigned) 0) },
{"none", 0}, { "none", 0 },
{NULL, 0}, { NULL, 0 },
}; };
static bool static bool
@ -619,31 +588,30 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
int group; int group;
act = (struct xkb_iso_action *) action; act = (struct xkb_iso_action *) action;
switch (field) switch (field) {
{
case F_Modifiers: case F_Modifiers:
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
flags = act->flags; flags = act->flags;
if (CheckModifierField(keymap, action->type, value, &flags, &mods)) if (CheckModifierField(keymap, action->type, value, &flags, &mods)) {
{
act->flags = flags & (~XkbSA_ISODfltIsGroup); act->flags = flags & (~XkbSA_ISODfltIsGroup);
act->real_mods = mods & 0xff; act->real_mods = mods & 0xff;
act->vmods = (mods >> 8) & 0xff; act->vmods = (mods >> 8) & 0xff;
return true; return true;
} }
return false; return false;
case F_Group: case F_Group:
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
flags = act->flags; flags = act->flags;
if (CheckGroupField(keymap, action->type, value, &flags, &group)) if (CheckGroupField(keymap, action->type, value, &flags, &group)) {
{
act->flags = flags | XkbSA_ISODfltIsGroup; act->flags = flags | XkbSA_ISODfltIsGroup;
act->group = group; act->group = group;
return true; return true;
} }
return false; return false;
case F_Affect: case F_Affect:
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
@ -663,38 +631,33 @@ HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
struct xkb_switch_screen_action *act; struct xkb_switch_screen_action *act;
act = (struct xkb_switch_screen_action *) action; act = (struct xkb_switch_screen_action *) action;
if (field == F_Screen) if (field == F_Screen) {
{
ExprDef *scrn; ExprDef *scrn;
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
{
act->flags &= ~XkbSA_SwitchAbsolute; act->flags &= ~XkbSA_SwitchAbsolute;
scrn = value->value.child; scrn = value->value.child;
} }
else else {
{
act->flags |= XkbSA_SwitchAbsolute; act->flags |= XkbSA_SwitchAbsolute;
scrn = value; scrn = value;
} }
if (!ExprResolveInteger(keymap->ctx, scrn, &rtrn)) if (!ExprResolveInteger(keymap->ctx, scrn, &rtrn))
return ReportMismatch(action->type, field, "integer (0..255)"); return ReportMismatch(action->type, field, "integer (0..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
{
ERROR("Screen index must be in the range 1..255\n"); ERROR("Screen index must be in the range 1..255\n");
ACTION("Illegal screen value %d ignored\n", rtrn.ival); ACTION("Illegal screen value %d ignored\n", rtrn.ival);
return false; return false;
} }
if (value->op == OpNegate) if (value->op == OpNegate)
act->screen = -rtrn.ival; act->screen = -rtrn.ival;
else else
act->screen = rtrn.ival; act->screen = rtrn.ival;
return true; return true;
} }
else if (field == F_Same) else if (field == F_Same) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn)) if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
@ -709,36 +672,37 @@ HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
} }
const LookupEntry ctrlNames[] = { const LookupEntry ctrlNames[] = {
{"repeatkeys", XkbRepeatKeysMask}, { "repeatkeys", XkbRepeatKeysMask },
{"repeat", XkbRepeatKeysMask}, { "repeat", XkbRepeatKeysMask },
{"autorepeat", XkbRepeatKeysMask}, { "autorepeat", XkbRepeatKeysMask },
{"slowkeys", XkbSlowKeysMask}, { "slowkeys", XkbSlowKeysMask },
{"bouncekeys", XkbBounceKeysMask}, { "bouncekeys", XkbBounceKeysMask },
{"stickykeys", XkbStickyKeysMask}, { "stickykeys", XkbStickyKeysMask },
{"mousekeys", XkbMouseKeysMask}, { "mousekeys", XkbMouseKeysMask },
{"mousekeysaccel", XkbMouseKeysAccelMask}, { "mousekeysaccel", XkbMouseKeysAccelMask },
{"accessxkeys", XkbAccessXKeysMask}, { "accessxkeys", XkbAccessXKeysMask },
{"accessxtimeout", XkbAccessXTimeoutMask}, { "accessxtimeout", XkbAccessXTimeoutMask },
{"accessxfeedback", XkbAccessXFeedbackMask}, { "accessxfeedback", XkbAccessXFeedbackMask },
{"audiblebell", XkbAudibleBellMask}, { "audiblebell", XkbAudibleBellMask },
{"ignoregrouplock", XkbIgnoreGroupLockMask}, { "ignoregrouplock", XkbIgnoreGroupLockMask },
{"all", XkbAllBooleanCtrlsMask}, { "all", XkbAllBooleanCtrlsMask },
{"overlay1", 0}, { "overlay1", 0 },
{"overlay2", 0}, { "overlay2", 0 },
{"none", 0}, { "none", 0 },
{NULL, 0} { NULL, 0 }
}; };
static bool static bool
HandleSetLockControls(struct xkb_keymap *keymap, struct xkb_any_action *action, HandleSetLockControls(struct xkb_keymap *keymap,
unsigned field, ExprDef *array_ndx, ExprDef *value) struct xkb_any_action *action,
unsigned field, ExprDef *array_ndx,
ExprDef *value)
{ {
ExprResult rtrn; ExprResult rtrn;
struct xkb_controls_action *act; struct xkb_controls_action *act;
act = (struct xkb_controls_action *) action; act = (struct xkb_controls_action *) action;
if (field == F_Controls) if (field == F_Controls) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
@ -750,13 +714,13 @@ HandleSetLockControls(struct xkb_keymap *keymap, struct xkb_any_action *action,
} }
static const LookupEntry evNames[] = { static const LookupEntry evNames[] = {
{"press", XkbSA_MessageOnPress}, { "press", XkbSA_MessageOnPress },
{"keypress", XkbSA_MessageOnPress}, { "keypress", XkbSA_MessageOnPress },
{"release", XkbSA_MessageOnRelease}, { "release", XkbSA_MessageOnRelease },
{"keyrelease", XkbSA_MessageOnRelease}, { "keyrelease", XkbSA_MessageOnRelease },
{"all", XkbSA_MessageOnPress | XkbSA_MessageOnRelease}, { "all", XkbSA_MessageOnPress | XkbSA_MessageOnRelease },
{"none", 0}, { "none", 0 },
{NULL, 0} { NULL, 0 }
}; };
static bool static bool
@ -767,8 +731,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
struct xkb_message_action *act; struct xkb_message_action *act;
act = (struct xkb_message_action *) action; act = (struct xkb_message_action *) action;
switch (field) switch (field) {
{
case F_Report: case F_Report:
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
@ -778,6 +741,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->flags = act->flags =
rtrn.uval & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease); rtrn.uval & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
return true; return true;
case F_GenKeyEvent: case F_GenKeyEvent:
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
@ -788,16 +752,14 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
else else
act->flags &= ~XkbSA_MessageGenKeyEvent; act->flags &= ~XkbSA_MessageGenKeyEvent;
return true; return true;
case F_Data: case F_Data:
if (array_ndx == NULL) if (array_ndx == NULL) {
{
if (!ExprResolveString(keymap->ctx, value, &rtrn)) if (!ExprResolveString(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "string"); return ReportMismatch(action->type, field, "string");
else else {
{
int len = strlen(rtrn.str); int len = strlen(rtrn.str);
if ((len < 1) || (len > 6)) if ((len < 1) || (len > 6)) {
{
WARN("An action message can hold only 6 bytes\n"); WARN("An action message can hold only 6 bytes\n");
ACTION("Extra %d bytes ignored\n", len - 6); ACTION("Extra %d bytes ignored\n", len - 6);
} }
@ -805,26 +767,22 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
} }
return true; return true;
} }
else else {
{
unsigned ndx; unsigned ndx;
if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
{
ERROR("Array subscript must be integer\n"); ERROR("Array subscript must be integer\n");
ACTION("Illegal subscript ignored\n"); ACTION("Illegal subscript ignored\n");
return false; return false;
} }
ndx = rtrn.uval; ndx = rtrn.uval;
if (ndx > 5) if (ndx > 5) {
{
ERROR("An action message is at most 6 bytes long\n"); ERROR("An action message is at most 6 bytes long\n");
ACTION("Attempt to use data[%d] ignored\n", ndx); ACTION("Attempt to use data[%d] ignored\n", ndx);
return false; return false;
} }
if (!ExprResolveInteger(keymap->ctx, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
{
ERROR("Message data must be in the range 0..255\n"); ERROR("Message data must be in the range 0..255\n");
ACTION("Illegal datum %d ignored\n", rtrn.ival); ACTION("Illegal datum %d ignored\n", rtrn.ival);
return false; return false;
@ -850,24 +808,23 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
act = (struct xkb_redirect_key_action *) action; act = (struct xkb_redirect_key_action *) action;
switch (field) switch (field) {
{
case F_Keycode: case F_Keycode:
if (!ExprResolveKeyName(keymap->ctx, value, &rtrn)) if (!ExprResolveKeyName(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "key name"); return ReportMismatch(action->type, field, "key name");
tmp = KeyNameToLong(rtrn.keyName.name); tmp = KeyNameToLong(rtrn.keyName.name);
if (!FindNamedKey(keymap, tmp, &kc, true, CreateKeyNames(keymap), 0)) if (!FindNamedKey(keymap, tmp, &kc, true, CreateKeyNames(keymap),
{ 0)) {
return ReportNotFound(action->type, field, "Key", return ReportNotFound(action->type, field, "Key",
XkbcKeyNameText(rtrn.keyName.name)); XkbcKeyNameText(rtrn.keyName.name));
} }
act->new_key = kc; act->new_key = kc;
return true; return true;
case F_ModsToClear: case F_ModsToClear:
case F_Modifiers: case F_Modifiers:
t1 = 0; t1 = 0;
if (CheckModifierField(keymap, action->type, value, &t1, &t2)) if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
{
act->mods_mask |= (t2 & 0xff); act->mods_mask |= (t2 & 0xff);
if (field == F_Modifiers) if (field == F_Modifiers)
act->mods |= (t2 & 0xff); act->mods |= (t2 & 0xff);
@ -895,15 +852,13 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
struct xkb_device_button_action *act; struct xkb_device_button_action *act;
act = (struct xkb_device_button_action *) action; act = (struct xkb_device_button_action *) action;
if (field == F_Button) if (field == F_Button) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveInteger(keymap->ctx, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, return ReportMismatch(action->type, field,
"integer (range 1..255)"); "integer (range 1..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
{
ERROR("Button must specify default or be in the range 1..255\n"); ERROR("Button must specify default or be in the range 1..255\n");
ACTION("Illegal button value %d ignored\n", rtrn.ival); ACTION("Illegal button value %d ignored\n", rtrn.ival);
return false; return false;
@ -911,8 +866,7 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->button = rtrn.ival; act->button = rtrn.ival;
return true; return true;
} }
else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect)) else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect)) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich)) if (!ExprResolveEnum(keymap->ctx, value, &rtrn, lockWhich))
@ -921,14 +875,12 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->flags |= rtrn.ival; act->flags |= rtrn.ival;
return true; return true;
} }
else if (field == F_Count) else if (field == F_Count) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &rtrn)) if (!ExprResolveButton(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
{
ERROR("The count field must have a value in the range 0..255\n"); ERROR("The count field must have a value in the range 0..255\n");
ACTION("Illegal count %d ignored\n", rtrn.ival); ACTION("Illegal count %d ignored\n", rtrn.ival);
return false; return false;
@ -936,15 +888,13 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->count = rtrn.ival; act->count = rtrn.ival;
return true; return true;
} }
else if (field == F_Device) else if (field == F_Device) {
{
if (array_ndx != NULL) if (array_ndx != NULL)
return ReportActionNotArray(action->type, field); return ReportActionNotArray(action->type, field);
if (!ExprResolveInteger(keymap->ctx, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, return ReportMismatch(action->type, field,
"integer (range 1..255)"); "integer (range 1..255)");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
{
ERROR("Device must specify default or be in the range 1..255\n"); ERROR("Device must specify default or be in the range 1..255\n");
ACTION("Illegal device value %d ignored\n", rtrn.ival); ACTION("Illegal device value %d ignored\n", rtrn.ival);
return false; return false;
@ -975,29 +925,25 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
{ {
ExprResult rtrn; ExprResult rtrn;
switch (field) switch (field) {
{
case F_Type: case F_Type:
if (!ExprResolveInteger(keymap->ctx, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(PrivateAction, field, "integer"); return ReportMismatch(PrivateAction, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
{
ERROR("Private action type must be in the range 0..255\n"); ERROR("Private action type must be in the range 0..255\n");
ACTION("Illegal type %d ignored\n", rtrn.ival); ACTION("Illegal type %d ignored\n", rtrn.ival);
return false; return false;
} }
action->type = rtrn.uval; action->type = rtrn.uval;
return true; return true;
case F_Data: case F_Data:
if (array_ndx == NULL) if (array_ndx == NULL) {
{
if (!ExprResolveString(keymap->ctx, value, &rtrn)) if (!ExprResolveString(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "string"); return ReportMismatch(action->type, field, "string");
else else {
{
int len = strlen(rtrn.str); int len = strlen(rtrn.str);
if ((len < 1) || (len > 7)) if ((len < 1) || (len > 7)) {
{
WARN("A private action has 7 data bytes\n"); WARN("A private action has 7 data bytes\n");
ACTION("Extra %d bytes ignored\n", len - 6); ACTION("Extra %d bytes ignored\n", len - 6);
return false; return false;
@ -1007,26 +953,22 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
free(rtrn.str); free(rtrn.str);
return true; return true;
} }
else else {
{
unsigned ndx; unsigned ndx;
if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
{
ERROR("Array subscript must be integer\n"); ERROR("Array subscript must be integer\n");
ACTION("Illegal subscript ignored\n"); ACTION("Illegal subscript ignored\n");
return false; return false;
} }
ndx = rtrn.uval; ndx = rtrn.uval;
if (ndx >= sizeof action->data) if (ndx >= sizeof action->data) {
{
ERROR("The data for a private action is 18 bytes long\n"); ERROR("The data for a private action is 18 bytes long\n");
ACTION("Attempt to use data[%d] ignored\n", ndx); ACTION("Attempt to use data[%d] ignored\n", ndx);
return false; return false;
} }
if (!ExprResolveInteger(keymap->ctx, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer"); return ReportMismatch(action->type, field, "integer");
if ((rtrn.ival < 0) || (rtrn.ival > 255)) if ((rtrn.ival < 0) || (rtrn.ival > 255)) {
{
ERROR("All data for a private action must be 0..255\n"); ERROR("All data for a private action must be 0..255\n");
ACTION("Illegal datum %d ignored\n", rtrn.ival); ACTION("Illegal datum %d ignored\n", rtrn.ival);
return false; return false;
@ -1038,33 +980,33 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
return ReportIllegal(PrivateAction, field); return ReportIllegal(PrivateAction, field);
} }
typedef bool (*actionHandler) (struct xkb_keymap *keymap, typedef bool (*actionHandler)(struct xkb_keymap *keymap,
struct xkb_any_action *action, unsigned field, struct xkb_any_action *action, unsigned field,
ExprDef *array_ndx, ExprDef *value); ExprDef *array_ndx, ExprDef *value);
static const actionHandler handleAction[XkbSA_NumActions + 1] = { static const actionHandler handleAction[XkbSA_NumActions + 1] = {
[XkbSA_NoAction] = HandleNoAction, [XkbSA_NoAction] = HandleNoAction,
[XkbSA_SetMods] = HandleSetLatchMods, [XkbSA_SetMods] = HandleSetLatchMods,
[XkbSA_LatchMods] = HandleSetLatchMods, [XkbSA_LatchMods] = HandleSetLatchMods,
[XkbSA_LockMods] = HandleLockMods, [XkbSA_LockMods] = HandleLockMods,
[XkbSA_SetGroup] = HandleSetLatchGroup, [XkbSA_SetGroup] = HandleSetLatchGroup,
[XkbSA_LatchGroup] = HandleSetLatchGroup, [XkbSA_LatchGroup] = HandleSetLatchGroup,
[XkbSA_LockGroup] = HandleLockGroup, [XkbSA_LockGroup] = HandleLockGroup,
[XkbSA_MovePtr] = HandleMovePtr, [XkbSA_MovePtr] = HandleMovePtr,
[XkbSA_PtrBtn] = HandlePtrBtn, [XkbSA_PtrBtn] = HandlePtrBtn,
[XkbSA_LockPtrBtn] = HandlePtrBtn, [XkbSA_LockPtrBtn] = HandlePtrBtn,
[XkbSA_SetPtrDflt] = HandleSetPtrDflt, [XkbSA_SetPtrDflt] = HandleSetPtrDflt,
[XkbSA_ISOLock] = HandleISOLock, [XkbSA_ISOLock] = HandleISOLock,
[XkbSA_Terminate] = HandleNoAction, [XkbSA_Terminate] = HandleNoAction,
[XkbSA_SwitchScreen] = HandleSwitchScreen, [XkbSA_SwitchScreen] = HandleSwitchScreen,
[XkbSA_SetControls] = HandleSetLockControls, [XkbSA_SetControls] = HandleSetLockControls,
[XkbSA_LockControls] = HandleSetLockControls, [XkbSA_LockControls] = HandleSetLockControls,
[XkbSA_ActionMessage] = HandleActionMessage, [XkbSA_ActionMessage] = HandleActionMessage,
[XkbSA_RedirectKey] = HandleRedirectKey, [XkbSA_RedirectKey] = HandleRedirectKey,
[XkbSA_DeviceBtn] = HandleDeviceBtn, [XkbSA_DeviceBtn] = HandleDeviceBtn,
[XkbSA_LockDeviceBtn] = HandleDeviceBtn, [XkbSA_LockDeviceBtn] = HandleDeviceBtn,
[XkbSA_DeviceValuator] = HandleDeviceValuator, [XkbSA_DeviceValuator] = HandleDeviceValuator,
[PrivateAction] = HandlePrivate, [PrivateAction] = HandlePrivate,
}; };
/***====================================================================***/ /***====================================================================***/
@ -1072,14 +1014,12 @@ static const actionHandler handleAction[XkbSA_NumActions + 1] = {
static void static void
ApplyActionFactoryDefaults(union xkb_action * action) ApplyActionFactoryDefaults(union xkb_action * action)
{ {
if (action->type == XkbSA_SetPtrDflt) if (action->type == XkbSA_SetPtrDflt) { /* increment default button */
{ /* increment default button */
action->dflt.affect = XkbSA_AffectDfltBtn; action->dflt.affect = XkbSA_AffectDfltBtn;
action->dflt.flags = 0; action->dflt.flags = 0;
action->dflt.value = 1; action->dflt.value = 1;
} }
else if (action->type == XkbSA_ISOLock) else if (action->type == XkbSA_ISOLock) {
{
action->iso.real_mods = LockMask; action->iso.real_mods = LockMask;
} }
} }
@ -1099,37 +1039,31 @@ HandleActionDef(ExprDef * def,
if (!actionsInitialized) if (!actionsInitialized)
ActionsInit(keymap->ctx); ActionsInit(keymap->ctx);
if (def->op != ExprActionDecl) if (def->op != ExprActionDecl) {
{
ERROR("Expected an action definition, found %s\n", ERROR("Expected an action definition, found %s\n",
exprOpText(def->op)); exprOpText(def->op));
return false; return false;
} }
str = xkb_atom_text(keymap->ctx, def->value.action.name); str = xkb_atom_text(keymap->ctx, def->value.action.name);
if (!str) if (!str) {
{
WSGO("Missing name in action definition!!\n"); WSGO("Missing name in action definition!!\n");
return false; return false;
} }
if (!stringToAction(str, &tmp)) if (!stringToAction(str, &tmp)) {
{
ERROR("Unknown action %s\n", str); ERROR("Unknown action %s\n", str);
return false; return false;
} }
action->type = hndlrType = tmp; action->type = hndlrType = tmp;
if (action->type != XkbSA_NoAction) if (action->type != XkbSA_NoAction) {
{
ApplyActionFactoryDefaults((union xkb_action *) action); ApplyActionFactoryDefaults((union xkb_action *) action);
while (info) while (info)
{ {
if ((info->action == XkbSA_NoAction) if ((info->action == XkbSA_NoAction)
|| (info->action == hndlrType)) || (info->action == hndlrType)) {
{ if (!(*handleAction[hndlrType])(keymap, action,
if (!(*handleAction[hndlrType]) (keymap, action, info->field,
info->field, info->array_ndx,
info->array_ndx, info->value)) {
info->value))
{
return false; return false;
} }
} }
@ -1137,27 +1071,22 @@ HandleActionDef(ExprDef * def,
} }
} }
for (arg = def->value.action.args; arg != NULL; for (arg = def->value.action.args; arg != NULL;
arg = (ExprDef *) arg->common.next) arg = (ExprDef *) arg->common.next) {
{
ExprDef *field, *value, *arrayRtrn; ExprDef *field, *value, *arrayRtrn;
ExprResult elemRtrn, fieldRtrn; ExprResult elemRtrn, fieldRtrn;
unsigned fieldNdx; unsigned fieldNdx;
if (arg->op == OpAssign) if (arg->op == OpAssign) {
{
field = arg->value.binary.left; field = arg->value.binary.left;
value = arg->value.binary.right; value = arg->value.binary.right;
} }
else else {
{ if ((arg->op == OpNot) || (arg->op == OpInvert)) {
if ((arg->op == OpNot) || (arg->op == OpInvert))
{
field = arg->value.child; field = arg->value.child;
constFalse.value.str = xkb_atom_intern(keymap->ctx, "false"); constFalse.value.str = xkb_atom_intern(keymap->ctx, "false");
value = &constFalse; value = &constFalse;
} }
else else {
{
field = arg; field = arg;
constTrue.value.str = xkb_atom_intern(keymap->ctx, "true"); constTrue.value.str = xkb_atom_intern(keymap->ctx, "true");
value = &constTrue; value = &constTrue;
@ -1166,17 +1095,15 @@ HandleActionDef(ExprDef * def,
if (!ExprResolveLhs(keymap, field, &elemRtrn, &fieldRtrn, &arrayRtrn)) if (!ExprResolveLhs(keymap, field, &elemRtrn, &fieldRtrn, &arrayRtrn))
return false; /* internal error -- already reported */ return false; /* internal error -- already reported */
if (elemRtrn.str != NULL) if (elemRtrn.str != NULL) {
{
ERROR("Cannot change defaults in an action definition\n"); ERROR("Cannot change defaults in an action definition\n");
ACTION("Ignoring attempt to change %s.%s\n", elemRtrn.str, ACTION("Ignoring attempt to change %s.%s\n", elemRtrn.str,
fieldRtrn.str); fieldRtrn.str);
free(elemRtrn.str); free(elemRtrn.str);
free(fieldRtrn.str); free(fieldRtrn.str);
return false; return false;
} }
if (!stringToField(fieldRtrn.str, &fieldNdx)) if (!stringToField(fieldRtrn.str, &fieldNdx)) {
{
ERROR("Unknown field name %s\n", uStringText(fieldRtrn.str)); ERROR("Unknown field name %s\n", uStringText(fieldRtrn.str));
free(elemRtrn.str); free(elemRtrn.str);
free(fieldRtrn.str); free(fieldRtrn.str);
@ -1205,30 +1132,25 @@ SetActionField(struct xkb_keymap *keymap,
ActionsInit(keymap->ctx); ActionsInit(keymap->ctx);
new = uTypedAlloc(ActionInfo); new = uTypedAlloc(ActionInfo);
if (new == NULL) if (new == NULL) {
{
WSGO("Couldn't allocate space for action default\n"); WSGO("Couldn't allocate space for action default\n");
return false; return false;
} }
if (strcasecmp(elem, "action") == 0) if (strcasecmp(elem, "action") == 0)
new->action = XkbSA_NoAction; new->action = XkbSA_NoAction;
else else {
{ if (!stringToAction(elem, &new->action)) {
if (!stringToAction(elem, &new->action))
{
free(new); free(new);
return false; return false;
} }
if (new->action == XkbSA_NoAction) if (new->action == XkbSA_NoAction) {
{
ERROR("\"%s\" is not a valid field in a NoAction action\n", ERROR("\"%s\" is not a valid field in a NoAction action\n",
field); field);
free(new); free(new);
return false; return false;
} }
} }
if (!stringToField(field, &new->field)) if (!stringToField(field, &new->field)) {
{
ERROR("\"%s\" is not a legal field name\n", field); ERROR("\"%s\" is not a legal field name\n", field);
free(new); free(new);
return false; return false;
@ -1251,8 +1173,7 @@ SetActionField(struct xkb_keymap *keymap,
static void static void
ActionsInit(struct xkb_context *ctx) ActionsInit(struct xkb_context *ctx)
{ {
if (!actionsInitialized) if (!actionsInitialized) {
{
memset(&constTrue, 0, sizeof(constTrue)); memset(&constTrue, 0, sizeof(constTrue));
memset(&constFalse, 0, sizeof(constFalse)); memset(&constFalse, 0, sizeof(constFalse));
constTrue.common.stmtType = StmtExpr; constTrue.common.stmtType = StmtExpr;

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef ACTION_H #ifndef ACTION_H
@ -30,36 +30,35 @@
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
#include "expr.h" #include "expr.h"
#define F_ClearLocks 0 #define F_ClearLocks 0
#define F_LatchToLock 1 #define F_LatchToLock 1
#define F_GenKeyEvent 2 #define F_GenKeyEvent 2
#define F_Report 3 #define F_Report 3
#define F_Default 4 #define F_Default 4
#define F_Affect 5 #define F_Affect 5
#define F_Increment 6 #define F_Increment 6
#define F_Modifiers 7 #define F_Modifiers 7
#define F_Group 8 #define F_Group 8
#define F_X 9 #define F_X 9
#define F_Y 10 #define F_Y 10
#define F_Accel 11 #define F_Accel 11
#define F_Button 12 #define F_Button 12
#define F_Value 13 #define F_Value 13
#define F_Controls 14 #define F_Controls 14
#define F_Type 15 #define F_Type 15
#define F_Count 16 #define F_Count 16
#define F_Screen 17 #define F_Screen 17
#define F_Same 18 #define F_Same 18
#define F_Data 19 #define F_Data 19
#define F_Device 20 #define F_Device 20
#define F_Keycode 21 #define F_Keycode 21
#define F_ModsToClear 22 #define F_ModsToClear 22
#define F_LastField F_ModsToClear #define F_LastField F_ModsToClear
#define F_NumFields (F_LastField+1) #define F_NumFields (F_LastField + 1)
#define PrivateAction (XkbSA_LastAction+1) #define PrivateAction (XkbSA_LastAction + 1)
typedef struct _ActionInfo typedef struct _ActionInfo {
{
unsigned action; unsigned action;
unsigned field; unsigned field;
ExprDef *array_ndx; ExprDef *array_ndx;
@ -69,11 +68,13 @@ typedef struct _ActionInfo
extern int extern int
HandleActionDef(ExprDef *def, struct xkb_keymap *keymap, HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
struct xkb_any_action *action, ActionInfo *info); struct xkb_any_action *action,
ActionInfo *info);
extern int extern int
SetActionField(struct xkb_keymap *keymap, char *elem, char *field, SetActionField(struct xkb_keymap *keymap, char *elem, char *field,
ExprDef *index, ExprDef *value, ActionInfo **info_rtrn); ExprDef *index, ExprDef *value,
ActionInfo **info_rtrn);
extern const LookupEntry ctrlNames[]; extern const LookupEntry ctrlNames[];

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "alias.h" #include "alias.h"
@ -30,36 +30,30 @@
static void static void
HandleCollision(AliasInfo * old, AliasInfo * new) HandleCollision(AliasInfo * old, AliasInfo * new)
{ {
if (strncmp(new->real, old->real, XkbKeyNameLength) == 0) if (strncmp(new->real, old->real, XkbKeyNameLength) == 0) {
{
if (((new->def.file_id == old->def.file_id) && (warningLevel > 0)) || if (((new->def.file_id == old->def.file_id) && (warningLevel > 0)) ||
(warningLevel > 9)) (warningLevel > 9)) {
{
WARN("Alias of %s for %s declared more than once\n", WARN("Alias of %s for %s declared more than once\n",
XkbcKeyNameText(new->alias), XkbcKeyNameText(new->real)); XkbcKeyNameText(new->alias), XkbcKeyNameText(new->real));
ACTION("First definition ignored\n"); ACTION("First definition ignored\n");
} }
} }
else else {
{
char *use, *ignore; char *use, *ignore;
if (new->def.merge == MERGE_AUGMENT) if (new->def.merge == MERGE_AUGMENT) {
{
use = old->real; use = old->real;
ignore = new->real; ignore = new->real;
} }
else else {
{
use = new->real; use = new->real;
ignore = old->real; ignore = old->real;
} }
if (((old->def.file_id == new->def.file_id) && (warningLevel > 0)) || if (((old->def.file_id == new->def.file_id) && (warningLevel > 0)) ||
(warningLevel > 9)) (warningLevel > 9)) {
{
WARN("Multiple definitions for alias %s\n", WARN("Multiple definitions for alias %s\n",
XkbcKeyNameText(old->alias)); XkbcKeyNameText(old->alias));
ACTION("Using %s, ignoring %s\n", ACTION("Using %s, ignoring %s\n",
XkbcKeyNameText(use), XkbcKeyNameText(ignore)); XkbcKeyNameText(use), XkbcKeyNameText(ignore));
} }
if (use != old->real) if (use != old->real)
memcpy(old->real, use, XkbKeyNameLength); memcpy(old->real, use, XkbKeyNameLength);
@ -70,7 +64,8 @@ HandleCollision(AliasInfo * old, AliasInfo * new)
static void static void
InitAliasInfo(AliasInfo * info, InitAliasInfo(AliasInfo * info,
enum merge_mode merge, unsigned file_id, char *alias, char *real) enum merge_mode merge, unsigned file_id, char *alias,
char *real)
{ {
memset(info, 0, sizeof(AliasInfo)); memset(info, 0, sizeof(AliasInfo));
info->def.merge = merge; info->def.merge = merge;
@ -85,10 +80,9 @@ HandleAliasDef(KeyAliasDef * def,
{ {
AliasInfo *info; AliasInfo *info;
for (info = *info_in; info != NULL; info = (AliasInfo *) info->def.next) for (info = *info_in; info != NULL; info =
{ (AliasInfo *) info->def.next) {
if (strncmp(info->alias, def->alias, XkbKeyNameLength) == 0) if (strncmp(info->alias, def->alias, XkbKeyNameLength) == 0) {
{
AliasInfo new; AliasInfo new;
InitAliasInfo(&new, merge, file_id, def->alias, def->real); InitAliasInfo(&new, merge, file_id, def->alias, def->real);
HandleCollision(info, &new); HandleCollision(info, &new);
@ -96,14 +90,13 @@ HandleAliasDef(KeyAliasDef * def,
} }
} }
info = uTypedCalloc(1, AliasInfo); info = uTypedCalloc(1, AliasInfo);
if (info == NULL) if (info == NULL) {
{
WSGO("Allocation failure in HandleAliasDef\n"); WSGO("Allocation failure in HandleAliasDef\n");
return false; return false;
} }
info->def.file_id = file_id; info->def.file_id = file_id;
info->def.merge = merge; info->def.merge = merge;
info->def.next = (CommonInfo *) * info_in; info->def.next = (CommonInfo *) *info_in;
memcpy(info->alias, def->alias, XkbKeyNameLength); memcpy(info->alias, def->alias, XkbKeyNameLength);
memcpy(info->real, def->real, XkbKeyNameLength); memcpy(info->real, def->real, XkbKeyNameLength);
*info_in = AddCommonInfo(&(*info_in)->def, &info->def); *info_in = AddCommonInfo(&(*info_in)->def, &info->def);
@ -126,15 +119,13 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge,
if ((*merge) == NULL) if ((*merge) == NULL)
return true; return true;
if ((*into) == NULL) if ((*into) == NULL) {
{
*into = *merge; *into = *merge;
*merge = NULL; *merge = NULL;
return true; return true;
} }
memset(&def, 0, sizeof(KeyAliasDef)); memset(&def, 0, sizeof(KeyAliasDef));
for (tmp = *merge; tmp != NULL; tmp = (AliasInfo *) tmp->def.next) for (tmp = *merge; tmp != NULL; tmp = (AliasInfo *) tmp->def.next) {
{
if (how_merge == MERGE_DEFAULT) if (how_merge == MERGE_DEFAULT)
def.merge = tmp->def.merge; def.merge = tmp->def.merge;
else else
@ -161,45 +152,39 @@ ApplyAliases(struct xkb_keymap *keymap, AliasInfo ** info_in)
nOld = (keymap->names ? darray_size(keymap->names->key_aliases) : 0); nOld = (keymap->names ? darray_size(keymap->names->key_aliases) : 0);
old = (keymap->names ? &darray_item(keymap->names->key_aliases, 0) : NULL); old = (keymap->names ? &darray_item(keymap->names->key_aliases, 0) : NULL);
for (nNew = 0, info = *info_in; info != NULL; for (nNew = 0, info = *info_in; info != NULL;
info = (AliasInfo *) info->def.next) info = (AliasInfo *) info->def.next) {
{
unsigned long lname; unsigned long lname;
xkb_keycode_t kc; xkb_keycode_t kc;
lname = KeyNameToLong(info->real); lname = KeyNameToLong(info->real);
if (!FindNamedKey(keymap, lname, &kc, false, CreateKeyNames(keymap), 0)) if (!FindNamedKey(keymap, lname, &kc, false, CreateKeyNames(keymap),
{ 0)) {
if (warningLevel > 4) if (warningLevel > 4) {
{
WARN("Attempt to alias %s to non-existent key %s\n", WARN("Attempt to alias %s to non-existent key %s\n",
XkbcKeyNameText(info->alias), XkbcKeyNameText(info->real)); XkbcKeyNameText(info->alias), XkbcKeyNameText(info->real));
ACTION("Ignored\n"); ACTION("Ignored\n");
} }
info->alias[0] = '\0'; info->alias[0] = '\0';
continue; continue;
} }
lname = KeyNameToLong(info->alias); lname = KeyNameToLong(info->alias);
if (FindNamedKey(keymap, lname, &kc, false, false, 0)) if (FindNamedKey(keymap, lname, &kc, false, false, 0)) {
{ if (warningLevel > 4) {
if (warningLevel > 4)
{
WARN("Attempt to create alias with the name of a real key\n"); WARN("Attempt to create alias with the name of a real key\n");
ACTION("Alias \"%s = %s\" ignored\n", ACTION("Alias \"%s = %s\" ignored\n",
XkbcKeyNameText(info->alias), XkbcKeyNameText(info->alias),
XkbcKeyNameText(info->real)); XkbcKeyNameText(info->real));
} }
info->alias[0] = '\0'; info->alias[0] = '\0';
continue; continue;
} }
nNew++; nNew++;
if (old) if (old) {
{ for (i = 0, a = old; i < nOld; i++, a++) {
for (i = 0, a = old; i < nOld; i++, a++) if (strncmp(a->alias, info->alias, XkbKeyNameLength) == 0) {
{
if (strncmp(a->alias, info->alias, XkbKeyNameLength) == 0)
{
AliasInfo old_info; AliasInfo old_info;
InitAliasInfo(&old_info, MERGE_AUGMENT, 0, a->alias, a->real); InitAliasInfo(&old_info, MERGE_AUGMENT, 0, a->alias,
a->real);
HandleCollision(&old_info, info); HandleCollision(&old_info, info);
memcpy(old_info.real, a->real, XkbKeyNameLength); memcpy(old_info.real, a->real, XkbKeyNameLength);
info->alias[0] = '\0'; info->alias[0] = '\0';
@ -209,34 +194,30 @@ ApplyAliases(struct xkb_keymap *keymap, AliasInfo ** info_in)
} }
} }
} }
if (nNew == 0) if (nNew == 0) {
{
ClearCommonInfo(&(*info_in)->def); ClearCommonInfo(&(*info_in)->def);
*info_in = NULL; *info_in = NULL;
return true; return true;
} }
status = XkbcAllocNames(keymap, XkbKeyAliasesMask, nOld + nNew); status = XkbcAllocNames(keymap, XkbKeyAliasesMask, nOld + nNew);
if (status != Success) if (status != Success) {
{
WSGO("Allocation failure in ApplyAliases\n"); WSGO("Allocation failure in ApplyAliases\n");
return false; return false;
} }
a = keymap->names ? &darray_item(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) for (info = *info_in; info != NULL; info =
{ (AliasInfo *) info->def.next) {
if (info->alias[0] != '\0') if (info->alias[0] != '\0') {
{
strncpy(a->alias, info->alias, XkbKeyNameLength); strncpy(a->alias, info->alias, XkbKeyNameLength);
strncpy(a->real, info->real, XkbKeyNameLength); strncpy(a->real, info->real, XkbKeyNameLength);
a++; a++;
} }
} }
#ifdef DEBUG #ifdef DEBUG
if ((a - old) != (nOld + nNew)) if ((a - old) != (nOld + nNew)) {
{
WSGO("Expected %d aliases total but created %d\n", nOld + nNew, WSGO("Expected %d aliases total but created %d\n", nOld + nNew,
a - old); a - old);
} }
#endif #endif
ClearCommonInfo(&(*info_in)->def); ClearCommonInfo(&(*info_in)->def);

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef ALIAS_H #ifndef ALIAS_H
@ -29,8 +29,7 @@
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
typedef struct _AliasInfo typedef struct _AliasInfo {
{
CommonInfo def; CommonInfo def;
char alias[XkbKeyNameLength + 1]; char alias[XkbKeyNameLength + 1];
char real[XkbKeyNameLength + 1]; char real[XkbKeyNameLength + 1];

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
@ -30,20 +30,18 @@
#include "indicators.h" #include "indicators.h"
#include "vmod.h" #include "vmod.h"
typedef struct _SymInterpInfo typedef struct _SymInterpInfo {
{
CommonInfo defs; CommonInfo defs;
struct xkb_sym_interpret interp; struct xkb_sym_interpret interp;
} SymInterpInfo; } SymInterpInfo;
#define _SI_VirtualMod (1<<0) #define _SI_VirtualMod (1 << 0)
#define _SI_Action (1<<1) #define _SI_Action (1 << 1)
#define _SI_AutoRepeat (1<<2) #define _SI_AutoRepeat (1 << 2)
#define _SI_LockingKey (1<<3) #define _SI_LockingKey (1 << 3)
#define _SI_LevelOneOnly (1<<4) #define _SI_LevelOneOnly (1 << 4)
typedef struct _GroupCompatInfo typedef struct _GroupCompatInfo {
{
unsigned file_id; unsigned file_id;
enum merge_mode merge; enum merge_mode merge;
bool defined; bool defined;
@ -51,8 +49,7 @@ typedef struct _GroupCompatInfo
xkb_atom_t vmods; xkb_atom_t vmods;
} GroupCompatInfo; } GroupCompatInfo;
typedef struct _CompatInfo typedef struct _CompatInfo {
{
char *name; char *name;
unsigned file_id; unsigned file_id;
int errorCount; int errorCount;
@ -69,10 +66,10 @@ typedef struct _CompatInfo
/***====================================================================***/ /***====================================================================***/
#define ReportSINotArray(si,f,i) \ #define ReportSINotArray(si, f, i) \
ReportNotArray("symbol interpretation",(f),siText((si),(i))) ReportNotArray("symbol interpretation", (f), siText((si), (i)))
#define ReportSIBadType(si,f,w,i) \ #define ReportSIBadType(si, f, w, i) \
ReportBadType("symbol interpretation",(f),siText((si),(i)),(w)) ReportBadType("symbol interpretation", (f), siText((si), (i)), (w))
/***====================================================================***/ /***====================================================================***/
@ -81,16 +78,14 @@ siText(SymInterpInfo * si, CompatInfo * info)
{ {
static char buf[128]; static char buf[128];
if (si == &info->dflt) if (si == &info->dflt) {
{
snprintf(buf, sizeof(buf), "default"); snprintf(buf, sizeof(buf), "default");
} }
else else {
{
snprintf(buf, sizeof(buf), "%s+%s(%s)", snprintf(buf, sizeof(buf), "%s+%s(%s)",
XkbcKeysymText(si->interp.sym), XkbcKeysymText(si->interp.sym),
XkbcSIMatchText(si->interp.match), XkbcSIMatchText(si->interp.match),
XkbcModMaskText(si->interp.mods, false)); XkbcModMaskText(si->interp.mods, false));
} }
return buf; return buf;
} }
@ -147,9 +142,9 @@ ClearCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
XkbNumKbdGroups * sizeof(GroupCompatInfo)); XkbNumKbdGroups * sizeof(GroupCompatInfo));
info->leds = ClearCommonInfo(&info->leds->defs); info->leds = ClearCommonInfo(&info->leds->defs);
while (info->act) { while (info->act) {
next = info->act->next; next = info->act->next;
free(info->act); free(info->act);
info->act = next; info->act = next;
} }
ClearVModInfo(&info->vmods, keymap); ClearVModInfo(&info->vmods, keymap);
} }
@ -160,8 +155,7 @@ NextInterp(CompatInfo * info)
SymInterpInfo *si; SymInterpInfo *si;
si = uTypedAlloc(SymInterpInfo); si = uTypedAlloc(SymInterpInfo);
if (si) if (si) {
{
memset(si, 0, sizeof(SymInterpInfo)); memset(si, 0, sizeof(SymInterpInfo));
info->interps = AddCommonInfo(&info->interps->defs, &si->defs); info->interps = AddCommonInfo(&info->interps->defs, &si->defs);
info->nInterps++; info->nInterps++;
@ -175,12 +169,10 @@ FindMatchingInterp(CompatInfo * info, SymInterpInfo * new)
SymInterpInfo *old; SymInterpInfo *old;
for (old = info->interps; old != NULL; for (old = info->interps; old != NULL;
old = (SymInterpInfo *) old->defs.next) old = (SymInterpInfo *) old->defs.next) {
{
if ((old->interp.sym == new->interp.sym) && if ((old->interp.sym == new->interp.sym) &&
(old->interp.mods == new->interp.mods) && (old->interp.mods == new->interp.mods) &&
(old->interp.match == new->interp.match)) (old->interp.match == new->interp.match)) {
{
return old; return old;
} }
} }
@ -195,14 +187,11 @@ AddInterp(CompatInfo * info, SymInterpInfo * new)
collide = 0; collide = 0;
old = FindMatchingInterp(info, new); old = FindMatchingInterp(info, new);
if (old != NULL) if (old != NULL) {
{ if (new->defs.merge == MERGE_REPLACE) {
if (new->defs.merge == MERGE_REPLACE)
{
SymInterpInfo *next = (SymInterpInfo *) old->defs.next; SymInterpInfo *next = (SymInterpInfo *) old->defs.next;
if (((old->defs.file_id == new->defs.file_id) if (((old->defs.file_id == new->defs.file_id)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9)) {
{
WARN("Multiple definitions for \"%s\"\n", siText(new, info)); WARN("Multiple definitions for \"%s\"\n", siText(new, info));
ACTION("Earlier interpretation ignored\n"); ACTION("Earlier interpretation ignored\n");
} }
@ -210,39 +199,34 @@ AddInterp(CompatInfo * info, SymInterpInfo * new)
old->defs.next = &next->defs; old->defs.next = &next->defs;
return true; return true;
} }
if (UseNewField(_SI_VirtualMod, &old->defs, &new->defs, &collide)) if (UseNewField(_SI_VirtualMod, &old->defs, &new->defs, &collide)) {
{
old->interp.virtual_mod = new->interp.virtual_mod; old->interp.virtual_mod = new->interp.virtual_mod;
old->defs.defined |= _SI_VirtualMod; old->defs.defined |= _SI_VirtualMod;
} }
if (UseNewField(_SI_Action, &old->defs, &new->defs, &collide)) if (UseNewField(_SI_Action, &old->defs, &new->defs, &collide)) {
{
old->interp.act = new->interp.act; old->interp.act = new->interp.act;
old->defs.defined |= _SI_Action; old->defs.defined |= _SI_Action;
} }
if (UseNewField(_SI_AutoRepeat, &old->defs, &new->defs, &collide)) if (UseNewField(_SI_AutoRepeat, &old->defs, &new->defs, &collide)) {
{
old->interp.flags &= ~XkbSI_AutoRepeat; old->interp.flags &= ~XkbSI_AutoRepeat;
old->interp.flags |= (new->interp.flags & XkbSI_AutoRepeat); old->interp.flags |= (new->interp.flags & XkbSI_AutoRepeat);
old->defs.defined |= _SI_AutoRepeat; old->defs.defined |= _SI_AutoRepeat;
} }
if (UseNewField(_SI_LockingKey, &old->defs, &new->defs, &collide)) if (UseNewField(_SI_LockingKey, &old->defs, &new->defs, &collide)) {
{
old->interp.flags &= ~XkbSI_LockingKey; old->interp.flags &= ~XkbSI_LockingKey;
old->interp.flags |= (new->interp.flags & XkbSI_LockingKey); old->interp.flags |= (new->interp.flags & XkbSI_LockingKey);
old->defs.defined |= _SI_LockingKey; old->defs.defined |= _SI_LockingKey;
} }
if (UseNewField(_SI_LevelOneOnly, &old->defs, &new->defs, &collide)) if (UseNewField(_SI_LevelOneOnly, &old->defs, &new->defs,
{ &collide)) {
old->interp.match &= ~XkbSI_LevelOneOnly; old->interp.match &= ~XkbSI_LevelOneOnly;
old->interp.match |= (new->interp.match & XkbSI_LevelOneOnly); old->interp.match |= (new->interp.match & XkbSI_LevelOneOnly);
old->defs.defined |= _SI_LevelOneOnly; old->defs.defined |= _SI_LevelOneOnly;
} }
if (collide) if (collide) {
{
WARN("Multiple interpretations of \"%s\"\n", siText(new, info)); WARN("Multiple interpretations of \"%s\"\n", siText(new, info));
ACTION("Using %s definition for duplicate fields\n", ACTION("Using %s definition for duplicate fields\n",
(new->defs.merge != MERGE_AUGMENT ? "last" : "first")); (new->defs.merge != MERGE_AUGMENT ? "last" : "first"));
} }
return true; return true;
} }
@ -262,16 +246,15 @@ AddGroupCompat(CompatInfo * info, unsigned group, GroupCompatInfo * newGC)
merge = newGC->merge; merge = newGC->merge;
gc = &info->groupCompat[group]; gc = &info->groupCompat[group];
if (((gc->real_mods == newGC->real_mods) && (gc->vmods == newGC->vmods))) if (((gc->real_mods == newGC->real_mods) &&
{ (gc->vmods == newGC->vmods))) {
return true; return true;
} }
if (((gc->file_id == newGC->file_id) && (warningLevel > 0)) if (((gc->file_id == newGC->file_id) && (warningLevel > 0))
|| (warningLevel > 9)) || (warningLevel > 9)) {
{
WARN("Compat map for group %d redefined\n", group + 1); WARN("Compat map for group %d redefined\n", group + 1);
ACTION("Using %s definition\n", ACTION("Using %s definition\n",
(merge == MERGE_AUGMENT ? "old" : "new")); (merge == MERGE_AUGMENT ? "old" : "new"));
} }
if (newGC->defined && (merge != MERGE_AUGMENT || !gc->defined)) if (newGC->defined && (merge != MERGE_AUGMENT || !gc->defined))
*gc = *newGC; *gc = *newGC;
@ -287,16 +270,14 @@ ResolveStateAndPredicate(ExprDef * expr,
{ {
ExprResult result; ExprResult result;
if (expr == NULL) if (expr == NULL) {
{
*pred_rtrn = XkbSI_AnyOfOrNone; *pred_rtrn = XkbSI_AnyOfOrNone;
*mods_rtrn = ~0; *mods_rtrn = ~0;
return true; return true;
} }
*pred_rtrn = XkbSI_Exactly; *pred_rtrn = XkbSI_Exactly;
if (expr->op == ExprActionDecl) if (expr->op == ExprActionDecl) {
{
const char *pred_txt = xkb_atom_text(info->keymap->ctx, const char *pred_txt = xkb_atom_text(info->keymap->ctx,
expr->value.action.name); expr->value.action.name);
if (strcasecmp(pred_txt, "noneof") == 0) if (strcasecmp(pred_txt, "noneof") == 0)
@ -309,28 +290,24 @@ ResolveStateAndPredicate(ExprDef * expr,
*pred_rtrn = XkbSI_AllOf; *pred_rtrn = XkbSI_AllOf;
else if (strcasecmp(pred_txt, "exactly") == 0) else if (strcasecmp(pred_txt, "exactly") == 0)
*pred_rtrn = XkbSI_Exactly; *pred_rtrn = XkbSI_Exactly;
else else {
{
ERROR("Illegal modifier predicate \"%s\"\n", pred_txt); ERROR("Illegal modifier predicate \"%s\"\n", pred_txt);
ACTION("Ignored\n"); ACTION("Ignored\n");
return false; return false;
} }
expr = expr->value.action.args; expr = expr->value.action.args;
} }
else if (expr->op == ExprIdent) else if (expr->op == ExprIdent) {
{
const char *pred_txt = xkb_atom_text(info->keymap->ctx, const char *pred_txt = xkb_atom_text(info->keymap->ctx,
expr->value.str); expr->value.str);
if ((pred_txt) && (strcasecmp(pred_txt, "any") == 0)) if ((pred_txt) && (strcasecmp(pred_txt, "any") == 0)) {
{
*pred_rtrn = XkbSI_AnyOf; *pred_rtrn = XkbSI_AnyOf;
*mods_rtrn = 0xff; *mods_rtrn = 0xff;
return true; return true;
} }
} }
if (ExprResolveModMask(info->keymap->ctx, expr, &result)) if (ExprResolveModMask(info->keymap->ctx, expr, &result)) {
{
*mods_rtrn = result.uval; *mods_rtrn = result.uval;
return true; return true;
} }
@ -340,39 +317,36 @@ ResolveStateAndPredicate(ExprDef * expr,
/***====================================================================***/ /***====================================================================***/
static void static void
MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, enum merge_mode merge) MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from,
enum merge_mode merge)
{ {
SymInterpInfo *si; SymInterpInfo *si;
LEDInfo *led, *rtrn, *next; LEDInfo *led, *rtrn, *next;
GroupCompatInfo *gcm; GroupCompatInfo *gcm;
int i; int i;
if (from->errorCount > 0) if (from->errorCount > 0) {
{
into->errorCount += from->errorCount; into->errorCount += from->errorCount;
return; return;
} }
if (into->name == NULL) if (into->name == NULL) {
{
into->name = from->name; into->name = from->name;
from->name = NULL; from->name = NULL;
} }
for (si = from->interps; si; si = (SymInterpInfo *) si->defs.next) for (si = from->interps; si; si = (SymInterpInfo *) si->defs.next) {
{
if (merge != MERGE_DEFAULT) if (merge != MERGE_DEFAULT)
si->defs.merge = merge; si->defs.merge = merge;
if (!AddInterp(into, si)) if (!AddInterp(into, si))
into->errorCount++; into->errorCount++;
} }
for (i = 0, gcm = &from->groupCompat[0]; i < XkbNumKbdGroups; i++, gcm++) for (i = 0, gcm = &from->groupCompat[0]; i < XkbNumKbdGroups; i++,
{ gcm++) {
if (merge != MERGE_DEFAULT) if (merge != MERGE_DEFAULT)
gcm->merge = merge; gcm->merge = merge;
if (!AddGroupCompat(into, i, gcm)) if (!AddGroupCompat(into, i, gcm))
into->errorCount++; into->errorCount++;
} }
for (led = from->leds; led != NULL; led = next) for (led = from->leds; led != NULL; led = next) {
{
next = (LEDInfo *) led->defs.next; next = (LEDInfo *) led->defs.next;
if (merge != MERGE_DEFAULT) if (merge != MERGE_DEFAULT)
led->defs.merge = merge; led->defs.merge = merge;
@ -385,7 +359,8 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, enum merge_mode me
} }
static void static void
HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge, HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge,
CompatInfo *info); CompatInfo *info);
static bool static bool
@ -398,53 +373,45 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
bool haveSelf; bool haveSelf;
haveSelf = false; haveSelf = false;
if ((stmt->file == NULL) && (stmt->map == NULL)) if ((stmt->file == NULL) && (stmt->map == NULL)) {
{
haveSelf = true; haveSelf = true;
included = *info; included = *info;
memset(info, 0, sizeof(CompatInfo)); memset(info, 0, sizeof(CompatInfo));
} }
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_COMPAT, &rtrn, else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_COMPAT, &rtrn,
&newMerge)) &newMerge)) {
{
InitCompatInfo(&included, keymap, rtrn->id); InitCompatInfo(&included, keymap, rtrn->id);
included.dflt = info->dflt; included.dflt = info->dflt;
included.dflt.defs.merge = newMerge; included.dflt.defs.merge = newMerge;
included.ledDflt.defs.merge = newMerge; included.ledDflt.defs.merge = newMerge;
included.act = info->act; included.act = info->act;
HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &included); HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &included);
if (stmt->stmt != NULL) if (stmt->stmt != NULL) {
{
free(included.name); free(included.name);
included.name = stmt->stmt; included.name = stmt->stmt;
stmt->stmt = NULL; stmt->stmt = NULL;
} }
if (info->act != NULL) if (info->act != NULL)
included.act = NULL; included.act = NULL;
FreeXKBFile(rtrn); FreeXKBFile(rtrn);
} }
else else {
{
info->errorCount += 10; info->errorCount += 10;
return false; return false;
} }
if ((stmt->next != NULL) && (included.errorCount < 1)) if ((stmt->next != NULL) && (included.errorCount < 1)) {
{
IncludeStmt *next; IncludeStmt *next;
unsigned op; unsigned op;
CompatInfo next_incl; CompatInfo next_incl;
for (next = stmt->next; next != NULL; next = next->next) for (next = stmt->next; next != NULL; next = next->next) {
{ if ((next->file == NULL) && (next->map == NULL)) {
if ((next->file == NULL) && (next->map == NULL))
{
haveSelf = true; haveSelf = true;
MergeIncludedCompatMaps(&included, info, next->merge); MergeIncludedCompatMaps(&included, info, next->merge);
ClearCompatInfo(info, keymap); ClearCompatInfo(info, keymap);
} }
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_COMPAT, else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_COMPAT,
&rtrn, &op)) &rtrn, &op)) {
{
InitCompatInfo(&next_incl, keymap, rtrn->id); InitCompatInfo(&next_incl, keymap, rtrn->id);
next_incl.file_id = rtrn->id; next_incl.file_id = rtrn->id;
next_incl.dflt = info->dflt; next_incl.dflt = info->dflt;
@ -456,12 +423,11 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl); HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
MergeIncludedCompatMaps(&included, &next_incl, op); MergeIncludedCompatMaps(&included, &next_incl, op);
if (info->act != NULL) if (info->act != NULL)
next_incl.act = NULL; next_incl.act = NULL;
ClearCompatInfo(&next_incl, keymap); ClearCompatInfo(&next_incl, keymap);
FreeXKBFile(rtrn); FreeXKBFile(rtrn);
} }
else else {
{
info->errorCount += 10; info->errorCount += 10;
return false; return false;
} }
@ -469,8 +435,7 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
} }
if (haveSelf) if (haveSelf)
*info = included; *info = included;
else else {
{
MergeIncludedCompatMaps(info, &included, newMerge); MergeIncludedCompatMaps(info, &included, newMerge);
ClearCompatInfo(&included, keymap); ClearCompatInfo(&included, keymap);
} }
@ -478,11 +443,11 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
} }
static const LookupEntry useModMapValues[] = { static const LookupEntry useModMapValues[] = {
{"levelone", 1}, { "levelone", 1 },
{"level1", 1}, { "level1", 1 },
{"anylevel", 0}, { "anylevel", 0 },
{"any", 0}, { "any", 0 },
{NULL, 0} { NULL, 0 }
}; };
static int static int
@ -492,8 +457,7 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
int ok = 1; int ok = 1;
ExprResult tmp; ExprResult tmp;
if (strcasecmp(field, "action") == 0) if (strcasecmp(field, "action") == 0) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportSINotArray(si, field, info); return ReportSINotArray(si, field, info);
ok = HandleActionDef(value, keymap, &si->interp.act.any, info->act); ok = HandleActionDef(value, keymap, &si->interp.act.any, info->act);
@ -501,26 +465,22 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
si->defs.defined |= _SI_Action; si->defs.defined |= _SI_Action;
} }
else if ((strcasecmp(field, "virtualmodifier") == 0) || else if ((strcasecmp(field, "virtualmodifier") == 0) ||
(strcasecmp(field, "virtualmod") == 0)) (strcasecmp(field, "virtualmod") == 0)) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportSINotArray(si, field, info); return ReportSINotArray(si, field, info);
ok = ResolveVirtualModifier(value, keymap, &tmp, &info->vmods); ok = ResolveVirtualModifier(value, keymap, &tmp, &info->vmods);
if (ok) if (ok) {
{
si->interp.virtual_mod = tmp.uval; si->interp.virtual_mod = tmp.uval;
si->defs.defined |= _SI_VirtualMod; si->defs.defined |= _SI_VirtualMod;
} }
else else
return ReportSIBadType(si, field, "virtual modifier", info); return ReportSIBadType(si, field, "virtual modifier", info);
} }
else if (strcasecmp(field, "repeat") == 0) else if (strcasecmp(field, "repeat") == 0) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportSINotArray(si, field, info); return ReportSINotArray(si, field, info);
ok = ExprResolveBoolean(keymap->ctx, value, &tmp); ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
if (ok) if (ok) {
{
if (tmp.uval) if (tmp.uval)
si->interp.flags |= XkbSI_AutoRepeat; si->interp.flags |= XkbSI_AutoRepeat;
else else
@ -530,13 +490,11 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
else else
return ReportSIBadType(si, field, "boolean", info); return ReportSIBadType(si, field, "boolean", info);
} }
else if (strcasecmp(field, "locking") == 0) else if (strcasecmp(field, "locking") == 0) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportSINotArray(si, field, info); return ReportSINotArray(si, field, info);
ok = ExprResolveBoolean(keymap->ctx, value, &tmp); ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
if (ok) if (ok) {
{
if (tmp.uval) if (tmp.uval)
si->interp.flags |= XkbSI_LockingKey; si->interp.flags |= XkbSI_LockingKey;
else else
@ -547,13 +505,11 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
return ReportSIBadType(si, field, "boolean", info); return ReportSIBadType(si, field, "boolean", info);
} }
else if ((strcasecmp(field, "usemodmap") == 0) || else if ((strcasecmp(field, "usemodmap") == 0) ||
(strcasecmp(field, "usemodmapmods") == 0)) (strcasecmp(field, "usemodmapmods") == 0)) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportSINotArray(si, field, info); return ReportSINotArray(si, field, info);
ok = ExprResolveEnum(keymap->ctx, value, &tmp, useModMapValues); ok = ExprResolveEnum(keymap->ctx, value, &tmp, useModMapValues);
if (ok) if (ok) {
{
if (tmp.uval) if (tmp.uval)
si->interp.match |= XkbSI_LevelOneOnly; si->interp.match |= XkbSI_LevelOneOnly;
else else
@ -563,8 +519,7 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
else else
return ReportSIBadType(si, field, "level specification", info); return ReportSIBadType(si, field, "level specification", info);
} }
else else {
{
ok = ReportBadField("symbol interpretation", field, siText(si, info)); ok = ReportBadField("symbol interpretation", field, siText(si, info));
} }
return ok; return ok;
@ -581,13 +536,13 @@ HandleInterpVar(VarDef * stmt, struct xkb_keymap *keymap, CompatInfo * info)
ret = 0; /* internal error, already reported */ ret = 0; /* internal error, already reported */
else if (elem.str && (strcasecmp(elem.str, "interpret") == 0)) else if (elem.str && (strcasecmp(elem.str, "interpret") == 0))
ret = SetInterpField(&info->dflt, keymap, field.str, ndx, stmt->value, ret = SetInterpField(&info->dflt, keymap, field.str, ndx, stmt->value,
info); info);
else if (elem.str && (strcasecmp(elem.str, "indicator") == 0)) else if (elem.str && (strcasecmp(elem.str, "indicator") == 0))
ret = SetIndicatorMapField(&info->ledDflt, keymap, field.str, ndx, ret = SetIndicatorMapField(&info->ledDflt, keymap, field.str, ndx,
stmt->value); stmt->value);
else else
ret = SetActionField(keymap, elem.str, field.str, ndx, stmt->value, ret = SetActionField(keymap, elem.str, field.str, ndx, stmt->value,
&info->act); &info->act);
free(elem.str); free(elem.str);
free(field.str); free(field.str);
return ret; return ret;
@ -601,10 +556,8 @@ HandleInterpBody(VarDef *def, struct xkb_keymap *keymap, SymInterpInfo *si,
ExprResult tmp, field; ExprResult tmp, field;
ExprDef *arrayNdx; ExprDef *arrayNdx;
for (; def != NULL; def = (VarDef *) def->common.next) for (; def != NULL; def = (VarDef *) def->common.next) {
{ if ((def->name) && (def->name->type == ExprFieldRef)) {
if ((def->name) && (def->name->type == ExprFieldRef))
{
ok = HandleInterpVar(def, keymap, info); ok = HandleInterpVar(def, keymap, info);
continue; continue;
} }
@ -619,14 +572,14 @@ HandleInterpBody(VarDef *def, struct xkb_keymap *keymap, SymInterpInfo *si,
} }
static int static int
HandleInterpDef(InterpDef *def, struct xkb_keymap *keymap, enum merge_mode merge, HandleInterpDef(InterpDef *def, struct xkb_keymap *keymap,
enum merge_mode merge,
CompatInfo *info) CompatInfo *info)
{ {
unsigned pred, mods; unsigned pred, mods;
SymInterpInfo si; SymInterpInfo si;
if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) {
{
ERROR("Couldn't determine matching modifiers\n"); ERROR("Couldn't determine matching modifiers\n");
ACTION("Symbol interpretation ignored\n"); ACTION("Symbol interpretation ignored\n");
return false; return false;
@ -636,22 +589,19 @@ HandleInterpDef(InterpDef *def, struct xkb_keymap *keymap, enum merge_mode merge
si = info->dflt; si = info->dflt;
si.defs.merge = merge; si.defs.merge = merge;
if (!LookupKeysym(def->sym, &si.interp.sym)) if (!LookupKeysym(def->sym, &si.interp.sym)) {
{
ERROR("Could not resolve keysym %s\n", def->sym); ERROR("Could not resolve keysym %s\n", def->sym);
ACTION("Symbol interpretation ignored\n"); ACTION("Symbol interpretation ignored\n");
return false; return false;
} }
si.interp.match = pred & XkbSI_OpMask; si.interp.match = pred & XkbSI_OpMask;
si.interp.mods = mods; si.interp.mods = mods;
if (!HandleInterpBody(def->def, keymap, &si, info)) if (!HandleInterpBody(def->def, keymap, &si, info)) {
{
info->errorCount++; info->errorCount++;
return false; return false;
} }
if (!AddInterp(info, &si)) if (!AddInterp(info, &si)) {
{
info->errorCount++; info->errorCount++;
return false; return false;
} }
@ -667,21 +617,19 @@ HandleGroupCompatDef(GroupCompatDef *def, struct xkb_keymap *keymap,
if (def->merge != MERGE_DEFAULT) if (def->merge != MERGE_DEFAULT)
merge = def->merge; merge = def->merge;
if (!XkbIsLegalGroup(def->group - 1)) if (!XkbIsLegalGroup(def->group - 1)) {
{
ERROR("Keyboard group must be in the range 1..%d\n", ERROR("Keyboard group must be in the range 1..%d\n",
XkbNumKbdGroups + 1); XkbNumKbdGroups + 1);
ACTION("Compatibility map for illegal group %d ignored\n", ACTION("Compatibility map for illegal group %d ignored\n",
def->group); def->group);
return false; return false;
} }
tmp.file_id = info->file_id; tmp.file_id = info->file_id;
tmp.merge = merge; tmp.merge = merge;
if (!ExprResolveVModMask(def->def, &val, keymap)) if (!ExprResolveVModMask(def->def, &val, keymap)) {
{
ERROR("Expected a modifier mask in group compatibility definition\n"); ERROR("Expected a modifier mask in group compatibility definition\n");
ACTION("Ignoring illegal compatibility map for group %d\n", ACTION("Ignoring illegal compatibility map for group %d\n",
def->group); def->group);
return false; return false;
} }
tmp.real_mods = val.uval & 0xff; tmp.real_mods = val.uval & 0xff;
@ -691,10 +639,12 @@ HandleGroupCompatDef(GroupCompatDef *def, struct xkb_keymap *keymap,
} }
static void static void
HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge, HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge,
CompatInfo *info) CompatInfo *info)
{ {
ParseCommon *stmt; ParseCommon *stmt;
LEDInfo *leds;
if (merge == MERGE_DEFAULT) if (merge == MERGE_DEFAULT)
merge = MERGE_AUGMENT; merge = MERGE_AUGMENT;
@ -703,8 +653,7 @@ HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode me
stmt = file->defs; stmt = file->defs;
while (stmt) while (stmt)
{ {
switch (stmt->stmtType) switch (stmt->stmtType) {
{
case StmtInclude: case StmtInclude:
if (!HandleIncludeCompatMap((IncludeStmt *) stmt, keymap, info)) if (!HandleIncludeCompatMap((IncludeStmt *) stmt, keymap, info))
info->errorCount++; info->errorCount++;
@ -715,20 +664,17 @@ HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode me
break; break;
case StmtGroupCompatDef: case StmtGroupCompatDef:
if (!HandleGroupCompatDef if (!HandleGroupCompatDef
((GroupCompatDef *) stmt, keymap, merge, info)) ((GroupCompatDef *) stmt, keymap, merge, info))
info->errorCount++; info->errorCount++;
break; break;
case StmtIndicatorMapDef: case StmtIndicatorMapDef:
{ leds = HandleIndicatorMapDef((IndicatorMapDef *) stmt, keymap,
LEDInfo *rtrn;
rtrn = HandleIndicatorMapDef((IndicatorMapDef *) stmt, keymap,
&info->ledDflt, info->leds, merge); &info->ledDflt, info->leds, merge);
if (rtrn != NULL) if (leds != NULL)
info->leds = rtrn; info->leds = leds;
else else
info->errorCount++; info->errorCount++;
} break;
break;
case StmtVarDef: case StmtVarDef:
if (!HandleInterpVar((VarDef *) stmt, keymap, info)) if (!HandleInterpVar((VarDef *) stmt, keymap, info))
info->errorCount++; info->errorCount++;
@ -744,12 +690,11 @@ HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode me
break; break;
default: default:
WSGO("Unexpected statement type %d in HandleCompatMapFile\n", WSGO("Unexpected statement type %d in HandleCompatMapFile\n",
stmt->stmtType); stmt->stmtType);
break; break;
} }
stmt = stmt->next; stmt = stmt->next;
if (info->errorCount > 10) if (info->errorCount > 10) {
{
#ifdef NOISY #ifdef NOISY
ERROR("Too many errors\n"); ERROR("Too many errors\n");
#endif #endif
@ -765,8 +710,7 @@ CopyInterps(CompatInfo * info,
{ {
SymInterpInfo *si; SymInterpInfo *si;
for (si = info->interps; si; si = (SymInterpInfo *) si->defs.next) for (si = info->interps; si; si = (SymInterpInfo *) si->defs.next) {
{
if (((si->interp.match & XkbSI_OpMask) != pred) || if (((si->interp.match & XkbSI_OpMask) != pred) ||
(needSymbol && (si->interp.sym == XKB_KEY_NoSymbol)) || (needSymbol && (si->interp.sym == XKB_KEY_NoSymbol)) ||
((!needSymbol) && (si->interp.sym != XKB_KEY_NoSymbol))) ((!needSymbol) && (si->interp.sym != XKB_KEY_NoSymbol)))
@ -776,7 +720,8 @@ CopyInterps(CompatInfo * info,
} }
bool bool
CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge)
{ {
int i; int i;
CompatInfo info; CompatInfo info;
@ -813,8 +758,10 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge
CopyInterps(&info, keymap->compat, false, XkbSI_AnyOfOrNone); CopyInterps(&info, keymap->compat, false, XkbSI_AnyOfOrNone);
} }
for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups; i++, gcm++) { for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups; i++,
if ((gcm->file_id != 0) || (gcm->real_mods != 0) || (gcm->vmods != 0)) { gcm++) {
if ((gcm->file_id != 0) || (gcm->real_mods != 0) ||
(gcm->vmods != 0)) {
keymap->compat->groups[i].mask = gcm->real_mods; keymap->compat->groups[i].mask = gcm->real_mods;
keymap->compat->groups[i].real_mods = gcm->real_mods; keymap->compat->groups[i].real_mods = gcm->real_mods;
keymap->compat->groups[i].vmods = gcm->vmods; keymap->compat->groups[i].vmods = gcm->vmods;
@ -866,12 +813,14 @@ UpdateActionMods(struct xkb_keymap *keymap, union xkb_action *act,
act->mods.mask = act->mods.real_mods; act->mods.mask = act->mods.real_mods;
act->mods.mask |= VModsToReal(keymap, act->mods.vmods); act->mods.mask |= VModsToReal(keymap, act->mods.vmods);
break; break;
case XkbSA_ISOLock: case XkbSA_ISOLock:
if (act->iso.flags & XkbSA_UseModMapMods) if (act->iso.flags & XkbSA_UseModMapMods)
act->iso.real_mods = rmodmask; act->iso.real_mods = rmodmask;
act->iso.mask = act->iso.real_mods; act->iso.mask = act->iso.real_mods;
act->iso.mask |= VModsToReal(keymap, act->iso.vmods); act->iso.mask |= VModsToReal(keymap, act->iso.vmods);
break; break;
default: default:
break; break;
} }
@ -960,7 +909,8 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
interps[i] = NULL; interps[i] = NULL;
for (group = 0; group < XkbKeyNumGroups(keymap, key); group++) { for (group = 0; group < XkbKeyNumGroups(keymap, key); group++) {
for (level = 0; level < XkbKeyGroupWidth(keymap, key, group); level++) { for (level = 0; level < XkbKeyGroupWidth(keymap, key, group);
level++) {
i = (group * width) + level; i = (group * width) + level;
if (i >= INTERP_SIZE) /* XXX FIXME */ if (i >= INTERP_SIZE) /* XXX FIXME */
return false; return false;
@ -977,7 +927,8 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
return false; return false;
for (group = 0; group < XkbKeyNumGroups(keymap, key); group++) { for (group = 0; group < XkbKeyNumGroups(keymap, key); group++) {
for (level = 0; level < XkbKeyGroupWidth(keymap, key, group); level++) { for (level = 0; level < XkbKeyGroupWidth(keymap, key, group);
level++) {
struct xkb_sym_interpret *interp; struct xkb_sym_interpret *interp;
i = (group * width) + level; i = (group * width) + level;
@ -985,10 +936,12 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
/* Infer default key behaviours from the base level. */ /* Infer default key behaviours from the base level. */
if (group == 0 && level == 0) { if (group == 0 && level == 0) {
if (!(keymap->server->explicit[key] & XkbExplicitAutoRepeatMask) && if (!(keymap->server->explicit[key] &
XkbExplicitAutoRepeatMask) &&
(!interp || interp->flags & XkbSI_AutoRepeat)) (!interp || interp->flags & XkbSI_AutoRepeat))
keymap->ctrls->per_key_repeat[key / 8] |= (1 << (key % 8)); keymap->ctrls->per_key_repeat[key / 8] |= (1 << (key % 8));
if (!(keymap->server->explicit[key] & XkbExplicitBehaviorMask) && if (!(keymap->server->explicit[key] &
XkbExplicitBehaviorMask) &&
interp && (interp->flags & XkbSI_LockingKey)) interp && (interp->flags & XkbSI_LockingKey))
keymap->server->behaviors[key].type = XkbKB_Lock; keymap->server->behaviors[key].type = XkbKB_Lock;
} }
@ -1058,8 +1011,8 @@ UpdateModifiersFromCompat(struct xkb_keymap *keymap)
} }
darray_foreach(entry, type->map) darray_foreach(entry, type->map)
entry->mods.mask = entry->mods.real_mods | entry->mods.mask = entry->mods.real_mods |
VModsToReal(keymap, entry->mods.vmods); VModsToReal(keymap, entry->mods.vmods);
} }
/* Update action modifiers. */ /* Update action modifiers. */

View File

@ -1,36 +1,36 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "expr.h" #include "expr.h"
/***====================================================================***/ /***====================================================================***/
typedef bool (*IdentLookupFunc) (struct xkb_context *ctx, const void *priv, typedef bool (*IdentLookupFunc)(struct xkb_context *ctx, const void *priv,
xkb_atom_t field, unsigned type, xkb_atom_t field, unsigned type,
ExprResult *val_rtrn); ExprResult *val_rtrn);
/***====================================================================***/ /***====================================================================***/
@ -39,8 +39,7 @@ exprOpText(unsigned type)
{ {
static char buf[32]; static char buf[32];
switch (type) switch (type) {
{
case ExprValue: case ExprValue:
strcpy(buf, "literal"); strcpy(buf, "literal");
break; break;
@ -101,8 +100,7 @@ exprTypeText(unsigned type)
{ {
static char buf[20]; static char buf[20];
switch (type) switch (type) {
{
case TypeUnknown: case TypeUnknown:
strcpy(buf, "unknown"); strcpy(buf, "unknown");
break; break;
@ -133,8 +131,7 @@ ExprResolveLhs(struct xkb_keymap *keymap, ExprDef *expr,
ExprResult *elem_rtrn, ExprResult *field_rtrn, ExprResult *elem_rtrn, ExprResult *field_rtrn,
ExprDef **index_rtrn) ExprDef **index_rtrn)
{ {
switch (expr->op) switch (expr->op) {
{
case ExprIdent: case ExprIdent:
elem_rtrn->str = NULL; elem_rtrn->str = NULL;
field_rtrn->str = xkb_atom_strdup(keymap->ctx, field_rtrn->str = xkb_atom_strdup(keymap->ctx,
@ -168,32 +165,30 @@ SimpleLookup(struct xkb_context *ctx, const void *priv,
const char *str; const char *str;
if ((priv == NULL) || (field == XKB_ATOM_NONE) || (type != TypeInt)) if ((priv == NULL) || (field == XKB_ATOM_NONE) || (type != TypeInt))
{
return false; return false;
}
str = xkb_atom_text(ctx, field); str = xkb_atom_text(ctx, field);
for (entry = priv; (entry != NULL) && (entry->name != NULL); entry++) for (entry = priv; (entry != NULL) && (entry->name != NULL); entry++) {
{ if (strcasecmp(str, entry->name) == 0) {
if (strcasecmp(str, entry->name) == 0)
{
val_rtrn->uval = entry->result; val_rtrn->uval = entry->result;
return true; return true;
} }
} }
return false; return false;
} }
static const LookupEntry modIndexNames[] = { static const LookupEntry modIndexNames[] = {
{"shift", ShiftMapIndex}, { "shift", ShiftMapIndex },
{"control", ControlMapIndex}, { "control", ControlMapIndex },
{"lock", LockMapIndex}, { "lock", LockMapIndex },
{"mod1", Mod1MapIndex}, { "mod1", Mod1MapIndex },
{"mod2", Mod2MapIndex}, { "mod2", Mod2MapIndex },
{"mod3", Mod3MapIndex}, { "mod3", Mod3MapIndex },
{"mod4", Mod4MapIndex}, { "mod4", Mod4MapIndex },
{"mod5", Mod5MapIndex}, { "mod5", Mod5MapIndex },
{"none", XkbNoModifier}, { "none", XkbNoModifier },
{NULL, 0} { NULL, 0 }
}; };
bool bool
@ -233,33 +228,29 @@ ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr,
int ok = 0; int ok = 0;
const char *bogus = NULL; const char *bogus = NULL;
switch (expr->op) switch (expr->op) {
{
case ExprValue: case ExprValue:
if (expr->type != TypeBoolean) if (expr->type != TypeBoolean) {
{
ERROR ERROR
("Found constant of type %s where boolean was expected\n", ("Found constant of type %s where boolean was expected\n",
exprTypeText(expr->type)); exprTypeText(expr->type));
return false; return false;
} }
val_rtrn->ival = expr->value.ival; val_rtrn->ival = expr->value.ival;
return true; return true;
case ExprIdent: case ExprIdent:
bogus = xkb_atom_text(ctx, expr->value.str); bogus = xkb_atom_text(ctx, expr->value.str);
if (bogus) if (bogus) {
{
if ((strcasecmp(bogus, "true") == 0) || if ((strcasecmp(bogus, "true") == 0) ||
(strcasecmp(bogus, "yes") == 0) || (strcasecmp(bogus, "yes") == 0) ||
(strcasecmp(bogus, "on") == 0)) (strcasecmp(bogus, "on") == 0)) {
{
val_rtrn->uval = 1; val_rtrn->uval = 1;
return true; return true;
} }
else if ((strcasecmp(bogus, "false") == 0) || else if ((strcasecmp(bogus, "false") == 0) ||
(strcasecmp(bogus, "no") == 0) || (strcasecmp(bogus, "no") == 0) ||
(strcasecmp(bogus, "off") == 0)) (strcasecmp(bogus, "off") == 0)) {
{
val_rtrn->uval = 0; val_rtrn->uval = 0;
return true; return true;
} }
@ -267,11 +258,13 @@ ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr,
ERROR("Identifier \"%s\" of type int is unknown\n", ERROR("Identifier \"%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return false; return false;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type boolean is unknown\n", ERROR("Default \"%s.%s\" of type boolean is unknown\n",
xkb_atom_text(ctx, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpInvert: case OpInvert:
case OpNot: case OpNot:
ok = ExprResolveBoolean(ctx, expr, val_rtrn); ok = ExprResolveBoolean(ctx, expr, val_rtrn);
@ -298,9 +291,11 @@ ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr,
bogus = "Negation"; bogus = "Negation";
ERROR("%s of boolean values not permitted\n", bogus); ERROR("%s of boolean values not permitted\n", bogus);
break; break;
case OpUnaryPlus: case OpUnaryPlus:
ERROR("Unary \"+\" operator not permitted for boolean values\n"); ERROR("Unary \"+\" operator not permitted for boolean values\n");
break; break;
default: default:
WSGO("Unknown operator %d in ResolveBoolean\n", expr->op); WSGO("Unknown operator %d in ResolveBoolean\n", expr->op);
break; break;
@ -316,38 +311,37 @@ ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
ExprResult leftRtrn, rightRtrn; ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right; ExprDef *left, *right;
switch (expr->op) switch (expr->op) {
{
case ExprValue: case ExprValue:
if (expr->type == TypeString) if (expr->type == TypeString) {
{
const char *str; const char *str;
str = xkb_atom_text(ctx, expr->value.str); str = xkb_atom_text(ctx, expr->value.str);
if ((str != NULL) && (strlen(str) == 1)) if ((str != NULL) && (strlen(str) == 1)) {
{
val_rtrn->uval = str[0] * XkbGeomPtsPerMM; val_rtrn->uval = str[0] * XkbGeomPtsPerMM;
return true; return true;
} }
} }
if (expr->type != TypeInt) if (expr->type != TypeInt) {
{
ERROR("Found constant of type %s, expected a number\n", ERROR("Found constant of type %s, expected a number\n",
exprTypeText(expr->type)); exprTypeText(expr->type));
return false; return false;
} }
val_rtrn->ival = expr->value.ival; val_rtrn->ival = expr->value.ival;
if (expr->type == TypeInt) if (expr->type == TypeInt)
val_rtrn->ival *= XkbGeomPtsPerMM; val_rtrn->ival *= XkbGeomPtsPerMM;
return true; return true;
case ExprIdent: case ExprIdent:
ERROR("Numeric identifier \"%s\" unknown\n", ERROR("Numeric identifier \"%s\" unknown\n",
xkb_atom_text(ctx, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return ok; return ok;
case ExprFieldRef: case ExprFieldRef:
ERROR("Numeric default \"%s.%s\" unknown\n", ERROR("Numeric default \"%s.%s\" unknown\n",
xkb_atom_text(ctx, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpAdd: case OpAdd:
case OpSubtract: case OpSubtract:
case OpMultiply: case OpMultiply:
@ -355,19 +349,20 @@ ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveFloat(ctx, left, &leftRtrn) && if (ExprResolveFloat(ctx, left, &leftRtrn) &&
ExprResolveFloat(ctx, right, &rightRtrn)) ExprResolveFloat(ctx, right, &rightRtrn)) {
{ switch (expr->op) {
switch (expr->op)
{
case OpAdd: case OpAdd:
val_rtrn->ival = leftRtrn.ival + rightRtrn.ival; val_rtrn->ival = leftRtrn.ival + rightRtrn.ival;
break; break;
case OpSubtract: case OpSubtract:
val_rtrn->ival = leftRtrn.ival - rightRtrn.ival; val_rtrn->ival = leftRtrn.ival - rightRtrn.ival;
break; break;
case OpMultiply: case OpMultiply:
val_rtrn->ival = leftRtrn.ival * rightRtrn.ival; val_rtrn->ival = leftRtrn.ival * rightRtrn.ival;
break; break;
case OpDivide: case OpDivide:
val_rtrn->ival = leftRtrn.ival / rightRtrn.ival; val_rtrn->ival = leftRtrn.ival / rightRtrn.ival;
break; break;
@ -375,17 +370,19 @@ ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
return true; return true;
} }
return false; return false;
case OpAssign: case OpAssign:
WSGO("Assignment operator not implemented yet\n"); WSGO("Assignment operator not implemented yet\n");
break; break;
case OpNot: case OpNot:
ERROR("The ! operator cannot be applied to a number\n"); ERROR("The ! operator cannot be applied to a number\n");
return false; return false;
case OpInvert: case OpInvert:
case OpNegate: case OpNegate:
left = expr->value.child; left = expr->value.child;
if (ExprResolveFloat(ctx, left, &leftRtrn)) if (ExprResolveFloat(ctx, left, &leftRtrn)) {
{
if (expr->op == OpNegate) if (expr->op == OpNegate)
val_rtrn->ival = -leftRtrn.ival; val_rtrn->ival = -leftRtrn.ival;
else else
@ -393,9 +390,11 @@ ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
return true; return true;
} }
return false; return false;
case OpUnaryPlus: case OpUnaryPlus:
left = expr->value.child; left = expr->value.child;
return ExprResolveFloat(ctx, left, val_rtrn); return ExprResolveFloat(ctx, left, val_rtrn);
default: default:
WSGO("Unknown operator %d in ResolveFloat\n", expr->op); WSGO("Unknown operator %d in ResolveFloat\n", expr->op);
break; break;
@ -410,18 +409,17 @@ ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr,
ExprResult leftRtrn, rightRtrn; ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right; ExprDef *left, *right;
switch (expr->op) switch (expr->op) {
{
case ExprValue: case ExprValue:
if (expr->type != TypeInt) if (expr->type != TypeInt) {
{
ERROR ERROR
("Found constant of type %s where an int was expected\n", ("Found constant of type %s where an int was expected\n",
exprTypeText(expr->type)); exprTypeText(expr->type));
return false; return false;
} }
val_rtrn->uval = expr->value.uval; val_rtrn->uval = expr->value.uval;
return true; return true;
case OpAdd: case OpAdd:
case OpSubtract: case OpSubtract:
case OpMultiply: case OpMultiply:
@ -429,10 +427,8 @@ ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr,
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveKeyCode(ctx, left, &leftRtrn) && if (ExprResolveKeyCode(ctx, left, &leftRtrn) &&
ExprResolveKeyCode(ctx, right, &rightRtrn)) ExprResolveKeyCode(ctx, right, &rightRtrn)) {
{ switch (expr->op) {
switch (expr->op)
{
case OpAdd: case OpAdd:
val_rtrn->uval = leftRtrn.uval + rightRtrn.uval; val_rtrn->uval = leftRtrn.uval + rightRtrn.uval;
break; break;
@ -449,17 +445,19 @@ ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr,
return true; return true;
} }
return false; return false;
case OpNegate: case OpNegate:
left = expr->value.child; left = expr->value.child;
if (ExprResolveKeyCode(ctx, left, &leftRtrn)) if (ExprResolveKeyCode(ctx, left, &leftRtrn)) {
{
val_rtrn->uval = ~leftRtrn.uval; val_rtrn->uval = ~leftRtrn.uval;
return true; return true;
} }
return false; return false;
case OpUnaryPlus: case OpUnaryPlus:
left = expr->value.child; left = expr->value.child;
return ExprResolveKeyCode(ctx, left, val_rtrn); return ExprResolveKeyCode(ctx, left, val_rtrn);
default: default:
WSGO("Unknown operator %d in ResolveKeyCode\n", expr->op); WSGO("Unknown operator %d in ResolveKeyCode\n", expr->op);
break; break;
@ -490,16 +488,13 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
ExprResult leftRtrn, rightRtrn; ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right; ExprDef *left, *right;
switch (expr->op) switch (expr->op) {
{
case ExprValue: case ExprValue:
if (expr->type == TypeString) if (expr->type == TypeString) {
{
const char *str; const char *str;
str = xkb_atom_text(ctx, expr->value.str); str = xkb_atom_text(ctx, expr->value.str);
if (str != NULL) if (str != NULL)
switch (strlen(str)) switch (strlen(str)) {
{
case 0: case 0:
val_rtrn->uval = 0; val_rtrn->uval = 0;
return true; return true;
@ -510,39 +505,41 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
break; break;
} }
} }
if (expr->type != TypeInt) if (expr->type != TypeInt) {
{
ERROR ERROR
("Found constant of type %s where an int was expected\n", ("Found constant of type %s where an int was expected\n",
exprTypeText(expr->type)); exprTypeText(expr->type));
return false; return false;
} }
val_rtrn->ival = expr->value.ival; val_rtrn->ival = expr->value.ival;
return true; return true;
case ExprIdent: case ExprIdent:
if (lookup) if (lookup)
ok = lookup(ctx, lookupPriv, expr->value.str, ok = lookup(ctx, lookupPriv, expr->value.str,
TypeInt, val_rtrn); TypeInt, val_rtrn);
if (!ok) if (!ok)
ERROR("Identifier \"%s\" of type int is unknown\n", ERROR("Identifier \"%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return ok; return ok;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type int is unknown\n", ERROR("Default \"%s.%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpAdd: case OpAdd:
case OpSubtract: case OpSubtract:
case OpMultiply: case OpMultiply:
case OpDivide: case OpDivide:
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup, lookupPriv) && if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
ExprResolveIntegerLookup(ctx, right, &rightRtrn, lookup, lookupPriv)) lookupPriv) &&
{ ExprResolveIntegerLookup(ctx, right, &rightRtrn, lookup,
switch (expr->op) lookupPriv)) {
{ switch (expr->op) {
case OpAdd: case OpAdd:
val_rtrn->ival = leftRtrn.ival + rightRtrn.ival; val_rtrn->ival = leftRtrn.ival + rightRtrn.ival;
break; break;
@ -559,18 +556,20 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
return true; return true;
} }
return false; return false;
case OpAssign: case OpAssign:
WSGO("Assignment operator not implemented yet\n"); WSGO("Assignment operator not implemented yet\n");
break; break;
case OpNot: case OpNot:
ERROR("The ! operator cannot be applied to an integer\n"); ERROR("The ! operator cannot be applied to an integer\n");
return false; return false;
case OpInvert: case OpInvert:
case OpNegate: case OpNegate:
left = expr->value.child; left = expr->value.child;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup, if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
lookupPriv)) lookupPriv)) {
{
if (expr->op == OpNegate) if (expr->op == OpNegate)
val_rtrn->ival = -leftRtrn.ival; val_rtrn->ival = -leftRtrn.ival;
else else
@ -578,10 +577,12 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
return true; return true;
} }
return false; return false;
case OpUnaryPlus: case OpUnaryPlus:
left = expr->value.child; left = expr->value.child;
return ExprResolveIntegerLookup(ctx, left, val_rtrn, lookup, return ExprResolveIntegerLookup(ctx, left, val_rtrn, lookup,
lookupPriv); lookupPriv);
default: default:
WSGO("Unknown operator %d in ResolveInteger\n", expr->op); WSGO("Unknown operator %d in ResolveInteger\n", expr->op);
break; break;
@ -685,34 +686,34 @@ ExprResolveString(struct xkb_context *ctx, ExprDef *expr,
ExprDef *right; ExprDef *right;
const char *bogus = NULL; const char *bogus = NULL;
switch (expr->op) switch (expr->op) {
{
case ExprValue: case ExprValue:
if (expr->type != TypeString) if (expr->type != TypeString) {
{
ERROR("Found constant of type %s, expected a string\n", ERROR("Found constant of type %s, expected a string\n",
exprTypeText(expr->type)); exprTypeText(expr->type));
return false; return false;
} }
val_rtrn->str = xkb_atom_strdup(ctx, expr->value.str); val_rtrn->str = xkb_atom_strdup(ctx, expr->value.str);
if (val_rtrn->str == NULL) if (val_rtrn->str == NULL)
val_rtrn->str = strdup(""); val_rtrn->str = strdup("");
return true; return true;
case ExprIdent: case ExprIdent:
ERROR("Identifier \"%s\" of type string not found\n", ERROR("Identifier \"%s\" of type string not found\n",
xkb_atom_text(ctx, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return false; return false;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type string not found\n", ERROR("Default \"%s.%s\" of type string not found\n",
xkb_atom_text(ctx, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpAdd: case OpAdd:
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveString(ctx, left, &leftRtrn) && if (ExprResolveString(ctx, left, &leftRtrn) &&
ExprResolveString(ctx, right, &rightRtrn)) ExprResolveString(ctx, right, &rightRtrn)) {
{
int len; int len;
char *new; char *new;
len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1; len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
@ -728,6 +729,7 @@ ExprResolveString(struct xkb_context *ctx, ExprDef *expr,
free(rightRtrn.str); free(rightRtrn.str);
} }
return false; return false;
case OpSubtract: case OpSubtract:
if (bogus == NULL) if (bogus == NULL)
bogus = "Subtraction"; bogus = "Subtraction";
@ -748,12 +750,15 @@ ExprResolveString(struct xkb_context *ctx, ExprDef *expr,
bogus = "Bitwise complement"; bogus = "Bitwise complement";
ERROR("%s of string values not permitted\n", bogus); ERROR("%s of string values not permitted\n", bogus);
return false; return false;
case OpNot: case OpNot:
ERROR("The ! operator cannot be applied to a string\n"); ERROR("The ! operator cannot be applied to a string\n");
return false; return false;
case OpUnaryPlus: case OpUnaryPlus:
ERROR("The + operator cannot be applied to a string\n"); ERROR("The + operator cannot be applied to a string\n");
return false; return false;
default: default:
WSGO("Unknown operator %d in ResolveString\n", expr->op); WSGO("Unknown operator %d in ResolveString\n", expr->op);
break; break;
@ -767,26 +772,27 @@ ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
{ {
const char *bogus = NULL; const char *bogus = NULL;
switch (expr->op) switch (expr->op) {
{
case ExprValue: case ExprValue:
if (expr->type != TypeKeyName) if (expr->type != TypeKeyName) {
{
ERROR("Found constant of type %s, expected a key name\n", ERROR("Found constant of type %s, expected a key name\n",
exprTypeText(expr->type)); exprTypeText(expr->type));
return false; return false;
} }
memcpy(val_rtrn->keyName.name, expr->value.keyName, XkbKeyNameLength); memcpy(val_rtrn->keyName.name, expr->value.keyName, XkbKeyNameLength);
return true; return true;
case ExprIdent: case ExprIdent:
ERROR("Identifier \"%s\" of type string not found\n", ERROR("Identifier \"%s\" of type string not found\n",
xkb_atom_text(ctx, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return false; return false;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type key name not found\n", ERROR("Default \"%s.%s\" of type key name not found\n",
xkb_atom_text(ctx, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case OpAdd: case OpAdd:
if (bogus == NULL) if (bogus == NULL)
bogus = "Addition"; bogus = "Addition";
@ -810,12 +816,15 @@ ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
bogus = "Bitwise complement"; bogus = "Bitwise complement";
ERROR("%s of key name values not permitted\n", bogus); ERROR("%s of key name values not permitted\n", bogus);
return false; return false;
case OpNot: case OpNot:
ERROR("The ! operator cannot be applied to a key name\n"); ERROR("The ! operator cannot be applied to a key name\n");
return false; return false;
case OpUnaryPlus: case OpUnaryPlus:
ERROR("The + operator cannot be applied to a key name\n"); ERROR("The + operator cannot be applied to a key name\n");
return false; return false;
default: default:
WSGO("Unknown operator %d in ResolveKeyName\n", expr->op); WSGO("Unknown operator %d in ResolveKeyName\n", expr->op);
break; break;
@ -829,17 +838,15 @@ int
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
ExprResult *val_rtrn, const LookupEntry *values) ExprResult *val_rtrn, const LookupEntry *values)
{ {
if (expr->op != ExprIdent) if (expr->op != ExprIdent) {
{
ERROR("Found a %s where an enumerated value was expected\n", ERROR("Found a %s where an enumerated value was expected\n",
exprOpText(expr->op)); exprOpText(expr->op));
return false; return false;
} }
if (!SimpleLookup(ctx, values, expr->value.str, TypeInt, val_rtrn)) if (!SimpleLookup(ctx, values, expr->value.str, TypeInt, val_rtrn)) {
{
int nOut = 0; int nOut = 0;
ERROR("Illegal identifier %s (expected one of: ", ERROR("Illegal identifier %s (expected one of: ",
xkb_atom_text(ctx, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
while (values && values->name) while (values && values->name)
{ {
if (nOut != 0) if (nOut != 0)
@ -865,48 +872,51 @@ ExprResolveMaskLookup(struct xkb_context *ctx, ExprDef *expr,
ExprDef *left, *right; ExprDef *left, *right;
const char *bogus = NULL; const char *bogus = NULL;
switch (expr->op) switch (expr->op) {
{
case ExprValue: case ExprValue:
if (expr->type != TypeInt) if (expr->type != TypeInt) {
{
ERROR ERROR
("Found constant of type %s where a mask was expected\n", ("Found constant of type %s where a mask was expected\n",
exprTypeText(expr->type)); exprTypeText(expr->type));
return false; return false;
} }
val_rtrn->ival = expr->value.ival; val_rtrn->ival = expr->value.ival;
return true; return true;
case ExprIdent: case ExprIdent:
ok = lookup(ctx, lookupPriv, expr->value.str, TypeInt, val_rtrn); ok = lookup(ctx, lookupPriv, expr->value.str, TypeInt, val_rtrn);
if (!ok) if (!ok)
ERROR("Identifier \"%s\" of type int is unknown\n", ERROR("Identifier \"%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.str)); xkb_atom_text(ctx, expr->value.str));
return ok; return ok;
case ExprFieldRef: case ExprFieldRef:
ERROR("Default \"%s.%s\" of type int is unknown\n", ERROR("Default \"%s.%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.field.element), xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field)); xkb_atom_text(ctx, expr->value.field.field));
return false; return false;
case ExprArrayRef: case ExprArrayRef:
bogus = "array reference"; bogus = "array reference";
case ExprActionDecl: case ExprActionDecl:
if (bogus == NULL) if (bogus == NULL)
bogus = "function use"; bogus = "function use";
ERROR("Unexpected %s in mask expression\n", bogus); ERROR("Unexpected %s in mask expression\n", bogus);
ACTION("Expression ignored\n"); ACTION("Expression ignored\n");
return false; return false;
case OpAdd: case OpAdd:
case OpSubtract: case OpSubtract:
case OpMultiply: case OpMultiply:
case OpDivide: case OpDivide:
left = expr->value.binary.left; left = expr->value.binary.left;
right = expr->value.binary.right; right = expr->value.binary.right;
if (ExprResolveMaskLookup(ctx, left, &leftRtrn, lookup, lookupPriv) && if (ExprResolveMaskLookup(ctx, left, &leftRtrn, lookup,
ExprResolveMaskLookup(ctx, right, &rightRtrn, lookup, lookupPriv)) lookupPriv) &&
{ ExprResolveMaskLookup(ctx, right, &rightRtrn, lookup,
switch (expr->op) lookupPriv)) {
{ switch (expr->op) {
case OpAdd: case OpAdd:
val_rtrn->ival = leftRtrn.ival | rightRtrn.ival; val_rtrn->ival = leftRtrn.ival | rightRtrn.ival;
break; break;
@ -916,36 +926,38 @@ ExprResolveMaskLookup(struct xkb_context *ctx, ExprDef *expr,
case OpMultiply: case OpMultiply:
case OpDivide: case OpDivide:
ERROR("Cannot %s masks\n", ERROR("Cannot %s masks\n",
expr->op == OpDivide ? "divide" : "multiply"); expr->op == OpDivide ? "divide" : "multiply");
ACTION("Illegal operation ignored\n"); ACTION("Illegal operation ignored\n");
return false; return false;
} }
return true; return true;
} }
return false; return false;
case OpAssign: case OpAssign:
WSGO("Assignment operator not implemented yet\n"); WSGO("Assignment operator not implemented yet\n");
break; break;
case OpInvert: case OpInvert:
left = expr->value.child; left = expr->value.child;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup, if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
lookupPriv)) lookupPriv)) {
{
val_rtrn->ival = ~leftRtrn.ival; val_rtrn->ival = ~leftRtrn.ival;
return true; return true;
} }
return false; return false;
case OpUnaryPlus: case OpUnaryPlus:
case OpNegate: case OpNegate:
case OpNot: case OpNot:
left = expr->value.child; left = expr->value.child;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup, if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
lookupPriv)) lookupPriv)) {
{
ERROR("The %s operator cannot be used with a mask\n", ERROR("The %s operator cannot be used with a mask\n",
(expr->op == OpNegate ? "-" : "!")); (expr->op == OpNegate ? "-" : "!"));
} }
return false; return false;
default: default:
WSGO("Unknown operator %d in ResolveMask\n", expr->op); WSGO("Unknown operator %d in ResolveMask\n", expr->op);
break; break;
@ -982,8 +994,7 @@ ExprResolveKeySym(struct xkb_context *ctx, ExprDef *expr,
int ok = 0; int ok = 0;
xkb_keysym_t sym; xkb_keysym_t sym;
if (expr->op == ExprIdent) if (expr->op == ExprIdent) {
{
const char *str; const char *str;
str = xkb_atom_text(ctx, expr->value.str); str = xkb_atom_text(ctx, expr->value.str);
if (str) { if (str) {

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef EXPR_H #ifndef EXPR_H
@ -29,8 +29,7 @@
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
typedef union _ExprResult typedef union _ExprResult {
{
char *str; char *str;
int ival; int ival;
unsigned uval; unsigned uval;
@ -42,27 +41,28 @@ ExprResolveLhs(struct xkb_keymap *keymap, ExprDef *expr,
ExprResult *elem_rtrn, ExprResult *field_rtrn, ExprResult *elem_rtrn, ExprResult *field_rtrn,
ExprDef **index_rtrn); ExprDef **index_rtrn);
typedef struct _LookupEntry typedef struct _LookupEntry {
{
const char *name; const char *name;
unsigned result; unsigned result;
} LookupEntry; } LookupEntry;
extern const char * extern const char *
exprOpText(unsigned type); exprOpText(unsigned type);
extern bool extern bool
LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field, LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn); unsigned type,
ExprResult *val_rtrn);
extern bool extern bool
LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field, LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn); unsigned type,
ExprResult *val_rtrn);
extern bool extern bool
LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field, LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn); unsigned type,
ExprResult *val_rtrn);
extern int extern int
ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr, ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr,
@ -85,20 +85,17 @@ ExprResolveInteger(struct xkb_context *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr, ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn);
ExprResult *val_rtrn);
extern int extern int
ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr, ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn);
ExprResult *val_rtrn);
extern int extern int
ExprResolveButton(struct xkb_context *ctx, ExprDef *expr, ExprResolveButton(struct xkb_context *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr, ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn);
ExprResult *val_rtrn);
extern int extern int
ExprResolveString(struct xkb_context *ctx, ExprDef *expr, ExprResolveString(struct xkb_context *ctx, ExprDef *expr,
@ -109,12 +106,12 @@ ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
ExprResult *val_rtrn); ExprResult *val_rtrn);
extern int extern int
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
ExprResult *val_rtrn, const LookupEntry *values); const LookupEntry *values);
extern int extern int
ExprResolveMask(struct xkb_context *ctx, ExprDef *expr, ExprResolveMask(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
ExprResult *val_rtrn, const LookupEntry *values); const LookupEntry *values);
extern int extern int
ExprResolveKeySym(struct xkb_context *ctx, ExprDef *expr, ExprResolveKeySym(struct xkb_context *ctx, ExprDef *expr,

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "indicators.h" #include "indicators.h"
@ -57,28 +57,23 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
unsigned collide; unsigned collide;
last = NULL; last = NULL;
for (old = oldLEDs; old != NULL; old = (LEDInfo *) old->defs.next) for (old = oldLEDs; old != NULL; old = (LEDInfo *) old->defs.next) {
{ if (old->name == new->name) {
if (old->name == new->name)
{
if ((old->real_mods == new->real_mods) && if ((old->real_mods == new->real_mods) &&
(old->vmods == new->vmods) && (old->vmods == new->vmods) &&
(old->groups == new->groups) && (old->groups == new->groups) &&
(old->ctrls == new->ctrls) && (old->ctrls == new->ctrls) &&
(old->which_mods == new->which_mods) && (old->which_mods == new->which_mods) &&
(old->which_groups == new->which_groups)) (old->which_groups == new->which_groups)) {
{
old->defs.defined |= new->defs.defined; old->defs.defined |= new->defs.defined;
return oldLEDs; return oldLEDs;
} }
if (new->defs.merge == MERGE_REPLACE) if (new->defs.merge == MERGE_REPLACE) {
{
CommonInfo *next = old->defs.next; CommonInfo *next = old->defs.next;
if (((old->defs.file_id == new->defs.file_id) if (((old->defs.file_id == new->defs.file_id)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9)) {
{
WARN("Map for indicator %s redefined\n", WARN("Map for indicator %s redefined\n",
xkb_atom_text(keymap->ctx, old->name)); xkb_atom_text(keymap->ctx, old->name));
ACTION("Earlier definition ignored\n"); ACTION("Earlier definition ignored\n");
} }
*old = *new; *old = *new;
@ -86,53 +81,48 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
return oldLEDs; return oldLEDs;
} }
collide = 0; collide = 0;
if (UseNewField(_LED_Index, &old->defs, &new->defs, &collide)) if (UseNewField(_LED_Index, &old->defs, &new->defs, &collide)) {
{
old->indicator = new->indicator; old->indicator = new->indicator;
old->defs.defined |= _LED_Index; old->defs.defined |= _LED_Index;
} }
if (UseNewField(_LED_Mods, &old->defs, &new->defs, &collide)) if (UseNewField(_LED_Mods, &old->defs, &new->defs, &collide)) {
{
old->which_mods = new->which_mods; old->which_mods = new->which_mods;
old->real_mods = new->real_mods; old->real_mods = new->real_mods;
old->vmods = new->vmods; old->vmods = new->vmods;
old->defs.defined |= _LED_Mods; old->defs.defined |= _LED_Mods;
} }
if (UseNewField(_LED_Groups, &old->defs, &new->defs, &collide)) if (UseNewField(_LED_Groups, &old->defs, &new->defs, &collide)) {
{
old->which_groups = new->which_groups; old->which_groups = new->which_groups;
old->groups = new->groups; old->groups = new->groups;
old->defs.defined |= _LED_Groups; old->defs.defined |= _LED_Groups;
} }
if (UseNewField(_LED_Ctrls, &old->defs, &new->defs, &collide)) if (UseNewField(_LED_Ctrls, &old->defs, &new->defs, &collide)) {
{
old->ctrls = new->ctrls; old->ctrls = new->ctrls;
old->defs.defined |= _LED_Ctrls; old->defs.defined |= _LED_Ctrls;
} }
if (UseNewField(_LED_Explicit, &old->defs, &new->defs, &collide)) if (UseNewField(_LED_Explicit, &old->defs, &new->defs,
{ &collide)) {
old->flags &= ~XkbIM_NoExplicit; old->flags &= ~XkbIM_NoExplicit;
old->flags |= (new->flags & XkbIM_NoExplicit); old->flags |= (new->flags & XkbIM_NoExplicit);
old->defs.defined |= _LED_Explicit; old->defs.defined |= _LED_Explicit;
} }
if (UseNewField(_LED_Automatic, &old->defs, &new->defs, &collide)) if (UseNewField(_LED_Automatic, &old->defs, &new->defs,
{ &collide)) {
old->flags &= ~XkbIM_NoAutomatic; old->flags &= ~XkbIM_NoAutomatic;
old->flags |= (new->flags & XkbIM_NoAutomatic); old->flags |= (new->flags & XkbIM_NoAutomatic);
old->defs.defined |= _LED_Automatic; old->defs.defined |= _LED_Automatic;
} }
if (UseNewField(_LED_DrivesKbd, &old->defs, &new->defs, &collide)) if (UseNewField(_LED_DrivesKbd, &old->defs, &new->defs,
{ &collide)) {
old->flags &= ~XkbIM_LEDDrivesKB; old->flags &= ~XkbIM_LEDDrivesKB;
old->flags |= (new->flags & XkbIM_LEDDrivesKB); old->flags |= (new->flags & XkbIM_LEDDrivesKB);
old->defs.defined |= _LED_DrivesKbd; old->defs.defined |= _LED_DrivesKbd;
} }
if (collide) if (collide) {
{
WARN("Map for indicator %s redefined\n", WARN("Map for indicator %s redefined\n",
xkb_atom_text(keymap->ctx, old->name)); xkb_atom_text(keymap->ctx, old->name));
ACTION("Using %s definition for duplicate fields\n", ACTION("Using %s definition for duplicate fields\n",
(new->defs.merge == MERGE_AUGMENT ? "first" : "last")); (new->defs.merge == MERGE_AUGMENT ? "first" : "last"));
} }
return oldLEDs; return oldLEDs;
} }
@ -141,17 +131,15 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
} }
/* new definition */ /* new definition */
old = uTypedAlloc(LEDInfo); old = uTypedAlloc(LEDInfo);
if (!old) if (!old) {
{
WSGO("Couldn't allocate indicator map\n"); WSGO("Couldn't allocate indicator map\n");
ACTION("Map for indicator %s not compiled\n", ACTION("Map for indicator %s not compiled\n",
xkb_atom_text(keymap->ctx, new->name)); xkb_atom_text(keymap->ctx, new->name));
return NULL; return NULL;
} }
*old = *new; *old = *new;
old->defs.next = NULL; old->defs.next = NULL;
if (last) if (last) {
{
last->defs.next = &old->defs; last->defs.next = &old->defs;
return oldLEDs; return oldLEDs;
} }
@ -159,37 +147,37 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
} }
static const LookupEntry modComponentNames[] = { static const LookupEntry modComponentNames[] = {
{"base", XkbIM_UseBase}, { "base", XkbIM_UseBase },
{"latched", XkbIM_UseLatched}, { "latched", XkbIM_UseLatched },
{"locked", XkbIM_UseLocked}, { "locked", XkbIM_UseLocked },
{"effective", XkbIM_UseEffective}, { "effective", XkbIM_UseEffective },
{"compat", XkbIM_UseCompat}, { "compat", XkbIM_UseCompat },
{"any", XkbIM_UseAnyMods}, { "any", XkbIM_UseAnyMods },
{"none", 0}, { "none", 0 },
{NULL, 0} { NULL, 0 }
}; };
static const LookupEntry groupComponentNames[] = { static const LookupEntry groupComponentNames[] = {
{"base", XkbIM_UseBase}, { "base", XkbIM_UseBase },
{"latched", XkbIM_UseLatched}, { "latched", XkbIM_UseLatched },
{"locked", XkbIM_UseLocked}, { "locked", XkbIM_UseLocked },
{"effective", XkbIM_UseEffective}, { "effective", XkbIM_UseEffective },
{"any", XkbIM_UseAnyGroup}, { "any", XkbIM_UseAnyGroup },
{"none", 0}, { "none", 0 },
{NULL, 0} { NULL, 0 }
}; };
static const LookupEntry groupNames[] = { static const LookupEntry groupNames[] = {
{"group1", 0x01}, { "group1", 0x01 },
{"group2", 0x02}, { "group2", 0x02 },
{"group3", 0x04}, { "group3", 0x04 },
{"group4", 0x08}, { "group4", 0x08 },
{"group5", 0x10}, { "group5", 0x10 },
{"group6", 0x20}, { "group6", 0x20 },
{"group7", 0x40}, { "group7", 0x40 },
{"group8", 0x80}, { "group8", 0x80 },
{"none", 0x00}, { "none", 0x00 },
{"all", 0xff}, { "all", 0xff },
{NULL, 0} { NULL, 0 }
}; };
int int
@ -201,8 +189,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
ok = true; ok = true;
if ((strcasecmp(field, "modifiers") == 0) || if ((strcasecmp(field, "modifiers") == 0) ||
(strcasecmp(field, "mods") == 0)) (strcasecmp(field, "mods") == 0)) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveVModMask(value, &rtrn, keymap)) if (!ExprResolveVModMask(value, &rtrn, keymap))
@ -211,8 +198,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->vmods = (rtrn.uval >> 8) & 0xff; led->vmods = (rtrn.uval >> 8) & 0xff;
led->defs.defined |= _LED_Mods; led->defs.defined |= _LED_Mods;
} }
else if (strcasecmp(field, "groups") == 0) else if (strcasecmp(field, "groups") == 0) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupNames))
@ -221,8 +207,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->defs.defined |= _LED_Groups; led->defs.defined |= _LED_Groups;
} }
else if ((strcasecmp(field, "controls") == 0) || else if ((strcasecmp(field, "controls") == 0) ||
(strcasecmp(field, "ctrls") == 0)) (strcasecmp(field, "ctrls") == 0)) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
@ -231,8 +216,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->ctrls = rtrn.uval; led->ctrls = rtrn.uval;
led->defs.defined |= _LED_Ctrls; led->defs.defined |= _LED_Ctrls;
} }
else if (strcasecmp(field, "allowexplicit") == 0) else if (strcasecmp(field, "allowexplicit") == 0) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn)) if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
@ -244,23 +228,20 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->defs.defined |= _LED_Explicit; led->defs.defined |= _LED_Explicit;
} }
else if ((strcasecmp(field, "whichmodstate") == 0) || else if ((strcasecmp(field, "whichmodstate") == 0) ||
(strcasecmp(field, "whichmodifierstate") == 0)) (strcasecmp(field, "whichmodifierstate") == 0)) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, modComponentNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn, modComponentNames)) {
{
return ReportIndicatorBadType(keymap, led, field, return ReportIndicatorBadType(keymap, led, field,
"mask of modifier state components"); "mask of modifier state components");
} }
led->which_mods = rtrn.uval; led->which_mods = rtrn.uval;
} }
else if (strcasecmp(field, "whichgroupstate") == 0) else if (strcasecmp(field, "whichgroupstate") == 0) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupComponentNames)) if (!ExprResolveMask(keymap->ctx, value, &rtrn,
{ groupComponentNames)) {
return ReportIndicatorBadType(keymap, led, field, return ReportIndicatorBadType(keymap, led, field,
"mask of group state components"); "mask of group state components");
} }
@ -271,8 +252,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
(strcasecmp(field, "leddriveskbd") == 0) || (strcasecmp(field, "leddriveskbd") == 0) ||
(strcasecmp(field, "leddriveskeyboard") == 0) || (strcasecmp(field, "leddriveskeyboard") == 0) ||
(strcasecmp(field, "indicatordriveskbd") == 0) || (strcasecmp(field, "indicatordriveskbd") == 0) ||
(strcasecmp(field, "indicatordriveskeyboard") == 0)) (strcasecmp(field, "indicatordriveskeyboard") == 0)) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn)) if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
@ -283,28 +263,25 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->flags &= ~XkbIM_LEDDrivesKB; led->flags &= ~XkbIM_LEDDrivesKB;
led->defs.defined |= _LED_DrivesKbd; led->defs.defined |= _LED_DrivesKbd;
} }
else if (strcasecmp(field, "index") == 0) else if (strcasecmp(field, "index") == 0) {
{
if (arrayNdx != NULL) if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field); return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveInteger(keymap->ctx, value, &rtrn)) if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportIndicatorBadType(keymap, led, field, return ReportIndicatorBadType(keymap, led, field,
"indicator index"); "indicator index");
if ((rtrn.uval < 1) || (rtrn.uval > 32)) if ((rtrn.uval < 1) || (rtrn.uval > 32)) {
{
ERROR("Illegal indicator index %d (range 1..%d)\n", ERROR("Illegal indicator index %d (range 1..%d)\n",
rtrn.uval, XkbNumIndicators); rtrn.uval, XkbNumIndicators);
ACTION("Index definition for %s indicator ignored\n", ACTION("Index definition for %s indicator ignored\n",
xkb_atom_text(keymap->ctx, led->name)); xkb_atom_text(keymap->ctx, led->name));
return false; return false;
} }
led->indicator = rtrn.uval; led->indicator = rtrn.uval;
led->defs.defined |= _LED_Index; led->defs.defined |= _LED_Index;
} }
else else {
{
ERROR("Unknown field %s in map for %s indicator\n", field, ERROR("Unknown field %s in map for %s indicator\n", field,
xkb_atom_text(keymap->ctx, led->name)); xkb_atom_text(keymap->ctx, led->name));
ACTION("Definition ignored\n"); ACTION("Definition ignored\n");
ok = false; ok = false;
} }
@ -327,33 +304,28 @@ HandleIndicatorMapDef(IndicatorMapDef *def, struct xkb_keymap *keymap,
led.name = def->name; led.name = def->name;
ok = true; ok = true;
for (var = def->body; var != NULL; var = (VarDef *) var->common.next) for (var = def->body; var != NULL; var = (VarDef *) var->common.next) {
{
ExprResult elem, field; ExprResult elem, field;
ExprDef *arrayNdx; ExprDef *arrayNdx;
if (!ExprResolveLhs(keymap, var->name, &elem, &field, &arrayNdx)) if (!ExprResolveLhs(keymap, var->name, &elem, &field, &arrayNdx)) {
{
ok = false; ok = false;
continue; continue;
} }
if (elem.str != NULL) if (elem.str != NULL) {
{
ERROR ERROR
("Cannot set defaults for \"%s\" element in indicator map\n", ("Cannot set defaults for \"%s\" element in indicator map\n",
elem.str); elem.str);
ACTION("Assignment to %s.%s ignored\n", elem.str, field.str); ACTION("Assignment to %s.%s ignored\n", elem.str, field.str);
ok = false; ok = false;
} }
else else {
{
ok = SetIndicatorMapField(&led, keymap, field.str, arrayNdx, ok = SetIndicatorMapField(&led, keymap, field.str, arrayNdx,
var->value) && ok; var->value) && ok;
} }
free(elem.str); free(elem.str);
free(field.str); free(field.str);
} }
if (ok) if (ok) {
{
rtrn = AddIndicatorMap(keymap, oldLEDs, &led); rtrn = AddIndicatorMap(keymap, oldLEDs, &led);
return rtrn; return rtrn;
} }
@ -366,74 +338,60 @@ BindIndicators(struct xkb_keymap *keymap, LEDInfo *unbound)
int i; int i;
LEDInfo *led, *next, *last; LEDInfo *led, *next, *last;
if (keymap->names != NULL) if (keymap->names != NULL) {
{ for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) if (led->indicator == _LED_NotBound) {
{ for (i = 0; i < XkbNumIndicators; i++) {
if (led->indicator == _LED_NotBound)
{
for (i = 0; i < XkbNumIndicators; i++)
{
if (keymap->names->indicators[i] && if (keymap->names->indicators[i] &&
strcmp(keymap->names->indicators[i], strcmp(keymap->names->indicators[i],
xkb_atom_text(keymap->ctx, led->name)) == 0) xkb_atom_text(keymap->ctx, led->name)) == 0) {
{
led->indicator = i + 1; led->indicator = i + 1;
break; break;
} }
} }
} }
} }
for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
{ if (led->indicator == _LED_NotBound) {
if (led->indicator == _LED_NotBound) for (i = 0; i < XkbNumIndicators; i++) {
{ if (keymap->names->indicators[i] == NULL) {
for (i = 0; i < XkbNumIndicators; i++)
{
if (keymap->names->indicators[i] == NULL)
{
keymap->names->indicators[i] = keymap->names->indicators[i] =
xkb_atom_strdup(keymap->ctx, led->name); xkb_atom_strdup(keymap->ctx, led->name);
led->indicator = i + 1; led->indicator = i + 1;
break; break;
} }
} }
if (led->indicator == _LED_NotBound) if (led->indicator == _LED_NotBound) {
{
ERROR("No unnamed indicators found\n"); ERROR("No unnamed indicators found\n");
ACTION ACTION
("Virtual indicator map \"%s\" not bound\n", ("Virtual indicator map \"%s\" not bound\n",
xkb_atom_text(keymap->ctx, led->name)); xkb_atom_text(keymap->ctx, led->name));
continue; continue;
} }
} }
} }
} }
for (last = NULL, led = unbound; led != NULL; led = next) for (last = NULL, led = unbound; led != NULL; led = next) {
{
next = (LEDInfo *) led->defs.next; next = (LEDInfo *) led->defs.next;
if (led->indicator == _LED_NotBound) if (led->indicator == _LED_NotBound) {
{
unbound = next; unbound = next;
free(led); free(led);
} }
else else {
{
if ((keymap->names != NULL) && if ((keymap->names != NULL) &&
(strcmp(keymap->names->indicators[led->indicator - 1], (strcmp(keymap->names->indicators[led->indicator - 1],
xkb_atom_text(keymap->ctx, led->name)) != 0)) xkb_atom_text(keymap->ctx, led->name)) != 0)) {
{ const char *old =
const char *old = keymap->names->indicators[led->indicator - 1]; keymap->names->indicators[led->indicator - 1];
ERROR("Multiple names bound to indicator %d\n", ERROR("Multiple names bound to indicator %d\n",
(unsigned int) led->indicator); (unsigned int) led->indicator);
ACTION("Using %s, ignoring %s\n", old, ACTION("Using %s, ignoring %s\n", old,
xkb_atom_text(keymap->ctx, led->name)); xkb_atom_text(keymap->ctx, led->name));
led->indicator = _LED_NotBound; led->indicator = _LED_NotBound;
unbound = next; unbound = next;
free(led); free(led);
} }
else else {
{
struct xkb_indicator_map * map; struct xkb_indicator_map * map;
map = &keymap->indicators->maps[led->indicator - 1]; map = &keymap->indicators->maps[led->indicator - 1];
map->flags = led->flags; map->flags = led->flags;
@ -454,8 +412,7 @@ BindIndicators(struct xkb_keymap *keymap, LEDInfo *unbound)
} }
} }
for (led = unbound; led != NULL; led = next) for (led = unbound; led != NULL; led = next) {
{
next = led ? (LEDInfo *) led->defs.next : NULL; next = led ? (LEDInfo *) led->defs.next : NULL;
free(led); free(led);
} }
@ -467,26 +424,22 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
LEDInfo *led, *next; LEDInfo *led, *next;
LEDInfo *unbound = NULL, *last = NULL; LEDInfo *unbound = NULL, *last = NULL;
if (XkbcAllocNames(keymap, XkbIndicatorNamesMask, 0) != Success) if (XkbcAllocNames(keymap, XkbIndicatorNamesMask, 0) != Success) {
{
WSGO("Couldn't allocate names\n"); WSGO("Couldn't allocate names\n");
ACTION("Indicator names may be incorrect\n"); ACTION("Indicator names may be incorrect\n");
} }
if (XkbcAllocIndicatorMaps(keymap) != Success) if (XkbcAllocIndicatorMaps(keymap) != Success) {
{
WSGO("Can't allocate indicator maps\n"); WSGO("Can't allocate indicator maps\n");
ACTION("Indicator map definitions may be lost\n"); ACTION("Indicator map definitions may be lost\n");
return false; return false;
} }
for (led = leds; led != NULL; led = next) for (led = leds; led != NULL; led = next) {
{
next = (LEDInfo *) led->defs.next; next = (LEDInfo *) led->defs.next;
if ((led->groups != 0) && (led->which_groups == 0)) if ((led->groups != 0) && (led->which_groups == 0))
led->which_groups = XkbIM_UseEffective; led->which_groups = XkbIM_UseEffective;
if ((led->which_mods == 0) && ((led->real_mods) || (led->vmods))) if ((led->which_mods == 0) && ((led->real_mods) || (led->vmods)))
led->which_mods = XkbIM_UseEffective; led->which_mods = XkbIM_UseEffective;
if ((led->indicator == _LED_NotBound) || (!keymap->indicators)) if ((led->indicator == _LED_NotBound) || (!keymap->indicators)) {
{
led->defs.next = NULL; led->defs.next = NULL;
if (last != NULL) if (last != NULL)
last->defs.next = (CommonInfo *) led; last->defs.next = (CommonInfo *) led;
@ -494,8 +447,7 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
unbound = led; unbound = led;
last = led; last = led;
} }
else else {
{
struct xkb_indicator_map * im; struct xkb_indicator_map * im;
im = &keymap->indicators->maps[led->indicator - 1]; im = &keymap->indicators->maps[led->indicator - 1];
im->flags = led->flags; im->flags = led->flags;
@ -506,10 +458,9 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
im->mods.real_mods = led->real_mods; im->mods.real_mods = led->real_mods;
im->mods.vmods = led->vmods; im->mods.vmods = led->vmods;
im->ctrls = led->ctrls; im->ctrls = led->ctrls;
if (keymap->names != NULL) if (keymap->names != NULL) {
{
free(keymap->names->indicators[led->indicator - 1]); free(keymap->names->indicators[led->indicator - 1]);
keymap->names->indicators[led->indicator-1] = keymap->names->indicators[led->indicator - 1] =
xkb_atom_strdup(keymap->ctx, led->name); xkb_atom_strdup(keymap->ctx, led->name);
} }
free(led); free(led);

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef INDICATORS_H #ifndef INDICATORS_H
@ -29,18 +29,17 @@
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
#define _LED_Index (1<<0) #define _LED_Index (1 << 0)
#define _LED_Mods (1<<1) #define _LED_Mods (1 << 1)
#define _LED_Groups (1<<2) #define _LED_Groups (1 << 2)
#define _LED_Ctrls (1<<3) #define _LED_Ctrls (1 << 3)
#define _LED_Explicit (1<<4) #define _LED_Explicit (1 << 4)
#define _LED_Automatic (1<<5) #define _LED_Automatic (1 << 5)
#define _LED_DrivesKbd (1<<6) #define _LED_DrivesKbd (1 << 6)
#define _LED_NotBound 255 #define _LED_NotBound 255
typedef struct _LEDInfo typedef struct _LEDInfo {
{
CommonInfo defs; CommonInfo defs;
xkb_atom_t name; xkb_atom_t name;
unsigned char indicator; unsigned char indicator;
@ -56,17 +55,18 @@ typedef struct _LEDInfo
extern void extern void
ClearIndicatorMapInfo(struct xkb_context *ctx, LEDInfo *info); ClearIndicatorMapInfo(struct xkb_context *ctx, LEDInfo *info);
extern LEDInfo * extern LEDInfo *
AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *newLED); AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *newLED);
extern int extern int
SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap, char *field, SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap, char *field,
ExprDef *arrayNdx, ExprDef *value); ExprDef *arrayNdx,
ExprDef *value);
extern LEDInfo * extern LEDInfo *
HandleIndicatorMapDef(IndicatorMapDef *stmt, struct xkb_keymap *keymap, HandleIndicatorMapDef(IndicatorMapDef *stmt, struct xkb_keymap *keymap,
LEDInfo *dflt, LEDInfo *oldLEDs, enum merge_mode mergeMode); LEDInfo *dflt, LEDInfo *oldLEDs,
enum merge_mode mergeMode);
extern bool extern bool
CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds); CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds);

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "keycodes.h" #include "keycodes.h"
@ -51,16 +51,14 @@ LongToKeyName(unsigned long val, char *name)
/***====================================================================***/ /***====================================================================***/
typedef struct _IndicatorNameInfo typedef struct _IndicatorNameInfo {
{
CommonInfo defs; CommonInfo defs;
int ndx; int ndx;
xkb_atom_t name; xkb_atom_t name;
bool virtual; bool virtual;
} IndicatorNameInfo; } IndicatorNameInfo;
typedef struct _KeyNamesInfo typedef struct _KeyNamesInfo {
{
char *name; /* e.g. evdev+aliases(qwerty) */ char *name; /* e.g. evdev+aliases(qwerty) */
int errorCount; int errorCount;
unsigned file_id; unsigned file_id;
@ -75,8 +73,10 @@ typedef struct _KeyNamesInfo
AliasInfo *aliases; AliasInfo *aliases;
} KeyNamesInfo; } KeyNamesInfo;
static void HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap, static void
enum merge_mode merge, KeyNamesInfo *info); HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge,
KeyNamesInfo *info);
static void static void
ResizeKeyNameArrays(KeyNamesInfo *info, int newMax) ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
@ -103,8 +103,7 @@ InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
static void static void
ClearIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info) ClearIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
{ {
if (ii == info->leds) if (ii == info->leds) {
{
ClearCommonInfo(&ii->defs); ClearCommonInfo(&ii->defs);
info->leds = NULL; info->leds = NULL;
} }
@ -116,8 +115,7 @@ NextIndicatorName(KeyNamesInfo * info)
IndicatorNameInfo *ii; IndicatorNameInfo *ii;
ii = uTypedAlloc(IndicatorNameInfo); ii = uTypedAlloc(IndicatorNameInfo);
if (ii) if (ii) {
{
InitIndicatorNameInfo(ii, info); InitIndicatorNameInfo(ii, info);
info->leds = AddCommonInfo(&info->leds->defs, &ii->defs); info->leds = AddCommonInfo(&info->leds->defs, &ii->defs);
} }
@ -130,8 +128,7 @@ FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
IndicatorNameInfo *old; IndicatorNameInfo *old;
for (old = info->leds; old != NULL; for (old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next) old = (IndicatorNameInfo *) old->defs.next) {
{
if (old->ndx == ndx) if (old->ndx == ndx)
return old; return old;
} }
@ -144,8 +141,7 @@ FindIndicatorByName(KeyNamesInfo * info, xkb_atom_t name)
IndicatorNameInfo *old; IndicatorNameInfo *old;
for (old = info->leds; old != NULL; for (old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next) old = (IndicatorNameInfo *) old->defs.next) {
{
if (old->name == name) if (old->name == name)
return old; return old;
} }
@ -153,7 +149,8 @@ FindIndicatorByName(KeyNamesInfo * info, xkb_atom_t name)
} }
static bool static bool
AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode merge, AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap,
enum merge_mode merge,
IndicatorNameInfo *new) IndicatorNameInfo *new)
{ {
IndicatorNameInfo *old; IndicatorNameInfo *old;
@ -161,49 +158,39 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE); replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE);
old = FindIndicatorByName(info, new->name); old = FindIndicatorByName(info, new->name);
if (old) if (old) {
{
if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0)) if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
|| (warningLevel > 9)) || (warningLevel > 9)) {
{
WARN("Multiple indicators named %s\n", WARN("Multiple indicators named %s\n",
xkb_atom_text(keymap->ctx, new->name)); xkb_atom_text(keymap->ctx, new->name));
if (old->ndx == new->ndx) if (old->ndx == new->ndx) {
{ if (old->virtual != new->virtual) {
if (old->virtual != new->virtual)
{
if (replace) if (replace)
old->virtual = new->virtual; old->virtual = new->virtual;
ACTION("Using %s instead of %s\n", ACTION("Using %s instead of %s\n",
(old->virtual ? "virtual" : "real"), (old->virtual ? "virtual" : "real"),
(old->virtual ? "real" : "virtual")); (old->virtual ? "real" : "virtual"));
} }
else else {
{
ACTION("Identical definitions ignored\n"); ACTION("Identical definitions ignored\n");
} }
return true; return true;
} }
else else {
{
if (replace) if (replace)
ACTION("Ignoring %d, using %d\n", old->ndx, new->ndx); ACTION("Ignoring %d, using %d\n", old->ndx, new->ndx);
else else
ACTION("Using %d, ignoring %d\n", old->ndx, new->ndx); ACTION("Using %d, ignoring %d\n", old->ndx, new->ndx);
} }
if (replace) if (replace) {
{
if (info->leds == old) if (info->leds == old)
info->leds = (IndicatorNameInfo *) old->defs.next; info->leds = (IndicatorNameInfo *) old->defs.next;
else else {
{
IndicatorNameInfo *tmp; IndicatorNameInfo *tmp;
tmp = info->leds; tmp = info->leds;
for (; tmp != NULL; for (; tmp != NULL;
tmp = (IndicatorNameInfo *) tmp->defs.next) tmp = (IndicatorNameInfo *) tmp->defs.next) {
{ if (tmp->defs.next == (CommonInfo *) old) {
if (tmp->defs.next == (CommonInfo *) old)
{
tmp->defs.next = old->defs.next; tmp->defs.next = old->defs.next;
break; break;
} }
@ -214,16 +201,13 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
} }
} }
old = FindIndicatorByIndex(info, new->ndx); old = FindIndicatorByIndex(info, new->ndx);
if (old) if (old) {
{
if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0)) if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
|| (warningLevel > 9)) || (warningLevel > 9)) {
{
WARN("Multiple names for indicator %d\n", new->ndx); WARN("Multiple names for indicator %d\n", new->ndx);
if ((old->name == new->name) && (old->virtual == new->virtual)) if ((old->name == new->name) && (old->virtual == new->virtual))
ACTION("Identical definitions ignored\n"); ACTION("Identical definitions ignored\n");
else else {
{
const char *oldType, *newType; const char *oldType, *newType;
xkb_atom_t using, ignoring; xkb_atom_t using, ignoring;
if (old->virtual) if (old->virtual)
@ -234,23 +218,20 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
newType = "virtual indicator"; newType = "virtual indicator";
else else
newType = "real indicator"; newType = "real indicator";
if (replace) if (replace) {
{
using = new->name; using = new->name;
ignoring = old->name; ignoring = old->name;
} }
else else {
{
using = old->name; using = old->name;
ignoring = new->name; ignoring = new->name;
} }
ACTION("Using %s %s, ignoring %s %s\n", ACTION("Using %s %s, ignoring %s %s\n",
oldType, xkb_atom_text(keymap->ctx, using), oldType, xkb_atom_text(keymap->ctx, using),
newType, xkb_atom_text(keymap->ctx, ignoring)); newType, xkb_atom_text(keymap->ctx, ignoring));
} }
} }
if (replace) if (replace) {
{
old->name = new->name; old->name = new->name;
old->virtual = new->virtual; old->virtual = new->virtual;
} }
@ -258,8 +239,7 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
} }
old = new; old = new;
new = NextIndicatorName(info); new = NextIndicatorName(info);
if (!new) if (!new) {
{
WSGO("Couldn't allocate name for indicator %d\n", old->ndx); WSGO("Couldn't allocate name for indicator %d\n", old->ndx);
ACTION("Ignored\n"); ACTION("Ignored\n");
return false; return false;
@ -331,39 +311,32 @@ AddKeyName(KeyNamesInfo * info,
info->computedMax = kc; info->computedMax = kc;
lval = KeyNameToLong(name); lval = KeyNameToLong(name);
if (reportCollisions) if (reportCollisions) {
{
reportCollisions = (warningLevel > 7 || reportCollisions = (warningLevel > 7 ||
(warningLevel > 0 && (warningLevel > 0 &&
file_id == darray_item(info->files, kc))); file_id == darray_item(info->files, kc)));
} }
if (darray_item(info->names, kc) != 0) if (darray_item(info->names, kc) != 0) {
{
char buf[6]; char buf[6];
LongToKeyName(darray_item(info->names, kc), buf); LongToKeyName(darray_item(info->names, kc), buf);
buf[4] = '\0'; buf[4] = '\0';
if (darray_item(info->names, kc) == lval && reportCollisions) if (darray_item(info->names, kc) == lval && reportCollisions) {
{
WARN("Multiple identical key name definitions\n"); WARN("Multiple identical key name definitions\n");
ACTION("Later occurences of \"<%s> = %d\" ignored\n", ACTION("Later occurences of \"<%s> = %d\" ignored\n",
buf, kc); buf, kc);
return true; return true;
} }
if (merge == MERGE_AUGMENT) if (merge == MERGE_AUGMENT) {
{ if (reportCollisions) {
if (reportCollisions)
{
WARN("Multiple names for keycode %d\n", kc); WARN("Multiple names for keycode %d\n", kc);
ACTION("Using <%s>, ignoring <%s>\n", buf, name); ACTION("Using <%s>, ignoring <%s>\n", buf, name);
} }
return true; return true;
} }
else else {
{ if (reportCollisions) {
if (reportCollisions)
{
WARN("Multiple names for keycode %d\n", kc); WARN("Multiple names for keycode %d\n", kc);
ACTION("Using <%s>, ignoring <%s>\n", name, buf); ACTION("Using <%s>, ignoring <%s>\n", name, buf);
} }
@ -372,22 +345,17 @@ AddKeyName(KeyNamesInfo * info,
} }
} }
old = FindKeyByLong(info, lval); old = FindKeyByLong(info, lval);
if ((old != 0) && (old != kc)) if ((old != 0) && (old != kc)) {
{ if (merge == MERGE_OVERRIDE) {
if (merge == MERGE_OVERRIDE)
{
darray_item(info->names, old) = 0; darray_item(info->names, old) = 0;
darray_item(info->files, old) = 0; darray_item(info->files, old) = 0;
if (reportCollisions) if (reportCollisions) {
{
WARN("Key name <%s> assigned to multiple keys\n", name); WARN("Key name <%s> assigned to multiple keys\n", name);
ACTION("Using %d, ignoring %d\n", kc, old); ACTION("Using %d, ignoring %d\n", kc, old);
} }
} }
else else {
{ if ((reportCollisions) && (warningLevel > 3)) {
if ((reportCollisions) && (warningLevel > 3))
{
WARN("Key name <%s> assigned to multiple keys\n", name); WARN("Key name <%s> assigned to multiple keys\n", name);
ACTION("Using %d, ignoring %d\n", old, kc); ACTION("Using %d, ignoring %d\n", old, kc);
} }
@ -408,21 +376,18 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
uint64_t i; uint64_t i;
char buf[5]; char buf[5];
if (from->errorCount > 0) if (from->errorCount > 0) {
{
into->errorCount += from->errorCount; into->errorCount += from->errorCount;
return; return;
} }
if (into->name == NULL) if (into->name == NULL) {
{
into->name = from->name; into->name = from->name;
from->name = NULL; from->name = NULL;
} }
ResizeKeyNameArrays(into, from->computedMax); ResizeKeyNameArrays(into, from->computedMax);
for (i = from->computedMin; i <= from->computedMax; i++) for (i = from->computedMin; i <= from->computedMax; i++) {
{
if (darray_item(from->names, i) == 0) if (darray_item(from->names, i) == 0)
continue; continue;
LongToKeyName(darray_item(from->names, i), buf); LongToKeyName(darray_item(from->names, i), buf);
@ -430,11 +395,9 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
if (!AddKeyName(into, i, buf, merge, from->file_id, false)) if (!AddKeyName(into, i, buf, merge, from->file_id, false))
into->errorCount++; into->errorCount++;
} }
if (from->leds) if (from->leds) {
{
IndicatorNameInfo *led, *next; IndicatorNameInfo *led, *next;
for (led = from->leds; led != NULL; led = next) for (led = from->leds; led != NULL; led = next) {
{
if (merge != MERGE_DEFAULT) if (merge != MERGE_DEFAULT)
led->defs.merge = merge; led->defs.merge = merge;
if (!AddIndicatorName(into, keymap, led->defs.merge, led)) if (!AddIndicatorName(into, keymap, led->defs.merge, led))
@ -444,14 +407,12 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
} }
if (!MergeAliases(&into->aliases, &from->aliases, merge)) if (!MergeAliases(&into->aliases, &from->aliases, merge))
into->errorCount++; into->errorCount++;
if (from->explicitMin != 0) if (from->explicitMin != 0) {
{
if ((into->explicitMin == 0) if ((into->explicitMin == 0)
|| (into->explicitMin > from->explicitMin)) || (into->explicitMin > from->explicitMin))
into->explicitMin = from->explicitMin; into->explicitMin = from->explicitMin;
} }
if (from->explicitMax > 0) if (from->explicitMax > 0) {
{
if ((into->explicitMax == 0) if ((into->explicitMax == 0)
|| (into->explicitMax < from->explicitMax)) || (into->explicitMax < from->explicitMax))
into->explicitMax = from->explicitMax; into->explicitMax = from->explicitMax;
@ -477,63 +438,53 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
memset(&included, 0, sizeof(included)); memset(&included, 0, sizeof(included));
haveSelf = false; haveSelf = false;
if ((stmt->file == NULL) && (stmt->map == NULL)) if ((stmt->file == NULL) && (stmt->map == NULL)) {
{
haveSelf = true; haveSelf = true;
included = *info; included = *info;
memset(info, 0, sizeof(KeyNamesInfo)); memset(info, 0, sizeof(KeyNamesInfo));
} }
else if (stmt->file && strcmp(stmt->file, "computed") == 0) else if (stmt->file && strcmp(stmt->file, "computed") == 0) {
{
keymap->flags |= AutoKeyNames; keymap->flags |= AutoKeyNames;
info->explicitMin = 0; info->explicitMin = 0;
info->explicitMax = XKB_KEYCODE_MAX; info->explicitMax = XKB_KEYCODE_MAX;
return (info->errorCount == 0); return (info->errorCount == 0);
} /* parse file, store returned info in the xkb struct */ } /* parse file, store returned info in the xkb struct */
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn, else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn,
&newMerge)) &newMerge)) {
{
InitKeyNamesInfo(&included, rtrn->id); InitKeyNamesInfo(&included, rtrn->id);
HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included); HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included);
if (stmt->stmt != NULL) if (stmt->stmt != NULL) {
{
free(included.name); free(included.name);
included.name = stmt->stmt; included.name = stmt->stmt;
stmt->stmt = NULL; stmt->stmt = NULL;
} }
FreeXKBFile(rtrn); FreeXKBFile(rtrn);
} }
else else {
{
info->errorCount += 10; /* XXX: why 10?? */ info->errorCount += 10; /* XXX: why 10?? */
return false; return false;
} }
/* Do we have more than one include statement? */ /* Do we have more than one include statement? */
if ((stmt->next != NULL) && (included.errorCount < 1)) if ((stmt->next != NULL) && (included.errorCount < 1)) {
{
IncludeStmt *next; IncludeStmt *next;
unsigned op; unsigned op;
KeyNamesInfo next_incl; KeyNamesInfo next_incl;
for (next = stmt->next; next != NULL; next = next->next) for (next = stmt->next; next != NULL; next = next->next) {
{ if ((next->file == NULL) && (next->map == NULL)) {
if ((next->file == NULL) && (next->map == NULL))
{
haveSelf = true; haveSelf = true;
MergeIncludedKeycodes(&included, keymap, info, next->merge); MergeIncludedKeycodes(&included, keymap, info, next->merge);
ClearKeyNamesInfo(info); ClearKeyNamesInfo(info);
} }
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES, else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES,
&rtrn, &op)) &rtrn, &op)) {
{
InitKeyNamesInfo(&next_incl, rtrn->id); InitKeyNamesInfo(&next_incl, rtrn->id);
HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl); HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
MergeIncludedKeycodes(&included, keymap, &next_incl, op); MergeIncludedKeycodes(&included, keymap, &next_incl, op);
ClearKeyNamesInfo(&next_incl); ClearKeyNamesInfo(&next_incl);
FreeXKBFile(rtrn); FreeXKBFile(rtrn);
} }
else else {
{
info->errorCount += 10; /* XXX: Why 10?? */ info->errorCount += 10; /* XXX: Why 10?? */
ClearKeyNamesInfo(&included); ClearKeyNamesInfo(&included);
return false; return false;
@ -542,8 +493,7 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
} }
if (haveSelf) if (haveSelf)
*info = included; *info = included;
else else {
{
MergeIncludedKeycodes(info, keymap, &included, newMerge); MergeIncludedKeycodes(info, keymap, &included, newMerge);
ClearKeyNamesInfo(&included); ClearKeyNamesInfo(&included);
} }
@ -558,16 +508,14 @@ static int
HandleKeycodeDef(KeycodeDef *stmt, enum merge_mode merge, KeyNamesInfo *info) HandleKeycodeDef(KeycodeDef *stmt, enum merge_mode merge, KeyNamesInfo *info)
{ {
if ((info->explicitMin != 0 && stmt->value < info->explicitMin) || if ((info->explicitMin != 0 && stmt->value < info->explicitMin) ||
(info->explicitMax != 0 && stmt->value > info->explicitMax)) (info->explicitMax != 0 && stmt->value > info->explicitMax)) {
{
ERROR("Illegal keycode %lu for name <%s>\n", stmt->value, stmt->name); ERROR("Illegal keycode %lu for name <%s>\n", stmt->value, stmt->name);
ACTION("Must be in the range %d-%d inclusive\n", ACTION("Must be in the range %d-%d inclusive\n",
info->explicitMin, info->explicitMin,
info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX); info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
return 0; return 0;
} }
if (stmt->merge != MERGE_DEFAULT) if (stmt->merge != MERGE_DEFAULT) {
{
if (stmt->merge == MERGE_REPLACE) if (stmt->merge == MERGE_REPLACE)
merge = MERGE_OVERRIDE; merge = MERGE_OVERRIDE;
else else
@ -577,8 +525,8 @@ HandleKeycodeDef(KeycodeDef *stmt, enum merge_mode merge, KeyNamesInfo *info)
true); true);
} }
#define MIN_KEYCODE_DEF 0 #define MIN_KEYCODE_DEF 0
#define MAX_KEYCODE_DEF 1 #define MAX_KEYCODE_DEF 1
/** /**
* Handle the minimum/maximum statement of the xkb file. * Handle the minimum/maximum statement of the xkb file.
@ -596,8 +544,7 @@ HandleKeyNameVar(VarDef *stmt, struct xkb_keymap *keymap, KeyNamesInfo *info)
if (ExprResolveLhs(keymap, stmt->name, &tmp, &field, &arrayNdx) == 0) if (ExprResolveLhs(keymap, stmt->name, &tmp, &field, &arrayNdx) == 0)
return 0; /* internal error, already reported */ return 0; /* internal error, already reported */
if (tmp.str != NULL) if (tmp.str != NULL) {
{
ERROR("Unknown element %s encountered\n", tmp.str); ERROR("Unknown element %s encountered\n", tmp.str);
ACTION("Default for field %s ignored\n", field.str); ACTION("Default for field %s ignored\n", field.str);
goto err_out; goto err_out;
@ -606,66 +553,56 @@ HandleKeyNameVar(VarDef *stmt, struct xkb_keymap *keymap, KeyNamesInfo *info)
which = MIN_KEYCODE_DEF; which = MIN_KEYCODE_DEF;
else if (strcasecmp(field.str, "maximum") == 0) else if (strcasecmp(field.str, "maximum") == 0)
which = MAX_KEYCODE_DEF; which = MAX_KEYCODE_DEF;
else else {
{
ERROR("Unknown field encountered\n"); ERROR("Unknown field encountered\n");
ACTION("Assigment to field %s ignored\n", field.str); ACTION("Assigment to field %s ignored\n", field.str);
goto err_out; goto err_out;
} }
if (arrayNdx != NULL) if (arrayNdx != NULL) {
{
ERROR("The %s setting is not an array\n", field.str); ERROR("The %s setting is not an array\n", field.str);
ACTION("Illegal array reference ignored\n"); ACTION("Illegal array reference ignored\n");
goto err_out; goto err_out;
} }
if (ExprResolveKeyCode(keymap->ctx, stmt->value, &tmp) == 0) if (ExprResolveKeyCode(keymap->ctx, stmt->value, &tmp) == 0) {
{
ACTION("Assignment to field %s ignored\n", field.str); ACTION("Assignment to field %s ignored\n", field.str);
goto err_out; goto err_out;
} }
if (tmp.uval > XKB_KEYCODE_MAX) if (tmp.uval > XKB_KEYCODE_MAX) {
{
ERROR ERROR
("Illegal keycode %d (must be in the range %d-%d inclusive)\n", ("Illegal keycode %d (must be in the range %d-%d inclusive)\n",
tmp.uval, 0, XKB_KEYCODE_MAX); tmp.uval, 0, XKB_KEYCODE_MAX);
ACTION("Value of \"%s\" not changed\n", field.str); ACTION("Value of \"%s\" not changed\n", field.str);
goto err_out; goto err_out;
} }
if (which == MIN_KEYCODE_DEF) if (which == MIN_KEYCODE_DEF) {
{ if ((info->explicitMax > 0) && (info->explicitMax < tmp.uval)) {
if ((info->explicitMax > 0) && (info->explicitMax < tmp.uval))
{
ERROR ERROR
("Minimum key code (%d) must be <= maximum key code (%d)\n", ("Minimum key code (%d) must be <= maximum key code (%d)\n",
tmp.uval, info->explicitMax); tmp.uval, info->explicitMax);
ACTION("Minimum key code value not changed\n"); ACTION("Minimum key code value not changed\n");
goto err_out; goto err_out;
} }
if ((info->computedMax > 0) && (info->computedMin < tmp.uval)) if ((info->computedMax > 0) && (info->computedMin < tmp.uval)) {
{
ERROR ERROR
("Minimum key code (%d) must be <= lowest defined key (%d)\n", ("Minimum key code (%d) must be <= lowest defined key (%d)\n",
tmp.uval, info->computedMin); tmp.uval, info->computedMin);
ACTION("Minimum key code value not changed\n"); ACTION("Minimum key code value not changed\n");
goto err_out; goto err_out;
} }
info->explicitMin = tmp.uval; info->explicitMin = tmp.uval;
} }
if (which == MAX_KEYCODE_DEF) if (which == MAX_KEYCODE_DEF) {
{ if ((info->explicitMin > 0) && (info->explicitMin > tmp.uval)) {
if ((info->explicitMin > 0) && (info->explicitMin > tmp.uval))
{
ERROR("Maximum code (%d) must be >= minimum key code (%d)\n", ERROR("Maximum code (%d) must be >= minimum key code (%d)\n",
tmp.uval, info->explicitMin); tmp.uval, info->explicitMin);
ACTION("Maximum code value not changed\n"); ACTION("Maximum code value not changed\n");
goto err_out; goto err_out;
} }
if ((info->computedMax > 0) && (info->computedMax > tmp.uval)) if ((info->computedMax > 0) && (info->computedMax > tmp.uval)) {
{
ERROR ERROR
("Maximum code (%d) must be >= highest defined key (%d)\n", ("Maximum code (%d) must be >= highest defined key (%d)\n",
tmp.uval, info->computedMax); tmp.uval, info->computedMax);
ACTION("Maximum code value not changed\n"); ACTION("Maximum code value not changed\n");
goto err_out; goto err_out;
} }
@ -687,8 +624,7 @@ HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
IndicatorNameInfo ii; IndicatorNameInfo ii;
ExprResult tmp; ExprResult tmp;
if ((def->ndx < 1) || (def->ndx > XkbNumIndicators)) if ((def->ndx < 1) || (def->ndx > XkbNumIndicators)) {
{
info->errorCount++; info->errorCount++;
ERROR("Name specified for illegal indicator index %d\n", def->ndx); ERROR("Name specified for illegal indicator index %d\n", def->ndx);
ACTION("Ignored\n"); ACTION("Ignored\n");
@ -696,8 +632,7 @@ HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
} }
InitIndicatorNameInfo(&ii, info); InitIndicatorNameInfo(&ii, info);
ii.ndx = def->ndx; ii.ndx = def->ndx;
if (!ExprResolveString(keymap->ctx, def->name, &tmp)) if (!ExprResolveString(keymap->ctx, def->name, &tmp)) {
{
char buf[20]; char buf[20];
snprintf(buf, sizeof(buf), "%d", def->ndx); snprintf(buf, sizeof(buf), "%d", def->ndx);
info->errorCount++; info->errorCount++;
@ -735,8 +670,7 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
stmt = file->defs; stmt = file->defs;
while (stmt) while (stmt)
{ {
switch (stmt->stmtType) switch (stmt->stmtType) {
{
case StmtInclude: /* e.g. include "evdev+aliases(qwerty)" */ case StmtInclude: /* e.g. include "evdev+aliases(qwerty)" */
if (!HandleIncludeKeycodes((IncludeStmt *) stmt, keymap, info)) if (!HandleIncludeKeycodes((IncludeStmt *) stmt, keymap, info))
info->errorCount++; info->errorCount++;
@ -763,19 +697,18 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
case StmtVModDef: case StmtVModDef:
ERROR("Keycode files may define key and indicator names only\n"); ERROR("Keycode files may define key and indicator names only\n");
ACTION("Ignoring definition of %s\n", ACTION("Ignoring definition of %s\n",
((stmt->stmtType == ((stmt->stmtType ==
StmtInterpDef) ? "a symbol interpretation" : StmtInterpDef) ? "a symbol interpretation" :
"virtual modifiers")); "virtual modifiers"));
info->errorCount++; info->errorCount++;
break; break;
default: default:
WSGO("Unexpected statement type %d in HandleKeycodesFile\n", WSGO("Unexpected statement type %d in HandleKeycodesFile\n",
stmt->stmtType); stmt->stmtType);
break; break;
} }
stmt = stmt->next; stmt = stmt->next;
if (info->errorCount > 10) if (info->errorCount > 10) {
{
#ifdef NOISY #ifdef NOISY
ERROR("Too many errors\n"); ERROR("Too many errors\n");
#endif #endif
@ -796,7 +729,8 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
* @return true on success, false otherwise. * @return true on success, false otherwise.
*/ */
bool bool
CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge)
{ {
KeyNamesInfo info; /* contains all the info after parsing */ KeyNamesInfo info; /* contains all the info after parsing */
@ -827,7 +761,8 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
darray_item(keymap->names->keys, i).name); darray_item(keymap->names->keys, i).name);
if (info.name) if (info.name)
keymap->names->keycodes = strdup(info.name); keymap->names->keycodes = strdup(info.name);
} else { }
else {
WSGO("Cannot create struct xkb_names in CompileKeycodes\n"); WSGO("Cannot create struct xkb_names in CompileKeycodes\n");
goto err_info; goto err_info;
} }
@ -839,7 +774,7 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
ACTION("Physical indicators not set\n"); ACTION("Physical indicators not set\n");
} }
for (ii = info.leds; ii; ii = (IndicatorNameInfo *)ii->defs.next) { for (ii = info.leds; ii; ii = (IndicatorNameInfo *) ii->defs.next) {
free(keymap->names->indicators[ii->ndx - 1]); free(keymap->names->indicators[ii->ndx - 1]);
keymap->names->indicators[ii->ndx - 1] = keymap->names->indicators[ii->ndx - 1] =
xkb_atom_strdup(keymap->ctx, ii->name); xkb_atom_strdup(keymap->ctx, ii->name);

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef KEYCODES_H #ifndef KEYCODES_H
@ -30,13 +30,14 @@
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
#define KeyNameToLong(n) ( \ #define KeyNameToLong(n) ( \
(((unsigned long)n[0]) << 24) | \ (((unsigned long) n[0]) << 24) | \
(((unsigned long)n[1]) << 16) | \ (((unsigned long) n[1]) << 16) | \
(((unsigned long)n[2]) << 8) | \ (((unsigned long) n[2]) << 8) | \
(((unsigned long)n[3]) << 0)) (((unsigned long) n[3]) << 0))
extern const extern const
char *longText(unsigned long val); char *
longText(unsigned long val);
extern void extern void
LongToKeyName(unsigned long val, char *name_rtrn); LongToKeyName(unsigned long val, char *name_rtrn);

View File

@ -1,35 +1,34 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
#include "parseutils.h" #include "parseutils.h"
#include "vmod.h" #include "vmod.h"
typedef struct _PreserveInfo typedef struct _PreserveInfo {
{
CommonInfo defs; CommonInfo defs;
short matchingMapIndex; short matchingMapIndex;
unsigned char indexMods; unsigned char indexMods;
@ -38,14 +37,13 @@ typedef struct _PreserveInfo
unsigned short preVMods; unsigned short preVMods;
} PreserveInfo; } PreserveInfo;
#define _KT_Name (1<<0) #define _KT_Name (1 << 0)
#define _KT_Mask (1<<1) #define _KT_Mask (1 << 1)
#define _KT_Map (1<<2) #define _KT_Map (1 << 2)
#define _KT_Preserve (1<<3) #define _KT_Preserve (1 << 3)
#define _KT_LevelNames (1<<4) #define _KT_LevelNames (1 << 4)
typedef struct _KeyTypeInfo typedef struct _KeyTypeInfo {
{
CommonInfo defs; CommonInfo defs;
xkb_atom_t name; xkb_atom_t name;
unsigned file_id; unsigned file_id;
@ -58,8 +56,7 @@ typedef struct _KeyTypeInfo
darray(xkb_atom_t) lvlNames; darray(xkb_atom_t) lvlNames;
} KeyTypeInfo; } KeyTypeInfo;
typedef struct _KeyTypesInfo typedef struct _KeyTypesInfo {
{
char *name; char *name;
int errorCount; int errorCount;
unsigned file_id; unsigned file_id;
@ -124,20 +121,17 @@ InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap,
darray_init(info->dflt.lvlNames); darray_init(info->dflt.lvlNames);
info->dflt.preserve = NULL; info->dflt.preserve = NULL;
InitVModInfo(&info->vmods, keymap); InitVModInfo(&info->vmods, keymap);
if (from != NULL) if (from != NULL) {
{
info->dflt = from->dflt; info->dflt = from->dflt;
darray_copy(info->dflt.entries, from->dflt.entries); darray_copy(info->dflt.entries, from->dflt.entries);
darray_copy(info->dflt.lvlNames, from->dflt.lvlNames); darray_copy(info->dflt.lvlNames, from->dflt.lvlNames);
if (from->dflt.preserve) if (from->dflt.preserve) {
{
PreserveInfo *old, *new, *last; PreserveInfo *old, *new, *last;
last = NULL; last = NULL;
old = from->dflt.preserve; old = from->dflt.preserve;
for (; old; old = (PreserveInfo *) old->defs.next) for (; old; old = (PreserveInfo *) old->defs.next) {
{
new = uTypedAlloc(PreserveInfo); new = uTypedAlloc(PreserveInfo);
if (!new) if (!new)
return; return;
@ -158,8 +152,7 @@ FreeKeyTypeInfo(KeyTypeInfo * type)
{ {
darray_free(type->entries); darray_free(type->entries);
darray_free(type->lvlNames); darray_free(type->lvlNames);
if (type->preserve != NULL) if (type->preserve != NULL) {
{
ClearCommonInfo(&type->preserve->defs); ClearCommonInfo(&type->preserve->defs);
type->preserve = NULL; type->preserve = NULL;
} }
@ -170,11 +163,10 @@ FreeKeyTypesInfo(KeyTypesInfo * info)
{ {
free(info->name); free(info->name);
info->name = NULL; info->name = NULL;
if (info->types) if (info->types) {
{
KeyTypeInfo *type; KeyTypeInfo *type;
for (type = info->types; type; type = (KeyTypeInfo *) type->defs.next) for (type = info->types; type; type =
{ (KeyTypeInfo *) type->defs.next) {
FreeKeyTypeInfo(type); FreeKeyTypeInfo(type);
} }
info->types = ClearCommonInfo(&info->types->defs); info->types = ClearCommonInfo(&info->types->defs);
@ -188,8 +180,7 @@ NextKeyType(KeyTypesInfo * info)
KeyTypeInfo *type; KeyTypeInfo *type;
type = uTypedAlloc(KeyTypeInfo); type = uTypedAlloc(KeyTypeInfo);
if (type != NULL) if (type != NULL) {
{
memset(type, 0, sizeof(KeyTypeInfo)); memset(type, 0, sizeof(KeyTypeInfo));
type->defs.file_id = info->file_id; type->defs.file_id = info->file_id;
info->types = AddCommonInfo(&info->types->defs, &type->defs); info->types = AddCommonInfo(&info->types->defs, &type->defs);
@ -203,8 +194,7 @@ FindMatchingKeyType(KeyTypesInfo * info, KeyTypeInfo * new)
{ {
KeyTypeInfo *old; KeyTypeInfo *old;
for (old = info->types; old; old = (KeyTypeInfo *) old->defs.next) for (old = info->types; old; old = (KeyTypeInfo *) old->defs.next) {
{
if (old->name == new->name) if (old->name == new->name)
return old; return old;
} }
@ -224,30 +214,26 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
{ {
KeyTypeInfo *old; KeyTypeInfo *old;
if (new->name == tok_ONE_LEVEL) if (new->name == tok_ONE_LEVEL) {
{
if (new->numLevels > 1) if (new->numLevels > 1)
return ReportTypeBadWidth("ONE_LEVEL", new->numLevels, 1); return ReportTypeBadWidth("ONE_LEVEL", new->numLevels, 1);
info->stdPresent |= XkbOneLevelMask; info->stdPresent |= XkbOneLevelMask;
} }
else if (new->name == tok_TWO_LEVEL) else if (new->name == tok_TWO_LEVEL) {
{
if (new->numLevels > 2) if (new->numLevels > 2)
return ReportTypeBadWidth("TWO_LEVEL", new->numLevels, 2); return ReportTypeBadWidth("TWO_LEVEL", new->numLevels, 2);
else if (new->numLevels < 2) else if (new->numLevels < 2)
new->numLevels = 2; new->numLevels = 2;
info->stdPresent |= XkbTwoLevelMask; info->stdPresent |= XkbTwoLevelMask;
} }
else if (new->name == tok_ALPHABETIC) else if (new->name == tok_ALPHABETIC) {
{
if (new->numLevels > 2) if (new->numLevels > 2)
return ReportTypeBadWidth("ALPHABETIC", new->numLevels, 2); return ReportTypeBadWidth("ALPHABETIC", new->numLevels, 2);
else if (new->numLevels < 2) else if (new->numLevels < 2)
new->numLevels = 2; new->numLevels = 2;
info->stdPresent |= XkbAlphabeticMask; info->stdPresent |= XkbAlphabeticMask;
} }
else if (new->name == tok_KEYPAD) else if (new->name == tok_KEYPAD) {
{
if (new->numLevels > 2) if (new->numLevels > 2)
return ReportTypeBadWidth("KEYPAD", new->numLevels, 2); return ReportTypeBadWidth("KEYPAD", new->numLevels, 2);
else if (new->numLevels < 2) else if (new->numLevels < 2)
@ -256,16 +242,13 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
} }
old = FindMatchingKeyType(info, new); old = FindMatchingKeyType(info, new);
if (old != NULL) if (old != NULL) {
{
bool report; bool report;
if ((new->defs.merge == MERGE_REPLACE) if ((new->defs.merge == MERGE_REPLACE)
|| (new->defs.merge == MERGE_OVERRIDE)) || (new->defs.merge == MERGE_OVERRIDE)) {
{
KeyTypeInfo *next = (KeyTypeInfo *) old->defs.next; KeyTypeInfo *next = (KeyTypeInfo *) old->defs.next;
if (((old->defs.file_id == new->defs.file_id) if (((old->defs.file_id == new->defs.file_id)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9)) {
{
WARN("Multiple definitions of the %s key type\n", WARN("Multiple definitions of the %s key type\n",
xkb_atom_text(keymap->ctx, new->name)); xkb_atom_text(keymap->ctx, new->name));
ACTION("Earlier definition ignored\n"); ACTION("Earlier definition ignored\n");
@ -278,9 +261,9 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
old->defs.next = &next->defs; old->defs.next = &next->defs;
return true; return true;
} }
report = (old->defs.file_id == new->defs.file_id) && (warningLevel > 0); report = (old->defs.file_id == new->defs.file_id) &&
if (report) (warningLevel > 0);
{ if (report) {
WARN("Multiple definitions of the %s key type\n", WARN("Multiple definitions of the %s key type\n",
xkb_atom_text(keymap->ctx, new->name)); xkb_atom_text(keymap->ctx, new->name));
ACTION("Later definition ignored\n"); ACTION("Later definition ignored\n");
@ -307,18 +290,15 @@ MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from,
{ {
KeyTypeInfo *type; KeyTypeInfo *type;
if (from->errorCount > 0) if (from->errorCount > 0) {
{
into->errorCount += from->errorCount; into->errorCount += from->errorCount;
return; return;
} }
if (into->name == NULL) if (into->name == NULL) {
{
into->name = from->name; into->name = from->name;
from->name = NULL; from->name = NULL;
} }
for (type = from->types; type; type = (KeyTypeInfo *) type->defs.next) for (type = from->types; type; type = (KeyTypeInfo *) type->defs.next) {
{
if (merge != MERGE_DEFAULT) if (merge != MERGE_DEFAULT)
type->defs.merge = merge; type->defs.merge = merge;
if (!AddKeyType(keymap, into, type)) if (!AddKeyType(keymap, into, type))
@ -329,7 +309,8 @@ MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from,
static void static void
HandleKeyTypesFile(XkbFile *file, struct xkb_keymap *keymap, HandleKeyTypesFile(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge, KeyTypesInfo *info); enum merge_mode merge,
KeyTypesInfo *info);
static bool static bool
HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap, HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
@ -341,49 +322,41 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
bool haveSelf; bool haveSelf;
haveSelf = false; haveSelf = false;
if ((stmt->file == NULL) && (stmt->map == NULL)) if ((stmt->file == NULL) && (stmt->map == NULL)) {
{
haveSelf = true; haveSelf = true;
included = *info; included = *info;
memset(info, 0, sizeof(KeyTypesInfo)); memset(info, 0, sizeof(KeyTypesInfo));
} }
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_TYPES, &rtrn, else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_TYPES, &rtrn,
&newMerge)) &newMerge)) {
{
InitKeyTypesInfo(&included, keymap, info, rtrn->id); InitKeyTypesInfo(&included, keymap, info, rtrn->id);
included.dflt.defs.merge = newMerge; included.dflt.defs.merge = newMerge;
HandleKeyTypesFile(rtrn, keymap, newMerge, &included); HandleKeyTypesFile(rtrn, keymap, newMerge, &included);
if (stmt->stmt != NULL) if (stmt->stmt != NULL) {
{
free(included.name); free(included.name);
included.name = stmt->stmt; included.name = stmt->stmt;
stmt->stmt = NULL; stmt->stmt = NULL;
} }
FreeXKBFile(rtrn); FreeXKBFile(rtrn);
} }
else else {
{
info->errorCount += 10; info->errorCount += 10;
return false; return false;
} }
if ((stmt->next != NULL) && (included.errorCount < 1)) if ((stmt->next != NULL) && (included.errorCount < 1)) {
{
IncludeStmt *next; IncludeStmt *next;
unsigned op; unsigned op;
KeyTypesInfo next_incl; KeyTypesInfo next_incl;
for (next = stmt->next; next != NULL; next = next->next) for (next = stmt->next; next != NULL; next = next->next) {
{ if ((next->file == NULL) && (next->map == NULL)) {
if ((next->file == NULL) && (next->map == NULL))
{
haveSelf = true; haveSelf = true;
MergeIncludedKeyTypes(&included, info, next->merge, keymap); MergeIncludedKeyTypes(&included, info, next->merge, keymap);
FreeKeyTypesInfo(info); FreeKeyTypesInfo(info);
} }
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_TYPES, else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_TYPES,
&rtrn, &op)) &rtrn, &op)) {
{
InitKeyTypesInfo(&next_incl, keymap, &included, rtrn->id); InitKeyTypesInfo(&next_incl, keymap, &included, rtrn->id);
next_incl.dflt.defs.merge = op; next_incl.dflt.defs.merge = op;
HandleKeyTypesFile(rtrn, keymap, op, &next_incl); HandleKeyTypesFile(rtrn, keymap, op, &next_incl);
@ -391,8 +364,7 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
FreeKeyTypesInfo(&next_incl); FreeKeyTypesInfo(&next_incl);
FreeXKBFile(rtrn); FreeXKBFile(rtrn);
} }
else else {
{
info->errorCount += 10; info->errorCount += 10;
FreeKeyTypesInfo(&included); FreeKeyTypesInfo(&included);
return false; return false;
@ -401,8 +373,7 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
} }
if (haveSelf) if (haveSelf)
*info = included; *info = included;
else else {
{
MergeIncludedKeyTypes(info, &included, newMerge, keymap); MergeIncludedKeyTypes(info, &included, newMerge, keymap);
FreeKeyTypesInfo(&included); FreeKeyTypesInfo(&included);
} }
@ -417,8 +388,8 @@ FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
struct xkb_kt_map_entry *entry; struct xkb_kt_map_entry *entry;
darray_foreach(entry, type->entries) darray_foreach(entry, type->entries)
if (entry->mods.real_mods == mask && entry->mods.vmods == vmask) if (entry->mods.real_mods == mask && entry->mods.vmods == vmask)
return entry; return entry;
return NULL; return NULL;
} }
@ -434,7 +405,7 @@ DeleteLevel1MapEntries(KeyTypeInfo * type)
for (n = i; n < darray_size(type->entries) - 1; n++) for (n = i; n < darray_size(type->entries) - 1; n++)
darray_item(type->entries, n) = darray_item(type->entries, n) =
darray_item(type->entries, n + 1); darray_item(type->entries, n + 1);
(void)darray_pop(type->entries); (void) darray_pop(type->entries);
} }
} }
} }
@ -456,27 +427,23 @@ AddPreserve(struct xkb_keymap *keymap, KeyTypeInfo *type,
while (old != NULL) while (old != NULL)
{ {
if ((old->indexMods != new->indexMods) || if ((old->indexMods != new->indexMods) ||
(old->indexVMods != new->indexVMods)) (old->indexVMods != new->indexVMods)) {
{
old = (PreserveInfo *) old->defs.next; old = (PreserveInfo *) old->defs.next;
continue; continue;
} }
if ((old->preMods == new->preMods) if ((old->preMods == new->preMods)
&& (old->preVMods == new->preVMods)) && (old->preVMods == new->preVMods)) {
{ if (warningLevel > 9) {
if (warningLevel > 9)
{
WARN("Identical definitions for preserve[%s] in %s\n", WARN("Identical definitions for preserve[%s] in %s\n",
PreserveIndexTxt(keymap, old), TypeTxt(keymap, type)); PreserveIndexTxt(keymap, old), TypeTxt(keymap, type));
ACTION("Ignored\n"); ACTION("Ignored\n");
} }
return true; return true;
} }
if (report && (warningLevel > 0)) if (report && (warningLevel > 0)) {
{
const char *str; const char *str;
WARN("Multiple definitions for preserve[%s] in %s\n", WARN("Multiple definitions for preserve[%s] in %s\n",
PreserveIndexTxt(keymap, old), TypeTxt(keymap, type)); PreserveIndexTxt(keymap, old), TypeTxt(keymap, type));
if (clobber) if (clobber)
str = PreserveTxt(keymap, new); str = PreserveTxt(keymap, new);
@ -489,16 +456,14 @@ AddPreserve(struct xkb_keymap *keymap, KeyTypeInfo *type,
str = PreserveTxt(keymap, new); str = PreserveTxt(keymap, new);
INFO("ignoring %s\n", str); INFO("ignoring %s\n", str);
} }
if (clobber) if (clobber) {
{
old->preMods = new->preMods; old->preMods = new->preMods;
old->preVMods = new->preVMods; old->preVMods = new->preVMods;
} }
return true; return true;
} }
old = uTypedAlloc(PreserveInfo); old = uTypedAlloc(PreserveInfo);
if (!old) if (!old) {
{
WSGO("Couldn't allocate preserve in %s\n", TypeTxt(keymap, type)); WSGO("Couldn't allocate preserve in %s\n", TypeTxt(keymap, type));
ACTION("Preserve[%s] lost\n", PreserveIndexTxt(keymap, new)); ACTION("Preserve[%s] lost\n", PreserveIndexTxt(keymap, new));
return false; return false;
@ -524,30 +489,26 @@ AddMapEntry(struct xkb_keymap *keymap, KeyTypeInfo *type,
struct xkb_kt_map_entry * old; struct xkb_kt_map_entry * old;
if ((old = if ((old =
FindMatchingMapEntry(type, new->mods.real_mods, new->mods.vmods))) FindMatchingMapEntry(type, new->mods.real_mods,
{ new->mods.vmods))) {
if (report && (old->level != new->level)) if (report && (old->level != new->level)) {
{
unsigned use, ignore; unsigned use, ignore;
if (clobber) if (clobber) {
{
use = new->level + 1; use = new->level + 1;
ignore = old->level + 1; ignore = old->level + 1;
} }
else else {
{
use = old->level + 1; use = old->level + 1;
ignore = new->level + 1; ignore = new->level + 1;
} }
WARN("Multiple map entries for %s in %s\n", WARN("Multiple map entries for %s in %s\n",
MapEntryTxt(keymap, new), TypeTxt(keymap, type)); MapEntryTxt(keymap, new), TypeTxt(keymap, type));
ACTION("Using %d, ignoring %d\n", use, ignore); ACTION("Using %d, ignoring %d\n", use, ignore);
} }
else if (warningLevel > 9) else if (warningLevel > 9) {
{
WARN("Multiple occurences of map[%s]= %d in %s\n", WARN("Multiple occurences of map[%s]= %d in %s\n",
MapEntryTxt(keymap, new), new->level + 1, MapEntryTxt(keymap, new), new->level + 1,
TypeTxt(keymap, type)); TypeTxt(keymap, type));
ACTION("Ignored\n"); ACTION("Ignored\n");
return true; return true;
} }
@ -580,13 +541,12 @@ SetMapEntry(KeyTypeInfo *type, struct xkb_keymap *keymap, ExprDef *arrayNdx,
entry.mods.real_mods = rtrn.uval & 0xff; /* modifiers < 512 */ entry.mods.real_mods = rtrn.uval & 0xff; /* modifiers < 512 */
entry.mods.vmods = (rtrn.uval >> 8) & 0xffff; /* modifiers > 512 */ entry.mods.vmods = (rtrn.uval >> 8) & 0xffff; /* modifiers > 512 */
if ((entry.mods.real_mods & (~type->mask)) || if ((entry.mods.real_mods & (~type->mask)) ||
((entry.mods.vmods & (~type->vmask)) != 0)) ((entry.mods.vmods & (~type->vmask)) != 0)) {
{ if (warningLevel > 0) {
if (warningLevel > 0) WARN("Map entry for unused modifiers in %s\n",
{ TypeTxt(keymap, type));
WARN("Map entry for unused modifiers in %s\n", TypeTxt(keymap, type));
ACTION("Using %s instead of ", ACTION("Using %s instead of ",
XkbcVModMaskText(keymap, XkbcVModMaskText(keymap,
entry.mods.real_mods & type->mask, entry.mods.real_mods & type->mask,
entry.mods.vmods & type->vmask)); entry.mods.vmods & type->vmask));
INFO("%s\n", MapEntryTxt(keymap, &entry)); INFO("%s\n", MapEntryTxt(keymap, &entry));
@ -594,8 +554,7 @@ SetMapEntry(KeyTypeInfo *type, struct xkb_keymap *keymap, ExprDef *arrayNdx,
entry.mods.real_mods &= type->mask; entry.mods.real_mods &= type->mask;
entry.mods.vmods &= type->vmask; entry.mods.vmods &= type->vmask;
} }
if (!ExprResolveLevel(keymap->ctx, value, &rtrn)) if (!ExprResolveLevel(keymap->ctx, value, &rtrn)) {
{
ERROR("Level specifications in a key type must be integer\n"); ERROR("Level specifications in a key type must be integer\n");
ACTION("Ignoring malformed level specification\n"); ACTION("Ignoring malformed level specification\n");
return false; return false;
@ -620,12 +579,11 @@ SetPreserve(KeyTypeInfo *type, struct xkb_keymap *keymap,
new.defs.next = NULL; new.defs.next = NULL;
new.indexMods = rtrn.uval & 0xff; new.indexMods = rtrn.uval & 0xff;
new.indexVMods = (rtrn.uval >> 8) & 0xffff; new.indexVMods = (rtrn.uval >> 8) & 0xffff;
if ((new.indexMods & (~type->mask)) || (new.indexVMods & (~type->vmask))) if ((new.indexMods & (~type->mask)) ||
{ (new.indexVMods & (~type->vmask))) {
if (warningLevel > 0) if (warningLevel > 0) {
{
WARN("Preserve for modifiers not used by the %s type\n", WARN("Preserve for modifiers not used by the %s type\n",
TypeTxt(keymap, type)); TypeTxt(keymap, type));
ACTION("Index %s converted to ", PreserveIndexTxt(keymap, &new)); ACTION("Index %s converted to ", PreserveIndexTxt(keymap, &new));
} }
new.indexMods &= type->mask; new.indexMods &= type->mask;
@ -633,28 +591,24 @@ SetPreserve(KeyTypeInfo *type, struct xkb_keymap *keymap,
if (warningLevel > 0) if (warningLevel > 0)
INFO("%s\n", PreserveIndexTxt(keymap, &new)); INFO("%s\n", PreserveIndexTxt(keymap, &new));
} }
if (!ExprResolveVModMask(value, &rtrn, keymap)) if (!ExprResolveVModMask(value, &rtrn, keymap)) {
{
ERROR("Preserve value in a key type is not a modifier mask\n"); ERROR("Preserve value in a key type is not a modifier mask\n");
ACTION("Ignoring preserve[%s] in type %s\n", ACTION("Ignoring preserve[%s] in type %s\n",
PreserveIndexTxt(keymap, &new), TypeTxt(keymap, type)); PreserveIndexTxt(keymap, &new), TypeTxt(keymap, type));
return false; return false;
} }
new.preMods = rtrn.uval & 0xff; new.preMods = rtrn.uval & 0xff;
new.preVMods = (rtrn.uval >> 16) & 0xffff; new.preVMods = (rtrn.uval >> 16) & 0xffff;
if ((new.preMods & (~new.indexMods)) if ((new.preMods & (~new.indexMods))
|| (new.preVMods & (~new.indexVMods))) || (new.preVMods & (~new.indexVMods))) {
{ if (warningLevel > 0) {
if (warningLevel > 0)
{
WARN("Illegal value for preserve[%s] in type %s\n", WARN("Illegal value for preserve[%s] in type %s\n",
PreserveTxt(keymap, &new), TypeTxt(keymap, type)); PreserveTxt(keymap, &new), TypeTxt(keymap, type));
ACTION("Converted %s to ", PreserveIndexTxt(keymap, &new)); ACTION("Converted %s to ", PreserveIndexTxt(keymap, &new));
} }
new.preMods &= new.indexMods; new.preMods &= new.indexMods;
new.preVMods &= new.indexVMods; new.preVMods &= new.indexVMods;
if (warningLevel > 0) if (warningLevel > 0) {
{
INFO("%s\n", PreserveIndexTxt(keymap, &new)); INFO("%s\n", PreserveIndexTxt(keymap, &new));
} }
} }
@ -713,10 +667,9 @@ SetLevelName(KeyTypeInfo *type, struct xkb_keymap *keymap, ExprDef *arrayNdx,
if (!ExprResolveLevel(keymap->ctx, arrayNdx, &rtrn)) if (!ExprResolveLevel(keymap->ctx, arrayNdx, &rtrn))
return ReportTypeBadType(keymap, type, "level name", "integer"); return ReportTypeBadType(keymap, type, "level name", "integer");
level = rtrn.ival - 1; level = rtrn.ival - 1;
if (!ExprResolveString(keymap->ctx, value, &rtrn)) if (!ExprResolveString(keymap->ctx, value, &rtrn)) {
{
ERROR("Non-string name for level %d in key type %s\n", level + 1, ERROR("Non-string name for level %d in key type %s\n", level + 1,
xkb_atom_text(keymap->ctx, type->name)); xkb_atom_text(keymap->ctx, type->name));
ACTION("Ignoring illegal level name definition\n"); ACTION("Ignoring illegal level name definition\n");
return false; return false;
} }
@ -739,27 +692,23 @@ SetKeyTypeField(KeyTypeInfo *type, struct xkb_keymap *keymap,
{ {
ExprResult tmp; ExprResult tmp;
if (strcasecmp(field, "modifiers") == 0) if (strcasecmp(field, "modifiers") == 0) {
{
unsigned mods, vmods; unsigned mods, vmods;
if (arrayNdx != NULL) if (arrayNdx != NULL) {
{
WARN("The modifiers field of a key type is not an array\n"); WARN("The modifiers field of a key type is not an array\n");
ACTION("Illegal array subscript ignored\n"); ACTION("Illegal array subscript ignored\n");
} }
/* get modifier mask for current type */ /* get modifier mask for current type */
if (!ExprResolveVModMask(value, &tmp, keymap)) if (!ExprResolveVModMask(value, &tmp, keymap)) {
{
ERROR("Key type mask field must be a modifier mask\n"); ERROR("Key type mask field must be a modifier mask\n");
ACTION("Key type definition ignored\n"); ACTION("Key type definition ignored\n");
return false; return false;
} }
mods = tmp.uval & 0xff; /* core mods */ mods = tmp.uval & 0xff; /* core mods */
vmods = (tmp.uval >> 8) & 0xffff; /* xkb virtual mods */ vmods = (tmp.uval >> 8) & 0xffff; /* xkb virtual mods */
if (type->defs.defined & _KT_Mask) if (type->defs.defined & _KT_Mask) {
{
WARN("Multiple modifier mask definitions for key type %s\n", WARN("Multiple modifier mask definitions for key type %s\n",
xkb_atom_text(keymap->ctx, type->name)); xkb_atom_text(keymap->ctx, type->name));
ACTION("Using %s, ", TypeMaskTxt(type, keymap)); ACTION("Using %s, ", TypeMaskTxt(type, keymap));
INFO("ignoring %s\n", XkbcVModMaskText(keymap, mods, vmods)); INFO("ignoring %s\n", XkbcVModMaskText(keymap, mods, vmods));
return false; return false;
@ -769,19 +718,16 @@ SetKeyTypeField(KeyTypeInfo *type, struct xkb_keymap *keymap,
type->defs.defined |= _KT_Mask; type->defs.defined |= _KT_Mask;
return true; return true;
} }
else if (strcasecmp(field, "map") == 0) else if (strcasecmp(field, "map") == 0) {
{
type->defs.defined |= _KT_Map; type->defs.defined |= _KT_Map;
return SetMapEntry(type, keymap, arrayNdx, value); return SetMapEntry(type, keymap, arrayNdx, value);
} }
else if (strcasecmp(field, "preserve") == 0) else if (strcasecmp(field, "preserve") == 0) {
{
type->defs.defined |= _KT_Preserve; type->defs.defined |= _KT_Preserve;
return SetPreserve(type, keymap, arrayNdx, value); return SetPreserve(type, keymap, arrayNdx, value);
} }
else if ((strcasecmp(field, "levelname") == 0) || else if ((strcasecmp(field, "levelname") == 0) ||
(strcasecmp(field, "level_name") == 0)) (strcasecmp(field, "level_name") == 0)) {
{
type->defs.defined |= _KT_LevelNames; type->defs.defined |= _KT_LevelNames;
return SetLevelName(type, keymap, arrayNdx, value); return SetLevelName(type, keymap, arrayNdx, value);
} }
@ -801,15 +747,13 @@ HandleKeyTypeVar(VarDef *stmt, struct xkb_keymap *keymap, KeyTypesInfo *info)
if (elem.str && (strcasecmp(elem.str, "type") == 0)) if (elem.str && (strcasecmp(elem.str, "type") == 0))
return SetKeyTypeField(&info->dflt, keymap, field.str, arrayNdx, return SetKeyTypeField(&info->dflt, keymap, field.str, arrayNdx,
stmt->value, info); stmt->value, info);
if (elem.str != NULL) if (elem.str != NULL) {
{
ERROR("Default for unknown element %s\n", uStringText(elem.str)); ERROR("Default for unknown element %s\n", uStringText(elem.str));
ACTION("Value for field %s ignored\n", uStringText(field.str)); ACTION("Value for field %s ignored\n", uStringText(field.str));
} }
else if (field.str != NULL) else if (field.str != NULL) {
{
ERROR("Default defined for unknown field %s\n", ERROR("Default defined for unknown field %s\n",
uStringText(field.str)); uStringText(field.str));
ACTION("Ignored\n"); ACTION("Ignored\n");
} }
return false; return false;
@ -823,10 +767,8 @@ HandleKeyTypeBody(VarDef *def, struct xkb_keymap *keymap,
ExprResult tmp, field; ExprResult tmp, field;
ExprDef *arrayNdx; ExprDef *arrayNdx;
for (; def != NULL; def = (VarDef *) def->common.next) for (; def != NULL; def = (VarDef *) def->common.next) {
{ if ((def->name) && (def->name->type == ExprFieldRef)) {
if ((def->name) && (def->name->type == ExprFieldRef))
{
ok = HandleKeyTypeVar(def, keymap, info); ok = HandleKeyTypeVar(def, keymap, info);
continue; continue;
} }
@ -869,8 +811,7 @@ HandleKeyTypeDef(KeyTypeDef *def, struct xkb_keymap *keymap,
type.preserve = NULL; type.preserve = NULL;
/* Parse the actual content. */ /* Parse the actual content. */
if (!HandleKeyTypeBody(def->body, keymap, &type, info)) if (!HandleKeyTypeBody(def->body, keymap, &type, info)) {
{
info->errorCount++; info->errorCount++;
return false; return false;
} }
@ -882,14 +823,12 @@ HandleKeyTypeDef(KeyTypeDef *def, struct xkb_keymap *keymap,
(entry->mods.vmods & type.vmask) == entry->mods.vmods) (entry->mods.vmods & type.vmask) == entry->mods.vmods)
AddMapEntry(keymap, &type, entry, false, false); AddMapEntry(keymap, &type, entry, false, false);
} }
if (info->dflt.preserve) if (info->dflt.preserve) {
{
PreserveInfo *dflt = info->dflt.preserve; PreserveInfo *dflt = info->dflt.preserve;
while (dflt) while (dflt)
{ {
if (((dflt->indexMods & type.mask) == dflt->indexMods) && if (((dflt->indexMods & type.mask) == dflt->indexMods) &&
((dflt->indexVMods & type.vmask) == dflt->indexVMods)) ((dflt->indexVMods & type.vmask) == dflt->indexVMods)) {
{
AddPreserve(keymap, &type, dflt, false, false); AddPreserve(keymap, &type, dflt, false, false);
} }
dflt = (PreserveInfo *) dflt->defs.next; dflt = (PreserveInfo *) dflt->defs.next;
@ -898,16 +837,14 @@ HandleKeyTypeDef(KeyTypeDef *def, struct xkb_keymap *keymap,
for (i = 0; i < darray_size(info->dflt.lvlNames); i++) { for (i = 0; i < darray_size(info->dflt.lvlNames); i++) {
if (i < type.numLevels && if (i < type.numLevels &&
darray_item(info->dflt.lvlNames, i) != XKB_ATOM_NONE) darray_item(info->dflt.lvlNames, i) != XKB_ATOM_NONE) {
{
AddLevelName(keymap, &type, i, AddLevelName(keymap, &type, i,
darray_item(info->dflt.lvlNames, i), false); darray_item(info->dflt.lvlNames, i), false);
} }
} }
/* Now add the new keytype to the info struct */ /* Now add the new keytype to the info struct */
if (!AddKeyType(keymap, info, &type)) if (!AddKeyType(keymap, info, &type)) {
{
info->errorCount++; info->errorCount++;
return false; return false;
} }
@ -932,8 +869,7 @@ HandleKeyTypesFile(XkbFile *file, struct xkb_keymap *keymap,
stmt = file->defs; stmt = file->defs;
while (stmt) while (stmt)
{ {
switch (stmt->stmtType) switch (stmt->stmtType) {
{
case StmtInclude: case StmtInclude:
if (!HandleIncludeKeyTypes((IncludeStmt *) stmt, keymap, info)) if (!HandleIncludeKeyTypes((IncludeStmt *) stmt, keymap, info))
info->errorCount++; info->errorCount++;
@ -967,12 +903,11 @@ HandleKeyTypesFile(XkbFile *file, struct xkb_keymap *keymap,
break; break;
default: default:
WSGO("Unexpected statement type %d in HandleKeyTypesFile\n", WSGO("Unexpected statement type %d in HandleKeyTypesFile\n",
stmt->stmtType); stmt->stmtType);
break; break;
} }
stmt = stmt->next; stmt = stmt->next;
if (info->errorCount > 10) if (info->errorCount > 10) {
{
#ifdef NOISY #ifdef NOISY
ERROR("Too many errors\n"); ERROR("Too many errors\n");
#endif #endif
@ -998,7 +933,8 @@ ComputeEffectiveMap(struct xkb_keymap *keymap, struct xkb_key_type *type)
if (tmp == 0) if (tmp == 0)
continue; continue;
} }
entry->mods.mask = (entry->mods.real_mods | tmp) & type->mods.mask; entry->mods.mask =
(entry->mods.real_mods | tmp) & type->mods.mask;
} }
} }
else else
@ -1015,8 +951,7 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
PreserveInfo *pre; PreserveInfo *pre;
for (pre = def->preserve; pre != NULL; for (pre = def->preserve; pre != NULL;
pre = (PreserveInfo *) pre->defs.next) pre = (PreserveInfo *) pre->defs.next) {
{
struct xkb_kt_map_entry * match; struct xkb_kt_map_entry * match;
struct xkb_kt_map_entry tmp; struct xkb_kt_map_entry tmp;
tmp.mods.real_mods = pre->indexMods; tmp.mods.real_mods = pre->indexMods;
@ -1024,8 +959,7 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
tmp.level = 0; tmp.level = 0;
AddMapEntry(keymap, def, &tmp, false, false); AddMapEntry(keymap, def, &tmp, false, false);
match = FindMatchingMapEntry(def, pre->indexMods, pre->indexVMods); match = FindMatchingMapEntry(def, pre->indexMods, pre->indexVMods);
if (!match) if (!match) {
{
WSGO("Couldn't find matching entry for preserve\n"); WSGO("Couldn't find matching entry for preserve\n");
ACTION("Aborting\n"); ACTION("Aborting\n");
return false; return false;
@ -1036,20 +970,16 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
type->mods.vmods = def->vmask; type->mods.vmods = def->vmask;
type->num_levels = def->numLevels; type->num_levels = def->numLevels;
memcpy(&type->map, &def->entries, sizeof(def->entries)); memcpy(&type->map, &def->entries, sizeof(def->entries));
if (def->preserve) if (def->preserve) {
{
type->preserve = uTypedCalloc(darray_size(type->map), struct xkb_mods); type->preserve = uTypedCalloc(darray_size(type->map), struct xkb_mods);
if (!type->preserve) if (!type->preserve) {
{
WARN("Couldn't allocate preserve array in CopyDefToKeyType\n"); WARN("Couldn't allocate preserve array in CopyDefToKeyType\n");
ACTION("Preserve setting for type %s lost\n", ACTION("Preserve setting for type %s lost\n",
xkb_atom_text(keymap->ctx, def->name)); xkb_atom_text(keymap->ctx, def->name));
} }
else else {
{
pre = def->preserve; pre = def->preserve;
for (; pre != NULL; pre = (PreserveInfo *) pre->defs.next) for (; pre != NULL; pre = (PreserveInfo *) pre->defs.next) {
{
int ndx = pre->matchingMapIndex; int ndx = pre->matchingMapIndex;
type->preserve[ndx].mask = pre->preMods; type->preserve[ndx].mask = pre->preMods;
type->preserve[ndx].real_mods = pre->preMods; type->preserve[ndx].real_mods = pre->preMods;
@ -1078,30 +1008,30 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
return ComputeEffectiveMap(keymap, type); return ComputeEffectiveMap(keymap, type);
} }
static struct xkb_kt_map_entry map2Level[]= { static struct xkb_kt_map_entry map2Level[] = {
{ {
.level = ShiftMask, .level = ShiftMask,
.mods = {.mask = 1, .vmods = ShiftMask, .real_mods = 0 } .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
} }
}; };
static struct xkb_kt_map_entry mapAlpha[]= { static struct xkb_kt_map_entry mapAlpha[] = {
{ {
.level = ShiftMask, .level = ShiftMask,
.mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 } .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
}, },
{ {
.level = LockMask, .level = LockMask,
.mods = { .mask = 0, .vmods = LockMask, .real_mods = 0 } .mods = { .mask = 0, .vmods = LockMask, .real_mods = 0 }
} }
}; };
static struct xkb_mods preAlpha[]= { static struct xkb_mods preAlpha[] = {
{ .mask = 0, .vmods = 0, .real_mods = 0 }, { .mask = 0, .vmods = 0, .real_mods = 0 },
{ .mask = LockMask, .vmods = LockMask, .real_mods = 0 } { .mask = LockMask, .vmods = LockMask, .real_mods = 0 }
}; };
static struct xkb_kt_map_entry mapKeypad[]= { static struct xkb_kt_map_entry mapKeypad[] = {
{ {
.level = ShiftMask, .level = ShiftMask,
.mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 } .mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
@ -1130,8 +1060,8 @@ static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
}, },
{ {
.mods = { .mods = {
.mask = ShiftMask|LockMask, .mask = ShiftMask | LockMask,
.vmods = ShiftMask|LockMask, .vmods = ShiftMask | LockMask,
.real_mods = 0 .real_mods = 0
}, },
.num_levels = 2, .num_levels = 2,
@ -1151,7 +1081,8 @@ static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
}; };
static int static int
InitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which, int keypadVMod) InitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which,
int keypadVMod)
{ {
struct xkb_client_map *map; struct xkb_client_map *map;
const struct xkb_key_type *from; const struct xkb_key_type *from;
@ -1210,7 +1141,8 @@ InitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which, int keypadVMod)
} }
bool bool
CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge) CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap,
enum merge_mode merge)
{ {
unsigned int i; unsigned int i;
struct xkb_key_type *type, *next; struct xkb_key_type *type, *next;
@ -1290,7 +1222,7 @@ CompileKeyTypes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
if (!CopyDefToKeyType(keymap, type, def)) if (!CopyDefToKeyType(keymap, type, def))
goto err_info; goto err_info;
def = (KeyTypeInfo *)def->defs.next; def = (KeyTypeInfo *) def->defs.next;
} }
FreeKeyTypesInfo(&info); FreeKeyTypesInfo(&info);

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
@ -54,16 +54,13 @@ ProcessIncludeFile(struct xkb_context *ctx,
XkbFile *rtrn, *mapToUse, *next; XkbFile *rtrn, *mapToUse, *next;
file = XkbFindFileInPath(ctx, stmt->file, file_type, &stmt->path); file = XkbFindFileInPath(ctx, stmt->file, file_type, &stmt->path);
if (file == NULL) if (file == NULL) {
{
ERROR("Can't find file \"%s\" for %s include\n", stmt->file, ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
XkbDirectoryForInclude(file_type)); XkbDirectoryForInclude(file_type));
return false; return false;
} }
if (!XKBParseFile(ctx, file, stmt->file, &rtrn)) {
if (!XKBParseFile(ctx, file, stmt->file, &rtrn))
{
ERROR("Error interpreting include file \"%s\"\n", stmt->file); ERROR("Error interpreting include file \"%s\"\n", stmt->file);
fclose(file); fclose(file);
return false; return false;
@ -71,41 +68,35 @@ ProcessIncludeFile(struct xkb_context *ctx,
fclose(file); fclose(file);
mapToUse = rtrn; mapToUse = rtrn;
if (stmt->map != NULL) if (stmt->map != NULL) {
{
while (mapToUse) while (mapToUse)
{ {
next = (XkbFile *)mapToUse->common.next; next = (XkbFile *) mapToUse->common.next;
mapToUse->common.next = NULL; mapToUse->common.next = NULL;
if (strcmp(mapToUse->name, stmt->map) == 0 && if (strcmp(mapToUse->name, stmt->map) == 0 &&
mapToUse->type == file_type) mapToUse->type == file_type) {
{ FreeXKBFile(next);
FreeXKBFile(next); break;
break;
} }
else else {
{
FreeXKBFile(mapToUse); FreeXKBFile(mapToUse);
} }
mapToUse = next; mapToUse = next;
} }
if (!mapToUse) if (!mapToUse) {
{
ERROR("No %s named \"%s\" in the include file \"%s\"\n", ERROR("No %s named \"%s\" in the include file \"%s\"\n",
XkbcFileTypeText(file_type), stmt->map, stmt->file); XkbcFileTypeText(file_type), stmt->map, stmt->file);
return false; return false;
} }
} }
else if ((rtrn->common.next != NULL) && (warningLevel > 5)) else if ((rtrn->common.next != NULL) && (warningLevel > 5)) {
{
WARN("No map in include statement, but \"%s\" contains several\n", WARN("No map in include statement, but \"%s\" contains several\n",
stmt->file); stmt->file);
ACTION("Using first defined map, \"%s\"\n", rtrn->name); ACTION("Using first defined map, \"%s\"\n", rtrn->name);
} }
if (mapToUse->type != file_type) if (mapToUse->type != file_type) {
{
ERROR("Include file wrong type (expected %s, got %s)\n", ERROR("Include file wrong type (expected %s, got %s)\n",
XkbcFileTypeText(file_type), XkbcFileTypeText(mapToUse->type)); XkbcFileTypeText(file_type), XkbcFileTypeText(mapToUse->type));
ACTION("Include file \"%s\" ignored\n", stmt->file); ACTION("Include file \"%s\" ignored\n", stmt->file);
return false; return false;
} }
@ -160,13 +151,10 @@ UseNewField(unsigned field,
bool useNew; bool useNew;
useNew = false; useNew = false;
if (oldDefs->defined & field) if (oldDefs->defined & field) {
{ if (newDefs->defined & field) {
if (newDefs->defined & field)
{
if (((oldDefs->file_id == newDefs->file_id) if (((oldDefs->file_id == newDefs->file_id)
&& (warningLevel > 0)) || (warningLevel > 9)) && (warningLevel > 0)) || (warningLevel > 9)) {
{
*pCollide |= field; *pCollide |= field;
} }
if (newDefs->merge != MERGE_AUGMENT) if (newDefs->merge != MERGE_AUGMENT)
@ -181,11 +169,9 @@ UseNewField(unsigned field,
void * void *
ClearCommonInfo(CommonInfo * cmn) ClearCommonInfo(CommonInfo * cmn)
{ {
if (cmn != NULL) if (cmn != NULL) {
{
CommonInfo *this, *next; CommonInfo *this, *next;
for (this = cmn; this != NULL; this = next) for (this = cmn; this != NULL; this = next) {
{
next = this->next; next = this->next;
free(this); free(this);
} }
@ -204,8 +190,7 @@ AddCommonInfo(CommonInfo * old, CommonInfo * new)
old = old->next; old = old->next;
} }
new->next = NULL; new->next = NULL;
if (old) if (old) {
{
old->next = new; old->next = new;
return first; return first;
} }
@ -234,56 +219,44 @@ FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
{ {
unsigned n; unsigned n;
if (start_from < keymap->min_key_code) if (start_from < keymap->min_key_code) {
{
start_from = keymap->min_key_code; start_from = keymap->min_key_code;
} }
else if (start_from > keymap->max_key_code) else if (start_from > keymap->max_key_code) {
{
return false; return false;
} }
*kc_rtrn = 0; /* some callers rely on this */ *kc_rtrn = 0; /* some callers rely on this */
if (keymap && keymap->names && !darray_empty(keymap->names->keys)) if (keymap && keymap->names && !darray_empty(keymap->names->keys)) {
{ for (n = start_from; n <= keymap->max_key_code; n++) {
for (n = start_from; n <= keymap->max_key_code; n++)
{
unsigned long tmp; unsigned long tmp;
tmp = KeyNameToLong(darray_item(keymap->names->keys, n).name); tmp = KeyNameToLong(darray_item(keymap->names->keys, n).name);
if (tmp == name) if (tmp == name) {
{
*kc_rtrn = n; *kc_rtrn = n;
return true; return true;
} }
} }
if (use_aliases) if (use_aliases) {
{
unsigned long new_name; unsigned long new_name;
if (FindKeyNameForAlias(keymap, name, &new_name)) if (FindKeyNameForAlias(keymap, name, &new_name))
return FindNamedKey(keymap, new_name, kc_rtrn, false, return FindNamedKey(keymap, new_name, kc_rtrn, false,
create, 0); create, 0);
} }
} }
if (create) if (create) {
{ if ((!keymap->names) || darray_empty(keymap->names->keys)) {
if ((!keymap->names) || darray_empty(keymap->names->keys)) if (XkbcAllocNames(keymap, XkbKeyNamesMask, 0) != Success) {
{ if (warningLevel > 0) {
if (XkbcAllocNames(keymap, XkbKeyNamesMask, 0) != Success)
{
if (warningLevel > 0)
{
WARN("Couldn't allocate key names in FindNamedKey\n"); WARN("Couldn't allocate key names in FindNamedKey\n");
ACTION("Key \"%s\" not automatically created\n", ACTION("Key \"%s\" not automatically created\n",
longText(name)); longText(name));
} }
return false; return false;
} }
} }
/* Find first unused keycode and store our key here */ /* Find first unused keycode and store our key here */
for (n = keymap->min_key_code; n <= keymap->max_key_code; n++) for (n = keymap->min_key_code; n <= keymap->max_key_code; n++) {
{ if (darray_item(keymap->names->keys, n).name[0] == '\0') {
if (darray_item(keymap->names->keys, n).name[0] == '\0')
{
char buf[XkbKeyNameLength + 1]; char buf[XkbKeyNameLength + 1];
LongToKeyName(name, buf); LongToKeyName(name, buf);
memcpy(darray_item(keymap->names->keys, n).name, buf, memcpy(darray_item(keymap->names->keys, n).name, buf,

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "parseutils.h" #include "parseutils.h"
@ -38,8 +38,7 @@ AppendStmt(ParseCommon * to, ParseCommon * append)
{ {
to = to->next; to = to->next;
} }
if (to) if (to) {
{
to->next = append; to->next = append;
return start; return start;
} }
@ -51,15 +50,13 @@ ExprCreate(unsigned op, unsigned type)
{ {
ExprDef *expr; ExprDef *expr;
expr = uTypedAlloc(ExprDef); expr = uTypedAlloc(ExprDef);
if (expr) if (expr) {
{
expr->common.stmtType = StmtExpr; expr->common.stmtType = StmtExpr;
expr->common.next = NULL; expr->common.next = NULL;
expr->op = op; expr->op = op;
expr->type = type; expr->type = type;
} }
else else {
{
FATAL("Couldn't allocate expression in parser\n"); FATAL("Couldn't allocate expression in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -71,16 +68,14 @@ ExprCreateUnary(unsigned op, unsigned type, ExprDef * child)
{ {
ExprDef *expr; ExprDef *expr;
expr = uTypedAlloc(ExprDef); expr = uTypedAlloc(ExprDef);
if (expr) if (expr) {
{
expr->common.stmtType = StmtExpr; expr->common.stmtType = StmtExpr;
expr->common.next = NULL; expr->common.next = NULL;
expr->op = op; expr->op = op;
expr->type = type; expr->type = type;
expr->value.child = child; expr->value.child = child;
} }
else else {
{
FATAL("Couldn't allocate expression in parser\n"); FATAL("Couldn't allocate expression in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -92,8 +87,7 @@ ExprCreateBinary(unsigned op, ExprDef * left, ExprDef * right)
{ {
ExprDef *expr; ExprDef *expr;
expr = uTypedAlloc(ExprDef); expr = uTypedAlloc(ExprDef);
if (expr) if (expr) {
{
expr->common.stmtType = StmtExpr; expr->common.stmtType = StmtExpr;
expr->common.next = NULL; expr->common.next = NULL;
expr->op = op; expr->op = op;
@ -106,8 +100,7 @@ ExprCreateBinary(unsigned op, ExprDef * left, ExprDef * right)
expr->value.binary.left = left; expr->value.binary.left = left;
expr->value.binary.right = right; expr->value.binary.right = right;
} }
else else {
{
FATAL("Couldn't allocate expression in parser\n"); FATAL("Couldn't allocate expression in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -120,16 +113,14 @@ KeycodeCreate(const char *name, unsigned long value)
KeycodeDef *def; KeycodeDef *def;
def = uTypedAlloc(KeycodeDef); def = uTypedAlloc(KeycodeDef);
if (def) if (def) {
{
def->common.stmtType = StmtKeycodeDef; def->common.stmtType = StmtKeycodeDef;
def->common.next = NULL; def->common.next = NULL;
strncpy(def->name, name, XkbKeyNameLength); strncpy(def->name, name, XkbKeyNameLength);
def->name[XkbKeyNameLength] = '\0'; def->name[XkbKeyNameLength] = '\0';
def->value = value; def->value = value;
} }
else else {
{
FATAL("Couldn't allocate key name definition in parser\n"); FATAL("Couldn't allocate key name definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -142,8 +133,7 @@ KeyAliasCreate(const char *alias, const char *real)
KeyAliasDef *def; KeyAliasDef *def;
def = uTypedAlloc(KeyAliasDef); def = uTypedAlloc(KeyAliasDef);
if (def) if (def) {
{
def->common.stmtType = StmtKeyAliasDef; def->common.stmtType = StmtKeyAliasDef;
def->common.next = NULL; def->common.next = NULL;
strncpy(def->alias, alias, XkbKeyNameLength); strncpy(def->alias, alias, XkbKeyNameLength);
@ -151,8 +141,7 @@ KeyAliasCreate(const char *alias, const char *real)
strncpy(def->real, real, XkbKeyNameLength); strncpy(def->real, real, XkbKeyNameLength);
def->real[XkbKeyNameLength] = '\0'; def->real[XkbKeyNameLength] = '\0';
} }
else else {
{
FATAL("Couldn't allocate key alias definition in parser\n"); FATAL("Couldn't allocate key alias definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -164,15 +153,13 @@ VModCreate(xkb_atom_t name, ExprDef * value)
{ {
VModDef *def; VModDef *def;
def = uTypedAlloc(VModDef); def = uTypedAlloc(VModDef);
if (def) if (def) {
{
def->common.stmtType = StmtVModDef; def->common.stmtType = StmtVModDef;
def->common.next = NULL; def->common.next = NULL;
def->name = name; def->name = name;
def->value = value; def->value = value;
} }
else else {
{
FATAL("Couldn't allocate variable definition in parser\n"); FATAL("Couldn't allocate variable definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -184,15 +171,13 @@ VarCreate(ExprDef * name, ExprDef * value)
{ {
VarDef *def; VarDef *def;
def = uTypedAlloc(VarDef); def = uTypedAlloc(VarDef);
if (def) if (def) {
{
def->common.stmtType = StmtVarDef; def->common.stmtType = StmtVarDef;
def->common.next = NULL; def->common.next = NULL;
def->name = name; def->name = name;
def->value = value; def->value = value;
} }
else else {
{
FATAL("Couldn't allocate variable definition in parser\n"); FATAL("Couldn't allocate variable definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -217,15 +202,13 @@ InterpCreate(char *sym, ExprDef * match)
InterpDef *def; InterpDef *def;
def = uTypedAlloc(InterpDef); def = uTypedAlloc(InterpDef);
if (def) if (def) {
{
def->common.stmtType = StmtInterpDef; def->common.stmtType = StmtInterpDef;
def->common.next = NULL; def->common.next = NULL;
def->sym = sym; def->sym = sym;
def->match = match; def->match = match;
} }
else else {
{
FATAL("Couldn't allocate interp definition in parser\n"); FATAL("Couldn't allocate interp definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -238,16 +221,14 @@ KeyTypeCreate(xkb_atom_t name, VarDef * body)
KeyTypeDef *def; KeyTypeDef *def;
def = uTypedAlloc(KeyTypeDef); def = uTypedAlloc(KeyTypeDef);
if (def) if (def) {
{
def->common.stmtType = StmtKeyTypeDef; def->common.stmtType = StmtKeyTypeDef;
def->common.next = NULL; def->common.next = NULL;
def->merge = MERGE_DEFAULT; def->merge = MERGE_DEFAULT;
def->name = name; def->name = name;
def->body = body; def->body = body;
} }
else else {
{
FATAL("Couldn't allocate key type definition in parser\n"); FATAL("Couldn't allocate key type definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -260,8 +241,7 @@ SymbolsCreate(const char *keyName, ExprDef *symbols)
SymbolsDef *def; SymbolsDef *def;
def = uTypedAlloc(SymbolsDef); def = uTypedAlloc(SymbolsDef);
if (def) if (def) {
{
def->common.stmtType = StmtSymbolsDef; def->common.stmtType = StmtSymbolsDef;
def->common.next = NULL; def->common.next = NULL;
def->merge = MERGE_DEFAULT; def->merge = MERGE_DEFAULT;
@ -269,8 +249,7 @@ SymbolsCreate(const char *keyName, ExprDef *symbols)
strncpy(def->keyName, keyName, 4); strncpy(def->keyName, keyName, 4);
def->symbols = symbols; def->symbols = symbols;
} }
else else {
{
FATAL("Couldn't allocate symbols definition in parser\n"); FATAL("Couldn't allocate symbols definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -283,16 +262,14 @@ GroupCompatCreate(int group, ExprDef * val)
GroupCompatDef *def; GroupCompatDef *def;
def = uTypedAlloc(GroupCompatDef); def = uTypedAlloc(GroupCompatDef);
if (def) if (def) {
{
def->common.stmtType = StmtGroupCompatDef; def->common.stmtType = StmtGroupCompatDef;
def->common.next = NULL; def->common.next = NULL;
def->merge = MERGE_DEFAULT; def->merge = MERGE_DEFAULT;
def->group = group; def->group = group;
def->def = val; def->def = val;
} }
else else {
{
FATAL("Couldn't allocate group compat definition in parser\n"); FATAL("Couldn't allocate group compat definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -305,16 +282,14 @@ ModMapCreate(uint32_t modifier, ExprDef * keys)
ModMapDef *def; ModMapDef *def;
def = uTypedAlloc(ModMapDef); def = uTypedAlloc(ModMapDef);
if (def) if (def) {
{
def->common.stmtType = StmtModMapDef; def->common.stmtType = StmtModMapDef;
def->common.next = NULL; def->common.next = NULL;
def->merge = MERGE_DEFAULT; def->merge = MERGE_DEFAULT;
def->modifier = modifier; def->modifier = modifier;
def->keys = keys; def->keys = keys;
} }
else else {
{
FATAL("Couldn't allocate mod mask definition in parser\n"); FATAL("Couldn't allocate mod mask definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -327,16 +302,14 @@ IndicatorMapCreate(xkb_atom_t name, VarDef * body)
IndicatorMapDef *def; IndicatorMapDef *def;
def = uTypedAlloc(IndicatorMapDef); def = uTypedAlloc(IndicatorMapDef);
if (def) if (def) {
{
def->common.stmtType = StmtIndicatorMapDef; def->common.stmtType = StmtIndicatorMapDef;
def->common.next = NULL; def->common.next = NULL;
def->merge = MERGE_DEFAULT; def->merge = MERGE_DEFAULT;
def->name = name; def->name = name;
def->body = body; def->body = body;
} }
else else {
{
FATAL("Couldn't allocate indicator map definition in parser\n"); FATAL("Couldn't allocate indicator map definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -349,8 +322,7 @@ IndicatorNameCreate(int ndx, ExprDef * name, bool virtual)
IndicatorNameDef *def; IndicatorNameDef *def;
def = uTypedAlloc(IndicatorNameDef); def = uTypedAlloc(IndicatorNameDef);
if (def) if (def) {
{
def->common.stmtType = StmtIndicatorNameDef; def->common.stmtType = StmtIndicatorNameDef;
def->common.next = NULL; def->common.next = NULL;
def->merge = MERGE_DEFAULT; def->merge = MERGE_DEFAULT;
@ -358,8 +330,7 @@ IndicatorNameCreate(int ndx, ExprDef * name, bool virtual)
def->name = name; def->name = name;
def->virtual = virtual; def->virtual = virtual;
} }
else else {
{
FATAL("Couldn't allocate indicator index definition in parser\n"); FATAL("Couldn't allocate indicator index definition in parser\n");
/* NOTREACHED */ /* NOTREACHED */
} }
@ -372,8 +343,7 @@ ActionCreate(xkb_atom_t name, ExprDef * args)
ExprDef *act; ExprDef *act;
act = uTypedAlloc(ExprDef); act = uTypedAlloc(ExprDef);
if (act) if (act) {
{
act->common.stmtType = StmtExpr; act->common.stmtType = StmtExpr;
act->common.next = NULL; act->common.next = NULL;
act->op = ExprActionDecl; act->op = ExprActionDecl;
@ -391,8 +361,7 @@ CreateKeysymList(char *sym)
ExprDef *def; ExprDef *def;
def = ExprCreate(ExprKeysymList, TypeSymbols); def = ExprCreate(ExprKeysymList, TypeSymbols);
if (!def) if (!def) {
{
FATAL("Couldn't allocate expression for keysym list in parser\n"); FATAL("Couldn't allocate expression for keysym list in parser\n");
return NULL; return NULL;
} }
@ -457,20 +426,17 @@ LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
xkb_keysym_t sym; xkb_keysym_t sym;
if ((!str) || (strcasecmp(str, "any") == 0) || if ((!str) || (strcasecmp(str, "any") == 0) ||
(strcasecmp(str, "nosymbol") == 0)) (strcasecmp(str, "nosymbol") == 0)) {
{
*sym_rtrn = XKB_KEY_NoSymbol; *sym_rtrn = XKB_KEY_NoSymbol;
return 1; return 1;
} }
else if ((strcasecmp(str, "none") == 0) || else if ((strcasecmp(str, "none") == 0) ||
(strcasecmp(str, "voidsymbol") == 0)) (strcasecmp(str, "voidsymbol") == 0)) {
{
*sym_rtrn = XKB_KEY_VoidSymbol; *sym_rtrn = XKB_KEY_VoidSymbol;
return 1; return 1;
} }
sym = xkb_keysym_from_name(str); sym = xkb_keysym_from_name(str);
if (sym != XKB_KEY_NoSymbol) if (sym != XKB_KEY_NoSymbol) {
{
*sym_rtrn = sym; *sym_rtrn = sym;
return 1; return 1;
} }
@ -495,23 +461,19 @@ IncludeCreate(char *str, enum merge_mode merge)
stmt = uDupString(str); stmt = uDupString(str);
while ((tmp) && (*tmp)) while ((tmp) && (*tmp))
{ {
if (XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data)) if (XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data)) {
{ if ((file == NULL) && (map == NULL)) {
if ((file == NULL) && (map == NULL))
{
if (haveSelf) if (haveSelf)
goto BAIL; goto BAIL;
haveSelf = true; haveSelf = true;
} }
if (first == NULL) if (first == NULL)
first = incl = uTypedAlloc(IncludeStmt); first = incl = uTypedAlloc(IncludeStmt);
else else {
{
incl->next = uTypedAlloc(IncludeStmt); incl->next = uTypedAlloc(IncludeStmt);
incl = incl->next; incl = incl->next;
} }
if (incl) if (incl) {
{
incl->common.stmtType = StmtInclude; incl->common.stmtType = StmtInclude;
incl->common.next = NULL; incl->common.next = NULL;
incl->merge = merge; incl->merge = merge;
@ -522,8 +484,7 @@ IncludeCreate(char *str, enum merge_mode merge)
incl->path = NULL; incl->path = NULL;
incl->next = NULL; incl->next = NULL;
} }
else else {
{
WSGO("Allocation failure in IncludeCreate\n"); WSGO("Allocation failure in IncludeCreate\n");
ACTION("Using only part of the include\n"); ACTION("Using only part of the include\n");
break; break;
@ -533,8 +494,7 @@ IncludeCreate(char *str, enum merge_mode merge)
else else
merge = MERGE_OVERRIDE; merge = MERGE_OVERRIDE;
} }
else else {
{
goto BAIL; goto BAIL;
} }
} }
@ -559,21 +519,17 @@ CheckDefaultMap(XkbFile * maps, const char *fileName)
dflt = NULL; dflt = NULL;
for (tmp = maps, dflt = NULL; tmp != NULL; for (tmp = maps, dflt = NULL; tmp != NULL;
tmp = (XkbFile *) tmp->common.next) tmp = (XkbFile *) tmp->common.next) {
{ if (tmp->flags & XkbLC_Default) {
if (tmp->flags & XkbLC_Default)
{
if (dflt == NULL) if (dflt == NULL)
dflt = tmp; dflt = tmp;
else else {
{ if (warningLevel > 2) {
if (warningLevel > 2)
{
WARN("Multiple default components in %s\n", WARN("Multiple default components in %s\n",
(fileName ? fileName : "(unknown)")); (fileName ? fileName : "(unknown)"));
ACTION("Using %s, ignoring %s\n", ACTION("Using %s, ignoring %s\n",
(dflt->name ? dflt->name : "(first)"), (dflt->name ? dflt->name : "(first)"),
(tmp->name ? tmp->name : "(subsequent)")); (tmp->name ? tmp->name : "(subsequent)"));
} }
tmp->flags &= (~XkbLC_Default); tmp->flags &= (~XkbLC_Default);
} }
@ -598,9 +554,9 @@ EnsureSafeMapName(char *name)
if (!name) if (!name)
return; return;
while (*name!='\0') { while (*name != '\0') {
if ((componentSpecLegal[(*name) / 8] & (1 << ((*name) % 8))) == 0) if ((componentSpecLegal[(*name) / 8] & (1 << ((*name) % 8))) == 0)
*name= '_'; *name = '_';
name++; name++;
} }
} }
@ -612,8 +568,7 @@ CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name,
XkbFile *file; XkbFile *file;
file = uTypedAlloc(XkbFile); file = uTypedAlloc(XkbFile);
if (file) if (file) {
{
EnsureSafeMapName(name); EnsureSafeMapName(name);
memset(file, 0, sizeof(XkbFile)); memset(file, 0, sizeof(XkbFile));
file->type = type; file->type = type;
@ -634,8 +589,7 @@ FreeExpr(ExprDef *expr)
if (!expr) if (!expr)
return; return;
switch (expr->op) switch (expr->op) {
{
case ExprActionList: case ExprActionList:
case OpNegate: case OpNegate:
case OpUnaryPlus: case OpUnaryPlus:
@ -643,6 +597,7 @@ FreeExpr(ExprDef *expr)
case OpInvert: case OpInvert:
FreeStmt(&expr->value.child->common); FreeStmt(&expr->value.child->common);
break; break;
case OpDivide: case OpDivide:
case OpAdd: case OpAdd:
case OpSubtract: case OpSubtract:
@ -651,19 +606,23 @@ FreeExpr(ExprDef *expr)
FreeStmt(&expr->value.binary.left->common); FreeStmt(&expr->value.binary.left->common);
FreeStmt(&expr->value.binary.right->common); FreeStmt(&expr->value.binary.right->common);
break; break;
case ExprActionDecl: case ExprActionDecl:
FreeStmt(&expr->value.action.args->common); FreeStmt(&expr->value.action.args->common);
break; break;
case ExprArrayRef: case ExprArrayRef:
FreeStmt(&expr->value.array.entry->common); FreeStmt(&expr->value.array.entry->common);
break; break;
case ExprKeysymList: case ExprKeysymList:
darray_foreach(sym, expr->value.list.syms) darray_foreach(sym, expr->value.list.syms)
free(*sym); free(*sym);
darray_free(expr->value.list.syms); darray_free(expr->value.list.syms);
darray_free(expr->value.list.symsMapIndex); darray_free(expr->value.list.symsMapIndex);
darray_free(expr->value.list.symsNumEntries); darray_free(expr->value.list.symsNumEntries);
break; break;
default: default:
break; break;
} }
@ -700,10 +659,9 @@ FreeStmt(ParseCommon *stmt)
next = stmt->next; next = stmt->next;
u.any = stmt; u.any = stmt;
switch (stmt->stmtType) switch (stmt->stmtType) {
{
case StmtInclude: case StmtInclude:
FreeInclude((IncludeStmt *)stmt); FreeInclude((IncludeStmt *) stmt);
/* stmt is already free'd here. */ /* stmt is already free'd here. */
stmt = NULL; stmt = NULL;
break; break;
@ -756,13 +714,13 @@ FreeXKBFile(XkbFile *file)
while (file) while (file)
{ {
next = (XkbFile *)file->common.next; next = (XkbFile *) file->common.next;
switch (file->type) switch (file->type) {
{
case FILE_TYPE_KEYMAP: case FILE_TYPE_KEYMAP:
FreeXKBFile((XkbFile *)file->defs); FreeXKBFile((XkbFile *) file->defs);
break; break;
case FILE_TYPE_TYPES: case FILE_TYPE_TYPES:
case FILE_TYPE_COMPAT: case FILE_TYPE_COMPAT:
case FILE_TYPE_SYMBOLS: case FILE_TYPE_SYMBOLS:
@ -770,6 +728,7 @@ FreeXKBFile(XkbFile *file)
case FILE_TYPE_GEOMETRY: case FILE_TYPE_GEOMETRY:
FreeStmt(file->defs); FreeStmt(file->defs);
break; break;
default: default:
break; break;
} }

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef PARSEUTILS_H #ifndef PARSEUTILS_H
@ -118,15 +118,17 @@ CheckDefaultMap(XkbFile *maps, const char *fileName);
extern XkbFile * extern XkbFile *
CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name, CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name,
ParseCommon *defs, unsigned flags); ParseCommon *defs,
unsigned flags);
extern bool extern bool
XKBParseFile(struct xkb_context *ctx, FILE *file, XKBParseFile(struct xkb_context *ctx, FILE *file, const char *file_name,
const char *file_name, XkbFile **out); XkbFile **out);
extern bool extern bool
XKBParseString(struct xkb_context *context, const char *string, XKBParseString(struct xkb_context *context, const char *string,
const char *file_name, XkbFile **out); const char *file_name,
XkbFile **out);
extern void extern void
FreeXKBFile(XkbFile *file); FreeXKBFile(XkbFile *file);

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include <errno.h> #include <errno.h>
@ -62,63 +62,52 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
char *tmp, *str, *next; char *tmp, *str, *next;
str = *str_inout; str = *str_inout;
if ((*str == '+') || (*str == '|')) if ((*str == '+') || (*str == '|')) {
{
*file_rtrn = *map_rtrn = NULL; *file_rtrn = *map_rtrn = NULL;
*nextop_rtrn = *str; *nextop_rtrn = *str;
next = str + 1; next = str + 1;
} }
else if (*str == '%') else if (*str == '%') {
{
*file_rtrn = *map_rtrn = NULL; *file_rtrn = *map_rtrn = NULL;
*nextop_rtrn = str[1]; *nextop_rtrn = str[1];
next = str + 2; next = str + 2;
} }
else else {
{
/* search for tokens inside the string */ /* search for tokens inside the string */
next = strpbrk(str, "|+"); next = strpbrk(str, "|+");
if (next) if (next) {
{
/* set nextop_rtrn to \0, next to next character */ /* set nextop_rtrn to \0, next to next character */
*nextop_rtrn = *next; *nextop_rtrn = *next;
*next++ = '\0'; *next++ = '\0';
} }
else else {
{
*nextop_rtrn = '\0'; *nextop_rtrn = '\0';
next = NULL; next = NULL;
} }
/* search for :, store result in extra_data */ /* search for :, store result in extra_data */
tmp = strchr(str, ':'); tmp = strchr(str, ':');
if (tmp != NULL) if (tmp != NULL) {
{
*tmp++ = '\0'; *tmp++ = '\0';
*extra_data = uDupString(tmp); *extra_data = uDupString(tmp);
} }
else else {
{
*extra_data = NULL; *extra_data = NULL;
} }
tmp = strchr(str, '('); tmp = strchr(str, '(');
if (tmp == NULL) if (tmp == NULL) {
{
*file_rtrn = uDupString(str); *file_rtrn = uDupString(str);
*map_rtrn = NULL; *map_rtrn = NULL;
} }
else if (str[0] == '(') else if (str[0] == '(') {
{
free(*extra_data); free(*extra_data);
return false; return false;
} }
else else {
{
*tmp++ = '\0'; *tmp++ = '\0';
*file_rtrn = uDupString(str); *file_rtrn = uDupString(str);
str = tmp; str = tmp;
tmp = strchr(str, ')'); tmp = strchr(str, ')');
if ((tmp == NULL) || (tmp[1] != '\0')) if ((tmp == NULL) || (tmp[1] != '\0')) {
{
free(*file_rtrn); free(*file_rtrn);
free(*extra_data); free(*extra_data);
return false; return false;
@ -144,22 +133,28 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
const char * const char *
XkbDirectoryForInclude(enum xkb_file_type type) XkbDirectoryForInclude(enum xkb_file_type type)
{ {
switch (type) switch (type) {
{
case FILE_TYPE_KEYMAP: case FILE_TYPE_KEYMAP:
return "keymap"; return "keymap";
case FILE_TYPE_KEYCODES: case FILE_TYPE_KEYCODES:
return "keycodes"; return "keycodes";
case FILE_TYPE_TYPES: case FILE_TYPE_TYPES:
return "types"; return "types";
case FILE_TYPE_SYMBOLS: case FILE_TYPE_SYMBOLS:
return "symbols"; return "symbols";
case FILE_TYPE_COMPAT: case FILE_TYPE_COMPAT:
return "compat"; return "compat";
case FILE_TYPE_GEOMETRY: case FILE_TYPE_GEOMETRY:
return "geometry"; return "geometry";
case FILE_TYPE_RULES: case FILE_TYPE_RULES:
return "rules"; return "rules";
default: default:
return ""; return "";
} }
@ -189,12 +184,10 @@ XkbFindFileInPath(struct xkb_context *ctx,
const char *typeDir; const char *typeDir;
typeDir = XkbDirectoryForInclude(type); typeDir = XkbDirectoryForInclude(type);
for (i = 0; i < xkb_context_num_include_paths(ctx); i++) for (i = 0; i < xkb_context_num_include_paths(ctx); i++) {
{
ret = snprintf(buf, sizeof(buf), "%s/%s/%s", ret = snprintf(buf, sizeof(buf), "%s/%s/%s",
xkb_context_include_path_get(ctx, i), typeDir, name); xkb_context_include_path_get(ctx, i), typeDir, name);
if (ret >= (ssize_t)sizeof(buf)) if (ret >= (ssize_t) sizeof(buf)) {
{
ERROR("File name (%s/%s/%s) too long\n", ERROR("File name (%s/%s/%s) too long\n",
xkb_context_include_path_get(ctx, i), typeDir, name); xkb_context_include_path_get(ctx, i), typeDir, name);
ACTION("Ignored\n"); ACTION("Ignored\n");

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef XKBCOMP_PATH_H #ifndef XKBCOMP_PATH_H
@ -33,13 +33,14 @@
bool bool
XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn, XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
char *nextop_rtrn, char **extra_data); char *nextop_rtrn,
char **extra_data);
const char * const char *
XkbDirectoryForInclude(unsigned type); XkbDirectoryForInclude(unsigned type);
FILE * FILE *
XkbFindFileInPath(struct xkb_context *ctx, XkbFindFileInPath(struct xkb_context *ctx, const char *name, unsigned type,
const char *name, unsigned type, char **pathRtrn); char **pathRtrn);
#endif /* XKBCOMP_PATH_H */ #endif /* XKBCOMP_PATH_H */

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include <stdio.h> #include <stdio.h>
@ -192,9 +192,9 @@ struct group {
enum rule_flag { enum rule_flag {
RULE_FLAG_PENDING_MATCH = (1L << 1), RULE_FLAG_PENDING_MATCH = (1L << 1),
RULE_FLAG_OPTION = (1L << 2), RULE_FLAG_OPTION = (1L << 2),
RULE_FLAG_APPEND = (1L << 3), RULE_FLAG_APPEND = (1L << 3),
RULE_FLAG_NORMAL = (1L << 4), RULE_FLAG_NORMAL = (1L << 4),
}; };
struct rule { struct rule {
@ -236,9 +236,11 @@ get_index(char *str, int *ndx)
if (consumed > 0) { if (consumed > 0) {
*ndx = num; *ndx = num;
str += consumed; str += consumed;
} else if (empty > 0) { }
else if (empty > 0) {
*ndx = -1; *ndx = -1;
} else { }
else {
*ndx = 0; *ndx = 0;
} }
@ -299,10 +301,12 @@ match_mapping_line(darray_char *line, struct mapping *mapping)
if (ndx < 1 || ndx > XkbNumKbdGroups) { if (ndx < 1 || ndx > XkbNumKbdGroups) {
WARN("Illegal %s index: %d\n", cname[i], ndx); WARN("Illegal %s index: %d\n", cname[i], ndx);
WARN("Index must be in range 1..%d\n", XkbNumKbdGroups); WARN("Index must be in range 1..%d\n",
XkbNumKbdGroups);
break; break;
} }
} else { }
else {
ndx = 0; ndx = 0;
} }
@ -412,7 +416,8 @@ match_rule_line(darray_char *line, struct mapping *mapping,
str = darray_mem(*line, 0); str = darray_mem(*line, 0);
for (nread = 0; (tok = strtok_r(str, " ", &strtok_buf)) != NULL; nread++) { for (nread = 0; (tok = strtok_r(str, " ", &strtok_buf)) != NULL;
nread++) {
str = NULL; str = NULL;
if (strcmp(tok, "=") == 0) { if (strcmp(tok, "=") == 0) {
@ -488,15 +493,15 @@ match_line(darray_char *line, struct mapping *mapping,
static void static void
squeeze_spaces(char *p1) squeeze_spaces(char *p1)
{ {
char *p2; char *p2;
for (p2 = p1; *p2; p2++) { for (p2 = p1; *p2; p2++) {
*p1 = *p2; *p1 = *p2;
if (*p1 != ' ') if (*p1 != ' ')
p1++; p1++;
} }
*p1 = '\0'; *p1 = '\0';
} }
/* /*
@ -577,7 +582,8 @@ make_multi_defs(struct multi_defs *mdefs, const struct xkb_rule_names *mlvo)
if ((p = strchr(p, ','))) { if ((p = strchr(p, ','))) {
*p++ = '\0'; *p++ = '\0';
mdefs->variant[i] = p; mdefs->variant[i] = p;
} else { }
else {
break; break;
} }
} }
@ -654,26 +660,26 @@ static bool
match_group_member(struct rules *rules, const char *group_name, match_group_member(struct rules *rules, const char *group_name,
const char *name) const char *name)
{ {
int i; int i;
const char *word; const char *word;
struct group *iter, *group = NULL; struct group *iter, *group = NULL;
darray_foreach(iter, rules->groups) { darray_foreach(iter, rules->groups) {
if (strcmp(iter->name, group_name) == 0) { if (strcmp(iter->name, group_name) == 0) {
group = iter; group = iter;
break; break;
} }
} }
if (!group) if (!group)
return false; return false;
word = group->words; word = group->words;
for (i = 0; i < group->number; i++, word += strlen(word) + 1) for (i = 0; i < group->number; i++, word += strlen(word) + 1)
if (strcmp(word, name) == 0) if (strcmp(word, name) == 0)
return true; return true;
return false; return false;
} }
/* Match @needle out of @sep-seperated @haystack. */ /* Match @needle out of @sep-seperated @haystack. */
@ -733,7 +739,7 @@ apply_rule_if_matches(struct rules *rules, struct rule *rule,
else if (rule->layout[0] == '$') { else if (rule->layout[0] == '$') {
if (!match_group_member(rules, rule->layout, if (!match_group_member(rules, rule->layout,
mdefs->layout[rule->layout_num])) mdefs->layout[rule->layout_num]))
return 0; return 0;
} }
else if (strcmp(rule->layout, else if (strcmp(rule->layout,
mdefs->layout[rule->layout_num]) != 0) { mdefs->layout[rule->layout_num]) != 0) {
@ -747,7 +753,8 @@ apply_rule_if_matches(struct rules *rules, struct rule *rule,
if (strcmp(rule->variant, "*") == 0) { if (strcmp(rule->variant, "*") == 0) {
pending = true; pending = true;
} else if (rule->variant[0] == '$') { }
else if (rule->variant[0] == '$') {
if (!match_group_member(rules, rule->variant, if (!match_group_member(rules, rule->variant,
mdefs->variant[rule->variant_num])) mdefs->variant[rule->variant_num]))
return 0; return 0;
@ -760,7 +767,8 @@ apply_rule_if_matches(struct rules *rules, struct rule *rule,
if (pending) { if (pending) {
rule->flags |= RULE_FLAG_PENDING_MATCH; rule->flags |= RULE_FLAG_PENDING_MATCH;
} else { }
else {
/* Exact match, apply it now. */ /* Exact match, apply it now. */
apply_rule(rule, kccgst); apply_rule(rule, kccgst);
} }
@ -774,7 +782,7 @@ clear_partial_matches(struct rules *rules)
struct rule *rule; struct rule *rule;
darray_foreach(rule, rules->rules) darray_foreach(rule, rules->rules)
rule->flags &= ~RULE_FLAG_PENDING_MATCH; rule->flags &= ~RULE_FLAG_PENDING_MATCH;
} }
static void static void
@ -783,8 +791,8 @@ apply_partial_matches(struct rules *rules, struct xkb_component_names *kccgst)
struct rule *rule; struct rule *rule;
darray_foreach(rule, rules->rules) darray_foreach(rule, rules->rules)
if (rule->flags & RULE_FLAG_PENDING_MATCH) if (rule->flags & RULE_FLAG_PENDING_MATCH)
apply_rule(rule, kccgst); apply_rule(rule, kccgst);
} }
static void static void
@ -904,7 +912,8 @@ substitute_vars(char *name, struct multi_defs *mdefs)
if (sfx) if (sfx)
*outstr++ = sfx; *outstr++ = sfx;
} }
else if (*var == 'v' && mdefs->variant[ndx] && *mdefs->variant[ndx]) { else if (*var == 'v' && mdefs->variant[ndx] &&
*mdefs->variant[ndx]) {
if (pfx) if (pfx)
*outstr++ = pfx; *outstr++ = pfx;
@ -919,11 +928,11 @@ substitute_vars(char *name, struct multi_defs *mdefs)
str++; str++;
} }
else { else {
*outstr++= *str++; *outstr++ = *str++;
} }
} }
*outstr++= '\0'; *outstr++ = '\0';
if (orig != name) if (orig != name)
free(orig); free(orig);
@ -959,8 +968,8 @@ get_components(struct rules *rules, const struct xkb_rule_names *mlvo,
free_multi_defs(&mdefs); free_multi_defs(&mdefs);
return return kccgst->keycodes && kccgst->symbols && kccgst->types &&
kccgst->keycodes && kccgst->symbols && kccgst->types && kccgst->compat; kccgst->compat;
} }
static struct rules * static struct rules *
@ -988,7 +997,8 @@ load_rules(FILE *file)
if (tgroup.number) { if (tgroup.number) {
darray_append(rules->groups, tgroup); darray_append(rules->groups, tgroup);
memset(&tgroup, 0, sizeof(tgroup)); memset(&tgroup, 0, sizeof(tgroup));
} else { }
else {
darray_append(rules->rules, trule); darray_append(rules->rules, trule);
memset(&trule, 0, sizeof(trule)); memset(&trule, 0, sizeof(trule));
} }

View File

@ -1,28 +1,28 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#ifndef RULES_H #ifndef RULES_H
#define RULES_H #define RULES_H

File diff suppressed because it is too large Load Diff

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#include "vmod.h" #include "vmod.h"
@ -47,11 +47,9 @@ ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
return; return;
info->keymap = keymap; info->keymap = keymap;
if (keymap && keymap->names) if (keymap && keymap->names) {
{
int bit; int bit;
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
{
if (keymap->names->vmods[i] != NULL) if (keymap->names->vmods[i] != NULL)
info->defined |= bit; info->defined |= bit;
} }
@ -69,7 +67,8 @@ ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
* @param mergeMode Merge strategy (e.g. MERGE_OVERRIDE) * @param mergeMode Merge strategy (e.g. MERGE_OVERRIDE)
*/ */
bool bool
HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, enum merge_mode mergeMode, HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
enum merge_mode mergeMode,
VModInfo *info) VModInfo *info)
{ {
int i, bit, nextFree; int i, bit, nextFree;
@ -77,23 +76,20 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, enum merge_mode mergeMod
struct xkb_server_map *srv = keymap->server; struct xkb_server_map *srv = keymap->server;
struct xkb_names *names = keymap->names; struct xkb_names *names = keymap->names;
for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<= 1) for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<=
{ 1) {
if (info->defined & bit) if (info->defined & bit) {
{
if (names->vmods[i] && if (names->vmods[i] &&
strcmp(names->vmods[i], strcmp(names->vmods[i],
xkb_atom_text(keymap->ctx, stmt->name)) == 0) xkb_atom_text(keymap->ctx, stmt->name)) == 0) { /* already defined */
{ /* already defined */
info->available |= bit; info->available |= bit;
if (stmt->value == NULL) if (stmt->value == NULL)
return true; return true;
else else {
{
const char *str1; const char *str1;
const char *str2 = ""; const char *str2 = "";
if (!ExprResolveModMask(keymap->ctx, stmt->value, &mod)) if (!ExprResolveModMask(keymap->ctx, stmt->value,
{ &mod)) {
str1 = xkb_atom_text(keymap->ctx, stmt->name); str1 = xkb_atom_text(keymap->ctx, stmt->name);
ACTION("Declaration of %s ignored\n", str1); ACTION("Declaration of %s ignored\n", str1);
return false; return false;
@ -104,8 +100,7 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, enum merge_mode mergeMod
str1 = xkb_atom_text(keymap->ctx, stmt->name); str1 = xkb_atom_text(keymap->ctx, stmt->name);
WARN("Virtual modifier %s multiply defined\n", str1); WARN("Virtual modifier %s multiply defined\n", str1);
str1 = XkbcModMaskText(srv->vmods[i], true); str1 = XkbcModMaskText(srv->vmods[i], true);
if (mergeMode == MERGE_OVERRIDE) if (mergeMode == MERGE_OVERRIDE) {
{
str2 = str1; str2 = str1;
str1 = XkbcModMaskText(mod.uval, true); str1 = XkbcModMaskText(mod.uval, true);
} }
@ -119,10 +114,9 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, enum merge_mode mergeMod
else if (nextFree < 0) else if (nextFree < 0)
nextFree = i; nextFree = i;
} }
if (nextFree < 0) if (nextFree < 0) {
{
ERROR("Too many virtual modifiers defined (maximum %d)\n", ERROR("Too many virtual modifiers defined (maximum %d)\n",
XkbNumVirtualMods); XkbNumVirtualMods);
return false; return false;
} }
info->defined |= (1 << nextFree); info->defined |= (1 << nextFree);
@ -131,12 +125,12 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, enum merge_mode mergeMod
names->vmods[nextFree] = xkb_atom_strdup(keymap->ctx, stmt->name); names->vmods[nextFree] = xkb_atom_strdup(keymap->ctx, stmt->name);
if (stmt->value == NULL) if (stmt->value == NULL)
return true; return true;
if (ExprResolveModMask(keymap->ctx, stmt->value, &mod)) if (ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
{
srv->vmods[nextFree] = mod.uval; srv->vmods[nextFree] = mod.uval;
return true; return true;
} }
ACTION("Declaration of %s ignored\n", xkb_atom_text(keymap->ctx, stmt->name)); ACTION("Declaration of %s ignored\n",
xkb_atom_text(keymap->ctx, stmt->name));
return false; return false;
} }
@ -158,8 +152,7 @@ LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
int i; int i;
const char *name = xkb_atom_text(keymap->ctx, field); const char *name = xkb_atom_text(keymap->ctx, field);
if ((keymap == NULL) || (keymap->names == NULL) || (type != TypeInt)) if ((keymap == NULL) || (keymap->names == NULL) || (type != TypeInt)) {
{
return false; return false;
} }
/* For each named modifier, get the name and compare it to the one passed /* For each named modifier, get the name and compare it to the one passed
@ -167,11 +160,9 @@ LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
* The order of modifiers is the same as in the virtual_modifiers line in * The order of modifiers is the same as in the virtual_modifiers line in
* the xkb_types section. * the xkb_types section.
*/ */
for (i = 0; i < XkbNumVirtualMods; i++) for (i = 0; i < XkbNumVirtualMods; i++) {
{
if (keymap->names->vmods[i] && if (keymap->names->vmods[i] &&
strcmp(keymap->names->vmods[i], name) == 0) strcmp(keymap->names->vmods[i], name) == 0) {
{
val_rtrn->uval = i; val_rtrn->uval = i;
return true; return true;
} }
@ -193,12 +184,10 @@ bool
LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field, LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn) unsigned type, ExprResult *val_rtrn)
{ {
if (LookupModMask(ctx, NULL, field, type, val_rtrn)) if (LookupModMask(ctx, NULL, field, type, val_rtrn)) {
{
return true; return true;
} }
else if (LookupVModIndex(priv, field, type, val_rtrn)) else if (LookupVModIndex(priv, field, type, val_rtrn)) {
{
unsigned ndx = val_rtrn->uval; unsigned ndx = val_rtrn->uval;
val_rtrn->uval = (1 << (XkbNumModifiers + ndx)); val_rtrn->uval = (1 << (XkbNumModifiers + ndx));
return true; return true;
@ -213,8 +202,7 @@ FindKeypadVMod(struct xkb_keymap *keymap)
ExprResult rtrn; ExprResult rtrn;
name = xkb_atom_intern(keymap->ctx, "NumLock"); name = xkb_atom_intern(keymap->ctx, "NumLock");
if ((keymap) && LookupVModIndex(keymap, name, TypeInt, &rtrn)) if ((keymap) && LookupVModIndex(keymap, name, TypeInt, &rtrn)) {
{
return rtrn.ival; return rtrn.ival;
} }
return -1; return -1;
@ -226,26 +214,22 @@ ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
{ {
struct xkb_names *names = keymap->names; struct xkb_names *names = keymap->names;
if (def->op == ExprIdent) if (def->op == ExprIdent) {
{
int i, bit; int i, bit;
const char *name = xkb_atom_text(keymap->ctx, def->value.str); const char *name = xkb_atom_text(keymap->ctx, def->value.str);
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1) {
{
if ((info->available & bit) && names->vmods[i] && if ((info->available & bit) && names->vmods[i] &&
strcmp(names->vmods[i], name) == 0) strcmp(names->vmods[i], name) == 0) {
{
val_rtrn->uval = i; val_rtrn->uval = i;
return true; return true;
} }
} }
} }
if (ExprResolveInteger(keymap->ctx, def, val_rtrn)) if (ExprResolveInteger(keymap->ctx, def, val_rtrn)) {
{
if (val_rtrn->uval < XkbNumVirtualMods) if (val_rtrn->uval < XkbNumVirtualMods)
return true; return true;
ERROR("Illegal virtual modifier %d (must be 0..%d inclusive)\n", ERROR("Illegal virtual modifier %d (must be 0..%d inclusive)\n",
val_rtrn->uval, XkbNumVirtualMods - 1); val_rtrn->uval, XkbNumVirtualMods - 1);
} }
return false; return false;
} }

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef VMOD_H #ifndef VMOD_H
@ -30,8 +30,7 @@
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
#include "expr.h" #include "expr.h"
typedef struct _VModInfo typedef struct _VModInfo {
{
struct xkb_keymap *keymap; struct xkb_keymap *keymap;
unsigned defined; unsigned defined;
unsigned available; unsigned available;
@ -46,7 +45,8 @@ extern void
ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap); ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap);
extern bool extern bool
HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, enum merge_mode mergeMode, HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap,
enum merge_mode mergeMode,
VModInfo *info); VModInfo *info);
extern bool extern bool
@ -57,6 +57,7 @@ FindKeypadVMod(struct xkb_keymap *keymap);
extern bool extern bool
ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap, ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
ExprResult *value_rtrn, VModInfo *info); ExprResult *value_rtrn,
VModInfo *info);
#endif /* VMOD_H */ #endif /* VMOD_H */

View File

@ -1,27 +1,27 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef XKBCOMP_PRIV_H #ifndef XKBCOMP_PRIV_H
@ -32,8 +32,7 @@
#include "text.h" #include "text.h"
#include "utils.h" #include "utils.h"
typedef struct _CommonInfo typedef struct _CommonInfo {
{
unsigned short defined; unsigned short defined;
unsigned file_id; unsigned file_id;
enum merge_mode merge; enum merge_mode merge;
@ -48,7 +47,7 @@ extern void *
ClearCommonInfo(CommonInfo *cmn); ClearCommonInfo(CommonInfo *cmn);
extern void * extern void *
AddCommonInfo(CommonInfo *old, CommonInfo *new); AddCommonInfo(CommonInfo * old, CommonInfo * new);
extern int extern int
ReportNotArray(const char *type, const char *field, const char *name); ReportNotArray(const char *type, const char *field, const char *name);
@ -64,9 +63,9 @@ extern int
ReportBadField(const char *type, const char *field, const char *name); ReportBadField(const char *type, const char *field, const char *name);
extern bool extern bool
ProcessIncludeFile(struct xkb_context *ctx, ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
IncludeStmt *stmt, enum xkb_file_type file_type, enum xkb_file_type file_type, XkbFile **file_rtrn,
XkbFile **file_rtrn, enum merge_mode *merge_rtrn); enum merge_mode *merge_rtrn);
extern bool extern bool
FindNamedKey(struct xkb_keymap *keymap, unsigned long name, FindNamedKey(struct xkb_keymap *keymap, unsigned long name,

View File

@ -1,28 +1,28 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#include "xkbcomp-priv.h" #include "xkbcomp-priv.h"
#include "rules.h" #include "rules.h"
@ -42,21 +42,21 @@ keymap_file_from_components(struct xkb_context *ctx,
inc = IncludeCreate(ktcsg->keycodes, MERGE_DEFAULT); inc = IncludeCreate(ktcsg->keycodes, MERGE_DEFAULT);
keycodes = CreateXKBFile(ctx, FILE_TYPE_KEYCODES, NULL, keycodes = CreateXKBFile(ctx, FILE_TYPE_KEYCODES, NULL,
(ParseCommon *)inc, 0); (ParseCommon *) inc, 0);
inc = IncludeCreate(ktcsg->types, MERGE_DEFAULT); inc = IncludeCreate(ktcsg->types, MERGE_DEFAULT);
types = CreateXKBFile(ctx, FILE_TYPE_TYPES, NULL, types = CreateXKBFile(ctx, FILE_TYPE_TYPES, NULL,
(ParseCommon *)inc, 0); (ParseCommon *) inc, 0);
AppendStmt(&keycodes->common, &types->common); AppendStmt(&keycodes->common, &types->common);
inc = IncludeCreate(ktcsg->compat, MERGE_DEFAULT); inc = IncludeCreate(ktcsg->compat, MERGE_DEFAULT);
compat = CreateXKBFile(ctx, FILE_TYPE_COMPAT, NULL, compat = CreateXKBFile(ctx, FILE_TYPE_COMPAT, NULL,
(ParseCommon *)inc, 0); (ParseCommon *) inc, 0);
AppendStmt(&keycodes->common, &compat->common); AppendStmt(&keycodes->common, &compat->common);
inc = IncludeCreate(ktcsg->symbols, MERGE_DEFAULT); inc = IncludeCreate(ktcsg->symbols, MERGE_DEFAULT);
symbols = CreateXKBFile(ctx, FILE_TYPE_SYMBOLS, NULL, symbols = CreateXKBFile(ctx, FILE_TYPE_SYMBOLS, NULL,
(ParseCommon *)inc, 0); (ParseCommon *) inc, 0);
AppendStmt(&keycodes->common, &symbols->common); AppendStmt(&keycodes->common, &symbols->common);
return CreateXKBFile(ctx, FILE_TYPE_KEYMAP, strdup(""), return CreateXKBFile(ctx, FILE_TYPE_KEYMAP, strdup(""),
@ -97,11 +97,11 @@ compile_keymap(struct xkb_context *ctx, XkbFile *file)
} }
/* Check for duplicate entries in the input file */ /* Check for duplicate entries in the input file */
for (file = (XkbFile *)file->defs; file; for (file = (XkbFile *) file->defs; file;
file = (XkbFile *)file->common.next) { file = (XkbFile *) file->common.next) {
if (have & file->type) { if (have & file->type) {
ERROR("More than one %s section in a keymap file\n", ERROR("More than one %s section in a keymap file\n",
XkbcFileTypeText(file->type)); XkbcFileTypeText(file->type));
ACTION("All sections after the first ignored\n"); ACTION("All sections after the first ignored\n");
continue; continue;
} }
@ -110,18 +110,22 @@ compile_keymap(struct xkb_context *ctx, XkbFile *file)
case FILE_TYPE_KEYCODES: case FILE_TYPE_KEYCODES:
keycodes = file; keycodes = file;
break; break;
case FILE_TYPE_TYPES: case FILE_TYPE_TYPES:
types = file; types = file;
break; break;
case FILE_TYPE_SYMBOLS: case FILE_TYPE_SYMBOLS:
symbols = file; symbols = file;
break; break;
case FILE_TYPE_COMPAT: case FILE_TYPE_COMPAT:
compat = file; compat = file;
break; break;
default: default:
ERROR("Cannot define %s in a keymap file\n", ERROR("Cannot define %s in a keymap file\n",
XkbcFileTypeText(file->type)); XkbcFileTypeText(file->type));
continue; continue;
} }

View File

@ -1,82 +1,81 @@
/************************************************************ /************************************************************
Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc. * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
*
Permission to use, copy, modify, and distribute this * Permission to use, copy, modify, and distribute this
software and its documentation for any purpose and without * software and its documentation for any purpose and without
fee is hereby granted, provided that the above copyright * fee is hereby granted, provided that the above copyright
notice appear in all copies and that both that copyright * notice appear in all copies and that both that copyright
notice and this permission notice appear in supporting * notice and this permission notice appear in supporting
documentation, and that the name of Silicon Graphics not be * documentation, and that the name of Silicon Graphics not be
used in advertising or publicity pertaining to distribution * used in advertising or publicity pertaining to distribution
of the software without specific prior written permission. * of the software without specific prior written permission.
Silicon Graphics makes no representation about the suitability * Silicon Graphics makes no representation about the suitability
of this software for any purpose. It is provided "as is" * of this software for any purpose. It is provided "as is"
without any express or implied warranty. * without any express or implied warranty.
*
SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
THE USE OR PERFORMANCE OF THIS SOFTWARE. * THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
********************************************************/ ********************************************************/
#ifndef XKBCOMP_H #ifndef XKBCOMP_H
#define XKBCOMP_H 1 #define XKBCOMP_H 1
#include "xkb-priv.h" #include "xkb-priv.h"
#define TypeUnknown 0 #define TypeUnknown 0
#define TypeBoolean 1 #define TypeBoolean 1
#define TypeInt 2 #define TypeInt 2
#define TypeString 4 #define TypeString 4
#define TypeAction 5 #define TypeAction 5
#define TypeKeyName 6 #define TypeKeyName 6
#define TypeSymbols 7 #define TypeSymbols 7
#define StmtUnknown 0 #define StmtUnknown 0
#define StmtInclude 1 #define StmtInclude 1
#define StmtKeycodeDef 2 #define StmtKeycodeDef 2
#define StmtKeyAliasDef 3 #define StmtKeyAliasDef 3
#define StmtExpr 4 #define StmtExpr 4
#define StmtVarDef 5 #define StmtVarDef 5
#define StmtKeyTypeDef 6 #define StmtKeyTypeDef 6
#define StmtInterpDef 7 #define StmtInterpDef 7
#define StmtVModDef 8 #define StmtVModDef 8
#define StmtSymbolsDef 9 #define StmtSymbolsDef 9
#define StmtModMapDef 10 #define StmtModMapDef 10
#define StmtGroupCompatDef 11 #define StmtGroupCompatDef 11
#define StmtIndicatorMapDef 12 #define StmtIndicatorMapDef 12
#define StmtIndicatorNameDef 13 #define StmtIndicatorNameDef 13
#define FileSymInterp 100 #define FileSymInterp 100
typedef struct _ParseCommon typedef struct _ParseCommon {
{
unsigned stmtType; unsigned stmtType;
struct _ParseCommon *next; struct _ParseCommon *next;
} ParseCommon; } ParseCommon;
#define ExprValue 0 #define ExprValue 0
#define ExprIdent 1 #define ExprIdent 1
#define ExprActionDecl 2 #define ExprActionDecl 2
#define ExprFieldRef 3 #define ExprFieldRef 3
#define ExprArrayRef 4 #define ExprArrayRef 4
#define ExprKeysymList 5 #define ExprKeysymList 5
#define ExprActionList 6 #define ExprActionList 6
#define OpAdd 20 #define OpAdd 20
#define OpSubtract 21 #define OpSubtract 21
#define OpMultiply 22 #define OpMultiply 22
#define OpDivide 23 #define OpDivide 23
#define OpAssign 24 #define OpAssign 24
#define OpNot 25 #define OpNot 25
#define OpNegate 26 #define OpNegate 26
#define OpInvert 27 #define OpInvert 27
#define OpUnaryPlus 28 #define OpUnaryPlus 28
enum merge_mode { enum merge_mode {
MERGE_DEFAULT, MERGE_DEFAULT,
@ -85,13 +84,12 @@ enum merge_mode {
MERGE_REPLACE, MERGE_REPLACE,
}; };
#define AutoKeyNames (1L << 0) #define AutoKeyNames (1L << 0)
#define CreateKeyNames(x) ((x)->flags&AutoKeyNames) #define CreateKeyNames(x) ((x)->flags & AutoKeyNames)
extern unsigned warningLevel; extern unsigned warningLevel;
typedef struct _IncludeStmt typedef struct _IncludeStmt {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
char *stmt; char *stmt;
@ -102,36 +100,29 @@ typedef struct _IncludeStmt
struct _IncludeStmt *next; struct _IncludeStmt *next;
} IncludeStmt; } IncludeStmt;
typedef struct _Expr typedef struct _Expr {
{
ParseCommon common; ParseCommon common;
unsigned op; unsigned op;
unsigned type; unsigned type;
union union {
{ struct {
struct
{
struct _Expr *left; struct _Expr *left;
struct _Expr *right; struct _Expr *right;
} binary; } binary;
struct struct {
{
xkb_atom_t element; xkb_atom_t element;
xkb_atom_t field; xkb_atom_t field;
} field; } field;
struct struct {
{
xkb_atom_t element; xkb_atom_t element;
xkb_atom_t field; xkb_atom_t field;
struct _Expr *entry; struct _Expr *entry;
} array; } array;
struct struct {
{
xkb_atom_t name; xkb_atom_t name;
struct _Expr *args; struct _Expr *args;
} action; } action;
struct struct {
{
darray(char *) syms; darray(char *) syms;
darray(int) symsMapIndex; darray(int) symsMapIndex;
darray(unsigned int) symsNumEntries; darray(unsigned int) symsNumEntries;
@ -144,72 +135,63 @@ typedef struct _Expr
} value; } value;
} ExprDef; } ExprDef;
typedef struct _VarDef typedef struct _VarDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
ExprDef *name; ExprDef *name;
ExprDef *value; ExprDef *value;
} VarDef; } VarDef;
typedef struct _VModDef typedef struct _VModDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
xkb_atom_t name; xkb_atom_t name;
ExprDef *value; ExprDef *value;
} VModDef; } VModDef;
typedef struct _KeycodeDef typedef struct _KeycodeDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
char name[5]; char name[5];
unsigned long value; unsigned long value;
} KeycodeDef; } KeycodeDef;
typedef struct _KeyAliasDef typedef struct _KeyAliasDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
char alias[5]; char alias[5];
char real[5]; char real[5];
} KeyAliasDef; } KeyAliasDef;
typedef struct _KeyTypeDef typedef struct _KeyTypeDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
xkb_atom_t name; xkb_atom_t name;
VarDef *body; VarDef *body;
} KeyTypeDef; } KeyTypeDef;
typedef struct _SymbolsDef typedef struct _SymbolsDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
char keyName[5]; char keyName[5];
ExprDef *symbols; ExprDef *symbols;
} SymbolsDef; } SymbolsDef;
typedef struct _ModMapDef typedef struct _ModMapDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
xkb_atom_t modifier; xkb_atom_t modifier;
ExprDef *keys; ExprDef *keys;
} ModMapDef; } ModMapDef;
typedef struct _GroupCompatDef typedef struct _GroupCompatDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
int group; int group;
ExprDef *def; ExprDef *def;
} GroupCompatDef; } GroupCompatDef;
typedef struct _InterpDef typedef struct _InterpDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
char *sym; char *sym;
@ -217,8 +199,7 @@ typedef struct _InterpDef
VarDef *def; VarDef *def;
} InterpDef; } InterpDef;
typedef struct _IndicatorNameDef typedef struct _IndicatorNameDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
int ndx; int ndx;
@ -226,8 +207,7 @@ typedef struct _IndicatorNameDef
bool virtual; bool virtual;
} IndicatorNameDef; } IndicatorNameDef;
typedef struct _IndicatorMapDef typedef struct _IndicatorMapDef {
{
ParseCommon common; ParseCommon common;
enum merge_mode merge; enum merge_mode merge;
unsigned type; unsigned type;
@ -235,8 +215,7 @@ typedef struct _IndicatorMapDef
VarDef *body; VarDef *body;
} IndicatorMapDef; } IndicatorMapDef;
typedef struct _XkbFile typedef struct _XkbFile {
{
ParseCommon common; ParseCommon common;
enum xkb_file_type type; enum xkb_file_type type;
char *topName; char *topName;

View File

@ -1,30 +1,30 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
Copyright © 2012 Daniel Stone * Copyright © 2012 Daniel Stone
Copyright © 2012 Ran Benita * Copyright © 2012 Ran Benita
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,28 +1,28 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#include <assert.h> #include <assert.h>
#include <fcntl.h> #include <fcntl.h>
@ -36,7 +36,8 @@ authorization from the authors.
#include "xkbcommon/xkbcommon.h" #include "xkbcommon/xkbcommon.h"
#include "test.h" #include "test.h"
int main(int argc, char *argv[]) int
main(int argc, char *argv[])
{ {
struct xkb_context *ctx = test_get_context(); struct xkb_context *ctx = test_get_context();
struct xkb_keymap *keymap; struct xkb_keymap *keymap;

View File

@ -1,28 +1,28 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,28 +1,28 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#include <assert.h> #include <assert.h>
#include <stdlib.h> #include <stdlib.h>

View File

@ -1,28 +1,28 @@
/* /*
Copyright 2009 Dan Nicholson * Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>

View File

@ -1,27 +1,27 @@
/* Copyright 2009 Dan Nicholson /* Copyright 2009 Dan Nicholson
*
Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"), * copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation * to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, * the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the * 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: * Software is furnished to do so, subject to the following conditions:
*
The above copyright notice and this permission notice shall be included in * The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software. * all copies or substantial portions of the Software.
*
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * 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 * 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 * 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. * 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 * 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 * institutions shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written * sale, use or other dealings in this Software without prior written
authorization from the authors. * authorization from the authors.
*/ */
#include <assert.h> #include <assert.h>
#include <fcntl.h> #include <fcntl.h>

View File

@ -42,5 +42,5 @@ test_compile_string(struct xkb_context *context, const char *string);
struct xkb_keymap * struct xkb_keymap *
test_compile_rules(struct xkb_context *context, const char *rules, test_compile_rules(struct xkb_context *context, const char *rules,
const char *model, const char *layout, const char *model, const char *layout, const char *variant,
const char *variant, const char *options); const char *options);