summaryrefslogtreecommitdiff
path: root/src/xkbcomp
diff options
context:
space:
mode:
authorDaniel Stone <daniel@fooishbar.org>2012-07-17 10:20:15 +0100
committerDaniel Stone <daniel@fooishbar.org>2012-07-17 10:20:15 +0100
commit9308a460395679aa3cb403211146e4ff9b920992 (patch)
treea060f3f7882c8edf35312c2210d9837ac3a4c306 /src/xkbcomp
parentc6c937abc2e7e9aa9dc952dea392329b88ab1011 (diff)
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>
Diffstat (limited to 'src/xkbcomp')
-rw-r--r--src/xkbcomp/action.c499
-rw-r--r--src/xkbcomp/action.h107
-rw-r--r--src/xkbcomp/alias.c143
-rw-r--r--src/xkbcomp/alias.h49
-rw-r--r--src/xkbcomp/compat.c349
-rw-r--r--src/xkbcomp/expr.c289
-rw-r--r--src/xkbcomp/expr.h79
-rw-r--r--src/xkbcomp/indicators.c287
-rw-r--r--src/xkbcomp/indicators.h72
-rw-r--r--src/xkbcomp/keycodes.c303
-rw-r--r--src/xkbcomp/keycodes.h57
-rw-r--r--src/xkbcomp/keytypes.c362
-rw-r--r--src/xkbcomp/misc.c141
-rw-r--r--src/xkbcomp/parseutils.c215
-rw-r--r--src/xkbcomp/parseutils.h56
-rw-r--r--src/xkbcomp/path.c95
-rw-r--r--src/xkbcomp/path.h53
-rw-r--r--src/xkbcomp/rules.c152
-rw-r--r--src/xkbcomp/rules.h48
-rw-r--r--src/xkbcomp/symbols.c848
-rw-r--r--src/xkbcomp/vmod.c118
-rw-r--r--src/xkbcomp/vmod.h55
-rw-r--r--src/xkbcomp/xkbcomp-priv.h57
-rw-r--r--src/xkbcomp/xkbcomp.c68
-rw-r--r--src/xkbcomp/xkbcomp.h199
25 files changed, 2056 insertions, 2645 deletions
diff --git a/src/xkbcomp/action.c b/src/xkbcomp/action.c
index a412d54..79643bf 100644
--- a/src/xkbcomp/action.c
+++ b/src/xkbcomp/action.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "action.h"
@@ -178,7 +178,7 @@ static bool
ReportIllegal(unsigned action, unsigned field)
{
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");
return false;
}
@@ -187,7 +187,7 @@ static bool
ReportActionNotArray(unsigned action, unsigned field)
{
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");
return false;
}
@@ -198,7 +198,7 @@ ReportNotFound(unsigned action, unsigned field, const char *what,
{
ERROR("%s named %s not found\n", what, bad);
ACTION("Ignoring the %s field of an %s action\n", fieldText(field),
- XkbcActionTypeText(action));
+ XkbcActionTypeText(action));
return false;
}
@@ -237,13 +237,11 @@ CheckModifierField(struct xkb_keymap *keymap, unsigned action, ExprDef *value,
{
ExprResult rtrn;
- if (value->op == ExprIdent)
- {
+ if (value->op == ExprIdent) {
const char *valStr;
valStr = xkb_atom_text(keymap->ctx, value->value.str);
if (valStr && ((strcasecmp(valStr, "usemodmapmods") == 0) ||
- (strcasecmp(valStr, "modmapmods") == 0)))
- {
+ (strcasecmp(valStr, "modmapmods") == 0))) {
*mods_rtrn = 0;
*flags_inout |= XkbSA_UseModMapMods;
@@ -266,31 +264,27 @@ HandleSetLatchMods(struct xkb_keymap *keymap, struct xkb_any_action *action,
unsigned t1, t2;
act = (struct xkb_mod_action *) action;
- if (array_ndx != NULL)
- {
- switch (field)
- {
+ if (array_ndx != NULL) {
+ switch (field) {
case F_ClearLocks:
case F_LatchToLock:
case F_Modifiers:
return ReportActionNotArray(action->type, field);
}
}
- switch (field)
- {
+ switch (field) {
case F_ClearLocks:
case F_LatchToLock:
rtrn = act->flags;
- if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn))
- {
+ if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
act->flags = rtrn;
return true;
}
return false;
+
case F_Modifiers:
t1 = act->flags;
- if (CheckModifierField(keymap, action->type, value, &t1, &t2))
- {
+ if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff);
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;
if ((array_ndx != NULL) && (field == F_Modifiers))
return ReportActionNotArray(action->type, field);
- switch (field)
- {
+ switch (field) {
case F_Modifiers:
t1 = act->flags;
- if (CheckModifierField(keymap, action->type, value, &t1, &t2))
- {
+ if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
act->flags = t1;
act->real_mods = act->mask = (t2 & 0xff);
act->vmods = (t2 >> 8) & 0xffff;
@@ -334,13 +326,11 @@ CheckGroupField(struct xkb_keymap *keymap, unsigned action,
ExprDef *spec;
ExprResult rtrn;
- if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
- {
+ if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
*flags_inout &= ~XkbSA_GroupAbsolute;
spec = value->value.child;
}
- else
- {
+ else {
*flags_inout |= XkbSA_GroupAbsolute;
spec = value;
}
@@ -366,33 +356,29 @@ HandleSetLatchGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
int t2;
act = (struct xkb_group_action *) action;
- if (array_ndx != NULL)
- {
- switch (field)
- {
+ if (array_ndx != NULL) {
+ switch (field) {
case F_ClearLocks:
case F_LatchToLock:
case F_Group:
return ReportActionNotArray(action->type, field);
}
}
- switch (field)
- {
+ switch (field) {
case F_ClearLocks:
case F_LatchToLock:
rtrn = act->flags;
- if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn))
- {
+ if (CheckLatchLockFlags(keymap, action->type, field, value, &rtrn)) {
act->flags = rtrn;
return true;
}
return false;
+
case F_Group:
t1 = act->flags;
- if (CheckGroupField(keymap, action->type, value, &t1, &t2))
- {
+ if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
act->flags = t1;
- act->group = t2;
+ act->group = t2;
return true;
}
return false;
@@ -411,13 +397,11 @@ HandleLockGroup(struct xkb_keymap *keymap, struct xkb_any_action *action,
act = (struct xkb_group_action *) action;
if ((array_ndx != NULL) && (field == F_Group))
return ReportActionNotArray(action->type, field);
- if (field == F_Group)
- {
+ if (field == F_Group) {
t1 = act->flags;
- if (CheckGroupField(keymap, action->type, value, &t1, &t2))
- {
+ if (CheckGroupField(keymap, action->type, value, &t1, &t2)) {
act->flags = t1;
- act->group = t2;
+ act->group = t2;
return true;
}
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)))
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))
absolute = false;
else
absolute = true;
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "integer");
- if (field == F_X)
- {
+ if (field == F_X) {
if (absolute)
act->flags |= XkbSA_MoveAbsoluteX;
act->x = rtrn.ival;
}
- else
- {
+ else {
if (absolute)
act->flags |= XkbSA_MoveAbsoluteY;
act->y = rtrn.ival;
}
return true;
}
- else if (field == F_Accel)
- {
+ else if (field == F_Accel) {
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "boolean");
if (rtrn.uval)
@@ -472,11 +452,11 @@ HandleMovePtr(struct xkb_keymap *keymap, struct xkb_any_action *action,
}
static const LookupEntry lockWhich[] = {
- {"both", 0},
- {"lock", XkbSA_LockNoUnlock},
- {"neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock)},
- {"unlock", XkbSA_LockNoLock},
- {NULL, 0}
+ { "both", 0 },
+ { "lock", XkbSA_LockNoUnlock },
+ { "neither", (XkbSA_LockNoLock | XkbSA_LockNoUnlock) },
+ { "unlock", XkbSA_LockNoLock },
+ { NULL, 0 }
};
static bool
@@ -487,15 +467,13 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
struct xkb_pointer_button_action *act;
act = (struct xkb_pointer_button_action *) action;
- if (field == F_Button)
- {
+ if (field == F_Button) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field,
"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");
ACTION("Illegal button value %d ignored\n", rtrn.ival);
return false;
@@ -503,8 +481,7 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->button = rtrn.ival;
return true;
}
- else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect))
- {
+ else if ((action->type == XkbSA_LockPtrBtn) && (field == F_Affect)) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
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;
return true;
}
- else if (field == F_Count)
- {
+ else if (field == F_Count) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &rtrn))
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");
ACTION("Illegal count %d ignored\n", rtrn.ival);
return false;
@@ -532,10 +507,10 @@ HandlePtrBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
}
static const LookupEntry ptrDflts[] = {
- {"dfltbtn", XkbSA_AffectDfltBtn},
- {"defaultbutton", XkbSA_AffectDfltBtn},
- {"button", XkbSA_AffectDfltBtn},
- {NULL, 0}
+ { "dfltbtn", XkbSA_AffectDfltBtn },
+ { "defaultbutton", XkbSA_AffectDfltBtn },
+ { "button", XkbSA_AffectDfltBtn },
+ { NULL, 0 }
};
static bool
@@ -546,8 +521,7 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
struct xkb_pointer_default_action *act;
act = (struct xkb_pointer_default_action *) action;
- if (field == F_Affect)
- {
+ if (field == F_Affect) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
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;
return true;
}
- else if ((field == F_Button) || (field == F_Value))
- {
+ else if ((field == F_Button) || (field == F_Value)) {
ExprDef *btn;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
- if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
- {
+ if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
act->flags &= ~XkbSA_DfltBtnAbsolute;
btn = value->value.child;
}
- else
- {
+ else {
act->flags |= XkbSA_DfltBtnAbsolute;
btn = value;
}
@@ -574,39 +545,37 @@ HandleSetPtrDflt(struct xkb_keymap *keymap, struct xkb_any_action *action,
if (!ExprResolveButton(keymap->ctx, btn, &rtrn))
return ReportMismatch(action->type, field,
"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");
ACTION("Illegal default button value %d ignored\n", rtrn.ival);
return false;
}
- if (rtrn.ival == 0)
- {
+ if (rtrn.ival == 0) {
ERROR("Cannot set default pointer button to \"default\"\n");
ACTION("Illegal default button setting ignored\n");
return false;
}
if (value->op == OpNegate)
- act->value = -rtrn.ival;
+ act->value = -rtrn.ival;
else
- act->value = rtrn.ival;
+ act->value = rtrn.ival;
return true;
}
return ReportIllegal(action->type, field);
}
static const LookupEntry isoNames[] = {
- {"mods", XkbSA_ISONoAffectMods},
- {"modifiers", XkbSA_ISONoAffectMods},
- {"group", XkbSA_ISONoAffectGroup},
- {"groups", XkbSA_ISONoAffectGroup},
- {"ptr", XkbSA_ISONoAffectPtr},
- {"pointer", XkbSA_ISONoAffectPtr},
- {"ctrls", XkbSA_ISONoAffectCtrls},
- {"controls", XkbSA_ISONoAffectCtrls},
- {"all", ~((unsigned) 0)},
- {"none", 0},
- {NULL, 0},
+ { "mods", XkbSA_ISONoAffectMods },
+ { "modifiers", XkbSA_ISONoAffectMods },
+ { "group", XkbSA_ISONoAffectGroup },
+ { "groups", XkbSA_ISONoAffectGroup },
+ { "ptr", XkbSA_ISONoAffectPtr },
+ { "pointer", XkbSA_ISONoAffectPtr },
+ { "ctrls", XkbSA_ISONoAffectCtrls },
+ { "controls", XkbSA_ISONoAffectCtrls },
+ { "all", ~((unsigned) 0) },
+ { "none", 0 },
+ { NULL, 0 },
};
static bool
@@ -619,31 +588,30 @@ HandleISOLock(struct xkb_keymap *keymap, struct xkb_any_action *action,
int group;
act = (struct xkb_iso_action *) action;
- switch (field)
- {
+ switch (field) {
case F_Modifiers:
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
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->real_mods = mods & 0xff;
act->vmods = (mods >> 8) & 0xff;
return true;
}
return false;
+
case F_Group:
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
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->group = group;
return true;
}
return false;
+
case F_Affect:
if (array_ndx != NULL)
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;
act = (struct xkb_switch_screen_action *) action;
- if (field == F_Screen)
- {
+ if (field == F_Screen) {
ExprDef *scrn;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
- if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
- {
+ if ((value->op == OpNegate) || (value->op == OpUnaryPlus)) {
act->flags &= ~XkbSA_SwitchAbsolute;
scrn = value->value.child;
}
- else
- {
+ else {
act->flags |= XkbSA_SwitchAbsolute;
scrn = value;
}
if (!ExprResolveInteger(keymap->ctx, scrn, &rtrn))
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");
ACTION("Illegal screen value %d ignored\n", rtrn.ival);
return false;
}
if (value->op == OpNegate)
- act->screen = -rtrn.ival;
+ act->screen = -rtrn.ival;
else
- act->screen = rtrn.ival;
+ act->screen = rtrn.ival;
return true;
}
- else if (field == F_Same)
- {
+ else if (field == F_Same) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
@@ -709,36 +672,37 @@ HandleSwitchScreen(struct xkb_keymap *keymap, struct xkb_any_action *action,
}
const LookupEntry ctrlNames[] = {
- {"repeatkeys", XkbRepeatKeysMask},
- {"repeat", XkbRepeatKeysMask},
- {"autorepeat", XkbRepeatKeysMask},
- {"slowkeys", XkbSlowKeysMask},
- {"bouncekeys", XkbBounceKeysMask},
- {"stickykeys", XkbStickyKeysMask},
- {"mousekeys", XkbMouseKeysMask},
- {"mousekeysaccel", XkbMouseKeysAccelMask},
- {"accessxkeys", XkbAccessXKeysMask},
- {"accessxtimeout", XkbAccessXTimeoutMask},
- {"accessxfeedback", XkbAccessXFeedbackMask},
- {"audiblebell", XkbAudibleBellMask},
- {"ignoregrouplock", XkbIgnoreGroupLockMask},
- {"all", XkbAllBooleanCtrlsMask},
- {"overlay1", 0},
- {"overlay2", 0},
- {"none", 0},
- {NULL, 0}
+ { "repeatkeys", XkbRepeatKeysMask },
+ { "repeat", XkbRepeatKeysMask },
+ { "autorepeat", XkbRepeatKeysMask },
+ { "slowkeys", XkbSlowKeysMask },
+ { "bouncekeys", XkbBounceKeysMask },
+ { "stickykeys", XkbStickyKeysMask },
+ { "mousekeys", XkbMouseKeysMask },
+ { "mousekeysaccel", XkbMouseKeysAccelMask },
+ { "accessxkeys", XkbAccessXKeysMask },
+ { "accessxtimeout", XkbAccessXTimeoutMask },
+ { "accessxfeedback", XkbAccessXFeedbackMask },
+ { "audiblebell", XkbAudibleBellMask },
+ { "ignoregrouplock", XkbIgnoreGroupLockMask },
+ { "all", XkbAllBooleanCtrlsMask },
+ { "overlay1", 0 },
+ { "overlay2", 0 },
+ { "none", 0 },
+ { NULL, 0 }
};
static bool
-HandleSetLockControls(struct xkb_keymap *keymap, struct xkb_any_action *action,
- unsigned field, ExprDef *array_ndx, ExprDef *value)
+HandleSetLockControls(struct xkb_keymap *keymap,
+ struct xkb_any_action *action,
+ unsigned field, ExprDef *array_ndx,
+ ExprDef *value)
{
ExprResult rtrn;
struct xkb_controls_action *act;
act = (struct xkb_controls_action *) action;
- if (field == F_Controls)
- {
+ if (field == F_Controls) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
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[] = {
- {"press", XkbSA_MessageOnPress},
- {"keypress", XkbSA_MessageOnPress},
- {"release", XkbSA_MessageOnRelease},
- {"keyrelease", XkbSA_MessageOnRelease},
- {"all", XkbSA_MessageOnPress | XkbSA_MessageOnRelease},
- {"none", 0},
- {NULL, 0}
+ { "press", XkbSA_MessageOnPress },
+ { "keypress", XkbSA_MessageOnPress },
+ { "release", XkbSA_MessageOnRelease },
+ { "keyrelease", XkbSA_MessageOnRelease },
+ { "all", XkbSA_MessageOnPress | XkbSA_MessageOnRelease },
+ { "none", 0 },
+ { NULL, 0 }
};
static bool
@@ -767,8 +731,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
struct xkb_message_action *act;
act = (struct xkb_message_action *) action;
- switch (field)
- {
+ switch (field) {
case F_Report:
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
@@ -778,6 +741,7 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->flags =
rtrn.uval & (XkbSA_MessageOnPress | XkbSA_MessageOnRelease);
return true;
+
case F_GenKeyEvent:
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
@@ -788,16 +752,14 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
else
act->flags &= ~XkbSA_MessageGenKeyEvent;
return true;
+
case F_Data:
- if (array_ndx == NULL)
- {
+ if (array_ndx == NULL) {
if (!ExprResolveString(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "string");
- else
- {
+ else {
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");
ACTION("Extra %d bytes ignored\n", len - 6);
}
@@ -805,26 +767,22 @@ HandleActionMessage(struct xkb_keymap *keymap, struct xkb_any_action *action,
}
return true;
}
- else
- {
+ else {
unsigned ndx;
- if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn))
- {
+ if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
ERROR("Array subscript must be integer\n");
ACTION("Illegal subscript ignored\n");
return false;
}
ndx = rtrn.uval;
- if (ndx > 5)
- {
+ if (ndx > 5) {
ERROR("An action message is at most 6 bytes long\n");
ACTION("Attempt to use data[%d] ignored\n", ndx);
return false;
}
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
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");
ACTION("Illegal datum %d ignored\n", rtrn.ival);
return false;
@@ -850,24 +808,23 @@ HandleRedirectKey(struct xkb_keymap *keymap, struct xkb_any_action *action,
return ReportActionNotArray(action->type, field);
act = (struct xkb_redirect_key_action *) action;
- switch (field)
- {
+ switch (field) {
case F_Keycode:
if (!ExprResolveKeyName(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "key 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",
XkbcKeyNameText(rtrn.keyName.name));
}
act->new_key = kc;
return true;
+
case F_ModsToClear:
case F_Modifiers:
t1 = 0;
- if (CheckModifierField(keymap, action->type, value, &t1, &t2))
- {
+ if (CheckModifierField(keymap, action->type, value, &t1, &t2)) {
act->mods_mask |= (t2 & 0xff);
if (field == F_Modifiers)
act->mods |= (t2 & 0xff);
@@ -895,15 +852,13 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
struct xkb_device_button_action *act;
act = (struct xkb_device_button_action *) action;
- if (field == F_Button)
- {
+ if (field == F_Button) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field,
"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");
ACTION("Illegal button value %d ignored\n", rtrn.ival);
return false;
@@ -911,8 +866,7 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->button = rtrn.ival;
return true;
}
- else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect))
- {
+ else if ((action->type == XkbSA_LockDeviceBtn) && (field == F_Affect)) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
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;
return true;
}
- else if (field == F_Count)
- {
+ else if (field == F_Count) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
if (!ExprResolveButton(keymap->ctx, value, &rtrn))
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");
ACTION("Illegal count %d ignored\n", rtrn.ival);
return false;
@@ -936,15 +888,13 @@ HandleDeviceBtn(struct xkb_keymap *keymap, struct xkb_any_action *action,
act->count = rtrn.ival;
return true;
}
- else if (field == F_Device)
- {
+ else if (field == F_Device) {
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field,
"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");
ACTION("Illegal device value %d ignored\n", rtrn.ival);
return false;
@@ -975,29 +925,25 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
{
ExprResult rtrn;
- switch (field)
- {
+ switch (field) {
case F_Type:
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
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");
ACTION("Illegal type %d ignored\n", rtrn.ival);
return false;
}
action->type = rtrn.uval;
return true;
+
case F_Data:
- if (array_ndx == NULL)
- {
+ if (array_ndx == NULL) {
if (!ExprResolveString(keymap->ctx, value, &rtrn))
return ReportMismatch(action->type, field, "string");
- else
- {
+ else {
int len = strlen(rtrn.str);
- if ((len < 1) || (len > 7))
- {
+ if ((len < 1) || (len > 7)) {
WARN("A private action has 7 data bytes\n");
ACTION("Extra %d bytes ignored\n", len - 6);
return false;
@@ -1007,26 +953,22 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
free(rtrn.str);
return true;
}
- else
- {
+ else {
unsigned ndx;
- if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn))
- {
+ if (!ExprResolveInteger(keymap->ctx, array_ndx, &rtrn)) {
ERROR("Array subscript must be integer\n");
ACTION("Illegal subscript ignored\n");
return false;
}
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");
ACTION("Attempt to use data[%d] ignored\n", ndx);
return false;
}
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
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");
ACTION("Illegal datum %d ignored\n", rtrn.ival);
return false;
@@ -1038,33 +980,33 @@ HandlePrivate(struct xkb_keymap *keymap, struct xkb_any_action *action,
return ReportIllegal(PrivateAction, field);
}
-typedef bool (*actionHandler) (struct xkb_keymap *keymap,
- struct xkb_any_action *action, unsigned field,
- ExprDef *array_ndx, ExprDef *value);
+typedef bool (*actionHandler)(struct xkb_keymap *keymap,
+ struct xkb_any_action *action, unsigned field,
+ ExprDef *array_ndx, ExprDef *value);
static const actionHandler handleAction[XkbSA_NumActions + 1] = {
- [XkbSA_NoAction] = HandleNoAction,
- [XkbSA_SetMods] = HandleSetLatchMods,
- [XkbSA_LatchMods] = HandleSetLatchMods,
- [XkbSA_LockMods] = HandleLockMods,
- [XkbSA_SetGroup] = HandleSetLatchGroup,
- [XkbSA_LatchGroup] = HandleSetLatchGroup,
- [XkbSA_LockGroup] = HandleLockGroup,
- [XkbSA_MovePtr] = HandleMovePtr,
- [XkbSA_PtrBtn] = HandlePtrBtn,
- [XkbSA_LockPtrBtn] = HandlePtrBtn,
- [XkbSA_SetPtrDflt] = HandleSetPtrDflt,
- [XkbSA_ISOLock] = HandleISOLock,
- [XkbSA_Terminate] = HandleNoAction,
- [XkbSA_SwitchScreen] = HandleSwitchScreen,
- [XkbSA_SetControls] = HandleSetLockControls,
- [XkbSA_LockControls] = HandleSetLockControls,
- [XkbSA_ActionMessage] = HandleActionMessage,
- [XkbSA_RedirectKey] = HandleRedirectKey,
- [XkbSA_DeviceBtn] = HandleDeviceBtn,
- [XkbSA_LockDeviceBtn] = HandleDeviceBtn,
+ [XkbSA_NoAction] = HandleNoAction,
+ [XkbSA_SetMods] = HandleSetLatchMods,
+ [XkbSA_LatchMods] = HandleSetLatchMods,
+ [XkbSA_LockMods] = HandleLockMods,
+ [XkbSA_SetGroup] = HandleSetLatchGroup,
+ [XkbSA_LatchGroup] = HandleSetLatchGroup,
+ [XkbSA_LockGroup] = HandleLockGroup,
+ [XkbSA_MovePtr] = HandleMovePtr,
+ [XkbSA_PtrBtn] = HandlePtrBtn,
+ [XkbSA_LockPtrBtn] = HandlePtrBtn,
+ [XkbSA_SetPtrDflt] = HandleSetPtrDflt,
+ [XkbSA_ISOLock] = HandleISOLock,
+ [XkbSA_Terminate] = HandleNoAction,
+ [XkbSA_SwitchScreen] = HandleSwitchScreen,
+ [XkbSA_SetControls] = HandleSetLockControls,
+ [XkbSA_LockControls] = HandleSetLockControls,
+ [XkbSA_ActionMessage] = HandleActionMessage,
+ [XkbSA_RedirectKey] = HandleRedirectKey,
+ [XkbSA_DeviceBtn] = HandleDeviceBtn,
+ [XkbSA_LockDeviceBtn] = HandleDeviceBtn,
[XkbSA_DeviceValuator] = HandleDeviceValuator,
- [PrivateAction] = HandlePrivate,
+ [PrivateAction] = HandlePrivate,
};
/***====================================================================***/
@@ -1072,14 +1014,12 @@ static const actionHandler handleAction[XkbSA_NumActions + 1] = {
static void
ApplyActionFactoryDefaults(union xkb_action * action)
{
- if (action->type == XkbSA_SetPtrDflt)
- { /* increment default button */
+ if (action->type == XkbSA_SetPtrDflt) { /* increment default button */
action->dflt.affect = XkbSA_AffectDfltBtn;
action->dflt.flags = 0;
action->dflt.value = 1;
}
- else if (action->type == XkbSA_ISOLock)
- {
+ else if (action->type == XkbSA_ISOLock) {
action->iso.real_mods = LockMask;
}
}
@@ -1099,37 +1039,31 @@ HandleActionDef(ExprDef * def,
if (!actionsInitialized)
ActionsInit(keymap->ctx);
- if (def->op != ExprActionDecl)
- {
+ if (def->op != ExprActionDecl) {
ERROR("Expected an action definition, found %s\n",
- exprOpText(def->op));
+ exprOpText(def->op));
return false;
}
str = xkb_atom_text(keymap->ctx, def->value.action.name);
- if (!str)
- {
+ if (!str) {
WSGO("Missing name in action definition!!\n");
return false;
}
- if (!stringToAction(str, &tmp))
- {
+ if (!stringToAction(str, &tmp)) {
ERROR("Unknown action %s\n", str);
return false;
}
action->type = hndlrType = tmp;
- if (action->type != XkbSA_NoAction)
- {
+ if (action->type != XkbSA_NoAction) {
ApplyActionFactoryDefaults((union xkb_action *) action);
while (info)
{
if ((info->action == XkbSA_NoAction)
- || (info->action == hndlrType))
- {
- if (!(*handleAction[hndlrType]) (keymap, action,
- info->field,
- info->array_ndx,
- info->value))
- {
+ || (info->action == hndlrType)) {
+ if (!(*handleAction[hndlrType])(keymap, action,
+ info->field,
+ info->array_ndx,
+ info->value)) {
return false;
}
}
@@ -1137,27 +1071,22 @@ HandleActionDef(ExprDef * def,
}
}
for (arg = def->value.action.args; arg != NULL;
- arg = (ExprDef *) arg->common.next)
- {
+ arg = (ExprDef *) arg->common.next) {
ExprDef *field, *value, *arrayRtrn;
ExprResult elemRtrn, fieldRtrn;
unsigned fieldNdx;
- if (arg->op == OpAssign)
- {
+ if (arg->op == OpAssign) {
field = arg->value.binary.left;
value = arg->value.binary.right;
}
- else
- {
- if ((arg->op == OpNot) || (arg->op == OpInvert))
- {
+ else {
+ if ((arg->op == OpNot) || (arg->op == OpInvert)) {
field = arg->value.child;
constFalse.value.str = xkb_atom_intern(keymap->ctx, "false");
value = &constFalse;
}
- else
- {
+ else {
field = arg;
constTrue.value.str = xkb_atom_intern(keymap->ctx, "true");
value = &constTrue;
@@ -1166,17 +1095,15 @@ HandleActionDef(ExprDef * def,
if (!ExprResolveLhs(keymap, field, &elemRtrn, &fieldRtrn, &arrayRtrn))
return false; /* internal error -- already reported */
- if (elemRtrn.str != NULL)
- {
+ if (elemRtrn.str != NULL) {
ERROR("Cannot change defaults in an action definition\n");
ACTION("Ignoring attempt to change %s.%s\n", elemRtrn.str,
- fieldRtrn.str);
+ fieldRtrn.str);
free(elemRtrn.str);
free(fieldRtrn.str);
return false;
}
- if (!stringToField(fieldRtrn.str, &fieldNdx))
- {
+ if (!stringToField(fieldRtrn.str, &fieldNdx)) {
ERROR("Unknown field name %s\n", uStringText(fieldRtrn.str));
free(elemRtrn.str);
free(fieldRtrn.str);
@@ -1205,30 +1132,25 @@ SetActionField(struct xkb_keymap *keymap,
ActionsInit(keymap->ctx);
new = uTypedAlloc(ActionInfo);
- if (new == NULL)
- {
+ if (new == NULL) {
WSGO("Couldn't allocate space for action default\n");
return false;
}
if (strcasecmp(elem, "action") == 0)
new->action = XkbSA_NoAction;
- else
- {
- if (!stringToAction(elem, &new->action))
- {
+ else {
+ if (!stringToAction(elem, &new->action)) {
free(new);
return false;
}
- if (new->action == XkbSA_NoAction)
- {
+ if (new->action == XkbSA_NoAction) {
ERROR("\"%s\" is not a valid field in a NoAction action\n",
- field);
+ field);
free(new);
return false;
}
}
- if (!stringToField(field, &new->field))
- {
+ if (!stringToField(field, &new->field)) {
ERROR("\"%s\" is not a legal field name\n", field);
free(new);
return false;
@@ -1251,8 +1173,7 @@ SetActionField(struct xkb_keymap *keymap,
static void
ActionsInit(struct xkb_context *ctx)
{
- if (!actionsInitialized)
- {
+ if (!actionsInitialized) {
memset(&constTrue, 0, sizeof(constTrue));
memset(&constFalse, 0, sizeof(constFalse));
constTrue.common.stmtType = StmtExpr;
diff --git a/src/xkbcomp/action.h b/src/xkbcomp/action.h
index 73cccff..0d70286 100644
--- a/src/xkbcomp/action.h
+++ b/src/xkbcomp/action.h
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef ACTION_H
@@ -30,36 +30,35 @@
#include "xkbcomp-priv.h"
#include "expr.h"
-#define F_ClearLocks 0
-#define F_LatchToLock 1
-#define F_GenKeyEvent 2
-#define F_Report 3
-#define F_Default 4
-#define F_Affect 5
-#define F_Increment 6
-#define F_Modifiers 7
-#define F_Group 8
-#define F_X 9
-#define F_Y 10
-#define F_Accel 11
-#define F_Button 12
-#define F_Value 13
-#define F_Controls 14
-#define F_Type 15
-#define F_Count 16
-#define F_Screen 17
-#define F_Same 18
-#define F_Data 19
-#define F_Device 20
-#define F_Keycode 21
-#define F_ModsToClear 22
-#define F_LastField F_ModsToClear
-#define F_NumFields (F_LastField+1)
+#define F_ClearLocks 0
+#define F_LatchToLock 1
+#define F_GenKeyEvent 2
+#define F_Report 3
+#define F_Default 4
+#define F_Affect 5
+#define F_Increment 6
+#define F_Modifiers 7
+#define F_Group 8
+#define F_X 9
+#define F_Y 10
+#define F_Accel 11
+#define F_Button 12
+#define F_Value 13
+#define F_Controls 14
+#define F_Type 15
+#define F_Count 16
+#define F_Screen 17
+#define F_Same 18
+#define F_Data 19
+#define F_Device 20
+#define F_Keycode 21
+#define F_ModsToClear 22
+#define F_LastField F_ModsToClear
+#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 field;
ExprDef *array_ndx;
@@ -69,11 +68,13 @@ typedef struct _ActionInfo
extern int
HandleActionDef(ExprDef *def, struct xkb_keymap *keymap,
- struct xkb_any_action *action, ActionInfo *info);
+ struct xkb_any_action *action,
+ ActionInfo *info);
extern int
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[];
diff --git a/src/xkbcomp/alias.c b/src/xkbcomp/alias.c
index e752919..922e54e 100644
--- a/src/xkbcomp/alias.c
+++ b/src/xkbcomp/alias.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "alias.h"
@@ -30,36 +30,30 @@
static void
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)) ||
- (warningLevel > 9))
- {
+ (warningLevel > 9)) {
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");
}
}
- else
- {
+ else {
char *use, *ignore;
- if (new->def.merge == MERGE_AUGMENT)
- {
+ if (new->def.merge == MERGE_AUGMENT) {
use = old->real;
ignore = new->real;
}
- else
- {
+ else {
use = new->real;
ignore = old->real;
}
if (((old->def.file_id == new->def.file_id) && (warningLevel > 0)) ||
- (warningLevel > 9))
- {
+ (warningLevel > 9)) {
WARN("Multiple definitions for alias %s\n",
- XkbcKeyNameText(old->alias));
+ XkbcKeyNameText(old->alias));
ACTION("Using %s, ignoring %s\n",
- XkbcKeyNameText(use), XkbcKeyNameText(ignore));
+ XkbcKeyNameText(use), XkbcKeyNameText(ignore));
}
if (use != old->real)
memcpy(old->real, use, XkbKeyNameLength);
@@ -70,7 +64,8 @@ HandleCollision(AliasInfo * old, AliasInfo * new)
static void
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));
info->def.merge = merge;
@@ -85,10 +80,9 @@ HandleAliasDef(KeyAliasDef * def,
{
AliasInfo *info;
- for (info = *info_in; info != NULL; info = (AliasInfo *) info->def.next)
- {
- if (strncmp(info->alias, def->alias, XkbKeyNameLength) == 0)
- {
+ for (info = *info_in; info != NULL; info =
+ (AliasInfo *) info->def.next) {
+ if (strncmp(info->alias, def->alias, XkbKeyNameLength) == 0) {
AliasInfo new;
InitAliasInfo(&new, merge, file_id, def->alias, def->real);
HandleCollision(info, &new);
@@ -96,14 +90,13 @@ HandleAliasDef(KeyAliasDef * def,
}
}
info = uTypedCalloc(1, AliasInfo);
- if (info == NULL)
- {
+ if (info == NULL) {
WSGO("Allocation failure in HandleAliasDef\n");
return false;
}
info->def.file_id = file_id;
info->def.merge = merge;
- info->def.next = (CommonInfo *) * info_in;
+ info->def.next = (CommonInfo *) *info_in;
memcpy(info->alias, def->alias, XkbKeyNameLength);
memcpy(info->real, def->real, XkbKeyNameLength);
*info_in = AddCommonInfo(&(*info_in)->def, &info->def);
@@ -126,15 +119,13 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge,
if ((*merge) == NULL)
return true;
- if ((*into) == NULL)
- {
+ if ((*into) == NULL) {
*into = *merge;
*merge = NULL;
return true;
}
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)
def.merge = tmp->def.merge;
else
@@ -161,45 +152,39 @@ ApplyAliases(struct xkb_keymap *keymap, AliasInfo ** info_in)
nOld = (keymap->names ? darray_size(keymap->names->key_aliases) : 0);
old = (keymap->names ? &darray_item(keymap->names->key_aliases, 0) : NULL);
for (nNew = 0, info = *info_in; info != NULL;
- info = (AliasInfo *) info->def.next)
- {
+ info = (AliasInfo *) info->def.next) {
unsigned long lname;
xkb_keycode_t kc;
lname = KeyNameToLong(info->real);
- if (!FindNamedKey(keymap, lname, &kc, false, CreateKeyNames(keymap), 0))
- {
- if (warningLevel > 4)
- {
+ if (!FindNamedKey(keymap, lname, &kc, false, CreateKeyNames(keymap),
+ 0)) {
+ if (warningLevel > 4) {
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");
}
info->alias[0] = '\0';
continue;
}
lname = KeyNameToLong(info->alias);
- if (FindNamedKey(keymap, lname, &kc, false, false, 0))
- {
- if (warningLevel > 4)
- {
+ if (FindNamedKey(keymap, lname, &kc, false, false, 0)) {
+ if (warningLevel > 4) {
WARN("Attempt to create alias with the name of a real key\n");
ACTION("Alias \"%s = %s\" ignored\n",
- XkbcKeyNameText(info->alias),
- XkbcKeyNameText(info->real));
+ XkbcKeyNameText(info->alias),
+ XkbcKeyNameText(info->real));
}
info->alias[0] = '\0';
continue;
}
nNew++;
- if (old)
- {
- for (i = 0, a = old; i < nOld; i++, a++)
- {
- if (strncmp(a->alias, info->alias, XkbKeyNameLength) == 0)
- {
+ if (old) {
+ for (i = 0, a = old; i < nOld; i++, a++) {
+ if (strncmp(a->alias, info->alias, XkbKeyNameLength) == 0) {
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);
memcpy(old_info.real, a->real, XkbKeyNameLength);
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);
*info_in = NULL;
return true;
}
status = XkbcAllocNames(keymap, XkbKeyAliasesMask, nOld + nNew);
- if (status != Success)
- {
+ if (status != Success) {
WSGO("Allocation failure in ApplyAliases\n");
return false;
}
a = keymap->names ? &darray_item(keymap->names->key_aliases, nOld) : NULL;
- for (info = *info_in; info != NULL; info = (AliasInfo *) info->def.next)
- {
- if (info->alias[0] != '\0')
- {
+ for (info = *info_in; info != NULL; info =
+ (AliasInfo *) info->def.next) {
+ if (info->alias[0] != '\0') {
strncpy(a->alias, info->alias, XkbKeyNameLength);
strncpy(a->real, info->real, XkbKeyNameLength);
a++;
}
}
#ifdef DEBUG
- if ((a - old) != (nOld + nNew))
- {
+ if ((a - old) != (nOld + nNew)) {
WSGO("Expected %d aliases total but created %d\n", nOld + nNew,
- a - old);
+ a - old);
}
#endif
ClearCommonInfo(&(*info_in)->def);
diff --git a/src/xkbcomp/alias.h b/src/xkbcomp/alias.h
index 606f32c..bd59847 100644
--- a/src/xkbcomp/alias.h
+++ b/src/xkbcomp/alias.h
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef ALIAS_H
@@ -29,8 +29,7 @@
#include "xkbcomp-priv.h"
-typedef struct _AliasInfo
-{
+typedef struct _AliasInfo {
CommonInfo def;
char alias[XkbKeyNameLength + 1];
char real[XkbKeyNameLength + 1];
diff --git a/src/xkbcomp/compat.c b/src/xkbcomp/compat.c
index 0e42242..88d0ff5 100644
--- a/src/xkbcomp/compat.c
+++ b/src/xkbcomp/compat.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "xkbcomp-priv.h"
@@ -30,20 +30,18 @@
#include "indicators.h"
#include "vmod.h"
-typedef struct _SymInterpInfo
-{
+typedef struct _SymInterpInfo {
CommonInfo defs;
struct xkb_sym_interpret interp;
} SymInterpInfo;
-#define _SI_VirtualMod (1<<0)
-#define _SI_Action (1<<1)
-#define _SI_AutoRepeat (1<<2)
-#define _SI_LockingKey (1<<3)
-#define _SI_LevelOneOnly (1<<4)
+#define _SI_VirtualMod (1 << 0)
+#define _SI_Action (1 << 1)
+#define _SI_AutoRepeat (1 << 2)
+#define _SI_LockingKey (1 << 3)
+#define _SI_LevelOneOnly (1 << 4)
-typedef struct _GroupCompatInfo
-{
+typedef struct _GroupCompatInfo {
unsigned file_id;
enum merge_mode merge;
bool defined;
@@ -51,8 +49,7 @@ typedef struct _GroupCompatInfo
xkb_atom_t vmods;
} GroupCompatInfo;
-typedef struct _CompatInfo
-{
+typedef struct _CompatInfo {
char *name;
unsigned file_id;
int errorCount;
@@ -69,10 +66,10 @@ typedef struct _CompatInfo
/***====================================================================***/
-#define ReportSINotArray(si,f,i) \
- ReportNotArray("symbol interpretation",(f),siText((si),(i)))
-#define ReportSIBadType(si,f,w,i) \
- ReportBadType("symbol interpretation",(f),siText((si),(i)),(w))
+#define ReportSINotArray(si, f, i) \
+ ReportNotArray("symbol interpretation", (f), siText((si), (i)))
+#define ReportSIBadType(si, f, w, i) \
+ ReportBadType("symbol interpretation", (f), siText((si), (i)), (w))
/***====================================================================***/
@@ -81,16 +78,14 @@ siText(SymInterpInfo * si, CompatInfo * info)
{
static char buf[128];
- if (si == &info->dflt)
- {
+ if (si == &info->dflt) {
snprintf(buf, sizeof(buf), "default");
}
- else
- {
+ else {
snprintf(buf, sizeof(buf), "%s+%s(%s)",
- XkbcKeysymText(si->interp.sym),
- XkbcSIMatchText(si->interp.match),
- XkbcModMaskText(si->interp.mods, false));
+ XkbcKeysymText(si->interp.sym),
+ XkbcSIMatchText(si->interp.match),
+ XkbcModMaskText(si->interp.mods, false));
}
return buf;
}
@@ -147,9 +142,9 @@ ClearCompatInfo(CompatInfo *info, struct xkb_keymap *keymap)
XkbNumKbdGroups * sizeof(GroupCompatInfo));
info->leds = ClearCommonInfo(&info->leds->defs);
while (info->act) {
- next = info->act->next;
- free(info->act);
- info->act = next;
+ next = info->act->next;
+ free(info->act);
+ info->act = next;
}
ClearVModInfo(&info->vmods, keymap);
}
@@ -160,8 +155,7 @@ NextInterp(CompatInfo * info)
SymInterpInfo *si;
si = uTypedAlloc(SymInterpInfo);
- if (si)
- {
+ if (si) {
memset(si, 0, sizeof(SymInterpInfo));
info->interps = AddCommonInfo(&info->interps->defs, &si->defs);
info->nInterps++;
@@ -175,12 +169,10 @@ FindMatchingInterp(CompatInfo * info, SymInterpInfo * new)
SymInterpInfo *old;
for (old = info->interps; old != NULL;
- old = (SymInterpInfo *) old->defs.next)
- {
+ old = (SymInterpInfo *) old->defs.next) {
if ((old->interp.sym == new->interp.sym) &&
(old->interp.mods == new->interp.mods) &&
- (old->interp.match == new->interp.match))
- {
+ (old->interp.match == new->interp.match)) {
return old;
}
}
@@ -195,14 +187,11 @@ AddInterp(CompatInfo * info, SymInterpInfo * new)
collide = 0;
old = FindMatchingInterp(info, new);
- if (old != NULL)
- {
- if (new->defs.merge == MERGE_REPLACE)
- {
+ if (old != NULL) {
+ if (new->defs.merge == MERGE_REPLACE) {
SymInterpInfo *next = (SymInterpInfo *) old->defs.next;
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));
ACTION("Earlier interpretation ignored\n");
}
@@ -210,39 +199,34 @@ AddInterp(CompatInfo * info, SymInterpInfo * new)
old->defs.next = &next->defs;
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->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->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 |= (new->interp.flags & XkbSI_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 |= (new->interp.flags & XkbSI_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 |= (new->interp.match & XkbSI_LevelOneOnly);
old->defs.defined |= _SI_LevelOneOnly;
}
- if (collide)
- {
+ if (collide) {
WARN("Multiple interpretations of \"%s\"\n", siText(new, info));
ACTION("Using %s definition for duplicate fields\n",
- (new->defs.merge != MERGE_AUGMENT ? "last" : "first"));
+ (new->defs.merge != MERGE_AUGMENT ? "last" : "first"));
}
return true;
}
@@ -262,16 +246,15 @@ AddGroupCompat(CompatInfo * info, unsigned group, GroupCompatInfo * newGC)
merge = newGC->merge;
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;
}
if (((gc->file_id == newGC->file_id) && (warningLevel > 0))
- || (warningLevel > 9))
- {
+ || (warningLevel > 9)) {
WARN("Compat map for group %d redefined\n", group + 1);
ACTION("Using %s definition\n",
- (merge == MERGE_AUGMENT ? "old" : "new"));
+ (merge == MERGE_AUGMENT ? "old" : "new"));
}
if (newGC->defined && (merge != MERGE_AUGMENT || !gc->defined))
*gc = *newGC;
@@ -287,16 +270,14 @@ ResolveStateAndPredicate(ExprDef * expr,
{
ExprResult result;
- if (expr == NULL)
- {
+ if (expr == NULL) {
*pred_rtrn = XkbSI_AnyOfOrNone;
*mods_rtrn = ~0;
return true;
}
*pred_rtrn = XkbSI_Exactly;
- if (expr->op == ExprActionDecl)
- {
+ if (expr->op == ExprActionDecl) {
const char *pred_txt = xkb_atom_text(info->keymap->ctx,
expr->value.action.name);
if (strcasecmp(pred_txt, "noneof") == 0)
@@ -309,28 +290,24 @@ ResolveStateAndPredicate(ExprDef * expr,
*pred_rtrn = XkbSI_AllOf;
else if (strcasecmp(pred_txt, "exactly") == 0)
*pred_rtrn = XkbSI_Exactly;
- else
- {
+ else {
ERROR("Illegal modifier predicate \"%s\"\n", pred_txt);
ACTION("Ignored\n");
return false;
}
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,
expr->value.str);
- if ((pred_txt) && (strcasecmp(pred_txt, "any") == 0))
- {
+ if ((pred_txt) && (strcasecmp(pred_txt, "any") == 0)) {
*pred_rtrn = XkbSI_AnyOf;
*mods_rtrn = 0xff;
return true;
}
}
- if (ExprResolveModMask(info->keymap->ctx, expr, &result))
- {
+ if (ExprResolveModMask(info->keymap->ctx, expr, &result)) {
*mods_rtrn = result.uval;
return true;
}
@@ -340,39 +317,36 @@ ResolveStateAndPredicate(ExprDef * expr,
/***====================================================================***/
static void
-MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, enum merge_mode merge)
+MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from,
+ enum merge_mode merge)
{
SymInterpInfo *si;
LEDInfo *led, *rtrn, *next;
GroupCompatInfo *gcm;
int i;
- if (from->errorCount > 0)
- {
+ if (from->errorCount > 0) {
into->errorCount += from->errorCount;
return;
}
- if (into->name == NULL)
- {
+ if (into->name == NULL) {
into->name = from->name;
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)
si->defs.merge = merge;
if (!AddInterp(into, si))
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)
gcm->merge = merge;
if (!AddGroupCompat(into, i, gcm))
into->errorCount++;
}
- for (led = from->leds; led != NULL; led = next)
- {
+ for (led = from->leds; led != NULL; led = next) {
next = (LEDInfo *) led->defs.next;
if (merge != MERGE_DEFAULT)
led->defs.merge = merge;
@@ -385,7 +359,8 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, enum merge_mode me
}
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);
static bool
@@ -398,53 +373,45 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
bool haveSelf;
haveSelf = false;
- if ((stmt->file == NULL) && (stmt->map == NULL))
- {
+ if ((stmt->file == NULL) && (stmt->map == NULL)) {
haveSelf = true;
included = *info;
memset(info, 0, sizeof(CompatInfo));
}
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_COMPAT, &rtrn,
- &newMerge))
- {
+ &newMerge)) {
InitCompatInfo(&included, keymap, rtrn->id);
included.dflt = info->dflt;
included.dflt.defs.merge = newMerge;
included.ledDflt.defs.merge = newMerge;
included.act = info->act;
HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &included);
- if (stmt->stmt != NULL)
- {
+ if (stmt->stmt != NULL) {
free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
if (info->act != NULL)
- included.act = NULL;
+ included.act = NULL;
FreeXKBFile(rtrn);
}
- else
- {
+ else {
info->errorCount += 10;
return false;
}
- if ((stmt->next != NULL) && (included.errorCount < 1))
- {
+ if ((stmt->next != NULL) && (included.errorCount < 1)) {
IncludeStmt *next;
unsigned op;
CompatInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next)
- {
- if ((next->file == NULL) && (next->map == NULL))
- {
+ for (next = stmt->next; next != NULL; next = next->next) {
+ if ((next->file == NULL) && (next->map == NULL)) {
haveSelf = true;
MergeIncludedCompatMaps(&included, info, next->merge);
ClearCompatInfo(info, keymap);
}
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_COMPAT,
- &rtrn, &op))
- {
+ &rtrn, &op)) {
InitCompatInfo(&next_incl, keymap, rtrn->id);
next_incl.file_id = rtrn->id;
next_incl.dflt = info->dflt;
@@ -456,12 +423,11 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
HandleCompatMapFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
MergeIncludedCompatMaps(&included, &next_incl, op);
if (info->act != NULL)
- next_incl.act = NULL;
+ next_incl.act = NULL;
ClearCompatInfo(&next_incl, keymap);
FreeXKBFile(rtrn);
}
- else
- {
+ else {
info->errorCount += 10;
return false;
}
@@ -469,8 +435,7 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
}
if (haveSelf)
*info = included;
- else
- {
+ else {
MergeIncludedCompatMaps(info, &included, newMerge);
ClearCompatInfo(&included, keymap);
}
@@ -478,11 +443,11 @@ HandleIncludeCompatMap(IncludeStmt *stmt, struct xkb_keymap *keymap,
}
static const LookupEntry useModMapValues[] = {
- {"levelone", 1},
- {"level1", 1},
- {"anylevel", 0},
- {"any", 0},
- {NULL, 0}
+ { "levelone", 1 },
+ { "level1", 1 },
+ { "anylevel", 0 },
+ { "any", 0 },
+ { NULL, 0 }
};
static int
@@ -492,8 +457,7 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
int ok = 1;
ExprResult tmp;
- if (strcasecmp(field, "action") == 0)
- {
+ if (strcasecmp(field, "action") == 0) {
if (arrayNdx != NULL)
return ReportSINotArray(si, field, info);
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;
}
else if ((strcasecmp(field, "virtualmodifier") == 0) ||
- (strcasecmp(field, "virtualmod") == 0))
- {
+ (strcasecmp(field, "virtualmod") == 0)) {
if (arrayNdx != NULL)
return ReportSINotArray(si, field, info);
ok = ResolveVirtualModifier(value, keymap, &tmp, &info->vmods);
- if (ok)
- {
+ if (ok) {
si->interp.virtual_mod = tmp.uval;
si->defs.defined |= _SI_VirtualMod;
}
else
return ReportSIBadType(si, field, "virtual modifier", info);
}
- else if (strcasecmp(field, "repeat") == 0)
- {
+ else if (strcasecmp(field, "repeat") == 0) {
if (arrayNdx != NULL)
return ReportSINotArray(si, field, info);
ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
- if (ok)
- {
+ if (ok) {
if (tmp.uval)
si->interp.flags |= XkbSI_AutoRepeat;
else
@@ -530,13 +490,11 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
else
return ReportSIBadType(si, field, "boolean", info);
}
- else if (strcasecmp(field, "locking") == 0)
- {
+ else if (strcasecmp(field, "locking") == 0) {
if (arrayNdx != NULL)
return ReportSINotArray(si, field, info);
ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
- if (ok)
- {
+ if (ok) {
if (tmp.uval)
si->interp.flags |= XkbSI_LockingKey;
else
@@ -547,13 +505,11 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
return ReportSIBadType(si, field, "boolean", info);
}
else if ((strcasecmp(field, "usemodmap") == 0) ||
- (strcasecmp(field, "usemodmapmods") == 0))
- {
+ (strcasecmp(field, "usemodmapmods") == 0)) {
if (arrayNdx != NULL)
return ReportSINotArray(si, field, info);
ok = ExprResolveEnum(keymap->ctx, value, &tmp, useModMapValues);
- if (ok)
- {
+ if (ok) {
if (tmp.uval)
si->interp.match |= XkbSI_LevelOneOnly;
else
@@ -563,8 +519,7 @@ SetInterpField(SymInterpInfo *si, struct xkb_keymap *keymap, char *field,
else
return ReportSIBadType(si, field, "level specification", info);
}
- else
- {
+ else {
ok = ReportBadField("symbol interpretation", field, siText(si, info));
}
return ok;
@@ -581,13 +536,13 @@ HandleInterpVar(VarDef * stmt, struct xkb_keymap *keymap, CompatInfo * info)
ret = 0; /* internal error, already reported */
else if (elem.str && (strcasecmp(elem.str, "interpret") == 0))
ret = SetInterpField(&info->dflt, keymap, field.str, ndx, stmt->value,
- info);
+ info);
else if (elem.str && (strcasecmp(elem.str, "indicator") == 0))
ret = SetIndicatorMapField(&info->ledDflt, keymap, field.str, ndx,
- stmt->value);
+ stmt->value);
else
ret = SetActionField(keymap, elem.str, field.str, ndx, stmt->value,
- &info->act);
+ &info->act);
free(elem.str);
free(field.str);
return ret;
@@ -601,10 +556,8 @@ HandleInterpBody(VarDef *def, struct xkb_keymap *keymap, SymInterpInfo *si,
ExprResult tmp, field;
ExprDef *arrayNdx;
- for (; def != NULL; def = (VarDef *) def->common.next)
- {
- if ((def->name) && (def->name->type == ExprFieldRef))
- {
+ for (; def != NULL; def = (VarDef *) def->common.next) {
+ if ((def->name) && (def->name->type == ExprFieldRef)) {
ok = HandleInterpVar(def, keymap, info);
continue;
}
@@ -619,14 +572,14 @@ HandleInterpBody(VarDef *def, struct xkb_keymap *keymap, SymInterpInfo *si,
}
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)
{
unsigned pred, mods;
SymInterpInfo si;
- if (!ResolveStateAndPredicate(def->match, &pred, &mods, info))
- {
+ if (!ResolveStateAndPredicate(def->match, &pred, &mods, info)) {
ERROR("Couldn't determine matching modifiers\n");
ACTION("Symbol interpretation ignored\n");
return false;
@@ -636,22 +589,19 @@ HandleInterpDef(InterpDef *def, struct xkb_keymap *keymap, enum merge_mode merge
si = info->dflt;
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);
ACTION("Symbol interpretation ignored\n");
return false;
}
si.interp.match = pred & XkbSI_OpMask;
si.interp.mods = mods;
- if (!HandleInterpBody(def->def, keymap, &si, info))
- {
+ if (!HandleInterpBody(def->def, keymap, &si, info)) {
info->errorCount++;
return false;
}
- if (!AddInterp(info, &si))
- {
+ if (!AddInterp(info, &si)) {
info->errorCount++;
return false;
}
@@ -667,21 +617,19 @@ HandleGroupCompatDef(GroupCompatDef *def, struct xkb_keymap *keymap,
if (def->merge != MERGE_DEFAULT)
merge = def->merge;
- if (!XkbIsLegalGroup(def->group - 1))
- {
+ if (!XkbIsLegalGroup(def->group - 1)) {
ERROR("Keyboard group must be in the range 1..%d\n",
- XkbNumKbdGroups + 1);
+ XkbNumKbdGroups + 1);
ACTION("Compatibility map for illegal group %d ignored\n",
- def->group);
+ def->group);
return false;
}
tmp.file_id = info->file_id;
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");
ACTION("Ignoring illegal compatibility map for group %d\n",
- def->group);
+ def->group);
return false;
}
tmp.real_mods = val.uval & 0xff;
@@ -691,10 +639,12 @@ HandleGroupCompatDef(GroupCompatDef *def, struct xkb_keymap *keymap,
}
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)
{
ParseCommon *stmt;
+ LEDInfo *leds;
if (merge == MERGE_DEFAULT)
merge = MERGE_AUGMENT;
@@ -703,8 +653,7 @@ HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode me
stmt = file->defs;
while (stmt)
{
- switch (stmt->stmtType)
- {
+ switch (stmt->stmtType) {
case StmtInclude:
if (!HandleIncludeCompatMap((IncludeStmt *) stmt, keymap, info))
info->errorCount++;
@@ -715,20 +664,17 @@ HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode me
break;
case StmtGroupCompatDef:
if (!HandleGroupCompatDef
- ((GroupCompatDef *) stmt, keymap, merge, info))
+ ((GroupCompatDef *) stmt, keymap, merge, info))
info->errorCount++;
break;
case StmtIndicatorMapDef:
- {
- LEDInfo *rtrn;
- rtrn = HandleIndicatorMapDef((IndicatorMapDef *) stmt, keymap,
+ leds = HandleIndicatorMapDef((IndicatorMapDef *) stmt, keymap,
&info->ledDflt, info->leds, merge);
- if (rtrn != NULL)
- info->leds = rtrn;
+ if (leds != NULL)
+ info->leds = leds;
else
info->errorCount++;
- }
- break;
+ break;
case StmtVarDef:
if (!HandleInterpVar((VarDef *) stmt, keymap, info))
info->errorCount++;
@@ -744,12 +690,11 @@ HandleCompatMapFile(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode me
break;
default:
WSGO("Unexpected statement type %d in HandleCompatMapFile\n",
- stmt->stmtType);
+ stmt->stmtType);
break;
}
stmt = stmt->next;
- if (info->errorCount > 10)
- {
+ if (info->errorCount > 10) {
#ifdef NOISY
ERROR("Too many errors\n");
#endif
@@ -765,8 +710,7 @@ CopyInterps(CompatInfo * info,
{
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) ||
(needSymbol && (si->interp.sym == XKB_KEY_NoSymbol)) ||
((!needSymbol) && (si->interp.sym != XKB_KEY_NoSymbol)))
@@ -776,7 +720,8 @@ CopyInterps(CompatInfo * info,
}
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;
CompatInfo info;
@@ -813,8 +758,10 @@ CompileCompatMap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge
CopyInterps(&info, keymap->compat, false, XkbSI_AnyOfOrNone);
}
- for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups; i++, gcm++) {
- if ((gcm->file_id != 0) || (gcm->real_mods != 0) || (gcm->vmods != 0)) {
+ for (i = 0, gcm = &info.groupCompat[0]; i < XkbNumKbdGroups; i++,
+ 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].real_mods = gcm->real_mods;
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 |= VModsToReal(keymap, act->mods.vmods);
break;
+
case XkbSA_ISOLock:
if (act->iso.flags & XkbSA_UseModMapMods)
act->iso.real_mods = rmodmask;
act->iso.mask = act->iso.real_mods;
act->iso.mask |= VModsToReal(keymap, act->iso.vmods);
break;
+
default:
break;
}
@@ -960,7 +909,8 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
interps[i] = NULL;
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;
if (i >= INTERP_SIZE) /* XXX FIXME */
return false;
@@ -977,7 +927,8 @@ ApplyInterpsToKey(struct xkb_keymap *keymap, xkb_keycode_t key)
return false;
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;
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. */
if (group == 0 && level == 0) {
- if (!(keymap->server->explicit[key] & XkbExplicitAutoRepeatMask) &&
+ if (!(keymap->server->explicit[key] &
+ XkbExplicitAutoRepeatMask) &&
(!interp || interp->flags & XkbSI_AutoRepeat))
- keymap->ctrls->per_key_repeat[key / 8] |= (1 << (key % 8));
- if (!(keymap->server->explicit[key] & XkbExplicitBehaviorMask) &&
+ keymap->ctrls->per_key_repeat[key / 8] |= (1 << (key % 8));
+ if (!(keymap->server->explicit[key] &
+ XkbExplicitBehaviorMask) &&
interp && (interp->flags & XkbSI_LockingKey))
keymap->server->behaviors[key].type = XkbKB_Lock;
}
@@ -1058,8 +1011,8 @@ UpdateModifiersFromCompat(struct xkb_keymap *keymap)
}
darray_foreach(entry, type->map)
- entry->mods.mask = entry->mods.real_mods |
- VModsToReal(keymap, entry->mods.vmods);
+ entry->mods.mask = entry->mods.real_mods |
+ VModsToReal(keymap, entry->mods.vmods);
}
/* Update action modifiers. */
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 3639017..f44acb2 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -1,36 +1,36 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "expr.h"
/***====================================================================***/
-typedef bool (*IdentLookupFunc) (struct xkb_context *ctx, const void *priv,
- xkb_atom_t field, unsigned type,
- ExprResult *val_rtrn);
+typedef bool (*IdentLookupFunc)(struct xkb_context *ctx, const void *priv,
+ xkb_atom_t field, unsigned type,
+ ExprResult *val_rtrn);
/***====================================================================***/
@@ -39,8 +39,7 @@ exprOpText(unsigned type)
{
static char buf[32];
- switch (type)
- {
+ switch (type) {
case ExprValue:
strcpy(buf, "literal");
break;
@@ -101,8 +100,7 @@ exprTypeText(unsigned type)
{
static char buf[20];
- switch (type)
- {
+ switch (type) {
case TypeUnknown:
strcpy(buf, "unknown");
break;
@@ -133,8 +131,7 @@ ExprResolveLhs(struct xkb_keymap *keymap, ExprDef *expr,
ExprResult *elem_rtrn, ExprResult *field_rtrn,
ExprDef **index_rtrn)
{
- switch (expr->op)
- {
+ switch (expr->op) {
case ExprIdent:
elem_rtrn->str = NULL;
field_rtrn->str = xkb_atom_strdup(keymap->ctx,
@@ -168,32 +165,30 @@ SimpleLookup(struct xkb_context *ctx, const void *priv,
const char *str;
if ((priv == NULL) || (field == XKB_ATOM_NONE) || (type != TypeInt))
- {
return false;
- }
+
str = xkb_atom_text(ctx, field);
- for (entry = priv; (entry != NULL) && (entry->name != NULL); entry++)
- {
- if (strcasecmp(str, entry->name) == 0)
- {
+ for (entry = priv; (entry != NULL) && (entry->name != NULL); entry++) {
+ if (strcasecmp(str, entry->name) == 0) {
val_rtrn->uval = entry->result;
return true;
}
}
+
return false;
}
static const LookupEntry modIndexNames[] = {
- {"shift", ShiftMapIndex},
- {"control", ControlMapIndex},
- {"lock", LockMapIndex},
- {"mod1", Mod1MapIndex},
- {"mod2", Mod2MapIndex},
- {"mod3", Mod3MapIndex},
- {"mod4", Mod4MapIndex},
- {"mod5", Mod5MapIndex},
- {"none", XkbNoModifier},
- {NULL, 0}
+ { "shift", ShiftMapIndex },
+ { "control", ControlMapIndex },
+ { "lock", LockMapIndex },
+ { "mod1", Mod1MapIndex },
+ { "mod2", Mod2MapIndex },
+ { "mod3", Mod3MapIndex },
+ { "mod4", Mod4MapIndex },
+ { "mod5", Mod5MapIndex },
+ { "none", XkbNoModifier },
+ { NULL, 0 }
};
bool
@@ -233,33 +228,29 @@ ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr,
int ok = 0;
const char *bogus = NULL;
- switch (expr->op)
- {
+ switch (expr->op) {
case ExprValue:
- if (expr->type != TypeBoolean)
- {
+ if (expr->type != TypeBoolean) {
ERROR
("Found constant of type %s where boolean was expected\n",
- exprTypeText(expr->type));
+ exprTypeText(expr->type));
return false;
}
val_rtrn->ival = expr->value.ival;
return true;
+
case ExprIdent:
bogus = xkb_atom_text(ctx, expr->value.str);
- if (bogus)
- {
+ if (bogus) {
if ((strcasecmp(bogus, "true") == 0) ||
(strcasecmp(bogus, "yes") == 0) ||
- (strcasecmp(bogus, "on") == 0))
- {
+ (strcasecmp(bogus, "on") == 0)) {
val_rtrn->uval = 1;
return true;
}
else if ((strcasecmp(bogus, "false") == 0) ||
(strcasecmp(bogus, "no") == 0) ||
- (strcasecmp(bogus, "off") == 0))
- {
+ (strcasecmp(bogus, "off") == 0)) {
val_rtrn->uval = 0;
return true;
}
@@ -267,11 +258,13 @@ ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr,
ERROR("Identifier \"%s\" of type int is unknown\n",
xkb_atom_text(ctx, expr->value.str));
return false;
+
case ExprFieldRef:
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.field));
return false;
+
case OpInvert:
case OpNot:
ok = ExprResolveBoolean(ctx, expr, val_rtrn);
@@ -298,9 +291,11 @@ ExprResolveBoolean(struct xkb_context *ctx, ExprDef *expr,
bogus = "Negation";
ERROR("%s of boolean values not permitted\n", bogus);
break;
+
case OpUnaryPlus:
ERROR("Unary \"+\" operator not permitted for boolean values\n");
break;
+
default:
WSGO("Unknown operator %d in ResolveBoolean\n", expr->op);
break;
@@ -316,38 +311,37 @@ ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right;
- switch (expr->op)
- {
+ switch (expr->op) {
case ExprValue:
- if (expr->type == TypeString)
- {
+ if (expr->type == TypeString) {
const char *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;
return true;
}
}
- if (expr->type != TypeInt)
- {
+ if (expr->type != TypeInt) {
ERROR("Found constant of type %s, expected a number\n",
- exprTypeText(expr->type));
+ exprTypeText(expr->type));
return false;
}
val_rtrn->ival = expr->value.ival;
if (expr->type == TypeInt)
val_rtrn->ival *= XkbGeomPtsPerMM;
return true;
+
case ExprIdent:
ERROR("Numeric identifier \"%s\" unknown\n",
xkb_atom_text(ctx, expr->value.str));
return ok;
+
case ExprFieldRef:
ERROR("Numeric default \"%s.%s\" unknown\n",
xkb_atom_text(ctx, expr->value.field.element),
xkb_atom_text(ctx, expr->value.field.field));
return false;
+
case OpAdd:
case OpSubtract:
case OpMultiply:
@@ -355,19 +349,20 @@ ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
left = expr->value.binary.left;
right = expr->value.binary.right;
if (ExprResolveFloat(ctx, left, &leftRtrn) &&
- ExprResolveFloat(ctx, right, &rightRtrn))
- {
- switch (expr->op)
- {
+ ExprResolveFloat(ctx, right, &rightRtrn)) {
+ switch (expr->op) {
case OpAdd:
val_rtrn->ival = leftRtrn.ival + rightRtrn.ival;
break;
+
case OpSubtract:
val_rtrn->ival = leftRtrn.ival - rightRtrn.ival;
break;
+
case OpMultiply:
val_rtrn->ival = leftRtrn.ival * rightRtrn.ival;
break;
+
case OpDivide:
val_rtrn->ival = leftRtrn.ival / rightRtrn.ival;
break;
@@ -375,17 +370,19 @@ ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
return true;
}
return false;
+
case OpAssign:
WSGO("Assignment operator not implemented yet\n");
break;
+
case OpNot:
ERROR("The ! operator cannot be applied to a number\n");
return false;
+
case OpInvert:
case OpNegate:
left = expr->value.child;
- if (ExprResolveFloat(ctx, left, &leftRtrn))
- {
+ if (ExprResolveFloat(ctx, left, &leftRtrn)) {
if (expr->op == OpNegate)
val_rtrn->ival = -leftRtrn.ival;
else
@@ -393,9 +390,11 @@ ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
return true;
}
return false;
+
case OpUnaryPlus:
left = expr->value.child;
return ExprResolveFloat(ctx, left, val_rtrn);
+
default:
WSGO("Unknown operator %d in ResolveFloat\n", expr->op);
break;
@@ -410,18 +409,17 @@ ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr,
ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right;
- switch (expr->op)
- {
+ switch (expr->op) {
case ExprValue:
- if (expr->type != TypeInt)
- {
+ if (expr->type != TypeInt) {
ERROR
("Found constant of type %s where an int was expected\n",
- exprTypeText(expr->type));
+ exprTypeText(expr->type));
return false;
}
val_rtrn->uval = expr->value.uval;
return true;
+
case OpAdd:
case OpSubtract:
case OpMultiply:
@@ -429,10 +427,8 @@ ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr,
left = expr->value.binary.left;
right = expr->value.binary.right;
if (ExprResolveKeyCode(ctx, left, &leftRtrn) &&
- ExprResolveKeyCode(ctx, right, &rightRtrn))
- {
- switch (expr->op)
- {
+ ExprResolveKeyCode(ctx, right, &rightRtrn)) {
+ switch (expr->op) {
case OpAdd:
val_rtrn->uval = leftRtrn.uval + rightRtrn.uval;
break;
@@ -449,17 +445,19 @@ ExprResolveKeyCode(struct xkb_context *ctx, ExprDef *expr,
return true;
}
return false;
+
case OpNegate:
left = expr->value.child;
- if (ExprResolveKeyCode(ctx, left, &leftRtrn))
- {
+ if (ExprResolveKeyCode(ctx, left, &leftRtrn)) {
val_rtrn->uval = ~leftRtrn.uval;
return true;
}
return false;
+
case OpUnaryPlus:
left = expr->value.child;
return ExprResolveKeyCode(ctx, left, val_rtrn);
+
default:
WSGO("Unknown operator %d in ResolveKeyCode\n", expr->op);
break;
@@ -490,16 +488,13 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
ExprResult leftRtrn, rightRtrn;
ExprDef *left, *right;
- switch (expr->op)
- {
+ switch (expr->op) {
case ExprValue:
- if (expr->type == TypeString)
- {
+ if (expr->type == TypeString) {
const char *str;
str = xkb_atom_text(ctx, expr->value.str);
if (str != NULL)
- switch (strlen(str))
- {
+ switch (strlen(str)) {
case 0:
val_rtrn->uval = 0;
return true;
@@ -510,39 +505,41 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
break;
}
}
- if (expr->type != TypeInt)
- {
+ if (expr->type != TypeInt) {
ERROR
("Found constant of type %s where an int was expected\n",
- exprTypeText(expr->type));
+ exprTypeText(expr->type));
return false;
}
val_rtrn->ival = expr->value.ival;
return true;
+
case ExprIdent:
if (lookup)
ok = lookup(ctx, lookupPriv, expr->value.str,
TypeInt, val_rtrn);
if (!ok)
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;
+
case ExprFieldRef:
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.field));
return false;
+
case OpAdd:
case OpSubtract:
case OpMultiply:
case OpDivide:
left = expr->value.binary.left;
right = expr->value.binary.right;
- if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup, lookupPriv) &&
- ExprResolveIntegerLookup(ctx, right, &rightRtrn, lookup, lookupPriv))
- {
- switch (expr->op)
- {
+ if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
+ lookupPriv) &&
+ ExprResolveIntegerLookup(ctx, right, &rightRtrn, lookup,
+ lookupPriv)) {
+ switch (expr->op) {
case OpAdd:
val_rtrn->ival = leftRtrn.ival + rightRtrn.ival;
break;
@@ -559,18 +556,20 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
return true;
}
return false;
+
case OpAssign:
WSGO("Assignment operator not implemented yet\n");
break;
+
case OpNot:
ERROR("The ! operator cannot be applied to an integer\n");
return false;
+
case OpInvert:
case OpNegate:
left = expr->value.child;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
- lookupPriv))
- {
+ lookupPriv)) {
if (expr->op == OpNegate)
val_rtrn->ival = -leftRtrn.ival;
else
@@ -578,10 +577,12 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, ExprDef *expr,
return true;
}
return false;
+
case OpUnaryPlus:
left = expr->value.child;
return ExprResolveIntegerLookup(ctx, left, val_rtrn, lookup,
lookupPriv);
+
default:
WSGO("Unknown operator %d in ResolveInteger\n", expr->op);
break;
@@ -685,34 +686,34 @@ ExprResolveString(struct xkb_context *ctx, ExprDef *expr,
ExprDef *right;
const char *bogus = NULL;
- switch (expr->op)
- {
+ switch (expr->op) {
case ExprValue:
- if (expr->type != TypeString)
- {
+ if (expr->type != TypeString) {
ERROR("Found constant of type %s, expected a string\n",
- exprTypeText(expr->type));
+ exprTypeText(expr->type));
return false;
}
val_rtrn->str = xkb_atom_strdup(ctx, expr->value.str);
if (val_rtrn->str == NULL)
val_rtrn->str = strdup("");
return true;
+
case ExprIdent:
ERROR("Identifier \"%s\" of type string not found\n",
xkb_atom_text(ctx, expr->value.str));
return false;
+
case ExprFieldRef:
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.field));
return false;
+
case OpAdd:
left = expr->value.binary.left;
right = expr->value.binary.right;
if (ExprResolveString(ctx, left, &leftRtrn) &&
- ExprResolveString(ctx, right, &rightRtrn))
- {
+ ExprResolveString(ctx, right, &rightRtrn)) {
int len;
char *new;
len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
@@ -728,6 +729,7 @@ ExprResolveString(struct xkb_context *ctx, ExprDef *expr,
free(rightRtrn.str);
}
return false;
+
case OpSubtract:
if (bogus == NULL)
bogus = "Subtraction";
@@ -748,12 +750,15 @@ ExprResolveString(struct xkb_context *ctx, ExprDef *expr,
bogus = "Bitwise complement";
ERROR("%s of string values not permitted\n", bogus);
return false;
+
case OpNot:
ERROR("The ! operator cannot be applied to a string\n");
return false;
+
case OpUnaryPlus:
ERROR("The + operator cannot be applied to a string\n");
return false;
+
default:
WSGO("Unknown operator %d in ResolveString\n", expr->op);
break;
@@ -767,26 +772,27 @@ ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
{
const char *bogus = NULL;
- switch (expr->op)
- {
+ switch (expr->op) {
case ExprValue:
- if (expr->type != TypeKeyName)
- {
+ if (expr->type != TypeKeyName) {
ERROR("Found constant of type %s, expected a key name\n",
- exprTypeText(expr->type));
+ exprTypeText(expr->type));
return false;
}
memcpy(val_rtrn->keyName.name, expr->value.keyName, XkbKeyNameLength);
return true;
+
case ExprIdent:
ERROR("Identifier \"%s\" of type string not found\n",
xkb_atom_text(ctx, expr->value.str));
return false;
+
case ExprFieldRef:
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.field));
return false;
+
case OpAdd:
if (bogus == NULL)
bogus = "Addition";
@@ -810,12 +816,15 @@ ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
bogus = "Bitwise complement";
ERROR("%s of key name values not permitted\n", bogus);
return false;
+
case OpNot:
ERROR("The ! operator cannot be applied to a key name\n");
return false;
+
case OpUnaryPlus:
ERROR("The + operator cannot be applied to a key name\n");
return false;
+
default:
WSGO("Unknown operator %d in ResolveKeyName\n", expr->op);
break;
@@ -829,17 +838,15 @@ int
ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
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",
- exprOpText(expr->op));
+ exprOpText(expr->op));
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;
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)
{
if (nOut != 0)
@@ -865,48 +872,51 @@ ExprResolveMaskLookup(struct xkb_context *ctx, ExprDef *expr,
ExprDef *left, *right;
const char *bogus = NULL;
- switch (expr->op)
- {
+ switch (expr->op) {
case ExprValue:
- if (expr->type != TypeInt)
- {
+ if (expr->type != TypeInt) {
ERROR
("Found constant of type %s where a mask was expected\n",
- exprTypeText(expr->type));
+ exprTypeText(expr->type));
return false;
}
val_rtrn->ival = expr->value.ival;
return true;
+
case ExprIdent:
ok = lookup(ctx, lookupPriv, expr->value.str, TypeInt, val_rtrn);
if (!ok)
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;
+
case ExprFieldRef:
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.field));
return false;
+
case ExprArrayRef:
bogus = "array reference";
+
case ExprActionDecl:
if (bogus == NULL)
bogus = "function use";
ERROR("Unexpected %s in mask expression\n", bogus);
ACTION("Expression ignored\n");
return false;
+
case OpAdd:
case OpSubtract:
case OpMultiply:
case OpDivide:
left = expr->value.binary.left;
right = expr->value.binary.right;
- if (ExprResolveMaskLookup(ctx, left, &leftRtrn, lookup, lookupPriv) &&
- ExprResolveMaskLookup(ctx, right, &rightRtrn, lookup, lookupPriv))
- {
- switch (expr->op)
- {
+ if (ExprResolveMaskLookup(ctx, left, &leftRtrn, lookup,
+ lookupPriv) &&
+ ExprResolveMaskLookup(ctx, right, &rightRtrn, lookup,
+ lookupPriv)) {
+ switch (expr->op) {
case OpAdd:
val_rtrn->ival = leftRtrn.ival | rightRtrn.ival;
break;
@@ -916,36 +926,38 @@ ExprResolveMaskLookup(struct xkb_context *ctx, ExprDef *expr,
case OpMultiply:
case OpDivide:
ERROR("Cannot %s masks\n",
- expr->op == OpDivide ? "divide" : "multiply");
+ expr->op == OpDivide ? "divide" : "multiply");
ACTION("Illegal operation ignored\n");
return false;
}
return true;
}
return false;
+
case OpAssign:
WSGO("Assignment operator not implemented yet\n");
break;
+
case OpInvert:
left = expr->value.child;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
- lookupPriv))
- {
+ lookupPriv)) {
val_rtrn->ival = ~leftRtrn.ival;
return true;
}
return false;
+
case OpUnaryPlus:
case OpNegate:
case OpNot:
left = expr->value.child;
if (ExprResolveIntegerLookup(ctx, left, &leftRtrn, lookup,
- lookupPriv))
- {
+ lookupPriv)) {
ERROR("The %s operator cannot be used with a mask\n",
- (expr->op == OpNegate ? "-" : "!"));
+ (expr->op == OpNegate ? "-" : "!"));
}
return false;
+
default:
WSGO("Unknown operator %d in ResolveMask\n", expr->op);
break;
@@ -982,8 +994,7 @@ ExprResolveKeySym(struct xkb_context *ctx, ExprDef *expr,
int ok = 0;
xkb_keysym_t sym;
- if (expr->op == ExprIdent)
- {
+ if (expr->op == ExprIdent) {
const char *str;
str = xkb_atom_text(ctx, expr->value.str);
if (str) {
diff --git a/src/xkbcomp/expr.h b/src/xkbcomp/expr.h
index e9abf59..c4371b4 100644
--- a/src/xkbcomp/expr.h
+++ b/src/xkbcomp/expr.h
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef EXPR_H
@@ -29,8 +29,7 @@
#include "xkbcomp-priv.h"
-typedef union _ExprResult
-{
+typedef union _ExprResult {
char *str;
int ival;
unsigned uval;
@@ -42,27 +41,28 @@ ExprResolveLhs(struct xkb_keymap *keymap, ExprDef *expr,
ExprResult *elem_rtrn, ExprResult *field_rtrn,
ExprDef **index_rtrn);
-typedef struct _LookupEntry
-{
+typedef struct _LookupEntry {
const char *name;
unsigned result;
} LookupEntry;
-
extern const char *
exprOpText(unsigned type);
extern bool
LookupModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- unsigned type, ExprResult *val_rtrn);
+ unsigned type,
+ ExprResult *val_rtrn);
extern bool
LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- unsigned type, ExprResult *val_rtrn);
+ unsigned type,
+ ExprResult *val_rtrn);
extern bool
LookupModIndex(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
- unsigned type, ExprResult *val_rtrn);
+ unsigned type,
+ ExprResult *val_rtrn);
extern int
ExprResolveModMask(struct xkb_context *ctx, ExprDef *expr,
@@ -85,20 +85,17 @@ ExprResolveInteger(struct xkb_context *ctx, ExprDef *expr,
ExprResult *val_rtrn);
extern int
-ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn);
+ExprResolveLevel(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn);
extern int
-ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn);
+ExprResolveGroup(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn);
extern int
ExprResolveButton(struct xkb_context *ctx, ExprDef *expr,
ExprResult *val_rtrn);
extern int
-ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn);
+ExprResolveFloat(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn);
extern int
ExprResolveString(struct xkb_context *ctx, ExprDef *expr,
@@ -109,12 +106,12 @@ ExprResolveKeyName(struct xkb_context *ctx, ExprDef *expr,
ExprResult *val_rtrn);
extern int
-ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn, const LookupEntry *values);
+ExprResolveEnum(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
+ const LookupEntry *values);
extern int
-ExprResolveMask(struct xkb_context *ctx, ExprDef *expr,
- ExprResult *val_rtrn, const LookupEntry *values);
+ExprResolveMask(struct xkb_context *ctx, ExprDef *expr, ExprResult *val_rtrn,
+ const LookupEntry *values);
extern int
ExprResolveKeySym(struct xkb_context *ctx, ExprDef *expr,
diff --git a/src/xkbcomp/indicators.c b/src/xkbcomp/indicators.c
index 060ed46..bcbded6 100644
--- a/src/xkbcomp/indicators.c
+++ b/src/xkbcomp/indicators.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "indicators.h"
@@ -57,28 +57,23 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
unsigned collide;
last = NULL;
- for (old = oldLEDs; old != NULL; old = (LEDInfo *) old->defs.next)
- {
- if (old->name == new->name)
- {
+ for (old = oldLEDs; old != NULL; old = (LEDInfo *) old->defs.next) {
+ if (old->name == new->name) {
if ((old->real_mods == new->real_mods) &&
(old->vmods == new->vmods) &&
(old->groups == new->groups) &&
(old->ctrls == new->ctrls) &&
(old->which_mods == new->which_mods) &&
- (old->which_groups == new->which_groups))
- {
+ (old->which_groups == new->which_groups)) {
old->defs.defined |= new->defs.defined;
return oldLEDs;
}
- if (new->defs.merge == MERGE_REPLACE)
- {
+ if (new->defs.merge == MERGE_REPLACE) {
CommonInfo *next = old->defs.next;
if (((old->defs.file_id == new->defs.file_id)
- && (warningLevel > 0)) || (warningLevel > 9))
- {
+ && (warningLevel > 0)) || (warningLevel > 9)) {
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");
}
*old = *new;
@@ -86,53 +81,48 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
return oldLEDs;
}
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->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->real_mods = new->real_mods;
old->vmods = new->vmods;
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->groups = new->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->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 |= (new->flags & XkbIM_NoExplicit);
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 |= (new->flags & XkbIM_NoAutomatic);
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 |= (new->flags & XkbIM_LEDDrivesKB);
old->defs.defined |= _LED_DrivesKbd;
}
- if (collide)
- {
+ if (collide) {
WARN("Map for indicator %s redefined\n",
xkb_atom_text(keymap->ctx, old->name));
ACTION("Using %s definition for duplicate fields\n",
- (new->defs.merge == MERGE_AUGMENT ? "first" : "last"));
+ (new->defs.merge == MERGE_AUGMENT ? "first" : "last"));
}
return oldLEDs;
}
@@ -141,17 +131,15 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
}
/* new definition */
old = uTypedAlloc(LEDInfo);
- if (!old)
- {
+ if (!old) {
WSGO("Couldn't allocate indicator map\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;
}
*old = *new;
old->defs.next = NULL;
- if (last)
- {
+ if (last) {
last->defs.next = &old->defs;
return oldLEDs;
}
@@ -159,37 +147,37 @@ AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *new)
}
static const LookupEntry modComponentNames[] = {
- {"base", XkbIM_UseBase},
- {"latched", XkbIM_UseLatched},
- {"locked", XkbIM_UseLocked},
- {"effective", XkbIM_UseEffective},
- {"compat", XkbIM_UseCompat},
- {"any", XkbIM_UseAnyMods},
- {"none", 0},
- {NULL, 0}
+ { "base", XkbIM_UseBase },
+ { "latched", XkbIM_UseLatched },
+ { "locked", XkbIM_UseLocked },
+ { "effective", XkbIM_UseEffective },
+ { "compat", XkbIM_UseCompat },
+ { "any", XkbIM_UseAnyMods },
+ { "none", 0 },
+ { NULL, 0 }
};
static const LookupEntry groupComponentNames[] = {
- {"base", XkbIM_UseBase},
- {"latched", XkbIM_UseLatched},
- {"locked", XkbIM_UseLocked},
- {"effective", XkbIM_UseEffective},
- {"any", XkbIM_UseAnyGroup},
- {"none", 0},
- {NULL, 0}
+ { "base", XkbIM_UseBase },
+ { "latched", XkbIM_UseLatched },
+ { "locked", XkbIM_UseLocked },
+ { "effective", XkbIM_UseEffective },
+ { "any", XkbIM_UseAnyGroup },
+ { "none", 0 },
+ { NULL, 0 }
};
static const LookupEntry groupNames[] = {
- {"group1", 0x01},
- {"group2", 0x02},
- {"group3", 0x04},
- {"group4", 0x08},
- {"group5", 0x10},
- {"group6", 0x20},
- {"group7", 0x40},
- {"group8", 0x80},
- {"none", 0x00},
- {"all", 0xff},
- {NULL, 0}
+ { "group1", 0x01 },
+ { "group2", 0x02 },
+ { "group3", 0x04 },
+ { "group4", 0x08 },
+ { "group5", 0x10 },
+ { "group6", 0x20 },
+ { "group7", 0x40 },
+ { "group8", 0x80 },
+ { "none", 0x00 },
+ { "all", 0xff },
+ { NULL, 0 }
};
int
@@ -201,8 +189,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
ok = true;
if ((strcasecmp(field, "modifiers") == 0) ||
- (strcasecmp(field, "mods") == 0))
- {
+ (strcasecmp(field, "mods") == 0)) {
if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveVModMask(value, &rtrn, keymap))
@@ -211,8 +198,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->vmods = (rtrn.uval >> 8) & 0xff;
led->defs.defined |= _LED_Mods;
}
- else if (strcasecmp(field, "groups") == 0)
- {
+ else if (strcasecmp(field, "groups") == 0) {
if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupNames))
@@ -221,8 +207,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->defs.defined |= _LED_Groups;
}
else if ((strcasecmp(field, "controls") == 0) ||
- (strcasecmp(field, "ctrls") == 0))
- {
+ (strcasecmp(field, "ctrls") == 0)) {
if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveMask(keymap->ctx, value, &rtrn, ctrlNames))
@@ -231,8 +216,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->ctrls = rtrn.uval;
led->defs.defined |= _LED_Ctrls;
}
- else if (strcasecmp(field, "allowexplicit") == 0)
- {
+ else if (strcasecmp(field, "allowexplicit") == 0) {
if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
@@ -244,23 +228,20 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->defs.defined |= _LED_Explicit;
}
else if ((strcasecmp(field, "whichmodstate") == 0) ||
- (strcasecmp(field, "whichmodifierstate") == 0))
- {
+ (strcasecmp(field, "whichmodifierstate") == 0)) {
if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field);
- if (!ExprResolveMask(keymap->ctx, value, &rtrn, modComponentNames))
- {
+ if (!ExprResolveMask(keymap->ctx, value, &rtrn, modComponentNames)) {
return ReportIndicatorBadType(keymap, led, field,
"mask of modifier state components");
}
led->which_mods = rtrn.uval;
}
- else if (strcasecmp(field, "whichgroupstate") == 0)
- {
+ else if (strcasecmp(field, "whichgroupstate") == 0) {
if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field);
- if (!ExprResolveMask(keymap->ctx, value, &rtrn, groupComponentNames))
- {
+ if (!ExprResolveMask(keymap->ctx, value, &rtrn,
+ groupComponentNames)) {
return ReportIndicatorBadType(keymap, led, field,
"mask of group state components");
}
@@ -271,8 +252,7 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
(strcasecmp(field, "leddriveskbd") == 0) ||
(strcasecmp(field, "leddriveskeyboard") == 0) ||
(strcasecmp(field, "indicatordriveskbd") == 0) ||
- (strcasecmp(field, "indicatordriveskeyboard") == 0))
- {
+ (strcasecmp(field, "indicatordriveskeyboard") == 0)) {
if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveBoolean(keymap->ctx, value, &rtrn))
@@ -283,28 +263,25 @@ SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap,
led->flags &= ~XkbIM_LEDDrivesKB;
led->defs.defined |= _LED_DrivesKbd;
}
- else if (strcasecmp(field, "index") == 0)
- {
+ else if (strcasecmp(field, "index") == 0) {
if (arrayNdx != NULL)
return ReportIndicatorNotArray(keymap, led, field);
if (!ExprResolveInteger(keymap->ctx, value, &rtrn))
return ReportIndicatorBadType(keymap, led, field,
"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",
- rtrn.uval, XkbNumIndicators);
+ rtrn.uval, XkbNumIndicators);
ACTION("Index definition for %s indicator ignored\n",
- xkb_atom_text(keymap->ctx, led->name));
+ xkb_atom_text(keymap->ctx, led->name));
return false;
}
led->indicator = rtrn.uval;
led->defs.defined |= _LED_Index;
}
- else
- {
+ else {
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");
ok = false;
}
@@ -327,33 +304,28 @@ HandleIndicatorMapDef(IndicatorMapDef *def, struct xkb_keymap *keymap,
led.name = def->name;
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;
ExprDef *arrayNdx;
- if (!ExprResolveLhs(keymap, var->name, &elem, &field, &arrayNdx))
- {
+ if (!ExprResolveLhs(keymap, var->name, &elem, &field, &arrayNdx)) {
ok = false;
continue;
}
- if (elem.str != NULL)
- {
+ if (elem.str != NULL) {
ERROR
("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);
ok = false;
}
- else
- {
+ else {
ok = SetIndicatorMapField(&led, keymap, field.str, arrayNdx,
var->value) && ok;
}
free(elem.str);
free(field.str);
}
- if (ok)
- {
+ if (ok) {
rtrn = AddIndicatorMap(keymap, oldLEDs, &led);
return rtrn;
}
@@ -366,74 +338,60 @@ BindIndicators(struct xkb_keymap *keymap, LEDInfo *unbound)
int i;
LEDInfo *led, *next, *last;
- if (keymap->names != NULL)
- {
- for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next)
- {
- if (led->indicator == _LED_NotBound)
- {
- for (i = 0; i < XkbNumIndicators; i++)
- {
+ if (keymap->names != NULL) {
+ for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
+ if (led->indicator == _LED_NotBound) {
+ for (i = 0; i < XkbNumIndicators; i++) {
if (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;
break;
}
}
}
}
- for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next)
- {
- if (led->indicator == _LED_NotBound)
- {
- for (i = 0; i < XkbNumIndicators; i++)
- {
- if (keymap->names->indicators[i] == NULL)
- {
+ for (led = unbound; led != NULL; led = (LEDInfo *) led->defs.next) {
+ if (led->indicator == _LED_NotBound) {
+ for (i = 0; i < XkbNumIndicators; i++) {
+ if (keymap->names->indicators[i] == NULL) {
keymap->names->indicators[i] =
xkb_atom_strdup(keymap->ctx, led->name);
led->indicator = i + 1;
break;
}
}
- if (led->indicator == _LED_NotBound)
- {
+ if (led->indicator == _LED_NotBound) {
ERROR("No unnamed indicators found\n");
ACTION
("Virtual indicator map \"%s\" not bound\n",
- xkb_atom_text(keymap->ctx, led->name));
+ xkb_atom_text(keymap->ctx, led->name));
continue;
}
}
}
}
- for (last = NULL, led = unbound; led != NULL; led = next)
- {
+ for (last = NULL, led = unbound; led != NULL; led = next) {
next = (LEDInfo *) led->defs.next;
- if (led->indicator == _LED_NotBound)
- {
+ if (led->indicator == _LED_NotBound) {
unbound = next;
free(led);
}
- else
- {
+ else {
if ((keymap->names != NULL) &&
(strcmp(keymap->names->indicators[led->indicator - 1],
- xkb_atom_text(keymap->ctx, led->name)) != 0))
- {
- const char *old = keymap->names->indicators[led->indicator - 1];
+ xkb_atom_text(keymap->ctx, led->name)) != 0)) {
+ const char *old =
+ keymap->names->indicators[led->indicator - 1];
ERROR("Multiple names bound to indicator %d\n",
- (unsigned int) led->indicator);
+ (unsigned int) led->indicator);
ACTION("Using %s, ignoring %s\n", old,
xkb_atom_text(keymap->ctx, led->name));
led->indicator = _LED_NotBound;
unbound = next;
free(led);
}
- else
- {
+ else {
struct xkb_indicator_map * map;
map = &keymap->indicators->maps[led->indicator - 1];
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;
free(led);
}
@@ -467,26 +424,22 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
LEDInfo *led, *next;
LEDInfo *unbound = NULL, *last = NULL;
- if (XkbcAllocNames(keymap, XkbIndicatorNamesMask, 0) != Success)
- {
+ if (XkbcAllocNames(keymap, XkbIndicatorNamesMask, 0) != Success) {
WSGO("Couldn't allocate names\n");
ACTION("Indicator names may be incorrect\n");
}
- if (XkbcAllocIndicatorMaps(keymap) != Success)
- {
+ if (XkbcAllocIndicatorMaps(keymap) != Success) {
WSGO("Can't allocate indicator maps\n");
ACTION("Indicator map definitions may be lost\n");
return false;
}
- for (led = leds; led != NULL; led = next)
- {
+ for (led = leds; led != NULL; led = next) {
next = (LEDInfo *) led->defs.next;
if ((led->groups != 0) && (led->which_groups == 0))
led->which_groups = XkbIM_UseEffective;
if ((led->which_mods == 0) && ((led->real_mods) || (led->vmods)))
led->which_mods = XkbIM_UseEffective;
- if ((led->indicator == _LED_NotBound) || (!keymap->indicators))
- {
+ if ((led->indicator == _LED_NotBound) || (!keymap->indicators)) {
led->defs.next = NULL;
if (last != NULL)
last->defs.next = (CommonInfo *) led;
@@ -494,8 +447,7 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
unbound = led;
last = led;
}
- else
- {
+ else {
struct xkb_indicator_map * im;
im = &keymap->indicators->maps[led->indicator - 1];
im->flags = led->flags;
@@ -506,10 +458,9 @@ CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds)
im->mods.real_mods = led->real_mods;
im->mods.vmods = led->vmods;
im->ctrls = led->ctrls;
- if (keymap->names != NULL)
- {
+ if (keymap->names != NULL) {
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);
}
free(led);
diff --git a/src/xkbcomp/indicators.h b/src/xkbcomp/indicators.h
index e485db5..707096c 100644
--- a/src/xkbcomp/indicators.h
+++ b/src/xkbcomp/indicators.h
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef INDICATORS_H
@@ -29,18 +29,17 @@
#include "xkbcomp-priv.h"
-#define _LED_Index (1<<0)
-#define _LED_Mods (1<<1)
-#define _LED_Groups (1<<2)
-#define _LED_Ctrls (1<<3)
-#define _LED_Explicit (1<<4)
-#define _LED_Automatic (1<<5)
-#define _LED_DrivesKbd (1<<6)
+#define _LED_Index (1 << 0)
+#define _LED_Mods (1 << 1)
+#define _LED_Groups (1 << 2)
+#define _LED_Ctrls (1 << 3)
+#define _LED_Explicit (1 << 4)
+#define _LED_Automatic (1 << 5)
+#define _LED_DrivesKbd (1 << 6)
-#define _LED_NotBound 255
+#define _LED_NotBound 255
-typedef struct _LEDInfo
-{
+typedef struct _LEDInfo {
CommonInfo defs;
xkb_atom_t name;
unsigned char indicator;
@@ -56,17 +55,18 @@ typedef struct _LEDInfo
extern void
ClearIndicatorMapInfo(struct xkb_context *ctx, LEDInfo *info);
-
extern LEDInfo *
AddIndicatorMap(struct xkb_keymap *keymap, LEDInfo *oldLEDs, LEDInfo *newLED);
extern int
SetIndicatorMapField(LEDInfo *led, struct xkb_keymap *keymap, char *field,
- ExprDef *arrayNdx, ExprDef *value);
+ ExprDef *arrayNdx,
+ ExprDef *value);
extern LEDInfo *
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
CopyIndicatorMapDefs(struct xkb_keymap *keymap, LEDInfo *leds);
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index d60c8a5..1ec1138 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "keycodes.h"
@@ -51,16 +51,14 @@ LongToKeyName(unsigned long val, char *name)
/***====================================================================***/
-typedef struct _IndicatorNameInfo
-{
+typedef struct _IndicatorNameInfo {
CommonInfo defs;
int ndx;
xkb_atom_t name;
bool virtual;
} IndicatorNameInfo;
-typedef struct _KeyNamesInfo
-{
+typedef struct _KeyNamesInfo {
char *name; /* e.g. evdev+aliases(qwerty) */
int errorCount;
unsigned file_id;
@@ -75,8 +73,10 @@ typedef struct _KeyNamesInfo
AliasInfo *aliases;
} KeyNamesInfo;
-static void HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
- enum merge_mode merge, KeyNamesInfo *info);
+static void
+HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
+ enum merge_mode merge,
+ KeyNamesInfo *info);
static void
ResizeKeyNameArrays(KeyNamesInfo *info, int newMax)
@@ -103,8 +103,7 @@ InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
static void
ClearIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
{
- if (ii == info->leds)
- {
+ if (ii == info->leds) {
ClearCommonInfo(&ii->defs);
info->leds = NULL;
}
@@ -116,8 +115,7 @@ NextIndicatorName(KeyNamesInfo * info)
IndicatorNameInfo *ii;
ii = uTypedAlloc(IndicatorNameInfo);
- if (ii)
- {
+ if (ii) {
InitIndicatorNameInfo(ii, info);
info->leds = AddCommonInfo(&info->leds->defs, &ii->defs);
}
@@ -130,8 +128,7 @@ FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
IndicatorNameInfo *old;
for (old = info->leds; old != NULL;
- old = (IndicatorNameInfo *) old->defs.next)
- {
+ old = (IndicatorNameInfo *) old->defs.next) {
if (old->ndx == ndx)
return old;
}
@@ -144,8 +141,7 @@ FindIndicatorByName(KeyNamesInfo * info, xkb_atom_t name)
IndicatorNameInfo *old;
for (old = info->leds; old != NULL;
- old = (IndicatorNameInfo *) old->defs.next)
- {
+ old = (IndicatorNameInfo *) old->defs.next) {
if (old->name == name)
return old;
}
@@ -153,7 +149,8 @@ FindIndicatorByName(KeyNamesInfo * info, xkb_atom_t name)
}
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 *old;
@@ -161,49 +158,39 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
replace = (merge == MERGE_REPLACE) || (merge == MERGE_OVERRIDE);
old = FindIndicatorByName(info, new->name);
- if (old)
- {
+ if (old) {
if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
- || (warningLevel > 9))
- {
+ || (warningLevel > 9)) {
WARN("Multiple indicators named %s\n",
xkb_atom_text(keymap->ctx, new->name));
- if (old->ndx == new->ndx)
- {
- if (old->virtual != new->virtual)
- {
+ if (old->ndx == new->ndx) {
+ if (old->virtual != new->virtual) {
if (replace)
old->virtual = new->virtual;
ACTION("Using %s instead of %s\n",
(old->virtual ? "virtual" : "real"),
(old->virtual ? "real" : "virtual"));
}
- else
- {
+ else {
ACTION("Identical definitions ignored\n");
}
return true;
}
- else
- {
+ else {
if (replace)
ACTION("Ignoring %d, using %d\n", old->ndx, new->ndx);
else
ACTION("Using %d, ignoring %d\n", old->ndx, new->ndx);
}
- if (replace)
- {
+ if (replace) {
if (info->leds == old)
info->leds = (IndicatorNameInfo *) old->defs.next;
- else
- {
+ else {
IndicatorNameInfo *tmp;
tmp = info->leds;
for (; tmp != NULL;
- tmp = (IndicatorNameInfo *) tmp->defs.next)
- {
- if (tmp->defs.next == (CommonInfo *) old)
- {
+ tmp = (IndicatorNameInfo *) tmp->defs.next) {
+ if (tmp->defs.next == (CommonInfo *) old) {
tmp->defs.next = old->defs.next;
break;
}
@@ -214,16 +201,13 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
}
}
old = FindIndicatorByIndex(info, new->ndx);
- if (old)
- {
+ if (old) {
if (((old->defs.file_id == new->defs.file_id) && (warningLevel > 0))
- || (warningLevel > 9))
- {
+ || (warningLevel > 9)) {
WARN("Multiple names for indicator %d\n", new->ndx);
if ((old->name == new->name) && (old->virtual == new->virtual))
ACTION("Identical definitions ignored\n");
- else
- {
+ else {
const char *oldType, *newType;
xkb_atom_t using, ignoring;
if (old->virtual)
@@ -234,23 +218,20 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
newType = "virtual indicator";
else
newType = "real indicator";
- if (replace)
- {
+ if (replace) {
using = new->name;
ignoring = old->name;
}
- else
- {
+ else {
using = old->name;
ignoring = new->name;
}
ACTION("Using %s %s, ignoring %s %s\n",
- oldType, xkb_atom_text(keymap->ctx, using),
- newType, xkb_atom_text(keymap->ctx, ignoring));
+ oldType, xkb_atom_text(keymap->ctx, using),
+ newType, xkb_atom_text(keymap->ctx, ignoring));
}
}
- if (replace)
- {
+ if (replace) {
old->name = new->name;
old->virtual = new->virtual;
}
@@ -258,8 +239,7 @@ AddIndicatorName(KeyNamesInfo *info, struct xkb_keymap *keymap, enum merge_mode
}
old = new;
new = NextIndicatorName(info);
- if (!new)
- {
+ if (!new) {
WSGO("Couldn't allocate name for indicator %d\n", old->ndx);
ACTION("Ignored\n");
return false;
@@ -331,39 +311,32 @@ AddKeyName(KeyNamesInfo * info,
info->computedMax = kc;
lval = KeyNameToLong(name);
- if (reportCollisions)
- {
+ if (reportCollisions) {
reportCollisions = (warningLevel > 7 ||
(warningLevel > 0 &&
file_id == darray_item(info->files, kc)));
}
- if (darray_item(info->names, kc) != 0)
- {
+ if (darray_item(info->names, kc) != 0) {
char buf[6];
LongToKeyName(darray_item(info->names, kc), buf);
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");
ACTION("Later occurences of \"<%s> = %d\" ignored\n",
buf, kc);
return true;
}
- if (merge == MERGE_AUGMENT)
- {
- if (reportCollisions)
- {
+ if (merge == MERGE_AUGMENT) {
+ if (reportCollisions) {
WARN("Multiple names for keycode %d\n", kc);
ACTION("Using <%s>, ignoring <%s>\n", buf, name);
}
return true;
}
- else
- {
- if (reportCollisions)
- {
+ else {
+ if (reportCollisions) {
WARN("Multiple names for keycode %d\n", kc);
ACTION("Using <%s>, ignoring <%s>\n", name, buf);
}
@@ -372,22 +345,17 @@ AddKeyName(KeyNamesInfo * info,
}
}
old = FindKeyByLong(info, lval);
- if ((old != 0) && (old != kc))
- {
- if (merge == MERGE_OVERRIDE)
- {
+ if ((old != 0) && (old != kc)) {
+ if (merge == MERGE_OVERRIDE) {
darray_item(info->names, old) = 0;
darray_item(info->files, old) = 0;
- if (reportCollisions)
- {
+ if (reportCollisions) {
WARN("Key name <%s> assigned to multiple keys\n", name);
ACTION("Using %d, ignoring %d\n", kc, old);
}
}
- else
- {
- if ((reportCollisions) && (warningLevel > 3))
- {
+ else {
+ if ((reportCollisions) && (warningLevel > 3)) {
WARN("Key name <%s> assigned to multiple keys\n", name);
ACTION("Using %d, ignoring %d\n", old, kc);
}
@@ -408,21 +376,18 @@ MergeIncludedKeycodes(KeyNamesInfo *into, struct xkb_keymap *keymap,
uint64_t i;
char buf[5];
- if (from->errorCount > 0)
- {
+ if (from->errorCount > 0) {
into->errorCount += from->errorCount;
return;
}
- if (into->name == NULL)
- {
+ if (into->name == NULL) {
into->name = from->name;
from->name = NULL;
}
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)
continue;
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))
into->errorCount++;
}
- if (from->leds)
- {
+ if (from->leds) {
IndicatorNameInfo *led, *next;
- for (led = from->leds; led != NULL; led = next)
- {
+ for (led = from->leds; led != NULL; led = next) {
if (merge != MERGE_DEFAULT)
led->defs.merge = merge;
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))
into->errorCount++;
- if (from->explicitMin != 0)
- {
+ if (from->explicitMin != 0) {
if ((into->explicitMin == 0)
|| (into->explicitMin > from->explicitMin))
into->explicitMin = from->explicitMin;
}
- if (from->explicitMax > 0)
- {
+ if (from->explicitMax > 0) {
if ((into->explicitMax == 0)
|| (into->explicitMax < from->explicitMax))
into->explicitMax = from->explicitMax;
@@ -477,63 +438,53 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
memset(&included, 0, sizeof(included));
haveSelf = false;
- if ((stmt->file == NULL) && (stmt->map == NULL))
- {
+ if ((stmt->file == NULL) && (stmt->map == NULL)) {
haveSelf = true;
included = *info;
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;
info->explicitMin = 0;
info->explicitMax = XKB_KEYCODE_MAX;
return (info->errorCount == 0);
} /* parse file, store returned info in the xkb struct */
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_KEYCODES, &rtrn,
- &newMerge))
- {
+ &newMerge)) {
InitKeyNamesInfo(&included, rtrn->id);
HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &included);
- if (stmt->stmt != NULL)
- {
+ if (stmt->stmt != NULL) {
free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
FreeXKBFile(rtrn);
}
- else
- {
+ else {
info->errorCount += 10; /* XXX: why 10?? */
return false;
}
/* Do we have more than one include statement? */
- if ((stmt->next != NULL) && (included.errorCount < 1))
- {
+ if ((stmt->next != NULL) && (included.errorCount < 1)) {
IncludeStmt *next;
unsigned op;
KeyNamesInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next)
- {
- if ((next->file == NULL) && (next->map == NULL))
- {
+ for (next = stmt->next; next != NULL; next = next->next) {
+ if ((next->file == NULL) && (next->map == NULL)) {
haveSelf = true;
MergeIncludedKeycodes(&included, keymap, info, next->merge);
ClearKeyNamesInfo(info);
}
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_KEYCODES,
- &rtrn, &op))
- {
+ &rtrn, &op)) {
InitKeyNamesInfo(&next_incl, rtrn->id);
HandleKeycodesFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
MergeIncludedKeycodes(&included, keymap, &next_incl, op);
ClearKeyNamesInfo(&next_incl);
FreeXKBFile(rtrn);
}
- else
- {
+ else {
info->errorCount += 10; /* XXX: Why 10?? */
ClearKeyNamesInfo(&included);
return false;
@@ -542,8 +493,7 @@ HandleIncludeKeycodes(IncludeStmt *stmt, struct xkb_keymap *keymap,
}
if (haveSelf)
*info = included;
- else
- {
+ else {
MergeIncludedKeycodes(info, keymap, &included, newMerge);
ClearKeyNamesInfo(&included);
}
@@ -558,16 +508,14 @@ static int
HandleKeycodeDef(KeycodeDef *stmt, enum merge_mode merge, KeyNamesInfo *info)
{
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);
ACTION("Must be in the range %d-%d inclusive\n",
- info->explicitMin,
- info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
+ info->explicitMin,
+ info->explicitMax ? info->explicitMax : XKB_KEYCODE_MAX);
return 0;
}
- if (stmt->merge != MERGE_DEFAULT)
- {
+ if (stmt->merge != MERGE_DEFAULT) {
if (stmt->merge == MERGE_REPLACE)
merge = MERGE_OVERRIDE;
else
@@ -577,8 +525,8 @@ HandleKeycodeDef(KeycodeDef *stmt, enum merge_mode merge, KeyNamesInfo *info)
true);
}
-#define MIN_KEYCODE_DEF 0
-#define MAX_KEYCODE_DEF 1
+#define MIN_KEYCODE_DEF 0
+#define MAX_KEYCODE_DEF 1
/**
* 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)
return 0; /* internal error, already reported */
- if (tmp.str != NULL)
- {
+ if (tmp.str != NULL) {
ERROR("Unknown element %s encountered\n", tmp.str);
ACTION("Default for field %s ignored\n", field.str);
goto err_out;
@@ -606,66 +553,56 @@ HandleKeyNameVar(VarDef *stmt, struct xkb_keymap *keymap, KeyNamesInfo *info)
which = MIN_KEYCODE_DEF;
else if (strcasecmp(field.str, "maximum") == 0)
which = MAX_KEYCODE_DEF;
- else
- {
+ else {
ERROR("Unknown field encountered\n");
ACTION("Assigment to field %s ignored\n", field.str);
goto err_out;
}
- if (arrayNdx != NULL)
- {
+ if (arrayNdx != NULL) {
ERROR("The %s setting is not an array\n", field.str);
ACTION("Illegal array reference ignored\n");
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);
goto err_out;
}
- if (tmp.uval > XKB_KEYCODE_MAX)
- {
+ if (tmp.uval > XKB_KEYCODE_MAX) {
ERROR
("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);
goto err_out;
}
- if (which == MIN_KEYCODE_DEF)
- {
- if ((info->explicitMax > 0) && (info->explicitMax < tmp.uval))
- {
+ if (which == MIN_KEYCODE_DEF) {
+ if ((info->explicitMax > 0) && (info->explicitMax < tmp.uval)) {
ERROR
("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");
goto err_out;
}
- if ((info->computedMax > 0) && (info->computedMin < tmp.uval))
- {
+ if ((info->computedMax > 0) && (info->computedMin < tmp.uval)) {
ERROR
("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");
goto err_out;
}
info->explicitMin = tmp.uval;
}
- if (which == MAX_KEYCODE_DEF)
- {
- if ((info->explicitMin > 0) && (info->explicitMin > tmp.uval))
- {
+ if (which == MAX_KEYCODE_DEF) {
+ if ((info->explicitMin > 0) && (info->explicitMin > tmp.uval)) {
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");
goto err_out;
}
- if ((info->computedMax > 0) && (info->computedMax > tmp.uval))
- {
+ if ((info->computedMax > 0) && (info->computedMax > tmp.uval)) {
ERROR
("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");
goto err_out;
}
@@ -687,8 +624,7 @@ HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
IndicatorNameInfo ii;
ExprResult tmp;
- if ((def->ndx < 1) || (def->ndx > XkbNumIndicators))
- {
+ if ((def->ndx < 1) || (def->ndx > XkbNumIndicators)) {
info->errorCount++;
ERROR("Name specified for illegal indicator index %d\n", def->ndx);
ACTION("Ignored\n");
@@ -696,8 +632,7 @@ HandleIndicatorNameDef(IndicatorNameDef *def, struct xkb_keymap *keymap,
}
InitIndicatorNameInfo(&ii, info);
ii.ndx = def->ndx;
- if (!ExprResolveString(keymap->ctx, def->name, &tmp))
- {
+ if (!ExprResolveString(keymap->ctx, def->name, &tmp)) {
char buf[20];
snprintf(buf, sizeof(buf), "%d", def->ndx);
info->errorCount++;
@@ -735,8 +670,7 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
stmt = file->defs;
while (stmt)
{
- switch (stmt->stmtType)
- {
+ switch (stmt->stmtType) {
case StmtInclude: /* e.g. include "evdev+aliases(qwerty)" */
if (!HandleIncludeKeycodes((IncludeStmt *) stmt, keymap, info))
info->errorCount++;
@@ -763,19 +697,18 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
case StmtVModDef:
ERROR("Keycode files may define key and indicator names only\n");
ACTION("Ignoring definition of %s\n",
- ((stmt->stmtType ==
- StmtInterpDef) ? "a symbol interpretation" :
- "virtual modifiers"));
+ ((stmt->stmtType ==
+ StmtInterpDef) ? "a symbol interpretation" :
+ "virtual modifiers"));
info->errorCount++;
break;
default:
WSGO("Unexpected statement type %d in HandleKeycodesFile\n",
- stmt->stmtType);
+ stmt->stmtType);
break;
}
stmt = stmt->next;
- if (info->errorCount > 10)
- {
+ if (info->errorCount > 10) {
#ifdef NOISY
ERROR("Too many errors\n");
#endif
@@ -796,7 +729,8 @@ HandleKeycodesFile(XkbFile *file, struct xkb_keymap *keymap,
* @return true on success, false otherwise.
*/
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 */
@@ -827,7 +761,8 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
darray_item(keymap->names->keys, i).name);
if (info.name)
keymap->names->keycodes = strdup(info.name);
- } else {
+ }
+ else {
WSGO("Cannot create struct xkb_names in CompileKeycodes\n");
goto err_info;
}
@@ -839,7 +774,7 @@ CompileKeycodes(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
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]);
keymap->names->indicators[ii->ndx - 1] =
xkb_atom_strdup(keymap->ctx, ii->name);
diff --git a/src/xkbcomp/keycodes.h b/src/xkbcomp/keycodes.h
index ba30be2..1f2a9bf 100644
--- a/src/xkbcomp/keycodes.h
+++ b/src/xkbcomp/keycodes.h
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef KEYCODES_H
@@ -30,13 +30,14 @@
#include "xkbcomp-priv.h"
#define KeyNameToLong(n) ( \
- (((unsigned long)n[0]) << 24) | \
- (((unsigned long)n[1]) << 16) | \
- (((unsigned long)n[2]) << 8) | \
- (((unsigned long)n[3]) << 0))
+ (((unsigned long) n[0]) << 24) | \
+ (((unsigned long) n[1]) << 16) | \
+ (((unsigned long) n[2]) << 8) | \
+ (((unsigned long) n[3]) << 0))
extern const
-char *longText(unsigned long val);
+char *
+longText(unsigned long val);
extern void
LongToKeyName(unsigned long val, char *name_rtrn);
diff --git a/src/xkbcomp/keytypes.c b/src/xkbcomp/keytypes.c
index 9d8e7d9..51ef217 100644
--- a/src/xkbcomp/keytypes.c
+++ b/src/xkbcomp/keytypes.c
@@ -1,35 +1,34 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "xkbcomp-priv.h"
#include "parseutils.h"
#include "vmod.h"
-typedef struct _PreserveInfo
-{
+typedef struct _PreserveInfo {
CommonInfo defs;
short matchingMapIndex;
unsigned char indexMods;
@@ -38,14 +37,13 @@ typedef struct _PreserveInfo
unsigned short preVMods;
} PreserveInfo;
-#define _KT_Name (1<<0)
-#define _KT_Mask (1<<1)
-#define _KT_Map (1<<2)
-#define _KT_Preserve (1<<3)
-#define _KT_LevelNames (1<<4)
+#define _KT_Name (1 << 0)
+#define _KT_Mask (1 << 1)
+#define _KT_Map (1 << 2)
+#define _KT_Preserve (1 << 3)
+#define _KT_LevelNames (1 << 4)
-typedef struct _KeyTypeInfo
-{
+typedef struct _KeyTypeInfo {
CommonInfo defs;
xkb_atom_t name;
unsigned file_id;
@@ -58,8 +56,7 @@ typedef struct _KeyTypeInfo
darray(xkb_atom_t) lvlNames;
} KeyTypeInfo;
-typedef struct _KeyTypesInfo
-{
+typedef struct _KeyTypesInfo {
char *name;
int errorCount;
unsigned file_id;
@@ -124,20 +121,17 @@ InitKeyTypesInfo(KeyTypesInfo *info, struct xkb_keymap *keymap,
darray_init(info->dflt.lvlNames);
info->dflt.preserve = NULL;
InitVModInfo(&info->vmods, keymap);
- if (from != NULL)
- {
+ if (from != NULL) {
info->dflt = from->dflt;
darray_copy(info->dflt.entries, from->dflt.entries);
darray_copy(info->dflt.lvlNames, from->dflt.lvlNames);
- if (from->dflt.preserve)
- {
+ if (from->dflt.preserve) {
PreserveInfo *old, *new, *last;
last = NULL;
old = from->dflt.preserve;
- for (; old; old = (PreserveInfo *) old->defs.next)
- {
+ for (; old; old = (PreserveInfo *) old->defs.next) {
new = uTypedAlloc(PreserveInfo);
if (!new)
return;
@@ -158,8 +152,7 @@ FreeKeyTypeInfo(KeyTypeInfo * type)
{
darray_free(type->entries);
darray_free(type->lvlNames);
- if (type->preserve != NULL)
- {
+ if (type->preserve != NULL) {
ClearCommonInfo(&type->preserve->defs);
type->preserve = NULL;
}
@@ -170,11 +163,10 @@ FreeKeyTypesInfo(KeyTypesInfo * info)
{
free(info->name);
info->name = NULL;
- if (info->types)
- {
+ if (info->types) {
KeyTypeInfo *type;
- for (type = info->types; type; type = (KeyTypeInfo *) type->defs.next)
- {
+ for (type = info->types; type; type =
+ (KeyTypeInfo *) type->defs.next) {
FreeKeyTypeInfo(type);
}
info->types = ClearCommonInfo(&info->types->defs);
@@ -188,8 +180,7 @@ NextKeyType(KeyTypesInfo * info)
KeyTypeInfo *type;
type = uTypedAlloc(KeyTypeInfo);
- if (type != NULL)
- {
+ if (type != NULL) {
memset(type, 0, sizeof(KeyTypeInfo));
type->defs.file_id = info->file_id;
info->types = AddCommonInfo(&info->types->defs, &type->defs);
@@ -203,8 +194,7 @@ FindMatchingKeyType(KeyTypesInfo * info, KeyTypeInfo * new)
{
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)
return old;
}
@@ -224,30 +214,26 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
{
KeyTypeInfo *old;
- if (new->name == tok_ONE_LEVEL)
- {
+ if (new->name == tok_ONE_LEVEL) {
if (new->numLevels > 1)
return ReportTypeBadWidth("ONE_LEVEL", new->numLevels, 1);
info->stdPresent |= XkbOneLevelMask;
}
- else if (new->name == tok_TWO_LEVEL)
- {
+ else if (new->name == tok_TWO_LEVEL) {
if (new->numLevels > 2)
return ReportTypeBadWidth("TWO_LEVEL", new->numLevels, 2);
else if (new->numLevels < 2)
new->numLevels = 2;
info->stdPresent |= XkbTwoLevelMask;
}
- else if (new->name == tok_ALPHABETIC)
- {
+ else if (new->name == tok_ALPHABETIC) {
if (new->numLevels > 2)
return ReportTypeBadWidth("ALPHABETIC", new->numLevels, 2);
else if (new->numLevels < 2)
new->numLevels = 2;
info->stdPresent |= XkbAlphabeticMask;
}
- else if (new->name == tok_KEYPAD)
- {
+ else if (new->name == tok_KEYPAD) {
if (new->numLevels > 2)
return ReportTypeBadWidth("KEYPAD", 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);
- if (old != NULL)
- {
+ if (old != NULL) {
bool report;
if ((new->defs.merge == MERGE_REPLACE)
- || (new->defs.merge == MERGE_OVERRIDE))
- {
+ || (new->defs.merge == MERGE_OVERRIDE)) {
KeyTypeInfo *next = (KeyTypeInfo *) old->defs.next;
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",
xkb_atom_text(keymap->ctx, new->name));
ACTION("Earlier definition ignored\n");
@@ -278,9 +261,9 @@ AddKeyType(struct xkb_keymap *keymap, KeyTypesInfo *info, KeyTypeInfo *new)
old->defs.next = &next->defs;
return true;
}
- report = (old->defs.file_id == new->defs.file_id) && (warningLevel > 0);
- if (report)
- {
+ report = (old->defs.file_id == new->defs.file_id) &&
+ (warningLevel > 0);
+ if (report) {
WARN("Multiple definitions of the %s key type\n",
xkb_atom_text(keymap->ctx, new->name));
ACTION("Later definition ignored\n");
@@ -307,18 +290,15 @@ MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from,
{
KeyTypeInfo *type;
- if (from->errorCount > 0)
- {
+ if (from->errorCount > 0) {
into->errorCount += from->errorCount;
return;
}
- if (into->name == NULL)
- {
+ if (into->name == NULL) {
into->name = from->name;
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)
type->defs.merge = merge;
if (!AddKeyType(keymap, into, type))
@@ -329,7 +309,8 @@ MergeIncludedKeyTypes(KeyTypesInfo *into, KeyTypesInfo *from,
static void
HandleKeyTypesFile(XkbFile *file, struct xkb_keymap *keymap,
- enum merge_mode merge, KeyTypesInfo *info);
+ enum merge_mode merge,
+ KeyTypesInfo *info);
static bool
HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
@@ -341,49 +322,41 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
bool haveSelf;
haveSelf = false;
- if ((stmt->file == NULL) && (stmt->map == NULL))
- {
+ if ((stmt->file == NULL) && (stmt->map == NULL)) {
haveSelf = true;
included = *info;
memset(info, 0, sizeof(KeyTypesInfo));
}
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_TYPES, &rtrn,
- &newMerge))
- {
+ &newMerge)) {
InitKeyTypesInfo(&included, keymap, info, rtrn->id);
included.dflt.defs.merge = newMerge;
HandleKeyTypesFile(rtrn, keymap, newMerge, &included);
- if (stmt->stmt != NULL)
- {
+ if (stmt->stmt != NULL) {
free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
FreeXKBFile(rtrn);
}
- else
- {
+ else {
info->errorCount += 10;
return false;
}
- if ((stmt->next != NULL) && (included.errorCount < 1))
- {
+ if ((stmt->next != NULL) && (included.errorCount < 1)) {
IncludeStmt *next;
unsigned op;
KeyTypesInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next)
- {
- if ((next->file == NULL) && (next->map == NULL))
- {
+ for (next = stmt->next; next != NULL; next = next->next) {
+ if ((next->file == NULL) && (next->map == NULL)) {
haveSelf = true;
MergeIncludedKeyTypes(&included, info, next->merge, keymap);
FreeKeyTypesInfo(info);
}
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_TYPES,
- &rtrn, &op))
- {
+ &rtrn, &op)) {
InitKeyTypesInfo(&next_incl, keymap, &included, rtrn->id);
next_incl.dflt.defs.merge = op;
HandleKeyTypesFile(rtrn, keymap, op, &next_incl);
@@ -391,8 +364,7 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
FreeKeyTypesInfo(&next_incl);
FreeXKBFile(rtrn);
}
- else
- {
+ else {
info->errorCount += 10;
FreeKeyTypesInfo(&included);
return false;
@@ -401,8 +373,7 @@ HandleIncludeKeyTypes(IncludeStmt *stmt, struct xkb_keymap *keymap,
}
if (haveSelf)
*info = included;
- else
- {
+ else {
MergeIncludedKeyTypes(info, &included, newMerge, keymap);
FreeKeyTypesInfo(&included);
}
@@ -417,8 +388,8 @@ FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
struct xkb_kt_map_entry *entry;
darray_foreach(entry, type->entries)
- if (entry->mods.real_mods == mask && entry->mods.vmods == vmask)
- return entry;
+ if (entry->mods.real_mods == mask && entry->mods.vmods == vmask)
+ return entry;
return NULL;
}
@@ -434,7 +405,7 @@ DeleteLevel1MapEntries(KeyTypeInfo * type)
for (n = i; n < darray_size(type->entries) - 1; n++)
darray_item(type->entries, n) =
darray_item(type->entries, n + 1);
- (void)darray_pop(type->entries);
+ (void) darray_pop(type->entries);
}
}
}
@@ -456,27 +427,23 @@ AddPreserve(struct xkb_keymap *keymap, KeyTypeInfo *type,
while (old != NULL)
{
if ((old->indexMods != new->indexMods) ||
- (old->indexVMods != new->indexVMods))
- {
+ (old->indexVMods != new->indexVMods)) {
old = (PreserveInfo *) old->defs.next;
continue;
}
if ((old->preMods == new->preMods)
- && (old->preVMods == new->preVMods))
- {
- if (warningLevel > 9)
- {
+ && (old->preVMods == new->preVMods)) {
+ if (warningLevel > 9) {
WARN("Identical definitions for preserve[%s] in %s\n",
- PreserveIndexTxt(keymap, old), TypeTxt(keymap, type));
+ PreserveIndexTxt(keymap, old), TypeTxt(keymap, type));
ACTION("Ignored\n");
}
return true;
}
- if (report && (warningLevel > 0))
- {
+ if (report && (warningLevel > 0)) {
const char *str;
WARN("Multiple definitions for preserve[%s] in %s\n",
- PreserveIndexTxt(keymap, old), TypeTxt(keymap, type));
+ PreserveIndexTxt(keymap, old), TypeTxt(keymap, type));
if (clobber)
str = PreserveTxt(keymap, new);
@@ -489,16 +456,14 @@ AddPreserve(struct xkb_keymap *keymap, KeyTypeInfo *type,
str = PreserveTxt(keymap, new);
INFO("ignoring %s\n", str);
}
- if (clobber)
- {
+ if (clobber) {
old->preMods = new->preMods;
old->preVMods = new->preVMods;
}
return true;
}
old = uTypedAlloc(PreserveInfo);
- if (!old)
- {
+ if (!old) {
WSGO("Couldn't allocate preserve in %s\n", TypeTxt(keymap, type));
ACTION("Preserve[%s] lost\n", PreserveIndexTxt(keymap, new));
return false;
@@ -524,30 +489,26 @@ AddMapEntry(struct xkb_keymap *keymap, KeyTypeInfo *type,
struct xkb_kt_map_entry * old;
if ((old =
- FindMatchingMapEntry(type, new->mods.real_mods, new->mods.vmods)))
- {
- if (report && (old->level != new->level))
- {
+ FindMatchingMapEntry(type, new->mods.real_mods,
+ new->mods.vmods))) {
+ if (report && (old->level != new->level)) {
unsigned use, ignore;
- if (clobber)
- {
+ if (clobber) {
use = new->level + 1;
ignore = old->level + 1;
}
- else
- {
+ else {
use = old->level + 1;
ignore = new->level + 1;
}
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);
}
- else if (warningLevel > 9)
- {
+ else if (warningLevel > 9) {
WARN("Multiple occurences of map[%s]= %d in %s\n",
- MapEntryTxt(keymap, new), new->level + 1,
- TypeTxt(keymap, type));
+ MapEntryTxt(keymap, new), new->level + 1,
+ TypeTxt(keymap, type));
ACTION("Ignored\n");
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.vmods = (rtrn.uval >> 8) & 0xffff; /* modifiers > 512 */
if ((entry.mods.real_mods & (~type->mask)) ||
- ((entry.mods.vmods & (~type->vmask)) != 0))
- {
- if (warningLevel > 0)
- {
- WARN("Map entry for unused modifiers in %s\n", TypeTxt(keymap, type));
+ ((entry.mods.vmods & (~type->vmask)) != 0)) {
+ if (warningLevel > 0) {
+ WARN("Map entry for unused modifiers in %s\n",
+ TypeTxt(keymap, type));
ACTION("Using %s instead of ",
- XkbcVModMaskText(keymap,
+ XkbcVModMaskText(keymap,
entry.mods.real_mods & type->mask,
entry.mods.vmods & type->vmask));
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.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");
ACTION("Ignoring malformed level specification\n");
return false;
@@ -620,12 +579,11 @@ SetPreserve(KeyTypeInfo *type, struct xkb_keymap *keymap,
new.defs.next = NULL;
new.indexMods = rtrn.uval & 0xff;
new.indexVMods = (rtrn.uval >> 8) & 0xffff;
- if ((new.indexMods & (~type->mask)) || (new.indexVMods & (~type->vmask)))
- {
- if (warningLevel > 0)
- {
+ if ((new.indexMods & (~type->mask)) ||
+ (new.indexVMods & (~type->vmask))) {
+ if (warningLevel > 0) {
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));
}
new.indexMods &= type->mask;
@@ -633,28 +591,24 @@ SetPreserve(KeyTypeInfo *type, struct xkb_keymap *keymap,
if (warningLevel > 0)
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");
ACTION("Ignoring preserve[%s] in type %s\n",
- PreserveIndexTxt(keymap, &new), TypeTxt(keymap, type));
+ PreserveIndexTxt(keymap, &new), TypeTxt(keymap, type));
return false;
}
new.preMods = rtrn.uval & 0xff;
new.preVMods = (rtrn.uval >> 16) & 0xffff;
if ((new.preMods & (~new.indexMods))
- || (new.preVMods & (~new.indexVMods)))
- {
- if (warningLevel > 0)
- {
+ || (new.preVMods & (~new.indexVMods))) {
+ if (warningLevel > 0) {
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));
}
new.preMods &= new.indexMods;
new.preVMods &= new.indexVMods;
- if (warningLevel > 0)
- {
+ if (warningLevel > 0) {
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))
return ReportTypeBadType(keymap, type, "level name", "integer");
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,
- xkb_atom_text(keymap->ctx, type->name));
+ xkb_atom_text(keymap->ctx, type->name));
ACTION("Ignoring illegal level name definition\n");
return false;
}
@@ -739,27 +692,23 @@ SetKeyTypeField(KeyTypeInfo *type, struct xkb_keymap *keymap,
{
ExprResult tmp;
- if (strcasecmp(field, "modifiers") == 0)
- {
+ if (strcasecmp(field, "modifiers") == 0) {
unsigned mods, vmods;
- if (arrayNdx != NULL)
- {
+ if (arrayNdx != NULL) {
WARN("The modifiers field of a key type is not an array\n");
ACTION("Illegal array subscript ignored\n");
}
/* 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");
ACTION("Key type definition ignored\n");
return false;
}
mods = tmp.uval & 0xff; /* core 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",
- xkb_atom_text(keymap->ctx, type->name));
+ xkb_atom_text(keymap->ctx, type->name));
ACTION("Using %s, ", TypeMaskTxt(type, keymap));
INFO("ignoring %s\n", XkbcVModMaskText(keymap, mods, vmods));
return false;
@@ -769,19 +718,16 @@ SetKeyTypeField(KeyTypeInfo *type, struct xkb_keymap *keymap,
type->defs.defined |= _KT_Mask;
return true;
}
- else if (strcasecmp(field, "map") == 0)
- {
+ else if (strcasecmp(field, "map") == 0) {
type->defs.defined |= _KT_Map;
return SetMapEntry(type, keymap, arrayNdx, value);
}
- else if (strcasecmp(field, "preserve") == 0)
- {
+ else if (strcasecmp(field, "preserve") == 0) {
type->defs.defined |= _KT_Preserve;
return SetPreserve(type, keymap, arrayNdx, value);
}
else if ((strcasecmp(field, "levelname") == 0) ||
- (strcasecmp(field, "level_name") == 0))
- {
+ (strcasecmp(field, "level_name") == 0)) {
type->defs.defined |= _KT_LevelNames;
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))
return SetKeyTypeField(&info->dflt, keymap, field.str, arrayNdx,
stmt->value, info);
- if (elem.str != NULL)
- {
+ if (elem.str != NULL) {
ERROR("Default for unknown element %s\n", uStringText(elem.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",
- uStringText(field.str));
+ uStringText(field.str));
ACTION("Ignored\n");
}
return false;
@@ -823,10 +767,8 @@ HandleKeyTypeBody(VarDef *def, struct xkb_keymap *keymap,
ExprResult tmp, field;
ExprDef *arrayNdx;
- for (; def != NULL; def = (VarDef *) def->common.next)
- {
- if ((def->name) && (def->name->type == ExprFieldRef))
- {
+ for (; def != NULL; def = (VarDef *) def->common.next) {
+ if ((def->name) && (def->name->type == ExprFieldRef)) {
ok = HandleKeyTypeVar(def, keymap, info);
continue;
}
@@ -869,8 +811,7 @@ HandleKeyTypeDef(KeyTypeDef *def, struct xkb_keymap *keymap,
type.preserve = NULL;
/* Parse the actual content. */
- if (!HandleKeyTypeBody(def->body, keymap, &type, info))
- {
+ if (!HandleKeyTypeBody(def->body, keymap, &type, info)) {
info->errorCount++;
return false;
}
@@ -882,14 +823,12 @@ HandleKeyTypeDef(KeyTypeDef *def, struct xkb_keymap *keymap,
(entry->mods.vmods & type.vmask) == entry->mods.vmods)
AddMapEntry(keymap, &type, entry, false, false);
}
- if (info->dflt.preserve)
- {
+ if (info->dflt.preserve) {
PreserveInfo *dflt = info->dflt.preserve;
while (dflt)
{
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);
}
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++) {
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,
darray_item(info->dflt.lvlNames, i), false);
}
}
/* Now add the new keytype to the info struct */
- if (!AddKeyType(keymap, info, &type))
- {
+ if (!AddKeyType(keymap, info, &type)) {
info->errorCount++;
return false;
}
@@ -932,8 +869,7 @@ HandleKeyTypesFile(XkbFile *file, struct xkb_keymap *keymap,
stmt = file->defs;
while (stmt)
{
- switch (stmt->stmtType)
- {
+ switch (stmt->stmtType) {
case StmtInclude:
if (!HandleIncludeKeyTypes((IncludeStmt *) stmt, keymap, info))
info->errorCount++;
@@ -967,12 +903,11 @@ HandleKeyTypesFile(XkbFile *file, struct xkb_keymap *keymap,
break;
default:
WSGO("Unexpected statement type %d in HandleKeyTypesFile\n",
- stmt->stmtType);
+ stmt->stmtType);
break;
}
stmt = stmt->next;
- if (info->errorCount > 10)
- {
+ if (info->errorCount > 10) {
#ifdef NOISY
ERROR("Too many errors\n");
#endif
@@ -998,7 +933,8 @@ ComputeEffectiveMap(struct xkb_keymap *keymap, struct xkb_key_type *type)
if (tmp == 0)
continue;
}
- entry->mods.mask = (entry->mods.real_mods | tmp) & type->mods.mask;
+ entry->mods.mask =
+ (entry->mods.real_mods | tmp) & type->mods.mask;
}
}
else
@@ -1015,8 +951,7 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
PreserveInfo *pre;
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 tmp;
tmp.mods.real_mods = pre->indexMods;
@@ -1024,8 +959,7 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
tmp.level = 0;
AddMapEntry(keymap, def, &tmp, false, false);
match = FindMatchingMapEntry(def, pre->indexMods, pre->indexVMods);
- if (!match)
- {
+ if (!match) {
WSGO("Couldn't find matching entry for preserve\n");
ACTION("Aborting\n");
return false;
@@ -1036,20 +970,16 @@ CopyDefToKeyType(struct xkb_keymap *keymap, struct xkb_key_type *type,
type->mods.vmods = def->vmask;
type->num_levels = def->numLevels;
memcpy(&type->map, &def->entries, sizeof(def->entries));
- if (def->preserve)
- {
+ if (def->preserve) {
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");
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;
- for (; pre != NULL; pre = (PreserveInfo *) pre->defs.next)
- {
+ for (; pre != NULL; pre = (PreserveInfo *) pre->defs.next) {
int ndx = pre->matchingMapIndex;
type->preserve[ndx].mask = 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);
}
-static struct xkb_kt_map_entry map2Level[]= {
+static struct xkb_kt_map_entry map2Level[] = {
{
.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,
.mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
},
{
.level = LockMask,
- .mods = { .mask = 0, .vmods = LockMask, .real_mods = 0 }
+ .mods = { .mask = 0, .vmods = LockMask, .real_mods = 0 }
}
};
-static struct xkb_mods preAlpha[]= {
- { .mask = 0, .vmods = 0, .real_mods = 0 },
+static struct xkb_mods preAlpha[] = {
+ { .mask = 0, .vmods = 0, .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,
.mods = { .mask = 1, .vmods = ShiftMask, .real_mods = 0 }
@@ -1130,8 +1060,8 @@ static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
},
{
.mods = {
- .mask = ShiftMask|LockMask,
- .vmods = ShiftMask|LockMask,
+ .mask = ShiftMask | LockMask,
+ .vmods = ShiftMask | LockMask,
.real_mods = 0
},
.num_levels = 2,
@@ -1151,7 +1081,8 @@ static const struct xkb_key_type canonicalTypes[XkbNumRequiredTypes] = {
};
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;
const struct xkb_key_type *from;
@@ -1210,7 +1141,8 @@ InitCanonicalKeyTypes(struct xkb_keymap *keymap, unsigned which, int keypadVMod)
}
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;
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))
goto err_info;
- def = (KeyTypeInfo *)def->defs.next;
+ def = (KeyTypeInfo *) def->defs.next;
}
FreeKeyTypesInfo(&info);
diff --git a/src/xkbcomp/misc.c b/src/xkbcomp/misc.c
index 4e69dd1..bc65623 100644
--- a/src/xkbcomp/misc.c
+++ b/src/xkbcomp/misc.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "xkbcomp-priv.h"
@@ -54,16 +54,13 @@ ProcessIncludeFile(struct xkb_context *ctx,
XkbFile *rtrn, *mapToUse, *next;
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,
- XkbDirectoryForInclude(file_type));
+ XkbDirectoryForInclude(file_type));
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);
fclose(file);
return false;
@@ -71,41 +68,35 @@ ProcessIncludeFile(struct xkb_context *ctx,
fclose(file);
mapToUse = rtrn;
- if (stmt->map != NULL)
- {
+ if (stmt->map != NULL) {
while (mapToUse)
{
- next = (XkbFile *)mapToUse->common.next;
+ next = (XkbFile *) mapToUse->common.next;
mapToUse->common.next = NULL;
if (strcmp(mapToUse->name, stmt->map) == 0 &&
- mapToUse->type == file_type)
- {
- FreeXKBFile(next);
- break;
+ mapToUse->type == file_type) {
+ FreeXKBFile(next);
+ break;
}
- else
- {
+ else {
FreeXKBFile(mapToUse);
}
mapToUse = next;
}
- if (!mapToUse)
- {
+ if (!mapToUse) {
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;
}
}
- 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",
- stmt->file);
+ stmt->file);
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",
- XkbcFileTypeText(file_type), XkbcFileTypeText(mapToUse->type));
+ XkbcFileTypeText(file_type), XkbcFileTypeText(mapToUse->type));
ACTION("Include file \"%s\" ignored\n", stmt->file);
return false;
}
@@ -160,13 +151,10 @@ UseNewField(unsigned field,
bool useNew;
useNew = false;
- if (oldDefs->defined & field)
- {
- if (newDefs->defined & field)
- {
+ if (oldDefs->defined & field) {
+ if (newDefs->defined & field) {
if (((oldDefs->file_id == newDefs->file_id)
- && (warningLevel > 0)) || (warningLevel > 9))
- {
+ && (warningLevel > 0)) || (warningLevel > 9)) {
*pCollide |= field;
}
if (newDefs->merge != MERGE_AUGMENT)
@@ -181,11 +169,9 @@ UseNewField(unsigned field,
void *
ClearCommonInfo(CommonInfo * cmn)
{
- if (cmn != NULL)
- {
+ if (cmn != NULL) {
CommonInfo *this, *next;
- for (this = cmn; this != NULL; this = next)
- {
+ for (this = cmn; this != NULL; this = next) {
next = this->next;
free(this);
}
@@ -204,8 +190,7 @@ AddCommonInfo(CommonInfo * old, CommonInfo * new)
old = old->next;
}
new->next = NULL;
- if (old)
- {
+ if (old) {
old->next = new;
return first;
}
@@ -234,56 +219,44 @@ FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
{
unsigned n;
- if (start_from < keymap->min_key_code)
- {
+ if (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;
}
*kc_rtrn = 0; /* some callers rely on this */
- if (keymap && keymap->names && !darray_empty(keymap->names->keys))
- {
- for (n = start_from; n <= keymap->max_key_code; n++)
- {
+ if (keymap && keymap->names && !darray_empty(keymap->names->keys)) {
+ for (n = start_from; n <= keymap->max_key_code; n++) {
unsigned long tmp;
tmp = KeyNameToLong(darray_item(keymap->names->keys, n).name);
- if (tmp == name)
- {
+ if (tmp == name) {
*kc_rtrn = n;
return true;
}
}
- if (use_aliases)
- {
+ if (use_aliases) {
unsigned long new_name;
if (FindKeyNameForAlias(keymap, name, &new_name))
return FindNamedKey(keymap, new_name, kc_rtrn, false,
create, 0);
}
}
- if (create)
- {
- if ((!keymap->names) || darray_empty(keymap->names->keys))
- {
- if (XkbcAllocNames(keymap, XkbKeyNamesMask, 0) != Success)
- {
- if (warningLevel > 0)
- {
+ if (create) {
+ if ((!keymap->names) || darray_empty(keymap->names->keys)) {
+ if (XkbcAllocNames(keymap, XkbKeyNamesMask, 0) != Success) {
+ if (warningLevel > 0) {
WARN("Couldn't allocate key names in FindNamedKey\n");
ACTION("Key \"%s\" not automatically created\n",
- longText(name));
+ longText(name));
}
return false;
}
}
/* Find first unused keycode and store our key here */
- for (n = keymap->min_key_code; n <= keymap->max_key_code; n++)
- {
- if (darray_item(keymap->names->keys, n).name[0] == '\0')
- {
+ for (n = keymap->min_key_code; n <= keymap->max_key_code; n++) {
+ if (darray_item(keymap->names->keys, n).name[0] == '\0') {
char buf[XkbKeyNameLength + 1];
LongToKeyName(name, buf);
memcpy(darray_item(keymap->names->keys, n).name, buf,
diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c
index 1bccb7a..02833d2 100644
--- a/src/xkbcomp/parseutils.c
+++ b/src/xkbcomp/parseutils.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "parseutils.h"
@@ -38,8 +38,7 @@ AppendStmt(ParseCommon * to, ParseCommon * append)
{
to = to->next;
}
- if (to)
- {
+ if (to) {
to->next = append;
return start;
}
@@ -51,15 +50,13 @@ ExprCreate(unsigned op, unsigned type)
{
ExprDef *expr;
expr = uTypedAlloc(ExprDef);
- if (expr)
- {
+ if (expr) {
expr->common.stmtType = StmtExpr;
expr->common.next = NULL;
expr->op = op;
expr->type = type;
}
- else
- {
+ else {
FATAL("Couldn't allocate expression in parser\n");
/* NOTREACHED */
}
@@ -71,16 +68,14 @@ ExprCreateUnary(unsigned op, unsigned type, ExprDef * child)
{
ExprDef *expr;
expr = uTypedAlloc(ExprDef);
- if (expr)
- {
+ if (expr) {
expr->common.stmtType = StmtExpr;
expr->common.next = NULL;
expr->op = op;
expr->type = type;
expr->value.child = child;
}
- else
- {
+ else {
FATAL("Couldn't allocate expression in parser\n");
/* NOTREACHED */
}
@@ -92,8 +87,7 @@ ExprCreateBinary(unsigned op, ExprDef * left, ExprDef * right)
{
ExprDef *expr;
expr = uTypedAlloc(ExprDef);
- if (expr)
- {
+ if (expr) {
expr->common.stmtType = StmtExpr;
expr->common.next = NULL;
expr->op = op;
@@ -106,8 +100,7 @@ ExprCreateBinary(unsigned op, ExprDef * left, ExprDef * right)
expr->value.binary.left = left;
expr->value.binary.right = right;
}
- else
- {
+ else {
FATAL("Couldn't allocate expression in parser\n");
/* NOTREACHED */
}
@@ -120,16 +113,14 @@ KeycodeCreate(const char *name, unsigned long value)
KeycodeDef *def;
def = uTypedAlloc(KeycodeDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtKeycodeDef;
def->common.next = NULL;
strncpy(def->name, name, XkbKeyNameLength);
def->name[XkbKeyNameLength] = '\0';
def->value = value;
}
- else
- {
+ else {
FATAL("Couldn't allocate key name definition in parser\n");
/* NOTREACHED */
}
@@ -142,8 +133,7 @@ KeyAliasCreate(const char *alias, const char *real)
KeyAliasDef *def;
def = uTypedAlloc(KeyAliasDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtKeyAliasDef;
def->common.next = NULL;
strncpy(def->alias, alias, XkbKeyNameLength);
@@ -151,8 +141,7 @@ KeyAliasCreate(const char *alias, const char *real)
strncpy(def->real, real, XkbKeyNameLength);
def->real[XkbKeyNameLength] = '\0';
}
- else
- {
+ else {
FATAL("Couldn't allocate key alias definition in parser\n");
/* NOTREACHED */
}
@@ -164,15 +153,13 @@ VModCreate(xkb_atom_t name, ExprDef * value)
{
VModDef *def;
def = uTypedAlloc(VModDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtVModDef;
def->common.next = NULL;
def->name = name;
def->value = value;
}
- else
- {
+ else {
FATAL("Couldn't allocate variable definition in parser\n");
/* NOTREACHED */
}
@@ -184,15 +171,13 @@ VarCreate(ExprDef * name, ExprDef * value)
{
VarDef *def;
def = uTypedAlloc(VarDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtVarDef;
def->common.next = NULL;
def->name = name;
def->value = value;
}
- else
- {
+ else {
FATAL("Couldn't allocate variable definition in parser\n");
/* NOTREACHED */
}
@@ -217,15 +202,13 @@ InterpCreate(char *sym, ExprDef * match)
InterpDef *def;
def = uTypedAlloc(InterpDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtInterpDef;
def->common.next = NULL;
def->sym = sym;
def->match = match;
}
- else
- {
+ else {
FATAL("Couldn't allocate interp definition in parser\n");
/* NOTREACHED */
}
@@ -238,16 +221,14 @@ KeyTypeCreate(xkb_atom_t name, VarDef * body)
KeyTypeDef *def;
def = uTypedAlloc(KeyTypeDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtKeyTypeDef;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->name = name;
def->body = body;
}
- else
- {
+ else {
FATAL("Couldn't allocate key type definition in parser\n");
/* NOTREACHED */
}
@@ -260,8 +241,7 @@ SymbolsCreate(const char *keyName, ExprDef *symbols)
SymbolsDef *def;
def = uTypedAlloc(SymbolsDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtSymbolsDef;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
@@ -269,8 +249,7 @@ SymbolsCreate(const char *keyName, ExprDef *symbols)
strncpy(def->keyName, keyName, 4);
def->symbols = symbols;
}
- else
- {
+ else {
FATAL("Couldn't allocate symbols definition in parser\n");
/* NOTREACHED */
}
@@ -283,16 +262,14 @@ GroupCompatCreate(int group, ExprDef * val)
GroupCompatDef *def;
def = uTypedAlloc(GroupCompatDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtGroupCompatDef;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->group = group;
def->def = val;
}
- else
- {
+ else {
FATAL("Couldn't allocate group compat definition in parser\n");
/* NOTREACHED */
}
@@ -305,16 +282,14 @@ ModMapCreate(uint32_t modifier, ExprDef * keys)
ModMapDef *def;
def = uTypedAlloc(ModMapDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtModMapDef;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->modifier = modifier;
def->keys = keys;
}
- else
- {
+ else {
FATAL("Couldn't allocate mod mask definition in parser\n");
/* NOTREACHED */
}
@@ -327,16 +302,14 @@ IndicatorMapCreate(xkb_atom_t name, VarDef * body)
IndicatorMapDef *def;
def = uTypedAlloc(IndicatorMapDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtIndicatorMapDef;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
def->name = name;
def->body = body;
}
- else
- {
+ else {
FATAL("Couldn't allocate indicator map definition in parser\n");
/* NOTREACHED */
}
@@ -349,8 +322,7 @@ IndicatorNameCreate(int ndx, ExprDef * name, bool virtual)
IndicatorNameDef *def;
def = uTypedAlloc(IndicatorNameDef);
- if (def)
- {
+ if (def) {
def->common.stmtType = StmtIndicatorNameDef;
def->common.next = NULL;
def->merge = MERGE_DEFAULT;
@@ -358,8 +330,7 @@ IndicatorNameCreate(int ndx, ExprDef * name, bool virtual)
def->name = name;
def->virtual = virtual;
}
- else
- {
+ else {
FATAL("Couldn't allocate indicator index definition in parser\n");
/* NOTREACHED */
}
@@ -372,8 +343,7 @@ ActionCreate(xkb_atom_t name, ExprDef * args)
ExprDef *act;
act = uTypedAlloc(ExprDef);
- if (act)
- {
+ if (act) {
act->common.stmtType = StmtExpr;
act->common.next = NULL;
act->op = ExprActionDecl;
@@ -391,8 +361,7 @@ CreateKeysymList(char *sym)
ExprDef *def;
def = ExprCreate(ExprKeysymList, TypeSymbols);
- if (!def)
- {
+ if (!def) {
FATAL("Couldn't allocate expression for keysym list in parser\n");
return NULL;
}
@@ -457,20 +426,17 @@ LookupKeysym(const char *str, xkb_keysym_t *sym_rtrn)
xkb_keysym_t sym;
if ((!str) || (strcasecmp(str, "any") == 0) ||
- (strcasecmp(str, "nosymbol") == 0))
- {
+ (strcasecmp(str, "nosymbol") == 0)) {
*sym_rtrn = XKB_KEY_NoSymbol;
return 1;
}
else if ((strcasecmp(str, "none") == 0) ||
- (strcasecmp(str, "voidsymbol") == 0))
- {
+ (strcasecmp(str, "voidsymbol") == 0)) {
*sym_rtrn = XKB_KEY_VoidSymbol;
return 1;
}
sym = xkb_keysym_from_name(str);
- if (sym != XKB_KEY_NoSymbol)
- {
+ if (sym != XKB_KEY_NoSymbol) {
*sym_rtrn = sym;
return 1;
}
@@ -495,23 +461,19 @@ IncludeCreate(char *str, enum merge_mode merge)
stmt = uDupString(str);
while ((tmp) && (*tmp))
{
- if (XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data))
- {
- if ((file == NULL) && (map == NULL))
- {
+ if (XkbParseIncludeMap(&tmp, &file, &map, &nextop, &extra_data)) {
+ if ((file == NULL) && (map == NULL)) {
if (haveSelf)
goto BAIL;
haveSelf = true;
}
if (first == NULL)
first = incl = uTypedAlloc(IncludeStmt);
- else
- {
+ else {
incl->next = uTypedAlloc(IncludeStmt);
incl = incl->next;
}
- if (incl)
- {
+ if (incl) {
incl->common.stmtType = StmtInclude;
incl->common.next = NULL;
incl->merge = merge;
@@ -522,8 +484,7 @@ IncludeCreate(char *str, enum merge_mode merge)
incl->path = NULL;
incl->next = NULL;
}
- else
- {
+ else {
WSGO("Allocation failure in IncludeCreate\n");
ACTION("Using only part of the include\n");
break;
@@ -533,8 +494,7 @@ IncludeCreate(char *str, enum merge_mode merge)
else
merge = MERGE_OVERRIDE;
}
- else
- {
+ else {
goto BAIL;
}
}
@@ -559,21 +519,17 @@ CheckDefaultMap(XkbFile * maps, const char *fileName)
dflt = NULL;
for (tmp = maps, dflt = NULL; tmp != NULL;
- tmp = (XkbFile *) tmp->common.next)
- {
- if (tmp->flags & XkbLC_Default)
- {
+ tmp = (XkbFile *) tmp->common.next) {
+ if (tmp->flags & XkbLC_Default) {
if (dflt == NULL)
dflt = tmp;
- else
- {
- if (warningLevel > 2)
- {
+ else {
+ if (warningLevel > 2) {
WARN("Multiple default components in %s\n",
- (fileName ? fileName : "(unknown)"));
+ (fileName ? fileName : "(unknown)"));
ACTION("Using %s, ignoring %s\n",
- (dflt->name ? dflt->name : "(first)"),
- (tmp->name ? tmp->name : "(subsequent)"));
+ (dflt->name ? dflt->name : "(first)"),
+ (tmp->name ? tmp->name : "(subsequent)"));
}
tmp->flags &= (~XkbLC_Default);
}
@@ -598,9 +554,9 @@ EnsureSafeMapName(char *name)
if (!name)
return;
- while (*name!='\0') {
+ while (*name != '\0') {
if ((componentSpecLegal[(*name) / 8] & (1 << ((*name) % 8))) == 0)
- *name= '_';
+ *name = '_';
name++;
}
}
@@ -612,8 +568,7 @@ CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name,
XkbFile *file;
file = uTypedAlloc(XkbFile);
- if (file)
- {
+ if (file) {
EnsureSafeMapName(name);
memset(file, 0, sizeof(XkbFile));
file->type = type;
@@ -634,8 +589,7 @@ FreeExpr(ExprDef *expr)
if (!expr)
return;
- switch (expr->op)
- {
+ switch (expr->op) {
case ExprActionList:
case OpNegate:
case OpUnaryPlus:
@@ -643,6 +597,7 @@ FreeExpr(ExprDef *expr)
case OpInvert:
FreeStmt(&expr->value.child->common);
break;
+
case OpDivide:
case OpAdd:
case OpSubtract:
@@ -651,19 +606,23 @@ FreeExpr(ExprDef *expr)
FreeStmt(&expr->value.binary.left->common);
FreeStmt(&expr->value.binary.right->common);
break;
+
case ExprActionDecl:
FreeStmt(&expr->value.action.args->common);
break;
+
case ExprArrayRef:
FreeStmt(&expr->value.array.entry->common);
break;
+
case ExprKeysymList:
darray_foreach(sym, expr->value.list.syms)
- free(*sym);
+ free(*sym);
darray_free(expr->value.list.syms);
darray_free(expr->value.list.symsMapIndex);
darray_free(expr->value.list.symsNumEntries);
break;
+
default:
break;
}
@@ -700,10 +659,9 @@ FreeStmt(ParseCommon *stmt)
next = stmt->next;
u.any = stmt;
- switch (stmt->stmtType)
- {
+ switch (stmt->stmtType) {
case StmtInclude:
- FreeInclude((IncludeStmt *)stmt);
+ FreeInclude((IncludeStmt *) stmt);
/* stmt is already free'd here. */
stmt = NULL;
break;
@@ -756,13 +714,13 @@ FreeXKBFile(XkbFile *file)
while (file)
{
- next = (XkbFile *)file->common.next;
+ next = (XkbFile *) file->common.next;
- switch (file->type)
- {
+ switch (file->type) {
case FILE_TYPE_KEYMAP:
- FreeXKBFile((XkbFile *)file->defs);
+ FreeXKBFile((XkbFile *) file->defs);
break;
+
case FILE_TYPE_TYPES:
case FILE_TYPE_COMPAT:
case FILE_TYPE_SYMBOLS:
@@ -770,6 +728,7 @@ FreeXKBFile(XkbFile *file)
case FILE_TYPE_GEOMETRY:
FreeStmt(file->defs);
break;
+
default:
break;
}
diff --git a/src/xkbcomp/parseutils.h b/src/xkbcomp/parseutils.h
index 74de816..c767b71 100644
--- a/src/xkbcomp/parseutils.h
+++ b/src/xkbcomp/parseutils.h
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef PARSEUTILS_H
@@ -118,15 +118,17 @@ CheckDefaultMap(XkbFile *maps, const char *fileName);
extern XkbFile *
CreateXKBFile(struct xkb_context *ctx, enum xkb_file_type type, char *name,
- ParseCommon *defs, unsigned flags);
+ ParseCommon *defs,
+ unsigned flags);
extern bool
-XKBParseFile(struct xkb_context *ctx, FILE *file,
- const char *file_name, XkbFile **out);
+XKBParseFile(struct xkb_context *ctx, FILE *file, const char *file_name,
+ XkbFile **out);
extern bool
XKBParseString(struct xkb_context *context, const char *string,
- const char *file_name, XkbFile **out);
+ const char *file_name,
+ XkbFile **out);
extern void
FreeXKBFile(XkbFile *file);
diff --git a/src/xkbcomp/path.c b/src/xkbcomp/path.c
index f98961f..687fb2f 100644
--- a/src/xkbcomp/path.c
+++ b/src/xkbcomp/path.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include <errno.h>
@@ -62,63 +62,52 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
char *tmp, *str, *next;
str = *str_inout;
- if ((*str == '+') || (*str == '|'))
- {
+ if ((*str == '+') || (*str == '|')) {
*file_rtrn = *map_rtrn = NULL;
*nextop_rtrn = *str;
next = str + 1;
}
- else if (*str == '%')
- {
+ else if (*str == '%') {
*file_rtrn = *map_rtrn = NULL;
*nextop_rtrn = str[1];
next = str + 2;
}
- else
- {
+ else {
/* search for tokens inside the string */
next = strpbrk(str, "|+");
- if (next)
- {
+ if (next) {
/* set nextop_rtrn to \0, next to next character */
*nextop_rtrn = *next;
*next++ = '\0';
}
- else
- {
+ else {
*nextop_rtrn = '\0';
next = NULL;
}
/* search for :, store result in extra_data */
tmp = strchr(str, ':');
- if (tmp != NULL)
- {
+ if (tmp != NULL) {
*tmp++ = '\0';
*extra_data = uDupString(tmp);
}
- else
- {
+ else {
*extra_data = NULL;
}
tmp = strchr(str, '(');
- if (tmp == NULL)
- {
+ if (tmp == NULL) {
*file_rtrn = uDupString(str);
*map_rtrn = NULL;
}
- else if (str[0] == '(')
- {
+ else if (str[0] == '(') {
free(*extra_data);
return false;
}
- else
- {
+ else {
*tmp++ = '\0';
*file_rtrn = uDupString(str);
str = tmp;
tmp = strchr(str, ')');
- if ((tmp == NULL) || (tmp[1] != '\0'))
- {
+ if ((tmp == NULL) || (tmp[1] != '\0')) {
free(*file_rtrn);
free(*extra_data);
return false;
@@ -144,22 +133,28 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
const char *
XkbDirectoryForInclude(enum xkb_file_type type)
{
- switch (type)
- {
+ switch (type) {
case FILE_TYPE_KEYMAP:
return "keymap";
+
case FILE_TYPE_KEYCODES:
return "keycodes";
+
case FILE_TYPE_TYPES:
return "types";
+
case FILE_TYPE_SYMBOLS:
return "symbols";
+
case FILE_TYPE_COMPAT:
return "compat";
+
case FILE_TYPE_GEOMETRY:
return "geometry";
+
case FILE_TYPE_RULES:
return "rules";
+
default:
return "";
}
@@ -189,12 +184,10 @@ XkbFindFileInPath(struct xkb_context *ctx,
const char *typeDir;
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",
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",
xkb_context_include_path_get(ctx, i), typeDir, name);
ACTION("Ignored\n");
diff --git a/src/xkbcomp/path.h b/src/xkbcomp/path.h
index 3ffc882..916d355 100644
--- a/src/xkbcomp/path.h
+++ b/src/xkbcomp/path.h
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef XKBCOMP_PATH_H
@@ -33,13 +33,14 @@
bool
XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
- char *nextop_rtrn, char **extra_data);
+ char *nextop_rtrn,
+ char **extra_data);
const char *
XkbDirectoryForInclude(unsigned type);
FILE *
-XkbFindFileInPath(struct xkb_context *ctx,
- const char *name, unsigned type, char **pathRtrn);
+XkbFindFileInPath(struct xkb_context *ctx, const char *name, unsigned type,
+ char **pathRtrn);
#endif /* XKBCOMP_PATH_H */
diff --git a/src/xkbcomp/rules.c b/src/xkbcomp/rules.c
index 5cd4e31..7f7d90b 100644
--- a/src/xkbcomp/rules.c
+++ b/src/xkbcomp/rules.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1996 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include <stdio.h>
@@ -192,9 +192,9 @@ struct group {
enum rule_flag {
RULE_FLAG_PENDING_MATCH = (1L << 1),
- RULE_FLAG_OPTION = (1L << 2),
- RULE_FLAG_APPEND = (1L << 3),
- RULE_FLAG_NORMAL = (1L << 4),
+ RULE_FLAG_OPTION = (1L << 2),
+ RULE_FLAG_APPEND = (1L << 3),
+ RULE_FLAG_NORMAL = (1L << 4),
};
struct rule {
@@ -236,9 +236,11 @@ get_index(char *str, int *ndx)
if (consumed > 0) {
*ndx = num;
str += consumed;
- } else if (empty > 0) {
+ }
+ else if (empty > 0) {
*ndx = -1;
- } else {
+ }
+ else {
*ndx = 0;
}
@@ -299,10 +301,12 @@ match_mapping_line(darray_char *line, struct mapping *mapping)
if (ndx < 1 || ndx > XkbNumKbdGroups) {
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;
}
- } else {
+ }
+ else {
ndx = 0;
}
@@ -412,7 +416,8 @@ match_rule_line(darray_char *line, struct mapping *mapping,
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;
if (strcmp(tok, "=") == 0) {
@@ -488,15 +493,15 @@ match_line(darray_char *line, struct mapping *mapping,
static void
squeeze_spaces(char *p1)
{
- char *p2;
+ char *p2;
- for (p2 = p1; *p2; p2++) {
- *p1 = *p2;
- if (*p1 != ' ')
- p1++;
- }
+ for (p2 = p1; *p2; p2++) {
+ *p1 = *p2;
+ if (*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, ','))) {
*p++ = '\0';
mdefs->variant[i] = p;
- } else {
+ }
+ else {
break;
}
}
@@ -654,26 +660,26 @@ static bool
match_group_member(struct rules *rules, const char *group_name,
const char *name)
{
- int i;
- const char *word;
- struct group *iter, *group = NULL;
-
- darray_foreach(iter, rules->groups) {
- if (strcmp(iter->name, group_name) == 0) {
- group = iter;
- break;
- }
- }
-
- if (!group)
- return false;
-
- word = group->words;
- for (i = 0; i < group->number; i++, word += strlen(word) + 1)
- if (strcmp(word, name) == 0)
- return true;
-
- return false;
+ int i;
+ const char *word;
+ struct group *iter, *group = NULL;
+
+ darray_foreach(iter, rules->groups) {
+ if (strcmp(iter->name, group_name) == 0) {
+ group = iter;
+ break;
+ }
+ }
+
+ if (!group)
+ return false;
+
+ word = group->words;
+ for (i = 0; i < group->number; i++, word += strlen(word) + 1)
+ if (strcmp(word, name) == 0)
+ return true;
+
+ return false;
}
/* Match @needle out of @sep-seperated @haystack. */
@@ -733,7 +739,7 @@ apply_rule_if_matches(struct rules *rules, struct rule *rule,
else if (rule->layout[0] == '$') {
if (!match_group_member(rules, rule->layout,
mdefs->layout[rule->layout_num]))
- return 0;
+ return 0;
}
else if (strcmp(rule->layout,
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) {
pending = true;
- } else if (rule->variant[0] == '$') {
+ }
+ else if (rule->variant[0] == '$') {
if (!match_group_member(rules, rule->variant,
mdefs->variant[rule->variant_num]))
return 0;
@@ -760,7 +767,8 @@ apply_rule_if_matches(struct rules *rules, struct rule *rule,
if (pending) {
rule->flags |= RULE_FLAG_PENDING_MATCH;
- } else {
+ }
+ else {
/* Exact match, apply it now. */
apply_rule(rule, kccgst);
}
@@ -774,7 +782,7 @@ clear_partial_matches(struct rules *rules)
struct rule *rule;
darray_foreach(rule, rules->rules)
- rule->flags &= ~RULE_FLAG_PENDING_MATCH;
+ rule->flags &= ~RULE_FLAG_PENDING_MATCH;
}
static void
@@ -783,8 +791,8 @@ apply_partial_matches(struct rules *rules, struct xkb_component_names *kccgst)
struct rule *rule;
darray_foreach(rule, rules->rules)
- if (rule->flags & RULE_FLAG_PENDING_MATCH)
- apply_rule(rule, kccgst);
+ if (rule->flags & RULE_FLAG_PENDING_MATCH)
+ apply_rule(rule, kccgst);
}
static void
@@ -904,7 +912,8 @@ substitute_vars(char *name, struct multi_defs *mdefs)
if (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)
*outstr++ = pfx;
@@ -919,11 +928,11 @@ substitute_vars(char *name, struct multi_defs *mdefs)
str++;
}
else {
- *outstr++= *str++;
+ *outstr++ = *str++;
}
}
- *outstr++= '\0';
+ *outstr++ = '\0';
if (orig != name)
free(orig);
@@ -959,8 +968,8 @@ get_components(struct rules *rules, const struct xkb_rule_names *mlvo,
free_multi_defs(&mdefs);
- return
- kccgst->keycodes && kccgst->symbols && kccgst->types && kccgst->compat;
+ return kccgst->keycodes && kccgst->symbols && kccgst->types &&
+ kccgst->compat;
}
static struct rules *
@@ -988,7 +997,8 @@ load_rules(FILE *file)
if (tgroup.number) {
darray_append(rules->groups, tgroup);
memset(&tgroup, 0, sizeof(tgroup));
- } else {
+ }
+ else {
darray_append(rules->rules, trule);
memset(&trule, 0, sizeof(trule));
}
diff --git a/src/xkbcomp/rules.h b/src/xkbcomp/rules.h
index d2d655a..889f17a 100644
--- a/src/xkbcomp/rules.h
+++ b/src/xkbcomp/rules.h
@@ -1,28 +1,28 @@
/*
-Copyright 2009 Dan Nicholson
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the names of the authors or their
-institutions shall not be used in advertising or otherwise to promote the
-sale, use or other dealings in this Software without prior written
-authorization from the authors.
-*/
+ * Copyright 2009 Dan Nicholson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
#ifndef RULES_H
#define RULES_H
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index 1c7396c..543b0e0 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include <limits.h>
@@ -36,24 +36,23 @@
/***====================================================================***/
/* Needed to work with the typechecker. */
-typedef darray(xkb_keysym_t) darray_xkb_keysym_t;
-typedef darray(union xkb_action) darray_xkb_action;
-
-#define RepeatYes 1
-#define RepeatNo 0
-#define RepeatUndefined ~((unsigned)0)
-
-#define _Key_Syms (1<<0)
-#define _Key_Acts (1<<1)
-#define _Key_Repeat (1<<2)
-#define _Key_Behavior (1<<3)
-#define _Key_Type_Dflt (1<<4)
-#define _Key_Types (1<<5)
-#define _Key_GroupInfo (1<<6)
-#define _Key_VModMap (1<<7)
-
-typedef struct _KeyInfo
-{
+typedef darray (xkb_keysym_t) darray_xkb_keysym_t;
+typedef darray (union xkb_action) darray_xkb_action;
+
+#define RepeatYes 1
+#define RepeatNo 0
+#define RepeatUndefined ~((unsigned) 0)
+
+#define _Key_Syms (1 << 0)
+#define _Key_Acts (1 << 1)
+#define _Key_Repeat (1 << 2)
+#define _Key_Behavior (1 << 3)
+#define _Key_Type_Dflt (1 << 4)
+#define _Key_Types (1 << 5)
+#define _Key_GroupInfo (1 << 6)
+#define _Key_VModMap (1 << 7)
+
+typedef struct _KeyInfo {
CommonInfo defs;
unsigned long name; /* the 4 chars of the key name, as long */
unsigned char groupInfo;
@@ -102,8 +101,7 @@ InitKeyInfo(KeyInfo * info, unsigned file_id)
info->name = KeyNameToLong(dflt);
info->groupInfo = 0;
info->typesDefined = info->symsDefined = info->actsDefined = 0;
- for (i = 0; i < XkbNumKbdGroups; i++)
- {
+ for (i = 0; i < XkbNumKbdGroups; i++) {
info->numLevels[i] = 0;
info->types[i] = XKB_ATOM_NONE;
darray_init(info->syms[i]);
@@ -132,8 +130,7 @@ FreeKeyInfo(KeyInfo * info)
info->defs.next = NULL;
info->groupInfo = 0;
info->typesDefined = info->symsDefined = info->actsDefined = 0;
- for (i = 0; i < XkbNumKbdGroups; i++)
- {
+ for (i = 0; i < XkbNumKbdGroups; i++) {
info->numLevels[i] = 0;
info->types[i] = XKB_ATOM_NONE;
darray_free(info->syms[i]);
@@ -184,20 +181,17 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, bool clearOld)
/***====================================================================***/
-typedef struct _ModMapEntry
-{
+typedef struct _ModMapEntry {
CommonInfo defs;
bool haveSymbol;
int modifier;
- union
- {
+ union {
unsigned long keyName;
xkb_keysym_t keySym;
} u;
} ModMapEntry;
-typedef struct _SymbolsInfo
-{
+typedef struct _SymbolsInfo {
char *name; /* e.g. pc+us+inet(evdev) */
int errorCount;
unsigned file_id;
@@ -242,7 +236,7 @@ FreeSymbolsInfo(SymbolsInfo * info)
free(info->name);
darray_foreach(key, info->keys)
- FreeKeyInfo(key);
+ FreeKeyInfo(key);
darray_free(info->keys);
if (info->modMap)
ClearCommonInfo(&info->modMap->defs);
@@ -304,17 +298,15 @@ MergeKeyGroups(SymbolsInfo * info,
clobber = (from->defs.merge != MERGE_AUGMENT);
report = (warningLevel > 9) ||
- ((into->defs.file_id == from->defs.file_id) && (warningLevel > 0));
+ ((into->defs.file_id == from->defs.file_id) && (warningLevel > 0));
darray_init(resultSyms);
- if (into->numLevels[group] >= from->numLevels[group])
- {
+ if (into->numLevels[group] >= from->numLevels[group]) {
resultActs = into->acts[group];
resultWidth = into->numLevels[group];
}
- else
- {
+ else {
resultActs = from->acts[group];
resultWidth = from->numLevels[group];
darray_resize(into->symsMapIndex[group],
@@ -327,11 +319,9 @@ MergeKeyGroups(SymbolsInfo * info,
}
if (darray_empty(resultActs) && (!darray_empty(into->acts[group]) ||
- !darray_empty(from->acts[group])))
- {
+ !darray_empty(from->acts[group]))) {
darray_resize0(resultActs, resultWidth);
- for (i = 0; i < resultWidth; i++)
- {
+ for (i = 0; i < resultWidth; i++) {
union xkb_action *fromAct = NULL, *toAct = NULL;
if (!darray_empty(from->acts[group]))
@@ -341,36 +331,30 @@ MergeKeyGroups(SymbolsInfo * info,
toAct = &darray_item(into->acts[group], i);
if (((fromAct == NULL) || (fromAct->type == XkbSA_NoAction))
- && (toAct != NULL))
- {
+ && (toAct != NULL)) {
darray_item(resultActs, i) = *toAct;
}
else if (((toAct == NULL) || (toAct->type == XkbSA_NoAction))
- && (fromAct != NULL))
- {
+ && (fromAct != NULL)) {
darray_item(resultActs, i) = *fromAct;
}
- else
- {
+ else {
union xkb_action *use, *ignore;
- if (clobber)
- {
+ if (clobber) {
use = fromAct;
ignore = toAct;
}
- else
- {
+ else {
use = toAct;
ignore = fromAct;
}
- if (report)
- {
+ if (report) {
WARN
("Multiple actions for level %d/group %d on key %s\n",
- i + 1, group + 1, longText(into->name));
+ i + 1, group + 1, longText(into->name));
ACTION("Using %s, ignoring %s\n",
- XkbcActionTypeText(use->type),
- XkbcActionTypeText(ignore->type));
+ XkbcActionTypeText(use->type),
+ XkbcActionTypeText(ignore->type));
}
if (use)
darray_item(resultActs, i) = *use;
@@ -378,8 +362,7 @@ MergeKeyGroups(SymbolsInfo * info,
}
}
- for (i = 0; i < resultWidth; i++)
- {
+ for (i = 0; i < resultWidth; i++) {
unsigned int fromSize = 0;
unsigned toSize = 0;
@@ -391,18 +374,15 @@ MergeKeyGroups(SymbolsInfo * info,
i < into->numLevels[group])
toSize = darray_item(into->symsMapNumEntries[group], i);
- if (fromSize == 0)
- {
+ if (fromSize == 0) {
resultSize += toSize;
using |= TO;
}
- else if (toSize == 0 || clobber)
- {
+ else if (toSize == 0 || clobber) {
resultSize += fromSize;
using |= FROM;
}
- else
- {
+ else {
resultSize += toSize;
using |= TO;
}
@@ -411,8 +391,7 @@ MergeKeyGroups(SymbolsInfo * info,
if (resultSize == 0)
goto out;
- if (using == FROM)
- {
+ if (using == FROM) {
resultSyms = from->syms[group];
darray_free(into->symsMapNumEntries[group]);
darray_free(into->symsMapIndex[group]);
@@ -422,16 +401,14 @@ MergeKeyGroups(SymbolsInfo * info,
darray_init(from->symsMapIndex[group]);
goto out;
}
- else if (using == TO)
- {
+ else if (using == TO) {
resultSyms = into->syms[group];
goto out;
}
darray_resize0(resultSyms, resultSize);
- for (i = 0; i < resultWidth; i++)
- {
+ for (i = 0; i < resultWidth; i++) {
enum key_group_selector use = NONE;
unsigned int fromSize = 0;
unsigned int toSize = 0;
@@ -442,8 +419,7 @@ MergeKeyGroups(SymbolsInfo * info,
if (i < into->numLevels[group])
toSize = darray_item(into->symsMapNumEntries[group], i);
- if (fromSize == 0 && toSize == 0)
- {
+ if (fromSize == 0 && toSize == 0) {
darray_item(into->symsMapIndex[group], i) = -1;
darray_item(into->symsMapNumEntries[group], i) = 0;
continue;
@@ -456,8 +432,7 @@ MergeKeyGroups(SymbolsInfo * info,
else
use = TO;
- if (toSize && fromSize && report)
- {
+ if (toSize && fromSize && report) {
INFO("Multiple symbols for group %d, level %d on key %s\n",
group + 1, i + 1, longText(into->name));
ACTION("Using %s, ignoring %s\n",
@@ -465,22 +440,22 @@ MergeKeyGroups(SymbolsInfo * info,
(use == FROM ? "to" : "from"));
}
- if (use == FROM)
- {
+ if (use == FROM) {
memcpy(darray_mem(resultSyms, cur_idx),
darray_mem(from->syms[group],
darray_item(from->symsMapIndex[group], i)),
- darray_item(from->symsMapNumEntries[group], i) * sizeof(xkb_keysym_t));
+ darray_item(from->symsMapNumEntries[group],
+ i) * sizeof(xkb_keysym_t));
darray_item(into->symsMapIndex[group], i) = cur_idx;
darray_item(into->symsMapNumEntries[group], i) =
darray_item(from->symsMapNumEntries[group], i);
}
- else
- {
+ else {
memcpy(darray_mem(resultSyms, cur_idx),
darray_mem(into->syms[group],
darray_item(into->symsMapIndex[group], i)),
- darray_item(into->symsMapNumEntries[group], i) * sizeof(xkb_keysym_t));
+ darray_item(into->symsMapNumEntries[group],
+ i) * sizeof(xkb_keysym_t));
darray_item(into->symsMapIndex[group], i) = cur_idx;
}
cur_idx += darray_item(into->symsMapNumEntries[group], i);
@@ -519,12 +494,9 @@ MergeKeys(SymbolsInfo *info, struct xkb_keymap *keymap,
unsigned collide = 0;
bool report;
- if (from->defs.merge == MERGE_REPLACE)
- {
- for (i = 0; i < XkbNumKbdGroups; i++)
- {
- if (into->numLevels[i] != 0)
- {
+ if (from->defs.merge == MERGE_REPLACE) {
+ for (i = 0; i < XkbNumKbdGroups; i++) {
+ if (into->numLevels[i] != 0) {
darray_free(into->syms[i]);
darray_free(into->acts[i]);
}
@@ -536,12 +508,9 @@ MergeKeys(SymbolsInfo *info, struct xkb_keymap *keymap,
report = ((warningLevel > 9) ||
((into->defs.file_id == from->defs.file_id)
&& (warningLevel > 0)));
- for (i = 0; i < XkbNumKbdGroups; i++)
- {
- if (from->numLevels[i] > 0)
- {
- if (into->numLevels[i] == 0)
- {
+ for (i = 0; i < XkbNumKbdGroups; i++) {
+ if (from->numLevels[i] > 0) {
+ if (into->numLevels[i] == 0) {
into->numLevels[i] = from->numLevels[i];
into->syms[i] = from->syms[i];
into->symsMapIndex[i] = from->symsMapIndex[i];
@@ -559,10 +528,8 @@ MergeKeys(SymbolsInfo *info, struct xkb_keymap *keymap,
if (!darray_empty(into->acts[i]))
into->defs.defined |= _Key_Acts;
}
- else
- {
- if (report)
- {
+ else {
+ if (report) {
if (!darray_empty(into->syms[i]))
collide |= _Key_Syms;
if (!darray_empty(into->acts[i]))
@@ -571,68 +538,57 @@ MergeKeys(SymbolsInfo *info, struct xkb_keymap *keymap,
MergeKeyGroups(info, into, from, (unsigned) i);
}
}
- if (from->types[i] != XKB_ATOM_NONE)
- {
+ if (from->types[i] != XKB_ATOM_NONE) {
if ((into->types[i] != XKB_ATOM_NONE) && report &&
- (into->types[i] != from->types[i]))
- {
+ (into->types[i] != from->types[i])) {
xkb_atom_t use, ignore;
collide |= _Key_Types;
- if (from->defs.merge != MERGE_AUGMENT)
- {
+ if (from->defs.merge != MERGE_AUGMENT) {
use = from->types[i];
ignore = into->types[i];
}
- else
- {
+ else {
use = into->types[i];
ignore = from->types[i];
}
WARN
("Multiple definitions for group %d type of key %s\n",
- i, longText(into->name));
+ i, longText(into->name));
ACTION("Using %s, ignoring %s\n",
- xkb_atom_text(keymap->ctx, use),
- xkb_atom_text(keymap->ctx, ignore));
+ xkb_atom_text(keymap->ctx, use),
+ xkb_atom_text(keymap->ctx, ignore));
}
if ((from->defs.merge != MERGE_AUGMENT)
- || (into->types[i] == XKB_ATOM_NONE))
- {
+ || (into->types[i] == XKB_ATOM_NONE)) {
into->types[i] = from->types[i];
}
}
}
- if (UseNewField(_Key_Behavior, &into->defs, &from->defs, &collide))
- {
+ if (UseNewField(_Key_Behavior, &into->defs, &from->defs, &collide)) {
into->behavior = from->behavior;
into->defs.defined |= _Key_Behavior;
}
- if (UseNewField(_Key_VModMap, &into->defs, &from->defs, &collide))
- {
+ if (UseNewField(_Key_VModMap, &into->defs, &from->defs, &collide)) {
into->vmodmap = from->vmodmap;
into->defs.defined |= _Key_VModMap;
}
- if (UseNewField(_Key_Repeat, &into->defs, &from->defs, &collide))
- {
+ if (UseNewField(_Key_Repeat, &into->defs, &from->defs, &collide)) {
into->repeat = from->repeat;
into->defs.defined |= _Key_Repeat;
}
- if (UseNewField(_Key_Type_Dflt, &into->defs, &from->defs, &collide))
- {
+ if (UseNewField(_Key_Type_Dflt, &into->defs, &from->defs, &collide)) {
into->dfltType = from->dfltType;
into->defs.defined |= _Key_Type_Dflt;
}
- if (UseNewField(_Key_GroupInfo, &into->defs, &from->defs, &collide))
- {
+ if (UseNewField(_Key_GroupInfo, &into->defs, &from->defs, &collide)) {
into->groupInfo = from->groupInfo;
into->defs.defined |= _Key_GroupInfo;
}
- if (collide)
- {
+ if (collide) {
WARN("Symbol map for key %s redefined\n",
- longText(into->name));
+ longText(into->name));
ACTION("Using %s definition for conflicting fields\n",
- (from->defs.merge == MERGE_AUGMENT ? "first" : "last"));
+ (from->defs.merge == MERGE_AUGMENT ? "first" : "last"));
}
return true;
}
@@ -644,13 +600,13 @@ AddKeySymbols(SymbolsInfo *info, KeyInfo *key, struct xkb_keymap *keymap)
KeyInfo *iter, *new;
darray_foreach(iter, info->keys)
- if (iter->name == key->name)
- return MergeKeys(info, keymap, iter, key);
+ if (iter->name == key->name)
+ return MergeKeys(info, keymap, iter, key);
if (FindKeyNameForAlias(keymap, key->name, &real_name))
darray_foreach(iter, info->keys)
- if (iter->name == real_name)
- return MergeKeys(info, keymap, iter, key);
+ if (iter->name == real_name)
+ return MergeKeys(info, keymap, iter, key);
darray_resize0(info->keys, darray_size(info->keys) + 1);
new = &darray_item(info->keys, darray_size(info->keys) - 1);
@@ -664,66 +620,56 @@ AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
bool clobber;
clobber = (new->defs.merge != MERGE_AUGMENT);
- for (mm = info->modMap; mm != NULL; mm = (ModMapEntry *) mm->defs.next)
- {
+ for (mm = info->modMap; mm != NULL; mm = (ModMapEntry *) mm->defs.next) {
if (new->haveSymbol && mm->haveSymbol
- && (new->u.keySym == mm->u.keySym))
- {
+ && (new->u.keySym == mm->u.keySym)) {
unsigned use, ignore;
- if (mm->modifier != new->modifier)
- {
- if (clobber)
- {
+ if (mm->modifier != new->modifier) {
+ if (clobber) {
use = new->modifier;
ignore = mm->modifier;
}
- else
- {
+ else {
use = mm->modifier;
ignore = new->modifier;
}
ERROR
("%s added to symbol map for multiple modifiers\n",
- XkbcKeysymText(new->u.keySym));
+ XkbcKeysymText(new->u.keySym));
ACTION("Using %s, ignoring %s.\n",
- XkbcModIndexText(use),
- XkbcModIndexText(ignore));
+ XkbcModIndexText(use),
+ XkbcModIndexText(ignore));
mm->modifier = use;
}
return true;
}
if ((!new->haveSymbol) && (!mm->haveSymbol) &&
- (new->u.keyName == mm->u.keyName))
- {
+ (new->u.keyName == mm->u.keyName)) {
unsigned use, ignore;
- if (mm->modifier != new->modifier)
- {
- if (clobber)
- {
+ if (mm->modifier != new->modifier) {
+ if (clobber) {
use = new->modifier;
ignore = mm->modifier;
}
- else
- {
+ else {
use = mm->modifier;
ignore = new->modifier;
}
ERROR("Key %s added to map for multiple modifiers\n",
- longText(new->u.keyName));
+ longText(new->u.keyName));
ACTION("Using %s, ignoring %s.\n",
- XkbcModIndexText(use),
- XkbcModIndexText(ignore));
+ XkbcModIndexText(use),
+ XkbcModIndexText(ignore));
mm->modifier = use;
}
return true;
}
}
mm = uTypedAlloc(ModMapEntry);
- if (mm == NULL)
- {
+ if (mm == NULL) {
WSGO("Could not allocate modifier map entry\n");
ACTION("Modifier map for %s will be incomplete\n",
- XkbcModIndexText(new->modifier));
+ XkbcModIndexText(new->modifier));
return false;
}
*mm = *new;
@@ -741,20 +687,16 @@ MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
unsigned int i;
KeyInfo *key;
- if (from->errorCount > 0)
- {
+ if (from->errorCount > 0) {
into->errorCount += from->errorCount;
return;
}
- if (into->name == NULL)
- {
+ if (into->name == NULL) {
into->name = from->name;
from->name = NULL;
}
- for (i = 0; i < XkbNumKbdGroups; i++)
- {
- if (from->groupNames[i] != XKB_ATOM_NONE)
- {
+ for (i = 0; i < XkbNumKbdGroups; i++) {
+ if (from->groupNames[i] != XKB_ATOM_NONE) {
if ((merge != MERGE_AUGMENT) ||
(into->groupNames[i] == XKB_ATOM_NONE))
into->groupNames[i] = from->groupNames[i];
@@ -769,11 +711,9 @@ MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
into->errorCount++;
}
- if (from->modMap != NULL)
- {
+ if (from->modMap != NULL) {
ModMapEntry *mm, *next;
- for (mm = from->modMap; mm != NULL; mm = next)
- {
+ for (mm = from->modMap; mm != NULL; mm = next) {
if (merge != MERGE_DEFAULT)
mm->defs.merge = merge;
if (!AddModMapEntry(into, mm))
@@ -789,7 +729,8 @@ MergeIncludedSymbols(SymbolsInfo *into, SymbolsInfo *from,
static void
HandleSymbolsFile(XkbFile *file, struct xkb_keymap *keymap,
- enum merge_mode merge, SymbolsInfo *info);
+ enum merge_mode merge,
+ SymbolsInfo *info);
static bool
HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap,
@@ -801,64 +742,52 @@ HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap,
bool haveSelf;
haveSelf = false;
- if ((stmt->file == NULL) && (stmt->map == NULL))
- {
+ if ((stmt->file == NULL) && (stmt->map == NULL)) {
haveSelf = true;
included = *info;
memset(info, 0, sizeof(SymbolsInfo));
}
else if (ProcessIncludeFile(keymap->ctx, stmt, FILE_TYPE_SYMBOLS, &rtrn,
- &newMerge))
- {
+ &newMerge)) {
InitSymbolsInfo(&included, keymap, rtrn->id);
included.merge = included.dflt.defs.merge = MERGE_OVERRIDE;
- if (stmt->modifier)
- {
+ if (stmt->modifier) {
included.explicit_group = atoi(stmt->modifier) - 1;
}
- else
- {
+ else {
included.explicit_group = info->explicit_group;
}
HandleSymbolsFile(rtrn, keymap, MERGE_OVERRIDE, &included);
- if (stmt->stmt != NULL)
- {
+ if (stmt->stmt != NULL) {
free(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
FreeXKBFile(rtrn);
}
- else
- {
+ else {
info->errorCount += 10;
return false;
}
- if ((stmt->next != NULL) && (included.errorCount < 1))
- {
+ if ((stmt->next != NULL) && (included.errorCount < 1)) {
IncludeStmt *next;
unsigned op;
SymbolsInfo next_incl;
- for (next = stmt->next; next != NULL; next = next->next)
- {
- if ((next->file == NULL) && (next->map == NULL))
- {
+ for (next = stmt->next; next != NULL; next = next->next) {
+ if ((next->file == NULL) && (next->map == NULL)) {
haveSelf = true;
MergeIncludedSymbols(&included, info, next->merge, keymap);
FreeSymbolsInfo(info);
}
else if (ProcessIncludeFile(keymap->ctx, next, FILE_TYPE_SYMBOLS,
- &rtrn, &op))
- {
+ &rtrn, &op)) {
InitSymbolsInfo(&next_incl, keymap, rtrn->id);
next_incl.merge = next_incl.dflt.defs.merge = MERGE_OVERRIDE;
- if (next->modifier)
- {
+ if (next->modifier) {
next_incl.explicit_group = atoi(next->modifier) - 1;
}
- else
- {
+ else {
next_incl.explicit_group = info->explicit_group;
}
HandleSymbolsFile(rtrn, keymap, MERGE_OVERRIDE, &next_incl);
@@ -866,30 +795,27 @@ HandleIncludeSymbols(IncludeStmt *stmt, struct xkb_keymap *keymap,
FreeSymbolsInfo(&next_incl);
FreeXKBFile(rtrn);
}
- else
- {
+ else {
info->errorCount += 10;
FreeSymbolsInfo(&included);
return false;
}
}
}
- else if (stmt->next)
- {
+ else if (stmt->next) {
info->errorCount += included.errorCount;
}
if (haveSelf)
*info = included;
- else
- {
+ else {
MergeIncludedSymbols(info, &included, newMerge, keymap);
FreeSymbolsInfo(&included);
}
return (info->errorCount == 0);
}
-#define SYMBOLS 1
-#define ACTIONS 2
+#define SYMBOLS 1
+#define ACTIONS 2
static bool
GetGroupIndex(KeyInfo *key, struct xkb_keymap *keymap,
@@ -903,8 +829,7 @@ GetGroupIndex(KeyInfo *key, struct xkb_keymap *keymap,
else
name = "actions";
- if (arrayNdx == NULL)
- {
+ if (arrayNdx == NULL) {
int i;
unsigned defined;
if (what == SYMBOLS)
@@ -912,23 +837,20 @@ GetGroupIndex(KeyInfo *key, struct xkb_keymap *keymap,
else
defined = key->actsDefined;
- for (i = 0; i < XkbNumKbdGroups; i++)
- {
- if ((defined & (1 << i)) == 0)
- {
+ for (i = 0; i < XkbNumKbdGroups; i++) {
+ if ((defined & (1 << i)) == 0) {
*ndx_rtrn = i;
return true;
}
}
ERROR("Too many groups of %s for key %s (max %d)\n", name,
- longText(key->name), XkbNumKbdGroups + 1);
+ longText(key->name), XkbNumKbdGroups + 1);
ACTION("Ignoring %s defined for extra groups\n", name);
return false;
}
- if (!ExprResolveGroup(keymap->ctx, arrayNdx, &tmp))
- {
+ if (!ExprResolveGroup(keymap->ctx, arrayNdx, &tmp)) {
ERROR("Illegal group index for %s of key %s\n", name,
- longText(key->name));
+ longText(key->name));
ACTION("Definition with non-integer array index ignored\n");
return false;
}
@@ -946,30 +868,26 @@ AddSymbolsToKey(KeyInfo *key, struct xkb_keymap *keymap,
if (!GetGroupIndex(key, keymap, arrayNdx, SYMBOLS, &ndx))
return false;
- if (value == NULL)
- {
+ if (value == NULL) {
key->symsDefined |= (1 << ndx);
return true;
}
- if (value->op != ExprKeysymList)
- {
+ if (value->op != ExprKeysymList) {
ERROR("Expected a list of symbols, found %s\n", exprOpText(value->op));
ACTION("Ignoring symbols for group %d of %s\n", ndx + 1,
- longText(key->name));
+ longText(key->name));
return false;
}
- if (!darray_empty(key->syms[ndx]))
- {
+ if (!darray_empty(key->syms[ndx])) {
ERROR("Symbols for key %s, group %d already defined\n",
- longText(key->name), ndx + 1);
+ longText(key->name), ndx + 1);
ACTION("Ignoring duplicate definition\n");
return false;
}
nSyms = darray_size(value->value.list.syms);
nLevels = darray_size(value->value.list.symsMapIndex);
if ((key->numLevels[ndx] < nSyms || darray_empty(key->syms[ndx])) &&
- (!ResizeKeyGroup(key, ndx, nLevels, nSyms, false)))
- {
+ (!ResizeKeyGroup(key, ndx, nLevels, nSyms, false))) {
WSGO("Could not resize group %d of key %s to contain %d levels\n",
ndx + 1, longText(key->name), nSyms);
ACTION("Symbols lost\n");
@@ -987,24 +905,29 @@ AddSymbolsToKey(KeyInfo *key, struct xkb_keymap *keymap,
if (darray_item(key->symsMapIndex[ndx], i) + j >= nSyms)
abort();
if (!LookupKeysym(darray_item(value->value.list.syms,
- darray_item(value->value.list.symsMapIndex, i) + j),
+ darray_item(value->value.list.
+ symsMapIndex, i) + j),
&darray_item(key->syms[ndx],
- darray_item(key->symsMapIndex[ndx], i) + j))) {
- WARN("Could not resolve keysym %s for key %s, group %d (%s), level %d\n",
- darray_item(value->value.list.syms, i),
- longText(key->name),
- ndx + 1,
- xkb_atom_text(keymap->ctx, info->groupNames[ndx]), nSyms);
+ darray_item(key->symsMapIndex[ndx],
+ i) + j))) {
+ WARN(
+ "Could not resolve keysym %s for key %s, group %d (%s), level %d\n",
+ darray_item(value->value.list.syms, i),
+ longText(key->name),
+ ndx + 1,
+ xkb_atom_text(keymap->ctx, info->groupNames[ndx]), nSyms);
while (--j >= 0)
darray_item(key->syms[ndx],
- darray_item(key->symsMapIndex[ndx], i) + j) = XKB_KEY_NoSymbol;
+ darray_item(key->symsMapIndex[ndx],
+ i) + j) = XKB_KEY_NoSymbol;
darray_item(key->symsMapIndex[ndx], i) = -1;
darray_item(key->symsMapNumEntries[ndx], i) = 0;
break;
}
if (darray_item(key->symsMapNumEntries[ndx], i) == 1 &&
darray_item(key->syms[ndx],
- darray_item(key->symsMapIndex[ndx], i) + j) == XKB_KEY_NoSymbol) {
+ darray_item(key->symsMapIndex[ndx],
+ i) + j) == XKB_KEY_NoSymbol) {
darray_item(key->symsMapIndex[ndx], i) = -1;
darray_item(key->symsMapNumEntries[ndx], i) = 0;
}
@@ -1028,38 +951,32 @@ AddActionsToKey(KeyInfo *key, struct xkb_keymap *keymap, ExprDef *arrayNdx,
if (!GetGroupIndex(key, keymap, arrayNdx, ACTIONS, &ndx))
return false;
- if (value == NULL)
- {
+ if (value == NULL) {
key->actsDefined |= (1 << ndx);
return true;
}
- if (value->op != ExprActionList)
- {
+ if (value->op != ExprActionList) {
WSGO("Bad expression type (%d) for action list value\n", value->op);
ACTION("Ignoring actions for group %d of %s\n", ndx,
- longText(key->name));
+ longText(key->name));
return false;
}
- if (!darray_empty(key->acts[ndx]))
- {
+ if (!darray_empty(key->acts[ndx])) {
WSGO("Actions for key %s, group %d already defined\n",
- longText(key->name), ndx);
+ longText(key->name), ndx);
return false;
}
- for (nActs = 0, act = value->value.child; act != NULL; nActs++)
- {
+ for (nActs = 0, act = value->value.child; act != NULL; nActs++) {
act = (ExprDef *) act->common.next;
}
- if (nActs < 1)
- {
+ if (nActs < 1) {
WSGO("Action list but not actions in AddActionsToKey\n");
return false;
}
if ((key->numLevels[ndx] < nActs || darray_empty(key->acts[ndx])) &&
- !ResizeKeyGroup(key, ndx, nActs, nActs, true))
- {
+ !ResizeKeyGroup(key, ndx, nActs, nActs, true)) {
WSGO("Could not resize group %d of key %s\n", ndx,
- longText(key->name));
+ longText(key->name));
ACTION("Actions lost\n");
return false;
}
@@ -1067,12 +984,10 @@ AddActionsToKey(KeyInfo *key, struct xkb_keymap *keymap, ExprDef *arrayNdx,
toAct = (struct xkb_any_action *) darray_mem(key->acts[ndx], 0);
act = value->value.child;
- for (i = 0; i < nActs; i++, toAct++)
- {
- if (!HandleActionDef(act, keymap, toAct, info->action))
- {
+ for (i = 0; i < nActs; i++, toAct++) {
+ if (!HandleActionDef(act, keymap, toAct, info->action)) {
ERROR("Illegal action definition for %s\n",
- longText(key->name));
+ longText(key->name));
ACTION("Action for group %d/level %d ignored\n", ndx + 1, i + 1);
}
act = (ExprDef *) act->common.next;
@@ -1081,25 +996,25 @@ AddActionsToKey(KeyInfo *key, struct xkb_keymap *keymap, ExprDef *arrayNdx,
}
static const LookupEntry lockingEntries[] = {
- {"true", XkbKB_Lock},
- {"yes", XkbKB_Lock},
- {"on", XkbKB_Lock},
- {"false", XkbKB_Default},
- {"no", XkbKB_Default},
- {"off", XkbKB_Default},
- {"permanent", XkbKB_Lock | XkbKB_Permanent},
- {NULL, 0}
+ { "true", XkbKB_Lock },
+ { "yes", XkbKB_Lock },
+ { "on", XkbKB_Lock },
+ { "false", XkbKB_Default },
+ { "no", XkbKB_Default },
+ { "off", XkbKB_Default },
+ { "permanent", XkbKB_Lock | XkbKB_Permanent },
+ { NULL, 0 }
};
static const LookupEntry repeatEntries[] = {
- {"true", RepeatYes},
- {"yes", RepeatYes},
- {"on", RepeatYes},
- {"false", RepeatNo},
- {"no", RepeatNo},
- {"off", RepeatNo},
- {"default", RepeatUndefined},
- {NULL, 0}
+ { "true", RepeatYes },
+ { "yes", RepeatYes },
+ { "on", RepeatYes },
+ { "false", RepeatNo },
+ { "no", RepeatNo },
+ { "off", RepeatNo },
+ { "default", RepeatUndefined },
+ { NULL, 0 }
};
static bool
@@ -1109,30 +1024,25 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
bool ok = true;
ExprResult tmp;
- if (strcasecmp(field, "type") == 0)
- {
+ if (strcasecmp(field, "type") == 0) {
ExprResult ndx;
if ((!ExprResolveString(keymap->ctx, value, &tmp))
- && (warningLevel > 0))
- {
+ && (warningLevel > 0)) {
WARN("The type field of a key symbol map must be a string\n");
ACTION("Ignoring illegal type definition\n");
}
- if (arrayNdx == NULL)
- {
+ if (arrayNdx == NULL) {
key->dfltType = xkb_atom_intern(keymap->ctx, tmp.str);
key->defs.defined |= _Key_Type_Dflt;
}
- else if (!ExprResolveGroup(keymap->ctx, arrayNdx, &ndx))
- {
+ else if (!ExprResolveGroup(keymap->ctx, arrayNdx, &ndx)) {
ERROR("Illegal group index for type of key %s\n",
- longText(key->name));
+ longText(key->name));
ACTION("Definition with non-integer array index ignored\n");
free(tmp.str);
return false;
}
- else
- {
+ else {
key->types[ndx.uval - 1] = xkb_atom_intern(keymap->ctx, tmp.str);
key->typesDefined |= (1 << (ndx.uval - 1));
}
@@ -1144,26 +1054,22 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
return AddActionsToKey(key, keymap, arrayNdx, value, info);
else if ((strcasecmp(field, "vmods") == 0) ||
(strcasecmp(field, "virtualmods") == 0) ||
- (strcasecmp(field, "virtualmodifiers") == 0))
- {
+ (strcasecmp(field, "virtualmodifiers") == 0)) {
ok = ExprResolveVModMask(value, &tmp, keymap);
- if (ok)
- {
+ if (ok) {
key->vmodmap = (tmp.uval >> 8);
key->defs.defined |= _Key_VModMap;
}
- else
- {
+ else {
ERROR("Expected a virtual modifier mask, found %s\n",
- exprOpText(value->op));
+ exprOpText(value->op));
ACTION("Ignoring virtual modifiers definition for key %s\n",
- longText(key->name));
+ longText(key->name));
}
}
else if ((strcasecmp(field, "locking") == 0) ||
(strcasecmp(field, "lock") == 0) ||
- (strcasecmp(field, "locks") == 0))
- {
+ (strcasecmp(field, "locks") == 0)) {
ok = ExprResolveEnum(keymap->ctx, value, &tmp, lockingEntries);
if (ok)
key->behavior.type = tmp.uval;
@@ -1171,27 +1077,25 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
}
else if ((strcasecmp(field, "radiogroup") == 0) ||
(strcasecmp(field, "permanentradiogroup") == 0) ||
- (strcasecmp(field, "allownone") == 0))
- {
+ (strcasecmp(field, "allownone") == 0)) {
ERROR("Radio groups not supported\n");
- ACTION("Ignoring radio group specification for key %s\n", longText(key->name));
+ ACTION("Ignoring radio group specification for key %s\n",
+ longText(key->name));
return false;
}
else if (uStrCasePrefix("overlay", field) ||
- uStrCasePrefix("permanentoverlay", field))
- {
+ uStrCasePrefix("permanentoverlay", field)) {
ERROR("Overlays not supported\n");
- ACTION("Ignoring overlay specification for key %s\n", longText(key->name));
+ ACTION("Ignoring overlay specification for key %s\n",
+ longText(key->name));
}
else if ((strcasecmp(field, "repeating") == 0) ||
(strcasecmp(field, "repeats") == 0) ||
- (strcasecmp(field, "repeat") == 0))
- {
+ (strcasecmp(field, "repeat") == 0)) {
ok = ExprResolveEnum(keymap->ctx, value, &tmp, repeatEntries);
- if (!ok)
- {
+ if (!ok) {
ERROR("Illegal repeat setting for %s\n",
- longText(key->name));
+ longText(key->name));
ACTION("Non-boolean repeat setting ignored\n");
return false;
}
@@ -1199,13 +1103,11 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
key->defs.defined |= _Key_Repeat;
}
else if ((strcasecmp(field, "groupswrap") == 0) ||
- (strcasecmp(field, "wrapgroups") == 0))
- {
+ (strcasecmp(field, "wrapgroups") == 0)) {
ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
- if (!ok)
- {
+ if (!ok) {
ERROR("Illegal groupsWrap setting for %s\n",
- longText(key->name));
+ longText(key->name));
ACTION("Non-boolean value ignored\n");
return false;
}
@@ -1216,13 +1118,11 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
key->defs.defined |= _Key_GroupInfo;
}
else if ((strcasecmp(field, "groupsclamp") == 0) ||
- (strcasecmp(field, "clampgroups") == 0))
- {
+ (strcasecmp(field, "clampgroups") == 0)) {
ok = ExprResolveBoolean(keymap->ctx, value, &tmp);
- if (!ok)
- {
+ if (!ok) {
ERROR("Illegal groupsClamp setting for %s\n",
- longText(key->name));
+ longText(key->name));
ACTION("Non-boolean value ignored\n");
return false;
}
@@ -1233,12 +1133,10 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
key->defs.defined |= _Key_GroupInfo;
}
else if ((strcasecmp(field, "groupsredirect") == 0) ||
- (strcasecmp(field, "redirectgroups") == 0))
- {
- if (!ExprResolveGroup(keymap->ctx, value, &tmp))
- {
+ (strcasecmp(field, "redirectgroups") == 0)) {
+ if (!ExprResolveGroup(keymap->ctx, value, &tmp)) {
ERROR("Illegal group index for redirect of key %s\n",
- longText(key->name));
+ longText(key->name));
ACTION("Definition with non-integer group ignored\n");
return false;
}
@@ -1246,8 +1144,7 @@ SetSymbolsField(KeyInfo *key, struct xkb_keymap *keymap, char *field,
XkbSetGroupInfo(0, XkbRedirectIntoRange, tmp.uval - 1);
key->defs.defined |= _Key_GroupInfo;
}
- else
- {
+ else {
ERROR("Unknown field %s in a symbol interpretation\n", field);
ACTION("Definition ignored\n");
ok = false;
@@ -1261,20 +1158,17 @@ SetGroupName(SymbolsInfo *info, struct xkb_keymap *keymap, ExprDef *arrayNdx,
{
ExprResult tmp, name;
- if ((arrayNdx == NULL) && (warningLevel > 0))
- {
+ if ((arrayNdx == NULL) && (warningLevel > 0)) {
WARN("You must specify an index when specifying a group name\n");
ACTION("Group name definition without array subscript ignored\n");
return false;
}
- if (!ExprResolveGroup(keymap->ctx, arrayNdx, &tmp))
- {
+ if (!ExprResolveGroup(keymap->ctx, arrayNdx, &tmp)) {
ERROR("Illegal index in group name definition\n");
ACTION("Definition with non-integer array index ignored\n");
return false;
}
- if (!ExprResolveString(keymap->ctx, value, &name))
- {
+ if (!ExprResolveString(keymap->ctx, value, &name)) {
ERROR("Group name must be a string\n");
ACTION("Illegal name for group %d ignored\n", tmp.uval);
return false;
@@ -1295,43 +1189,38 @@ HandleSymbolsVar(VarDef *stmt, struct xkb_keymap *keymap, SymbolsInfo *info)
if (ExprResolveLhs(keymap, stmt->name, &elem, &field, &arrayNdx) == 0)
return 0; /* internal error, already reported */
- if (elem.str && (strcasecmp(elem.str, "key") == 0))
- {
+ if (elem.str && (strcasecmp(elem.str, "key") == 0)) {
ret = SetSymbolsField(&info->dflt, keymap, field.str, arrayNdx,
stmt->value, info);
}
else if ((elem.str == NULL) && ((strcasecmp(field.str, "name") == 0) ||
(strcasecmp(field.str, "groupname") ==
- 0)))
- {
+ 0))) {
ret = SetGroupName(info, keymap, arrayNdx, stmt->value);
}
else if ((elem.str == NULL)
&& ((strcasecmp(field.str, "groupswrap") == 0) ||
- (strcasecmp(field.str, "wrapgroups") == 0)))
- {
+ (strcasecmp(field.str, "wrapgroups") == 0))) {
ERROR("Global \"groupswrap\" not supported\n");
ACTION("Ignored\n");
ret = true;
}
else if ((elem.str == NULL)
&& ((strcasecmp(field.str, "groupsclamp") == 0) ||
- (strcasecmp(field.str, "clampgroups") == 0)))
- {
+ (strcasecmp(field.str, "clampgroups") == 0))) {
ERROR("Global \"groupsclamp\" not supported\n");
ACTION("Ignored\n");
ret = true;
}
else if ((elem.str == NULL)
&& ((strcasecmp(field.str, "groupsredirect") == 0) ||
- (strcasecmp(field.str, "redirectgroups") == 0)))
- {
+ (strcasecmp(field.str, "redirectgroups") == 0))) {
ERROR("Global \"groupsredirect\" not supported\n");
ACTION("Ignored\n");
ret = true;
}
- else if ((elem.str == NULL) && (strcasecmp(field.str, "allownone") == 0))
- {
+ else if ((elem.str == NULL) &&
+ (strcasecmp(field.str, "allownone") == 0)) {
ERROR("Radio groups not supported\n");
ACTION("Ignoring \"allownone\" specification\n");
ret = true;
@@ -1354,17 +1243,13 @@ HandleSymbolsBody(VarDef *def, struct xkb_keymap *keymap, KeyInfo *key,
ExprResult tmp, field;
ExprDef *arrayNdx;
- for (; def != NULL; def = (VarDef *) def->common.next)
- {
- if ((def->name) && (def->name->type == ExprFieldRef))
- {
+ for (; def != NULL; def = (VarDef *) def->common.next) {
+ if ((def->name) && (def->name->type == ExprFieldRef)) {
ok = HandleSymbolsVar(def, keymap, info);
continue;
}
- else
- {
- if (def->name == NULL)
- {
+ else {
+ if (def->name == NULL) {
if ((def->value == NULL)
|| (def->value->op == ExprKeysymList))
field.str = strdup("symbols");
@@ -1372,8 +1257,7 @@ HandleSymbolsBody(VarDef *def, struct xkb_keymap *keymap, KeyInfo *key,
field.str = strdup("actions");
arrayNdx = NULL;
}
- else
- {
+ else {
ok = ExprResolveLhs(keymap, def->name, &tmp, &field,
&arrayNdx);
}
@@ -1394,15 +1278,13 @@ SetExplicitGroup(SymbolsInfo *info, KeyInfo *key)
if (group == 0)
return true;
- if ((key->typesDefined | key->symsDefined | key->actsDefined) & ~1)
- {
+ if ((key->typesDefined | key->symsDefined | key->actsDefined) & ~1) {
int i;
WARN("For the map %s an explicit group specified\n", info->name);
WARN("but key %s has more than one group defined\n",
- longText(key->name));
+ longText(key->name));
ACTION("All groups except first one will be ignored\n");
- for (i = 1; i < XkbNumKbdGroups; i++)
- {
+ for (i = 1; i < XkbNumKbdGroups; i++) {
key->numLevels[i] = 0;
darray_free(key->syms[i]);
darray_free(key->acts[i]);
@@ -1436,20 +1318,17 @@ HandleSymbolsDef(SymbolsDef *stmt, struct xkb_keymap *keymap,
CopyKeyInfo(&info->dflt, &key, false);
key.defs.merge = stmt->merge;
key.name = KeyNameToLong(stmt->keyName);
- if (!HandleSymbolsBody((VarDef *) stmt->symbols, keymap, &key, info))
- {
+ if (!HandleSymbolsBody((VarDef *) stmt->symbols, keymap, &key, info)) {
info->errorCount++;
return false;
}
- if (!SetExplicitGroup(info, &key))
- {
+ if (!SetExplicitGroup(info, &key)) {
info->errorCount++;
return false;
}
- if (!AddKeySymbols(info, &key, keymap))
- {
+ if (!AddKeySymbols(info, &key, keymap)) {
info->errorCount++;
return false;
}
@@ -1464,32 +1343,27 @@ HandleModMapDef(ModMapDef *def, struct xkb_keymap *keymap, SymbolsInfo *info)
ExprResult rtrn;
bool ok;
- if (!LookupModIndex(keymap->ctx, NULL, def->modifier, TypeInt, &rtrn))
- {
+ if (!LookupModIndex(keymap->ctx, NULL, def->modifier, TypeInt, &rtrn)) {
ERROR("Illegal modifier map definition\n");
ACTION("Ignoring map for non-modifier \"%s\"\n",
- xkb_atom_text(keymap->ctx, def->modifier));
+ xkb_atom_text(keymap->ctx, def->modifier));
return false;
}
ok = true;
tmp.modifier = rtrn.uval;
- for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next)
- {
- if ((key->op == ExprValue) && (key->type == TypeKeyName))
- {
+ for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next) {
+ if ((key->op == ExprValue) && (key->type == TypeKeyName)) {
tmp.haveSymbol = false;
tmp.u.keyName = KeyNameToLong(key->value.keyName);
}
- else if (ExprResolveKeySym(keymap->ctx, key, &rtrn))
- {
+ else if (ExprResolveKeySym(keymap->ctx, key, &rtrn)) {
tmp.haveSymbol = true;
tmp.u.keySym = rtrn.uval;
}
- else
- {
+ else {
ERROR("Modmap entries may contain only key names or keysyms\n");
ACTION("Illegal definition for %s modifier ignored\n",
- XkbcModIndexText(tmp.modifier));
+ XkbcModIndexText(tmp.modifier));
continue;
}
@@ -1509,8 +1383,7 @@ HandleSymbolsFile(XkbFile *file, struct xkb_keymap *keymap,
stmt = file->defs;
while (stmt)
{
- switch (stmt->stmtType)
- {
+ switch (stmt->stmtType) {
case StmtInclude:
if (!HandleIncludeSymbols((IncludeStmt *) stmt, keymap, info))
info->errorCount++;
@@ -1543,12 +1416,11 @@ HandleSymbolsFile(XkbFile *file, struct xkb_keymap *keymap,
break;
default:
WSGO("Unexpected statement type %d in HandleSymbolsFile\n",
- stmt->stmtType);
+ stmt->stmtType);
break;
}
stmt = stmt->next;
- if (info->errorCount > 10)
- {
+ if (info->errorCount > 10) {
#ifdef NOISY
ERROR("Too many errors\n");
#endif
@@ -1576,13 +1448,10 @@ FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym,
xkb_keycode_t key;
unsigned int group, level, min_group = UINT_MAX, min_level = UINT_MAX;
- for (key = keymap->min_key_code; key <= keymap->max_key_code; key++)
- {
- for (group = 0; group < XkbKeyNumGroups(keymap, key); group++)
- {
+ for (key = keymap->min_key_code; key <= keymap->max_key_code; key++) {
+ for (group = 0; group < XkbKeyNumGroups(keymap, key); group++) {
for (level = 0; level < XkbKeyGroupWidth(keymap, key, group);
- level++)
- {
+ level++) {
if (XkbKeyNumSyms(keymap, key, group, level) != 1 ||
(XkbKeySymEntry(keymap, key, group, level))[0] != sym)
continue;
@@ -1597,7 +1466,8 @@ FindKeyForSymbol(struct xkb_keymap *keymap, xkb_keysym_t sym,
*kc_rtrn = key;
if (group == 0 && level == 0) {
return true;
- } else {
+ }
+ else {
min_group = group;
min_level = level;
}
@@ -1662,32 +1532,26 @@ FindAutomaticType(struct xkb_keymap *keymap, int width,
bool *autoType)
{
*autoType = false;
- if ((width == 1) || (width == 0))
- {
+ if ((width == 1) || (width == 0)) {
*typeNameRtrn = xkb_atom_intern(keymap->ctx, "ONE_LEVEL");
*autoType = true;
}
- else if (width == 2)
- {
+ else if (width == 2) {
if (syms && xkb_keysym_is_lower(syms[0]) &&
- xkb_keysym_is_upper(syms[1]))
- {
+ xkb_keysym_is_upper(syms[1])) {
*typeNameRtrn = xkb_atom_intern(keymap->ctx, "ALPHABETIC");
}
else if (syms && (xkb_keysym_is_keypad(syms[0]) ||
- xkb_keysym_is_keypad(syms[1])))
- {
+ xkb_keysym_is_keypad(syms[1]))) {
*typeNameRtrn = xkb_atom_intern(keymap->ctx, "KEYPAD");
*autoType = true;
}
- else
- {
+ else {
*typeNameRtrn = xkb_atom_intern(keymap->ctx, "TWO_LEVEL");
*autoType = true;
}
}
- else if (width <= 4)
- {
+ else if (width <= 4) {
if (syms && xkb_keysym_is_lower(syms[0]) &&
xkb_keysym_is_upper(syms[1]))
if (xkb_keysym_is_lower(syms[2]) && xkb_keysym_is_upper(syms[3]))
@@ -1719,8 +1583,7 @@ PrepareKeyDef(KeyInfo * key)
defined = key->symsDefined | key->actsDefined | key->typesDefined;
/* get highest group number */
- for (i = XkbNumKbdGroups - 1; i >= 0; i--)
- {
+ for (i = XkbNumKbdGroups - 1; i >= 0; i--) {
if (defined & (1 << i))
break;
}
@@ -1732,44 +1595,36 @@ PrepareKeyDef(KeyInfo * key)
/* If there are empty groups between non-empty ones fill them with data */
/* from the first group. */
/* We can make a wrong assumption here. But leaving gaps is worse. */
- for (i = lastGroup; i > 0; i--)
- {
+ for (i = lastGroup; i > 0; i--) {
if (defined & (1 << i))
continue;
width = key->numLevels[0];
- if (key->typesDefined & 1)
- {
- for (j = 0; j < width; j++)
- {
+ if (key->typesDefined & 1) {
+ for (j = 0; j < width; j++) {
key->types[i] = key->types[0];
}
key->typesDefined |= 1 << i;
}
- if ((key->actsDefined & 1) && !darray_empty(key->acts[0]))
- {
+ if ((key->actsDefined & 1) && !darray_empty(key->acts[0])) {
darray_copy(key->acts[i], key->acts[0]);
key->actsDefined |= 1 << i;
}
- if ((key->symsDefined & 1) && !darray_empty(key->syms[0]))
- {
+ if ((key->symsDefined & 1) && !darray_empty(key->syms[0])) {
darray_copy(key->syms[i], key->syms[0]);
darray_copy(key->symsMapIndex[i], key->symsMapIndex[0]);
darray_copy(key->symsMapNumEntries[i], key->symsMapNumEntries[0]);
key->symsDefined |= 1 << i;
}
- if (defined & 1)
- {
+ if (defined & 1) {
key->numLevels[i] = key->numLevels[0];
}
}
/* If all groups are completely identical remove them all */
/* exept the first one. */
identical = true;
- for (i = lastGroup; i > 0; i--)
- {
+ for (i = lastGroup; i > 0; i--) {
if ((key->numLevels[i] != key->numLevels[0]) ||
- (key->types[i] != key->types[0]))
- {
+ (key->types[i] != key->types[0])) {
identical = false;
break;
}
@@ -1778,8 +1633,7 @@ PrepareKeyDef(KeyInfo * key)
darray_size(key->syms[i]) != darray_size(key->syms[0]) ||
memcmp(darray_mem(key->syms[i], 0),
darray_mem(key->syms[0], 0),
- sizeof(xkb_keysym_t) * darray_size(key->syms[0]))))
- {
+ sizeof(xkb_keysym_t) * darray_size(key->syms[0])))) {
identical = false;
break;
}
@@ -1788,18 +1642,17 @@ PrepareKeyDef(KeyInfo * key)
darray_empty(key->symsMapIndex[0]) ||
memcmp(darray_mem(key->symsMapIndex[i], 0),
darray_mem(key->symsMapIndex[0], 0),
- key->numLevels[0] * sizeof(int))))
- {
+ key->numLevels[0] * sizeof(int)))) {
identical = false;
continue;
}
- if (!darray_same(key->symsMapNumEntries[i], key->symsMapNumEntries[0]) &&
+ if (!darray_same(key->symsMapNumEntries[i],
+ key->symsMapNumEntries[0]) &&
(darray_empty(key->symsMapNumEntries[i]) ||
darray_empty(key->symsMapNumEntries[0]) ||
memcmp(darray_mem(key->symsMapNumEntries[i], 0),
darray_mem(key->symsMapNumEntries[0], 0),
- key->numLevels[0] * sizeof(size_t))))
- {
+ key->numLevels[0] * sizeof(size_t)))) {
identical = false;
continue;
}
@@ -1807,16 +1660,13 @@ PrepareKeyDef(KeyInfo * key)
(darray_empty(key->acts[i]) || darray_empty(key->acts[0]) ||
memcmp(darray_mem(key->acts[i], 0),
darray_mem(key->acts[0], 0),
- key->numLevels[0] * sizeof(union xkb_action))))
- {
+ key->numLevels[0] * sizeof(union xkb_action)))) {
identical = false;
break;
}
}
- if (identical)
- {
- for (i = lastGroup; i > 0; i--)
- {
+ if (identical) {
+ for (i = lastGroup; i > 0; i--) {
key->numLevels[i] = 0;
darray_free(key->syms[i]);
darray_free(key->symsMapIndex[i]);
@@ -1853,10 +1703,8 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
/* get the keycode for the key. */
if (!FindNamedKey(keymap, key->name, &kc, useAlias,
- CreateKeyNames(keymap), start_from))
- {
- if ((start_from == 0) && (warningLevel >= 5))
- {
+ CreateKeyNames(keymap), start_from)) {
+ if ((start_from == 0) && (warningLevel >= 5)) {
WARN("Key %s not found in keycodes\n", longText(key->name));
ACTION("Symbols ignored\n");
}
@@ -1864,8 +1712,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
}
haveActions = false;
- for (i = width = nGroups = 0; i < XkbNumKbdGroups; i++)
- {
+ for (i = width = nGroups = 0; i < XkbNumKbdGroups; i++) {
if (((i + 1) > nGroups)
&& (((key->symsDefined | key->actsDefined) & (1 << i))
|| (key->typesDefined) & (1 << i)))
@@ -1874,49 +1721,39 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
haveActions = true;
autoType = false;
/* Assign the type to the key, if it is missing. */
- if (key->types[i] == XKB_ATOM_NONE)
- {
+ if (key->types[i] == XKB_ATOM_NONE) {
if (key->dfltType != XKB_ATOM_NONE)
key->types[i] = key->dfltType;
else if (FindAutomaticType(keymap, key->numLevels[i],
darray_mem(key->syms[i], 0),
- &key->types[i], &autoType))
- {
- }
- else
- {
- if (warningLevel >= 5)
- {
+ &key->types[i], &autoType)) { }
+ else {
+ if (warningLevel >= 5) {
WARN("No automatic type for %d symbols\n",
- (unsigned int) key->numLevels[i]);
+ (unsigned int) key->numLevels[i]);
ACTION("Using %s for the %s key (keycode %d)\n",
- xkb_atom_text(keymap->ctx, key->types[i]),
- longText(key->name), kc);
+ xkb_atom_text(keymap->ctx, key->types[i]),
+ longText(key->name), kc);
}
}
}
- if (FindNamedType(keymap, key->types[i], &types[i]))
- {
+ if (FindNamedType(keymap, key->types[i], &types[i])) {
if (!autoType || key->numLevels[i] > 2)
keymap->server->explicit[kc] |= (1 << i);
}
- else
- {
- if (warningLevel >= 3)
- {
+ else {
+ if (warningLevel >= 3) {
WARN("Type \"%s\" is not defined\n",
- xkb_atom_text(keymap->ctx, key->types[i]));
+ xkb_atom_text(keymap->ctx, key->types[i]));
ACTION("Using TWO_LEVEL for the %s key (keycode %d)\n",
- longText(key->name), kc);
+ longText(key->name), kc);
}
types[i] = XkbTwoLevelIndex;
}
/* if the type specifies fewer levels than the key has, shrink the key */
type = &darray_item(keymap->map->types, types[i]);
- if (type->num_levels < key->numLevels[i])
- {
- if (warningLevel > 0)
- {
+ if (type->num_levels < key->numLevels[i]) {
+ if (warningLevel > 0) {
WARN("Type \"%s\" has %d levels, but %s has %d symbols\n",
type->name, type->num_levels,
xkb_atom_text(keymap->ctx, key->name), key->numLevels[i]);
@@ -1931,19 +1768,16 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
sizeSyms += darray_size(key->syms[i]);
}
- if (!XkbcResizeKeySyms(keymap, kc, sizeSyms))
- {
+ if (!XkbcResizeKeySyms(keymap, kc, sizeSyms)) {
WSGO("Could not enlarge symbols for %s (keycode %d)\n",
- longText(key->name), kc);
+ longText(key->name), kc);
return false;
}
- if (haveActions)
- {
+ if (haveActions) {
outActs = XkbcResizeKeyActions(keymap, kc, width * nGroups);
- if (outActs == NULL)
- {
+ if (outActs == NULL) {
WSGO("Could not enlarge actions for %s (key %d)\n",
- longText(key->name), kc);
+ longText(key->name), kc);
return false;
}
keymap->server->explicit[kc] |= XkbExplicitInterpretMask;
@@ -1963,8 +1797,7 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
sym_map->sym_index = uTypedCalloc(nGroups * width, int);
sym_map->num_syms = uTypedCalloc(nGroups * width, unsigned int);
- for (i = 0; i < nGroups; i++)
- {
+ for (i = 0; i < nGroups; i++) {
/* assign kt_index[i] to the index of the type in map->types.
* kt_index[i] may have been set by a previous run (if we have two
* layouts specified). Let's not overwrite it with the ONE_LEVEL
@@ -1974,30 +1807,26 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
*/
if (key->numLevels[i])
sym_map->kt_index[i] = types[i];
- if (!darray_empty(key->syms[i]))
- {
+ if (!darray_empty(key->syms[i])) {
/* fill key to "width" symbols*/
- for (tmp = 0; tmp < width; tmp++)
- {
+ for (tmp = 0; tmp < width; tmp++) {
if (tmp < key->numLevels[i] &&
- darray_item(key->symsMapNumEntries[i], tmp) != 0)
- {
+ darray_item(key->symsMapNumEntries[i], tmp) != 0) {
memcpy(darray_mem(sym_map->syms, symIndex),
darray_mem(key->syms[i],
darray_item(key->symsMapIndex[i], tmp)),
- darray_item(key->symsMapNumEntries[i], tmp) * sizeof(xkb_keysym_t));
+ darray_item(key->symsMapNumEntries[i],
+ tmp) * sizeof(xkb_keysym_t));
sym_map->sym_index[(i * width) + tmp] = symIndex;
sym_map->num_syms[(i * width) + tmp] =
darray_item(key->symsMapNumEntries[i], tmp);
symIndex += sym_map->num_syms[(i * width) + tmp];
}
- else
- {
+ else {
sym_map->sym_index[(i * width) + tmp] = -1;
sym_map->num_syms[(i * width) + tmp] = 0;
}
- if (outActs != NULL && !darray_empty(key->acts[i]))
- {
+ if (outActs != NULL && !darray_empty(key->acts[i])) {
if (tmp < key->numLevels[i])
outActs[tmp] = darray_item(key->acts[i], tmp);
else
@@ -2006,22 +1835,20 @@ CopySymbolsDef(struct xkb_keymap *keymap, KeyInfo *key, int start_from)
}
}
}
- switch (key->behavior.type & XkbKB_OpMask)
- {
+ switch (key->behavior.type & XkbKB_OpMask) {
case XkbKB_Default:
break;
+
default:
keymap->server->behaviors[kc] = key->behavior;
keymap->server->explicit[kc] |= XkbExplicitBehaviorMask;
break;
}
- if (key->defs.defined & _Key_VModMap)
- {
+ if (key->defs.defined & _Key_VModMap) {
keymap->server->vmodmap[kc] = key->vmodmap;
keymap->server->explicit[kc] |= XkbExplicitVModMapMask;
}
- if (key->repeat != RepeatUndefined)
- {
+ if (key->repeat != RepeatUndefined) {
if (key->repeat == RepeatYes)
keymap->ctrls->per_key_repeat[kc / 8] |= (1 << (kc % 8));
else
@@ -2041,26 +1868,22 @@ CopyModMapDef(struct xkb_keymap *keymap, ModMapEntry *entry)
if (!entry->haveSymbol &&
!FindNamedKey(keymap, entry->u.keyName, &kc, true,
- CreateKeyNames(keymap), 0))
- {
- if (warningLevel >= 5)
- {
+ CreateKeyNames(keymap), 0)) {
+ if (warningLevel >= 5) {
WARN("Key %s not found in keycodes\n",
- longText(entry->u.keyName));
+ longText(entry->u.keyName));
ACTION("Modifier map entry for %s not updated\n",
- XkbcModIndexText(entry->modifier));
+ XkbcModIndexText(entry->modifier));
}
return false;
}
else if (entry->haveSymbol &&
- !FindKeyForSymbol(keymap, entry->u.keySym, &kc))
- {
- if (warningLevel > 5)
- {
+ !FindKeyForSymbol(keymap, entry->u.keySym, &kc)) {
+ if (warningLevel > 5) {
WARN("Key \"%s\" not found in symbol map\n",
- XkbcKeysymText(entry->u.keySym));
+ XkbcKeysymText(entry->u.keySym));
ACTION("Modifier map entry for %s not updated\n",
- XkbcModIndexText(entry->modifier));
+ XkbcModIndexText(entry->modifier));
}
return false;
}
@@ -2076,7 +1899,8 @@ CopyModMapDef(struct xkb_keymap *keymap, ModMapEntry *entry)
* @param merge Merge strategy (e.g. MERGE_OVERRIDE).
*/
bool
-CompileSymbols(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
+CompileSymbols(XkbFile *file, struct xkb_keymap *keymap,
+ enum merge_mode merge)
{
unsigned int i;
SymbolsInfo info;
@@ -2135,12 +1959,12 @@ CompileSymbols(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
/* sanitize keys */
darray_foreach(key, info.keys)
- PrepareKeyDef(key);
+ PrepareKeyDef(key);
/* copy! */
darray_foreach(key, info.keys)
- if (!CopySymbolsDef(keymap, key, 0))
- info.errorCount++;
+ if (!CopySymbolsDef(keymap, key, 0))
+ info.errorCount++;
if (warningLevel > 3) {
for (i = keymap->min_key_code; i <= keymap->max_key_code; i++) {
diff --git a/src/xkbcomp/vmod.c b/src/xkbcomp/vmod.c
index ae5867c..2a90603 100644
--- a/src/xkbcomp/vmod.c
+++ b/src/xkbcomp/vmod.c
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#include "vmod.h"
@@ -47,11 +47,9 @@ ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
return;
info->keymap = keymap;
- if (keymap && keymap->names)
- {
+ if (keymap && keymap->names) {
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)
info->defined |= bit;
}
@@ -69,7 +67,8 @@ ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap)
* @param mergeMode Merge strategy (e.g. MERGE_OVERRIDE)
*/
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)
{
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_names *names = keymap->names;
- for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<= 1)
- {
- if (info->defined & bit)
- {
+ for (i = 0, bit = 1, nextFree = -1; i < XkbNumVirtualMods; i++, bit <<=
+ 1) {
+ if (info->defined & bit) {
if (names->vmods[i] &&
strcmp(names->vmods[i],
- xkb_atom_text(keymap->ctx, stmt->name)) == 0)
- { /* already defined */
+ xkb_atom_text(keymap->ctx, stmt->name)) == 0) { /* already defined */
info->available |= bit;
if (stmt->value == NULL)
return true;
- else
- {
+ else {
const char *str1;
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);
ACTION("Declaration of %s ignored\n", str1);
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);
WARN("Virtual modifier %s multiply defined\n", str1);
str1 = XkbcModMaskText(srv->vmods[i], true);
- if (mergeMode == MERGE_OVERRIDE)
- {
+ if (mergeMode == MERGE_OVERRIDE) {
str2 = str1;
str1 = XkbcModMaskText(mod.uval, true);
}
@@ -119,10 +114,9 @@ HandleVModDef(VModDef *stmt, struct xkb_keymap *keymap, enum merge_mode mergeMod
else if (nextFree < 0)
nextFree = i;
}
- if (nextFree < 0)
- {
+ if (nextFree < 0) {
ERROR("Too many virtual modifiers defined (maximum %d)\n",
- XkbNumVirtualMods);
+ XkbNumVirtualMods);
return false;
}
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);
if (stmt->value == NULL)
return true;
- if (ExprResolveModMask(keymap->ctx, stmt->value, &mod))
- {
+ if (ExprResolveModMask(keymap->ctx, stmt->value, &mod)) {
srv->vmods[nextFree] = mod.uval;
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;
}
@@ -158,8 +152,7 @@ LookupVModIndex(const struct xkb_keymap *keymap, xkb_atom_t field,
int i;
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;
}
/* 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 xkb_types section.
*/
- for (i = 0; i < XkbNumVirtualMods; i++)
- {
+ for (i = 0; i < XkbNumVirtualMods; i++) {
if (keymap->names->vmods[i] &&
- strcmp(keymap->names->vmods[i], name) == 0)
- {
+ strcmp(keymap->names->vmods[i], name) == 0) {
val_rtrn->uval = i;
return true;
}
@@ -193,12 +184,10 @@ bool
LookupVModMask(struct xkb_context *ctx, const void *priv, xkb_atom_t field,
unsigned type, ExprResult *val_rtrn)
{
- if (LookupModMask(ctx, NULL, field, type, val_rtrn))
- {
+ if (LookupModMask(ctx, NULL, field, type, val_rtrn)) {
return true;
}
- else if (LookupVModIndex(priv, field, type, val_rtrn))
- {
+ else if (LookupVModIndex(priv, field, type, val_rtrn)) {
unsigned ndx = val_rtrn->uval;
val_rtrn->uval = (1 << (XkbNumModifiers + ndx));
return true;
@@ -213,8 +202,7 @@ FindKeypadVMod(struct xkb_keymap *keymap)
ExprResult rtrn;
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 -1;
@@ -226,26 +214,22 @@ ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
{
struct xkb_names *names = keymap->names;
- if (def->op == ExprIdent)
- {
+ if (def->op == ExprIdent) {
int i, bit;
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] &&
- strcmp(names->vmods[i], name) == 0)
- {
+ strcmp(names->vmods[i], name) == 0) {
val_rtrn->uval = i;
return true;
}
}
}
- if (ExprResolveInteger(keymap->ctx, def, val_rtrn))
- {
+ if (ExprResolveInteger(keymap->ctx, def, val_rtrn)) {
if (val_rtrn->uval < XkbNumVirtualMods)
return true;
ERROR("Illegal virtual modifier %d (must be 0..%d inclusive)\n",
- val_rtrn->uval, XkbNumVirtualMods - 1);
+ val_rtrn->uval, XkbNumVirtualMods - 1);
}
return false;
}
diff --git a/src/xkbcomp/vmod.h b/src/xkbcomp/vmod.h
index 96f99b2..ad3e819 100644
--- a/src/xkbcomp/vmod.h
+++ b/src/xkbcomp/vmod.h
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef VMOD_H
@@ -30,8 +30,7 @@
#include "xkbcomp-priv.h"
#include "expr.h"
-typedef struct _VModInfo
-{
+typedef struct _VModInfo {
struct xkb_keymap *keymap;
unsigned defined;
unsigned available;
@@ -46,7 +45,8 @@ extern void
ClearVModInfo(VModInfo *info, struct xkb_keymap *keymap);
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);
extern bool
@@ -57,6 +57,7 @@ FindKeypadVMod(struct xkb_keymap *keymap);
extern bool
ResolveVirtualModifier(ExprDef *def, struct xkb_keymap *keymap,
- ExprResult *value_rtrn, VModInfo *info);
+ ExprResult *value_rtrn,
+ VModInfo *info);
#endif /* VMOD_H */
diff --git a/src/xkbcomp/xkbcomp-priv.h b/src/xkbcomp/xkbcomp-priv.h
index 7b9858d..d998bb1 100644
--- a/src/xkbcomp/xkbcomp-priv.h
+++ b/src/xkbcomp/xkbcomp-priv.h
@@ -1,27 +1,27 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef XKBCOMP_PRIV_H
@@ -32,8 +32,7 @@
#include "text.h"
#include "utils.h"
-typedef struct _CommonInfo
-{
+typedef struct _CommonInfo {
unsigned short defined;
unsigned file_id;
enum merge_mode merge;
@@ -48,7 +47,7 @@ extern void *
ClearCommonInfo(CommonInfo *cmn);
extern void *
-AddCommonInfo(CommonInfo *old, CommonInfo *new);
+AddCommonInfo(CommonInfo * old, CommonInfo * new);
extern int
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);
extern bool
-ProcessIncludeFile(struct xkb_context *ctx,
- IncludeStmt *stmt, enum xkb_file_type file_type,
- XkbFile **file_rtrn, enum merge_mode *merge_rtrn);
+ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
+ enum xkb_file_type file_type, XkbFile **file_rtrn,
+ enum merge_mode *merge_rtrn);
extern bool
FindNamedKey(struct xkb_keymap *keymap, unsigned long name,
diff --git a/src/xkbcomp/xkbcomp.c b/src/xkbcomp/xkbcomp.c
index d45d3e6..56839a5 100644
--- a/src/xkbcomp/xkbcomp.c
+++ b/src/xkbcomp/xkbcomp.c
@@ -1,28 +1,28 @@
/*
-Copyright 2009 Dan Nicholson
-
-Permission is hereby granted, free of charge, to any person obtaining a
-copy of this software and associated documentation files (the "Software"),
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense,
-and/or sell copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
-ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-Except as contained in this notice, the names of the authors or their
-institutions shall not be used in advertising or otherwise to promote the
-sale, use or other dealings in this Software without prior written
-authorization from the authors.
-*/
+ * Copyright 2009 Dan Nicholson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Except as contained in this notice, the names of the authors or their
+ * institutions shall not be used in advertising or otherwise to promote the
+ * sale, use or other dealings in this Software without prior written
+ * authorization from the authors.
+ */
#include "xkbcomp-priv.h"
#include "rules.h"
@@ -42,21 +42,21 @@ keymap_file_from_components(struct xkb_context *ctx,
inc = IncludeCreate(ktcsg->keycodes, MERGE_DEFAULT);
keycodes = CreateXKBFile(ctx, FILE_TYPE_KEYCODES, NULL,
- (ParseCommon *)inc, 0);
+ (ParseCommon *) inc, 0);
inc = IncludeCreate(ktcsg->types, MERGE_DEFAULT);
types = CreateXKBFile(ctx, FILE_TYPE_TYPES, NULL,
- (ParseCommon *)inc, 0);
+ (ParseCommon *) inc, 0);
AppendStmt(&keycodes->common, &types->common);
inc = IncludeCreate(ktcsg->compat, MERGE_DEFAULT);
compat = CreateXKBFile(ctx, FILE_TYPE_COMPAT, NULL,
- (ParseCommon *)inc, 0);
+ (ParseCommon *) inc, 0);
AppendStmt(&keycodes->common, &compat->common);
inc = IncludeCreate(ktcsg->symbols, MERGE_DEFAULT);
symbols = CreateXKBFile(ctx, FILE_TYPE_SYMBOLS, NULL,
- (ParseCommon *)inc, 0);
+ (ParseCommon *) inc, 0);
AppendStmt(&keycodes->common, &symbols->common);
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 */
- for (file = (XkbFile *)file->defs; file;
- file = (XkbFile *)file->common.next) {
+ for (file = (XkbFile *) file->defs; file;
+ file = (XkbFile *) file->common.next) {
if (have & file->type) {
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");
continue;
}
@@ -110,18 +110,22 @@ compile_keymap(struct xkb_context *ctx, XkbFile *file)
case FILE_TYPE_KEYCODES:
keycodes = file;
break;
+
case FILE_TYPE_TYPES:
types = file;
break;
+
case FILE_TYPE_SYMBOLS:
symbols = file;
break;
+
case FILE_TYPE_COMPAT:
compat = file;
break;
+
default:
ERROR("Cannot define %s in a keymap file\n",
- XkbcFileTypeText(file->type));
+ XkbcFileTypeText(file->type));
continue;
}
diff --git a/src/xkbcomp/xkbcomp.h b/src/xkbcomp/xkbcomp.h
index eaf2d81..23cc6fb 100644
--- a/src/xkbcomp/xkbcomp.h
+++ b/src/xkbcomp/xkbcomp.h
@@ -1,82 +1,81 @@
/************************************************************
- Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
-
- Permission to use, copy, modify, and distribute this
- software and its documentation for any purpose and without
- fee is hereby granted, provided that the above copyright
- notice appear in all copies and that both that copyright
- notice and this permission notice appear in supporting
- documentation, and that the name of Silicon Graphics not be
- used in advertising or publicity pertaining to distribution
- of the software without specific prior written permission.
- Silicon Graphics makes no representation about the suitability
- of this software for any purpose. It is provided "as is"
- without any express or implied warranty.
-
- SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
- SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
- AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
- GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
- DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
- THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
+ * Copyright (c) 1994 by Silicon Graphics Computer Systems, Inc.
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright
+ * notice and this permission notice appear in supporting
+ * documentation, and that the name of Silicon Graphics not be
+ * used in advertising or publicity pertaining to distribution
+ * of the software without specific prior written permission.
+ * Silicon Graphics makes no representation about the suitability
+ * of this software for any purpose. It is provided "as is"
+ * without any express or implied warranty.
+ *
+ * SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+ * GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+ * THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ *
********************************************************/
#ifndef XKBCOMP_H
-#define XKBCOMP_H 1
+#define XKBCOMP_H 1
#include "xkb-priv.h"
-#define TypeUnknown 0
-#define TypeBoolean 1
-#define TypeInt 2
-#define TypeString 4
-#define TypeAction 5
-#define TypeKeyName 6
-#define TypeSymbols 7
-
-#define StmtUnknown 0
-#define StmtInclude 1
-#define StmtKeycodeDef 2
-#define StmtKeyAliasDef 3
-#define StmtExpr 4
-#define StmtVarDef 5
-#define StmtKeyTypeDef 6
-#define StmtInterpDef 7
-#define StmtVModDef 8
-#define StmtSymbolsDef 9
-#define StmtModMapDef 10
-#define StmtGroupCompatDef 11
-#define StmtIndicatorMapDef 12
-#define StmtIndicatorNameDef 13
-
-#define FileSymInterp 100
-
-typedef struct _ParseCommon
-{
+#define TypeUnknown 0
+#define TypeBoolean 1
+#define TypeInt 2
+#define TypeString 4
+#define TypeAction 5
+#define TypeKeyName 6
+#define TypeSymbols 7
+
+#define StmtUnknown 0
+#define StmtInclude 1
+#define StmtKeycodeDef 2
+#define StmtKeyAliasDef 3
+#define StmtExpr 4
+#define StmtVarDef 5
+#define StmtKeyTypeDef 6
+#define StmtInterpDef 7
+#define StmtVModDef 8
+#define StmtSymbolsDef 9
+#define StmtModMapDef 10
+#define StmtGroupCompatDef 11
+#define StmtIndicatorMapDef 12
+#define StmtIndicatorNameDef 13
+
+#define FileSymInterp 100
+
+typedef struct _ParseCommon {
unsigned stmtType;
struct _ParseCommon *next;
} ParseCommon;
-#define ExprValue 0
-#define ExprIdent 1
-#define ExprActionDecl 2
-#define ExprFieldRef 3
-#define ExprArrayRef 4
-#define ExprKeysymList 5
-#define ExprActionList 6
-
-#define OpAdd 20
-#define OpSubtract 21
-#define OpMultiply 22
-#define OpDivide 23
-#define OpAssign 24
-#define OpNot 25
-#define OpNegate 26
-#define OpInvert 27
-#define OpUnaryPlus 28
+#define ExprValue 0
+#define ExprIdent 1
+#define ExprActionDecl 2
+#define ExprFieldRef 3
+#define ExprArrayRef 4
+#define ExprKeysymList 5
+#define ExprActionList 6
+
+#define OpAdd 20
+#define OpSubtract 21
+#define OpMultiply 22
+#define OpDivide 23
+#define OpAssign 24
+#define OpNot 25
+#define OpNegate 26
+#define OpInvert 27
+#define OpUnaryPlus 28
enum merge_mode {
MERGE_DEFAULT,
@@ -85,13 +84,12 @@ enum merge_mode {
MERGE_REPLACE,
};
-#define AutoKeyNames (1L << 0)
-#define CreateKeyNames(x) ((x)->flags&AutoKeyNames)
+#define AutoKeyNames (1L << 0)
+#define CreateKeyNames(x) ((x)->flags & AutoKeyNames)
extern unsigned warningLevel;
-typedef struct _IncludeStmt
-{
+typedef struct _IncludeStmt {
ParseCommon common;
enum merge_mode merge;
char *stmt;
@@ -102,36 +100,29 @@ typedef struct _IncludeStmt
struct _IncludeStmt *next;
} IncludeStmt;
-typedef struct _Expr
-{
+typedef struct _Expr {
ParseCommon common;
unsigned op;
unsigned type;
- union
- {
- struct
- {
+ union {
+ struct {
struct _Expr *left;
struct _Expr *right;
} binary;
- struct
- {
+ struct {
xkb_atom_t element;
xkb_atom_t field;
} field;
- struct
- {
+ struct {
xkb_atom_t element;
xkb_atom_t field;
struct _Expr *entry;
} array;
- struct
- {
+ struct {
xkb_atom_t name;
struct _Expr *args;
} action;
- struct
- {
+ struct {
darray(char *) syms;
darray(int) symsMapIndex;
darray(unsigned int) symsNumEntries;
@@ -144,72 +135,63 @@ typedef struct _Expr
} value;
} ExprDef;
-typedef struct _VarDef
-{
+typedef struct _VarDef {
ParseCommon common;
enum merge_mode merge;
ExprDef *name;
ExprDef *value;
} VarDef;
-typedef struct _VModDef
-{
+typedef struct _VModDef {
ParseCommon common;
enum merge_mode merge;
xkb_atom_t name;
ExprDef *value;
} VModDef;
-typedef struct _KeycodeDef
-{
+typedef struct _KeycodeDef {
ParseCommon common;
enum merge_mode merge;
char name[5];
unsigned long value;
} KeycodeDef;
-typedef struct _KeyAliasDef
-{
+typedef struct _KeyAliasDef {
ParseCommon common;
enum merge_mode merge;
char alias[5];
char real[5];
} KeyAliasDef;
-typedef struct _KeyTypeDef
-{
+typedef struct _KeyTypeDef {
ParseCommon common;
enum merge_mode merge;
xkb_atom_t name;
VarDef *body;
} KeyTypeDef;
-typedef struct _SymbolsDef
-{
+typedef struct _SymbolsDef {
ParseCommon common;
enum merge_mode merge;
char keyName[5];
ExprDef *symbols;
} SymbolsDef;
-typedef struct _ModMapDef
-{
+typedef struct _ModMapDef {
ParseCommon common;
enum merge_mode merge;
xkb_atom_t modifier;
ExprDef *keys;
} ModMapDef;
-typedef struct _GroupCompatDef
-{
+typedef struct _GroupCompatDef {
ParseCommon common;
enum merge_mode merge;
int group;
ExprDef *def;
} GroupCompatDef;
-typedef struct _InterpDef
-{
+typedef struct _InterpDef {
ParseCommon common;
enum merge_mode merge;
char *sym;
@@ -217,8 +199,7 @@ typedef struct _InterpDef
VarDef *def;
} InterpDef;
-typedef struct _IndicatorNameDef
-{
+typedef struct _IndicatorNameDef {
ParseCommon common;
enum merge_mode merge;
int ndx;
@@ -226,8 +207,7 @@ typedef struct _IndicatorNameDef
bool virtual;
} IndicatorNameDef;
-typedef struct _IndicatorMapDef
-{
+typedef struct _IndicatorMapDef {
ParseCommon common;
enum merge_mode merge;
unsigned type;
@@ -235,8 +215,7 @@ typedef struct _IndicatorMapDef
VarDef *body;
} IndicatorMapDef;
-typedef struct _XkbFile
-{
+typedef struct _XkbFile {
ParseCommon common;
enum xkb_file_type type;
char *topName;