revert to xkbcomp 1.4.6 for now

This commit is contained in:
purplerain 2024-05-11 19:43:34 +00:00
parent 155eb8555e
commit f60577aa63
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
34 changed files with 5337 additions and 6152 deletions

View file

@ -1,4 +1,4 @@
# $OpenBSD: MODULES,v 1.519 2024/04/28 14:46:15 matthieu Exp $
# $OpenBSD: MODULES,v 1.520 2024/05/04 10:29:47 matthieu Exp $
#
# X.Org maintained modules
#
@ -45,7 +45,7 @@ app/xgc 1.0.6
app/xhost 1.0.9
app/xinit 1.4.2
app/xinput 1.6.4
app/xkbcomp 1.4.7
app/xkbcomp 1.4.7 reverted
app/xkbevd 1.1.5
app/xkbprint 1.0.6
app/xkbutils 1.0.6

View file

@ -1,396 +1,3 @@
commit e26102f28f08e5432b1ad44bbaef7f32aff199f6
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Feb 3 14:23:58 2024 -0800
xkbcomp 1.4.7
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit ff32f542c94f1b30ba2ba58193adb3774a5c50e6
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Oct 7 11:09:44 2023 -0700
GenerateListing: close outFile before returning
Found by Oracle Parfait static analyzer:
Error: File Leak
File Leak [file-ptr-leak]:
Leaked File outFile
at line 497 of app/xkbcomp/listing.c in function 'GenerateListing'.
outFile initialized at line 432 with fopen
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 1f1ea56ca22a85164c4362650b004e202f4007fd
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Mon Feb 6 13:13:21 2023 -0800
configure: raise minimum autoconf requirement to 2.70
Needed for builds on NetBSD to work correctly, since it depends on
AC_USE_SYSTEM_EXTENSIONS defining _OPENBSD_SOURCE to expose the
prototype for reallocarray() in the system headers.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 6ce2c46869ced346839eb7e0c3f83170025495c6
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Fri Jan 27 09:02:26 2023 -0800
xkbcomp.h: include config.h before any other headers
Ensures flags set by AC_USE_SYSTEM_EXTENSIONS are correctly
propogated when including system headers.
Closes: #22 xkbcomp from git compile error
Fixes: 81e46ca ("Use asprintf() if the platform supports it")
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 772470d0e4fef8e0a3d6eaf4c563fa7b1f6d6d19
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 15:32:03 2022 -0800
Replace calloc(strlen())+strcpy() pairs with strdup() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 6db8fd556e2562e9a0a821c0d6fd4f7cdcf6266c
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 15:18:26 2022 -0800
Mark more pointers as const
Some suggested by cppcheck, others by manual code inspection
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 299c9762b1dbe53f3297c54e5526aeae767d1a10
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 10:24:13 2022 -0800
Use unsigned ints when shifting to create bitmasks
symbols.c:1057:28: portability: Shifting signed 32-bit value by 31 bits
is implementation-defined behaviour. See condition at line 1049.
[shiftTooManyBitsSigned]
radio_groups |= (1 << (tmp.uval - 1));
^
symbols.c:1049:41: note: Assuming that condition 'tmp.uval>32' is not redundant
if ((tmp.uval < 1) || (tmp.uval > XkbMaxRadioGroups))
^
symbols.c:1057:28: note: Shift
radio_groups |= (1 << (tmp.uval - 1));
^
symbols.c:1057:28: warning: Either the condition 'tmp.uval>32' is redundant
or there is signed integer overflow for expression '1<<(tmp.uval-1)'.
[integerOverflowCond]
radio_groups |= (1 << (tmp.uval - 1));
^
symbols.c:1049:41: note: Assuming that condition 'tmp.uval>32' is not redundant
if ((tmp.uval < 1) || (tmp.uval > XkbMaxRadioGroups))
^
symbols.c:1057:28: note: Integer overflow
radio_groups |= (1 << (tmp.uval - 1));
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit e4cba31313b44e40efcc0c260a33c3ec83e4b772
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 10:20:05 2022 -0800
Stop building more unused functions
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 3e486c4578f3f6a81fc0f9afba6551dfa8c7b63b
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 10:02:13 2022 -0800
Only build debug infrastructure if DEBUG is defined
It's only used when DEBUG is defined, so don't build it when
we're not using it.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit a3bbf780252e55bb1dcab717289ef09e00d11223
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 09:55:55 2022 -0800
Remove unused "no indent" (NOI) debug functions
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 0493c7216dd39baeb420583be71af095576dbf74
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 09:50:55 2022 -0800
Mark more functions and variables static
Stop exporting things that aren't used outside the file
that defines them.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 4119707089b5c14f53bd5ff0b86ee7e575ac9316
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 09:22:57 2022 -0800
XkbAddDirectoryToPath: don't leak existing paths on realloc() failure
Found by cppcheck:
xkbpath.c:217:9: error: Common realloc mistake: 'includePath' nulled
but not freed upon failure [memleakOnRealloc]
includePath = (char **) realloc(includePath, szPath * sizeof(char *));
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 0d22aac7bb50ff1f7588f78ec25e9fb62a7b2e5e
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 09:17:56 2022 -0800
FindKeypadVMod: check xkb is not NULL before dereference, not after
As found by cppcheck:
vmod.c:232:26: warning: Either the condition 'xkb' is redundant or there
is possible null pointer dereference: xkb. [nullPointerRedundantCheck]
name = XkbInternAtom(xkb->dpy, "NumLock", False);
^
vmod.c:233:10: note: Assuming that condition 'xkb' is not redundant
if ((xkb) && LookupVModIndex((XPointer) xkb, None, name, TypeInt, &rtrn))
^
vmod.c:232:26: note: Null pointer dereference
name = XkbInternAtom(xkb->dpy, "NumLock", False);
^
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit c7a5d1468c75adb2139d2c2facc73854f13b5ba3
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sun Dec 11 08:57:56 2022 -0800
Remove #ifdef sgi sections
They just included an additional malloc.h header, but SGI Irix
has been unsupported for a decade now.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit e6821a8a7b16e5a8e4c478c9544798fae59a21d1
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 16:20:58 2022 -0800
Handle -Wstringop-truncation warning in HandleOverlayDef()
In function HandleOverlayDef,
inlined from HandleSectionBody at geometry.c:2778:18,
inlined from HandleSectionDef at geometry.c:2818:10,
inlined from HandleGeometryFile at geometry.c:2864:18:
geometry.c:2573:9: warning: strncpy output may be truncated copying
4 bytes from a string of length 4 [-Wstringop-truncation]
2573 | strncpy(key->over, keyDef->over, XkbKeyNameLength);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
geometry.c:2574:9: warning: strncpy output may be truncated copying
4 bytes from a string of length 4 [-Wstringop-truncation]
2574 | strncpy(key->under, keyDef->under, XkbKeyNameLength);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 81e46cab5f4bdd69fa0a644dba86f6902cece175
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 16:10:01 2022 -0800
Use asprintf() if the platform supports it
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit a1551b78e9ac0e2075ca241c0e8ae361758f26b4
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 15:39:39 2022 -0800
Replace && with & for bitwise comparison
Clears up gcc warning:
keytypes.c: In function SetPreserve:
keytypes.c:757:26: warning: promoted ~unsigned is always non-zero
[-Wsign-compare]
|| (new.preVMods && (~new.indexVMods)))
^~
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit e4e821d5083072e796d6489ddcacf895a43c66f1
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 15:37:56 2022 -0800
Fix 106 missing-field-initializers warnings in misc.c
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 1fb639c97fc28b8ed66b5553eafbbeed07e4cb09
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 15:33:17 2022 -0800
Replace malloc()+bzero() pairs with calloc() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 8e58b7949ab96180d60fb13f7820d6cc01c228ae
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 15:21:49 2022 -0800
Remove unnecessary casts from bzero() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit bdbfa354dd4d93657104ccd7c9e892ed45197dd8
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 15:16:05 2022 -0800
Remove unnecessary casts from memcpy() calls
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit f1757a005f471044da3f8e946a091b067996d270
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 14:30:21 2022 -0800
Replace Opaque with direct usage of void *
Only one use was left after deleting the *alloc/free() wrappers
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 5655379ce89ab55f25a536972aaa310480de9432
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 14:23:11 2022 -0800
Remove unnecessary checks for NULL pointers before calling free()
Not needed in C89 and later
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 2ac6a7f029d8855fbb4e8024aab0511727ac3a67
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 14:10:32 2022 -0800
Replace uFree() with direct free() calls
All these wrappers did was mess with types and add a test for
NULL pointers that isn't needed in C89 and later.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 8d85bd1e2f9473958b235caf7af9913b518f73dd
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 14:07:18 2022 -0800
Replace uTypedRecalloc() with direct recallocarray() calls
Retains uRecalloc() as a fallback for platforms without recallocarray()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit e02e32f71f6c24fcc69bdaf58f6f9e973a017896
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 13:49:56 2022 -0800
Replace uTypedRealloc() with direct reallocarray() calls
Falls back to realloc() if platform doesn't offer reallocarray().
Also removes uRealloc() since it had no other uses.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 75af06f5f8ffc41fabd100253aad222cb4ab8662
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 13:44:17 2022 -0800
Replace uCalloc() and uTypedCalloc() with direct calloc() calls
All these wrappers did was mess with types.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 265ea3a77418df2744575f1168f89a33f01e72d4
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 13:39:10 2022 -0800
Replace uAlloc() and uTypedAlloc() with direct malloc() calls
All these wrappers did was mess with types.
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 81e51cf1ff494131827df487a0f538c3b07e0407
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 13:34:09 2022 -0800
Delete unused uTmpAlloc/uTmpFree wrappers around alloca()
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 77b1efa1c83ad64d49d1e9c085d2a496580ce6f9
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 13:26:39 2022 -0800
Use C99 struct initializers
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 64761ee9424f755b84ab0ce02d13eda32d215a14
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 11:38:04 2022 -0800
Variable scope reductions
Some found by cppcheck, some found by manual code inspection
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 9737af15196380a1687d18a17d297ee17b45a83f
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 11:03:40 2022 -0800
Remove register keyword from variable declarations
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit b67c058e2ccc27472b238a6b5dc5e4cd20f6d2bd
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Sat Dec 10 09:08:33 2022 -0800
Eliminate 20 -Wimplicit-fallthrough warnings
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 634f60a9b25b5d03c78e90574adce3e38f378333
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Thu Jul 28 17:30:21 2022 -0700
gitlab CI: stop requiring Signed-off-by in commits
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 931c469b2b91603c5c196abf65a39c7dab8609d7
Author: Leandro Nini <drfiemost@email.it>
Date: Sat Dec 10 07:49:56 2022 +0000
Avoid possibly dereferencing null pointer
This addresses issue #21
Signed-off-by: Leandro Nini <drfiemost@email.it>
commit 7bac6a25bb44d39710f1b2b5fdad56d7f4c01c39
Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Wed Dec 7 17:53:16 2022 -0800
@ -562,7 +169,7 @@ Date: Thu Nov 5 14:24:24 2020 +1000
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit a0a4f112c5858ac2b932247dba2d85061bb59145
Author: Miroslav Koškár <mk@mkoskar.com>
Author: Miroslav Koškár < <mk@mkoskar.com>
Date: Mon Jul 6 07:48:48 2020 +0200
Fix lockdevbtn to be XkbSA_LockDeviceBtn action
@ -658,7 +265,7 @@ Date: Sat Feb 15 17:34:41 2014 +0100
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 9edd61b91a02bda31fc6edd2c32c553e872b6ea2
Author: Miroslav Koškár <mk@mkoskar.com>
Author: Miroslav Koškár < <mk@mkoskar.com>
Date: Fri Jan 18 20:01:01 2019 +0100
Fix invalid error report on F_Accel field

View file

@ -38,8 +38,6 @@ static Bool actionsInitialized;
static ExprDef constTrue;
static ExprDef constFalse;
static void ActionsInit(void);
/***====================================================================***/
static Bool
@ -335,15 +333,16 @@ ReportNotFound(unsigned action, unsigned field, const char *what, char *bad)
}
static Bool
HandleNoAction(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleNoAction(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
return ReportIllegal(action->type, field);
}
static Bool
CheckLatchLockFlags(unsigned action, unsigned field,
const ExprDef *value, unsigned *flags_inout)
CheckLatchLockFlags(unsigned action,
unsigned field, ExprDef * value, unsigned *flags_inout)
{
unsigned tmp;
ExprResult result;
@ -364,14 +363,16 @@ CheckLatchLockFlags(unsigned action, unsigned field,
}
static Bool
CheckModifierField(XkbDescPtr xkb, unsigned action, const ExprDef *value,
CheckModifierField(XkbDescPtr xkb,
unsigned action,
ExprDef * value,
unsigned *flags_inout, unsigned *mods_rtrn)
{
ExprResult rtrn;
if (value->op == ExprIdent)
{
char *valStr;
register char *valStr;
valStr = XkbAtomGetString(NULL, value->value.str);
if (valStr && ((uStrCaseCmp(valStr, "usemodmapmods") == 0) ||
(uStrCaseCmp(valStr, "modmapmods") == 0)))
@ -390,10 +391,13 @@ CheckModifierField(XkbDescPtr xkb, unsigned action, const ExprDef *value,
}
static Bool
HandleSetLatchMods(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleSetLatchMods(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbModAction *act;
unsigned rtrn;
unsigned t1, t2;
act = (XkbModAction *) action;
if (array_ndx != NULL)
@ -410,18 +414,15 @@ HandleSetLatchMods(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
{
case F_ClearLocks:
case F_LatchToLock:
{
unsigned rtrn = act->flags;
rtrn = act->flags;
if (CheckLatchLockFlags(action->type, field, value, &rtrn))
{
act->flags = rtrn;
return True;
}
return False;
}
case F_Modifiers:
{
unsigned t1 = act->flags, t2;
t1 = act->flags;
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
{
act->flags = t1;
@ -432,7 +433,6 @@ HandleSetLatchMods(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
return False;
}
}
return ReportIllegal(action->type, field);
}
@ -445,10 +445,13 @@ static LookupEntry lockWhich[] = {
};
static Bool
HandleLockMods(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleLockMods(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbModAction *act;
unsigned t1, t2;
ExprResult rtrn;
act = (XkbModAction *) action;
if ((array_ndx != NULL) && (field == F_Modifiers || field == F_Affect))
@ -456,17 +459,13 @@ HandleLockMods(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
switch (field)
{
case F_Affect:
{
ExprResult rtrn;
if (!ExprResolveEnum(value, &rtrn, lockWhich))
return ReportMismatch(action->type, field, "lock or unlock");
act->flags &= ~(XkbSA_LockNoLock | XkbSA_LockNoUnlock);
act->flags |= rtrn.uval;
return True;
}
case F_Modifiers:
{
unsigned t1 = act->flags, t2;
t1 = act->flags;
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
{
act->flags = t1;
@ -477,7 +476,6 @@ HandleLockMods(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
return False;
}
}
return ReportIllegal(action->type, field);
}
@ -494,10 +492,10 @@ static LookupEntry groupNames[] = {
};
static Bool
CheckGroupField(unsigned action, const ExprDef *value,
unsigned *flags_inout, int *grp_rtrn)
CheckGroupField(unsigned action,
ExprDef * value, unsigned *flags_inout, int *grp_rtrn)
{
const ExprDef *spec;
ExprDef *spec;
ExprResult rtrn;
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
@ -531,10 +529,14 @@ CheckGroupField(unsigned action, const ExprDef *value,
}
static Bool
HandleSetLatchGroup(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleSetLatchGroup(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbGroupAction *act;
unsigned rtrn;
unsigned t1;
int t2;
act = (XkbGroupAction *) action;
if (array_ndx != NULL)
@ -551,19 +553,15 @@ HandleSetLatchGroup(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
{
case F_ClearLocks:
case F_LatchToLock:
{
unsigned rtrn = act->flags;
rtrn = act->flags;
if (CheckLatchLockFlags(action->type, field, value, &rtrn))
{
act->flags = rtrn;
return True;
}
return False;
}
case F_Group:
{
unsigned t1 = act->flags;
int t2;
t1 = act->flags;
if (CheckGroupField(action->type, value, &t1, &t2))
{
act->flags = t1;
@ -572,23 +570,24 @@ HandleSetLatchGroup(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
return False;
}
}
return ReportIllegal(action->type, field);
}
static Bool
HandleLockGroup(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef * array_ndx, const ExprDef *value)
HandleLockGroup(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
XkbGroupAction *act;
unsigned t1;
int t2;
act = (XkbGroupAction *) action;
if ((array_ndx != NULL) && (field == F_Group))
return ReportActionNotArray(action->type, field);
if (field == F_Group)
{
unsigned t1 = act->flags;
int t2;
t1 = act->flags;
if (CheckGroupField(action->type, value, &t1, &t2))
{
act->flags = t1;
@ -601,11 +600,13 @@ HandleLockGroup(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
static Bool
HandleMovePtr(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleMovePtr(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
XkbPtrAction *act;
Bool absolute;
act = (XkbPtrAction *) action;
if ((array_ndx != NULL) && ((field == F_X) || (field == F_Y)))
@ -613,8 +614,6 @@ HandleMovePtr(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
if ((field == F_X) || (field == F_Y))
{
Bool absolute;
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
absolute = False;
else
@ -659,8 +658,9 @@ static LookupEntry btnNames[] = {
};
static Bool
HandlePtrBtn(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandlePtrBtn(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
XkbPtrBtnAction *act;
@ -720,8 +720,9 @@ static LookupEntry ptrDflts[] = {
};
static Bool
HandleSetPtrDflt(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleSetPtrDflt(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
XkbPtrDfltAction *act;
@ -738,7 +739,7 @@ HandleSetPtrDflt(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
else if ((field == F_Button) || (field == F_Value))
{
const ExprDef *btn;
ExprDef *btn;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
@ -796,19 +797,19 @@ static LookupEntry isoNames[] = {
};
static Bool
HandleISOLock(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleISOLock(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
XkbISOAction *act;
unsigned flags;
unsigned flags, mods;
int group;
act = (XkbISOAction *) action;
switch (field)
{
case F_Modifiers:
{
unsigned mods;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
flags = act->flags;
@ -821,10 +822,7 @@ HandleISOLock(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
return True;
}
return False;
}
case F_Group:
{
int group;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
flags = act->flags;
@ -835,7 +833,6 @@ HandleISOLock(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
return True;
}
return False;
}
case F_Affect:
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
@ -850,8 +847,9 @@ HandleISOLock(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
static Bool
HandleSwitchScreen(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleSwitchScreen(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
XkbSwitchScreenAction *act;
@ -859,7 +857,7 @@ HandleSwitchScreen(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
act = (XkbSwitchScreenAction *) action;
if (field == F_Screen)
{
const ExprDef *scrn;
ExprDef *scrn;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
if ((value->op == OpNegate) || (value->op == OpUnaryPlus))
@ -941,8 +939,9 @@ LookupEntry ctrlNames[] = {
};
static Bool
HandleSetLockControls(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleSetLockControls(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
XkbCtrlsAction *act;
@ -981,8 +980,9 @@ static LookupEntry evNames[] = {
};
static Bool
HandleActionMessage(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleActionMessage(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
XkbMessageAction *act;
@ -1058,11 +1058,14 @@ HandleActionMessage(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
static Bool
HandleRedirectKey(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleRedirectKey(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
XkbRedirectKeyAction *act;
unsigned t1, t2, vmods, vmask;
unsigned long tmp;
if (array_ndx != NULL)
return ReportActionNotArray(action->type, field);
@ -1071,10 +1074,6 @@ HandleRedirectKey(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
switch (field)
{
case F_Keycode:
{
unsigned int t1;
unsigned long tmp;
if (!ExprResolveKeyName(value, &rtrn, NULL, NULL))
return ReportMismatch(action->type, field, "key name");
tmp = KeyNameToLong(rtrn.keyName.name);
@ -1086,16 +1085,11 @@ HandleRedirectKey(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
act->new_key = t1;
return True;
}
case F_ModsToClear:
case F_Modifiers:
{
unsigned t1 = 0, t2;
t1 = 0;
if (CheckModifierField(xkb, action->type, value, &t1, &t2))
{
unsigned vmods, vmask;
act->mods_mask |= (t2 & 0xff);
if (field == F_Modifiers)
act->mods |= (t2 & 0xff);
@ -1116,13 +1110,13 @@ HandleRedirectKey(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
return True;
}
}
return ReportIllegal(action->type, field);
}
static Bool
HandleDeviceBtn(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleDeviceBtn(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
XkbDeviceBtnAction *act;
@ -1190,8 +1184,9 @@ HandleDeviceBtn(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
static Bool
HandleDeviceValuator(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandleDeviceValuator(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
#if 0
ExprResult rtrn;
@ -1204,8 +1199,9 @@ HandleDeviceValuator(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
}
static Bool
HandlePrivate(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
const ExprDef *array_ndx, const ExprDef *value)
HandlePrivate(XkbDescPtr xkb,
XkbAnyAction * action,
unsigned field, ExprDef * array_ndx, ExprDef * value)
{
ExprResult rtrn;
@ -1274,8 +1270,8 @@ HandlePrivate(XkbDescPtr xkb, XkbAnyAction *action, unsigned field,
typedef Bool(*actionHandler) (XkbDescPtr /* xkb */ ,
XkbAnyAction * /* action */ ,
unsigned /* field */ ,
const ExprDef * /* array_ndx */ ,
const ExprDef * /* value */
ExprDef * /* array_ndx */ ,
ExprDef * /* value */
);
static actionHandler handleAction[XkbSA_NumActions + 1] = {
@ -1323,11 +1319,12 @@ ApplyActionFactoryDefaults(XkbAction * action)
int
HandleActionDef(const ExprDef *def, XkbDescPtr xkb, XkbAnyAction *action,
unsigned mergeMode, const ActionInfo *info)
HandleActionDef(ExprDef * def,
XkbDescPtr xkb,
XkbAnyAction * action, unsigned mergeMode, ActionInfo * info)
{
ExprDef *arg;
const char *str;
register char *str;
unsigned tmp, hndlrType;
if (!actionsInitialized)
@ -1422,7 +1419,9 @@ HandleActionDef(const ExprDef *def, XkbDescPtr xkb, XkbAnyAction *action,
/***====================================================================***/
int
SetActionField(XkbDescPtr xkb, const char *elem, const char *field,
SetActionField(XkbDescPtr xkb,
const char *elem,
const char *field,
ExprDef * array_ndx, ExprDef * value, ActionInfo ** info_rtrn)
{
ActionInfo *new, *old;
@ -1430,7 +1429,7 @@ SetActionField(XkbDescPtr xkb, const char *elem, const char *field,
if (!actionsInitialized)
ActionsInit();
new = malloc(sizeof(ActionInfo));
new = uTypedAlloc(ActionInfo);
if (new == NULL)
{
WSGO("Couldn't allocate space for action default\n");
@ -1469,27 +1468,23 @@ SetActionField(XkbDescPtr xkb, const char *elem, const char *field,
/***====================================================================***/
static void
void
ActionsInit(void)
{
if (!actionsInitialized)
{
bzero(&constTrue, sizeof(constTrue));
constTrue = (ExprDef) {
.common.stmtType = StmtExpr,
.common.next = NULL,
.op = ExprIdent,
.type = TypeBoolean,
.value.str = XkbInternAtom(NULL, "true", False)
};
bzero(&constFalse, sizeof(constFalse));
constFalse = (ExprDef) {
.common.stmtType = StmtExpr,
.common.next = NULL,
.op = ExprIdent,
.type = TypeBoolean,
.value.str = XkbInternAtom(NULL, "false", False)
};
bzero((char *) &constTrue, sizeof(constTrue));
bzero((char *) &constFalse, sizeof(constFalse));
constTrue.common.stmtType = StmtExpr;
constTrue.common.next = NULL;
constTrue.op = ExprIdent;
constTrue.type = TypeBoolean;
constTrue.value.str = XkbInternAtom(NULL, "true", False);
constFalse.common.stmtType = StmtExpr;
constFalse.common.next = NULL;
constFalse.op = ExprIdent;
constFalse.type = TypeBoolean;
constFalse.value.str = XkbInternAtom(NULL, "false", False);
actionsInitialized = 1;
}
return;

View file

@ -64,11 +64,11 @@ typedef struct _ActionInfo
struct _ActionInfo *next;
} ActionInfo;
extern int HandleActionDef(const ExprDef * /* def */ ,
extern int HandleActionDef(ExprDef * /* def */ ,
XkbDescPtr /* xkb */ ,
XkbAnyAction * /* action */ ,
unsigned /* mergeMode */ ,
const ActionInfo * /* info */
ActionInfo * /* info */
);
extern int SetActionField(XkbDescPtr /* xkb */ ,
@ -79,6 +79,8 @@ extern int SetActionField(XkbDescPtr /* xkb */ ,
ActionInfo ** /* info_rtrn */
);
extern void ActionsInit(void);
extern LookupEntry ctrlNames[];
#endif /* ACTION_H */

View file

@ -76,8 +76,8 @@ HandleCollision(AliasInfo * old, AliasInfo * new)
}
static void
InitAliasInfo(AliasInfo *info, unsigned merge, unsigned file_id,
const char *alias, const char *real)
InitAliasInfo(AliasInfo * info,
unsigned merge, unsigned file_id, char *alias, char *real)
{
bzero(info, sizeof(AliasInfo));
info->def.merge = merge;
@ -88,7 +88,7 @@ InitAliasInfo(AliasInfo *info, unsigned merge, unsigned file_id,
}
int
HandleAliasDef(const KeyAliasDef *def,
HandleAliasDef(KeyAliasDef * def,
unsigned merge, unsigned file_id, AliasInfo ** info_in)
{
AliasInfo *info;
@ -103,7 +103,7 @@ HandleAliasDef(const KeyAliasDef *def,
return True;
}
}
info = calloc(1, sizeof(AliasInfo));
info = uTypedCalloc(1, AliasInfo);
if (info == NULL)
{
WSGO("Allocation failure in HandleAliasDef\n");
@ -140,7 +140,7 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge, unsigned how_merge)
*merge = NULL;
return True;
}
bzero(&def, sizeof(KeyAliasDef));
bzero((char *) &def, sizeof(KeyAliasDef));
for (tmp = *merge; tmp != NULL; tmp = (AliasInfo *) tmp->def.next)
{
if (how_merge == MergeDefault)
@ -158,7 +158,7 @@ MergeAliases(AliasInfo ** into, AliasInfo ** merge, unsigned how_merge)
int
ApplyAliases(XkbDescPtr xkb, Bool toGeom, AliasInfo ** info_in)
{
int i;
register int i;
XkbKeyAliasPtr old, a;
AliasInfo *info;
int nNew, nOld;
@ -237,10 +237,10 @@ ApplyAliases(XkbDescPtr xkb, Bool toGeom, AliasInfo ** info_in)
{
if (!xkb->geom)
{
XkbGeometrySizesRec sizes = {
.which = XkbGeomKeyAliasesMask,
.num_key_aliases = nOld + nNew
};
XkbGeometrySizesRec sizes;
bzero((char *) &sizes, sizeof(XkbGeometrySizesRec));
sizes.which = XkbGeomKeyAliasesMask;
sizes.num_key_aliases = nOld + nNew;
status = XkbAllocGeometry(xkb, &sizes);
}
else

View file

@ -34,7 +34,7 @@ typedef struct _AliasInfo
char real[XkbKeyNameLength + 1];
} AliasInfo;
extern int HandleAliasDef(const KeyAliasDef * /* def */ ,
extern int HandleAliasDef(KeyAliasDef * /* def */ ,
unsigned /* merge */ ,
unsigned /* file_id */ ,
AliasInfo ** /* info */

View file

@ -81,7 +81,7 @@ typedef struct _CompatInfo
/***====================================================================***/
static char *
siText(const SymInterpInfo *si, const CompatInfo *info)
siText(SymInterpInfo * si, CompatInfo * info)
{
static char buf[128];
@ -102,6 +102,8 @@ siText(const SymInterpInfo *si, const CompatInfo *info)
static void
InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
{
register int i;
info->xkb = xkb;
info->name = NULL;
info->fileID = 0;
@ -115,7 +117,7 @@ InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
info->dflt.interp.flags = 0;
info->dflt.interp.virtual_mod = XkbNoModifier;
info->dflt.interp.act.type = XkbSA_NoAction;
for (int i = 0; i < XkbAnyActionDataSize; i++)
for (i = 0; i < XkbAnyActionDataSize; i++)
{
info->dflt.interp.act.data[i] = 0;
}
@ -123,7 +125,8 @@ InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
info->ledDflt.defs.fileID = info->fileID;
info->ledDflt.defs.defined = 0;
info->ledDflt.defs.merge = MergeOverride;
bzero(&info->groupCompat[0], XkbNumKbdGroups * sizeof(GroupCompatInfo));
bzero((char *) &info->groupCompat[0],
XkbNumKbdGroups * sizeof(GroupCompatInfo));
info->leds = NULL;
InitVModInfo(&info->vmods, xkb);
return;
@ -132,21 +135,25 @@ InitCompatInfo(CompatInfo * info, XkbDescPtr xkb)
static void
ClearCompatInfo(CompatInfo * info, XkbDescPtr xkb)
{
free(info->name);
register int i;
if (info->name != NULL)
uFree(info->name);
info->name = NULL;
info->dflt.defs.defined = 0;
info->dflt.defs.merge = MergeAugment;
info->dflt.interp.flags = 0;
info->dflt.interp.virtual_mod = XkbNoModifier;
info->dflt.interp.act.type = XkbSA_NoAction;
for (int i = 0; i < XkbAnyActionDataSize; i++)
for (i = 0; i < XkbAnyActionDataSize; i++)
{
info->dflt.interp.act.data[i] = 0;
}
ClearIndicatorMapInfo(xkb->dpy, &info->ledDflt);
info->nInterps = 0;
info->interps = (SymInterpInfo *) ClearCommonInfo(&info->interps->defs);
bzero(&info->groupCompat[0], XkbNumKbdGroups * sizeof(GroupCompatInfo));
bzero((char *) &info->groupCompat[0],
XkbNumKbdGroups * sizeof(GroupCompatInfo));
info->leds = (LEDInfo *) ClearCommonInfo(&info->leds->defs);
/* 3/30/94 (ef) -- XXX! Should free action info here */
ClearVModInfo(&info->vmods, xkb);
@ -158,9 +165,10 @@ NextInterp(CompatInfo * info)
{
SymInterpInfo *si;
si = calloc(1, sizeof(SymInterpInfo));
si = uTypedAlloc(SymInterpInfo);
if (si)
{
bzero((char *) si, sizeof(SymInterpInfo));
info->interps =
(SymInterpInfo *) AddCommonInfo(&info->interps->defs,
(CommonInfo *) si);
@ -170,7 +178,7 @@ NextInterp(CompatInfo * info)
}
static SymInterpInfo *
FindMatchingInterp(CompatInfo *info, const SymInterpInfo *new)
FindMatchingInterp(CompatInfo * info, SymInterpInfo * new)
{
SymInterpInfo *old;
@ -190,13 +198,13 @@ FindMatchingInterp(CompatInfo *info, const SymInterpInfo *new)
static Bool
AddInterp(CompatInfo * info, SymInterpInfo * new)
{
unsigned collide;
SymInterpInfo *old;
collide = 0;
old = FindMatchingInterp(info, new);
if (old != NULL)
{
unsigned collide = 0;
if (new->defs.merge == MergeReplace)
{
SymInterpInfo *next = (SymInterpInfo *) old->defs.next;
@ -255,7 +263,7 @@ AddInterp(CompatInfo * info, SymInterpInfo * new)
}
static Bool
AddGroupCompat(CompatInfo *info, unsigned group, const GroupCompatInfo *newGC)
AddGroupCompat(CompatInfo * info, unsigned group, GroupCompatInfo * newGC)
{
GroupCompatInfo *gc;
unsigned merge;
@ -281,9 +289,9 @@ AddGroupCompat(CompatInfo *info, unsigned group, const GroupCompatInfo *newGC)
/***====================================================================***/
static Bool
ResolveStateAndPredicate(const ExprDef *expr,
unsigned *pred_rtrn, unsigned *mods_rtrn,
const CompatInfo *info)
ResolveStateAndPredicate(ExprDef * expr,
unsigned *pred_rtrn,
unsigned *mods_rtrn, CompatInfo * info)
{
ExprResult result;
@ -341,9 +349,10 @@ ResolveStateAndPredicate(const ExprDef *expr,
static void
MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
{
LEDInfo *next;
SymInterpInfo *si;
LEDInfo *led, *rtrn, *next;
GroupCompatInfo *gcm;
int i;
register int i;
if (from->errorCount > 0)
{
@ -355,8 +364,7 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
into->name = from->name;
from->name = NULL;
}
for (SymInterpInfo *si = from->interps; si;
si = (SymInterpInfo *) si->defs.next)
for (si = from->interps; si; si = (SymInterpInfo *) si->defs.next)
{
if (merge != MergeDefault)
si->defs.merge = merge;
@ -370,10 +378,8 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
if (!AddGroupCompat(into, i, gcm))
into->errorCount++;
}
for (LEDInfo *led = from->leds; led != NULL; led = next)
for (led = from->leds; led != NULL; led = next)
{
LEDInfo *rtrn;
next = (LEDInfo *) led->defs.next;
if (merge != MergeDefault)
led->defs.merge = merge;
@ -386,7 +392,7 @@ MergeIncludedCompatMaps(CompatInfo * into, CompatInfo * from, unsigned merge)
return;
}
typedef void (*FileHandler) (const XkbFile * /* rtrn */ ,
typedef void (*FileHandler) (XkbFile * /* rtrn */ ,
XkbDescPtr /* xkb */ ,
unsigned /* merge */ ,
CompatInfo * /* info */
@ -421,7 +427,8 @@ HandleIncludeCompatMap(IncludeStmt *stmt,
(*hndlr) (rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
free(included.name);
if (included.name != NULL)
uFree(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@ -485,9 +492,10 @@ static LookupEntry useModMapValues[] = {
};
static int
SetInterpField(SymInterpInfo *si, XkbDescPtr xkb, const char *field,
const ExprDef *arrayNdx, const ExprDef *value,
const CompatInfo *info)
SetInterpField(SymInterpInfo * si,
XkbDescPtr xkb,
const char *field,
ExprDef * arrayNdx, ExprDef * value, CompatInfo * info)
{
int ok = 1;
ExprResult tmp;
@ -596,7 +604,7 @@ LookupEntry groupNames[] = {
};
static int
HandleInterpVar(const VarDef *stmt, XkbDescPtr xkb, CompatInfo *info)
HandleInterpVar(VarDef * stmt, XkbDescPtr xkb, CompatInfo * info)
{
ExprResult elem, field;
ExprDef *ndx;
@ -616,7 +624,7 @@ HandleInterpVar(const VarDef *stmt, XkbDescPtr xkb, CompatInfo *info)
}
static int
HandleInterpBody(const VarDef *def, XkbDescPtr xkb, SymInterpInfo *si,
HandleInterpBody(VarDef * def, XkbDescPtr xkb, SymInterpInfo * si,
CompatInfo * info)
{
int ok = 1;
@ -639,7 +647,7 @@ HandleInterpBody(const VarDef *def, XkbDescPtr xkb, SymInterpInfo *si,
}
static int
HandleInterpDef(const InterpDef *def, XkbDescPtr xkb, unsigned merge,
HandleInterpDef(InterpDef * def, XkbDescPtr xkb, unsigned merge,
CompatInfo * info)
{
unsigned pred, mods;
@ -681,7 +689,7 @@ HandleInterpDef(const InterpDef *def, XkbDescPtr xkb, unsigned merge,
}
static int
HandleGroupCompatDef(const GroupCompatDef *def,
HandleGroupCompatDef(GroupCompatDef * def,
XkbDescPtr xkb, unsigned merge, CompatInfo * info)
{
ExprResult val;
@ -713,7 +721,7 @@ HandleGroupCompatDef(const GroupCompatDef *def,
}
static void
HandleCompatMapFile(const XkbFile *file,
HandleCompatMapFile(XkbFile * file,
XkbDescPtr xkb, unsigned merge, CompatInfo * info)
{
ParseCommon *stmt;
@ -783,11 +791,12 @@ HandleCompatMapFile(const XkbFile *file,
}
static void
CopyInterps(const CompatInfo *info,
CopyInterps(CompatInfo * info,
XkbCompatMapPtr compat, Bool needSymbol, unsigned pred)
{
for (SymInterpInfo *si = info->interps; si;
si = (SymInterpInfo *) si->defs.next)
SymInterpInfo *si;
for (si = info->interps; si; si = (SymInterpInfo *) si->defs.next)
{
if (((si->interp.match & XkbSI_OpMask) != pred) ||
(needSymbol && (si->interp.sym == NoSymbol)) ||
@ -805,11 +814,13 @@ CopyInterps(const CompatInfo *info,
}
Bool
CompileCompatMap(const XkbFile *file,
CompileCompatMap(XkbFile * file,
XkbFileInfo * result, unsigned merge, LEDInfo ** unboundLEDs)
{
int i;
CompatInfo info;
XkbDescPtr xkb;
GroupCompatInfo *gcm;
xkb = result->xkb;
InitCompatInfo(&info, xkb);
@ -819,9 +830,7 @@ CompileCompatMap(const XkbFile *file,
if (info.errorCount == 0)
{
int size, i;
GroupCompatInfo *gcm;
int size;
if (XkbAllocCompatMap(xkb, XkbAllCompatMask, info.nInterps) !=
Success)
{
@ -874,6 +883,7 @@ CompileCompatMap(const XkbFile *file,
ClearCompatInfo(&info, xkb);
return True;
}
free(info.interps);
if (info.interps != NULL)
uFree(info.interps);
return False;
}

View file

@ -1,20 +1,8 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the `asprintf' function. */
#undef HAVE_ASPRINTF
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the <minix/config.h> header file. */
#undef HAVE_MINIX_CONFIG_H
/* Define to 1 if you have the `reallocarray' function. */
#undef HAVE_REALLOCARRAY
/* Define to 1 if you have the `recallocarray' function. */
#undef HAVE_RECALLOCARRAY
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
@ -45,9 +33,6 @@
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Name of package */
#undef PACKAGE
@ -83,94 +68,6 @@
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable general extensions on macOS. */
#ifndef _DARWIN_C_SOURCE
# undef _DARWIN_C_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable X/Open compliant socket functions that do not require linking
with -lxnet on HP-UX 11.11. */
#ifndef _HPUX_ALT_XOPEN_SOCKET_API
# undef _HPUX_ALT_XOPEN_SOCKET_API
#endif
/* Identify the host operating system as Minix.
This macro does not affect the system headers' behavior.
A future release of Autoconf may stop defining this macro. */
#ifndef _MINIX
# undef _MINIX
#endif
/* Enable general extensions on NetBSD.
Enable NetBSD compatibility extensions on Minix. */
#ifndef _NETBSD_SOURCE
# undef _NETBSD_SOURCE
#endif
/* Enable OpenBSD compatibility extensions on NetBSD.
Oddly enough, this does nothing on OpenBSD. */
#ifndef _OPENBSD_SOURCE
# undef _OPENBSD_SOURCE
#endif
/* Define to 1 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_SOURCE
# undef _POSIX_SOURCE
#endif
/* Define to 2 if needed for POSIX-compatible behavior. */
#ifndef _POSIX_1_SOURCE
# undef _POSIX_1_SOURCE
#endif
/* Enable POSIX-compatible threading on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */
#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */
#ifndef __STDC_WANT_IEC_60559_BFP_EXT__
# undef __STDC_WANT_IEC_60559_BFP_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */
#ifndef __STDC_WANT_IEC_60559_DFP_EXT__
# undef __STDC_WANT_IEC_60559_DFP_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */
#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__
# undef __STDC_WANT_IEC_60559_FUNCS_EXT__
#endif
/* Enable extensions specified by ISO/IEC TS 18661-3:2015. */
#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__
# undef __STDC_WANT_IEC_60559_TYPES_EXT__
#endif
/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */
#ifndef __STDC_WANT_LIB_EXT2__
# undef __STDC_WANT_LIB_EXT2__
#endif
/* Enable extensions specified by ISO/IEC 24747:2009. */
#ifndef __STDC_WANT_MATH_SPEC_FUNCS__
# undef __STDC_WANT_MATH_SPEC_FUNCS__
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable X/Open extensions. Define to 500 only if necessary
to make mbstate_t available. */
#ifndef _XOPEN_SOURCE
# undef _XOPEN_SOURCE
#endif
/* Version number of package */
#undef VERSION

8282
app/xkbcomp/configure vendored

File diff suppressed because it is too large Load diff

View file

@ -21,17 +21,12 @@ dnl
dnl Process this file with autoconf to create configure.
# Initialize Autoconf
AC_PREREQ([2.70])
AC_INIT([xkbcomp], [1.4.7],
AC_PREREQ([2.60])
AC_INIT([xkbcomp], [1.4.6],
[https://gitlab.freedesktop.org/xorg/app/xkbcomp/-/issues], [xkbcomp])
AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h])
# Set common system defines for POSIX extensions, such as _GNU_SOURCE
# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL)
# to avoid autoconf errors.
AC_USE_SYSTEM_EXTENSIONS
# Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-xz])
@ -50,7 +45,7 @@ if test ! -f "$srcdir/xkbparse.c"; then
fi
fi
AC_CHECK_FUNCS([asprintf reallocarray recallocarray strdup strcasecmp])
AC_CHECK_FUNCS([strdup strcasecmp])
# Checks for pkg-config packages
PKG_CHECK_MODULES(XKBCOMP, [x11 xkbfile xproto >= 7.0.17])

View file

@ -94,7 +94,7 @@ exprOpText(unsigned type)
return buf;
}
static char *
char *
exprTypeText(unsigned type)
{
static char buf[20];
@ -127,7 +127,8 @@ exprTypeText(unsigned type)
}
int
ExprResolveLhs(const ExprDef *expr, ExprResult *elem_rtrn,
ExprResolveLhs(ExprDef * expr,
ExprResult * elem_rtrn,
ExprResult * field_rtrn, ExprDef ** index_rtrn)
{
switch (expr->op)
@ -153,10 +154,11 @@ ExprResolveLhs(const ExprDef *expr, ExprResult *elem_rtrn,
}
Bool
SimpleLookup(const XPointer priv,
SimpleLookup(XPointer priv,
Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
{
char *str;
LookupEntry *entry;
register char *str;
if ((priv == NULL) ||
(field == None) || (elem != None) ||
@ -165,7 +167,7 @@ SimpleLookup(const XPointer priv,
return False;
}
str = XkbAtomGetString(NULL, field);
for (const LookupEntry *entry = (const LookupEntry *) priv;
for (entry = (LookupEntry *) priv;
(entry != NULL) && (entry->name != NULL); entry++)
{
if (uStrCaseCmp(str, entry->name) == 0)
@ -180,10 +182,10 @@ SimpleLookup(const XPointer priv,
}
Bool
RadioLookup(const XPointer priv,
RadioLookup(XPointer priv,
Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
{
char *str;
register char *str;
int rg;
if ((field == None) || (elem != None) || (type != TypeInt))
@ -207,13 +209,12 @@ RadioLookup(const XPointer priv,
return True;
}
#if 0
static int
int
TableLookup(XPointer priv,
Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
{
LookupTable *tbl = (LookupTable *) priv;
char *str;
register char *str;
if ((priv == NULL) || (field == None) || (type != TypeInt))
return False;
@ -233,7 +234,6 @@ TableLookup(XPointer priv,
priv = (XPointer) tbl->entries;
return SimpleLookup(priv, (Atom) None, field, type, val_rtrn);
}
#endif
static LookupEntry modIndexNames[] = {
{"shift", ShiftMapIndex},
@ -248,15 +248,15 @@ static LookupEntry modIndexNames[] = {
{NULL, 0}
};
Bool
LookupModIndex(const XPointer priv,
int
LookupModIndex(XPointer priv,
Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
{
return SimpleLookup((XPointer) modIndexNames, elem, field, type,
val_rtrn);
}
static int
int
LookupModMask(XPointer priv,
Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
{
@ -272,7 +272,7 @@ LookupModMask(XPointer priv,
else if (uStrCaseCmp(str, "none") == 0)
val_rtrn->uval = 0;
else if (LookupModIndex(priv, elem, field, type, val_rtrn))
val_rtrn->uval = (1U << val_rtrn->uval);
val_rtrn->uval = (1 << val_rtrn->uval);
else if (priv != NULL)
{
LookupPriv *lpriv = (LookupPriv *) priv;
@ -286,9 +286,8 @@ LookupModMask(XPointer priv,
return True;
}
#if 0
int
ExprResolveModIndex(const ExprDef *expr,
ExprResolveModIndex(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, XPointer lookupPriv)
{
@ -363,23 +362,23 @@ ExprResolveModIndex(const ExprDef *expr,
}
return ok;
}
#endif
int
ExprResolveModMask(const ExprDef *expr, ExprResult *val_rtrn,
ExprResolveModMask(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, XPointer lookupPriv)
{
LookupPriv priv = {
.priv = NULL,
.chain = lookup,
.chainPriv = lookupPriv
};
LookupPriv priv;
priv.priv = NULL;
priv.chain = lookup;
priv.chainPriv = lookupPriv;
return ExprResolveMask(expr, val_rtrn, LookupModMask, (XPointer) & priv);
}
int
ExprResolveBoolean(const ExprDef *expr, ExprResult *val_rtrn,
ExprResolveBoolean(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
@ -444,24 +443,23 @@ ExprResolveBoolean(const ExprDef *expr, ExprResult *val_rtrn,
val_rtrn->uval = !val_rtrn->uval;
return ok;
case OpAdd:
if (bogus == NULL)
bogus = "Addition";
goto boolean;
case OpSubtract:
if (bogus == NULL)
bogus = "Subtraction";
goto boolean;
case OpMultiply:
if (bogus == NULL)
bogus = "Multiplication";
goto boolean;
case OpDivide:
if (bogus == NULL)
bogus = "Division";
goto boolean;
case OpAssign:
if (bogus == NULL)
bogus = "Assignment";
goto boolean;
case OpNegate:
if (bogus == NULL)
bogus = "Negation";
goto boolean;
boolean:
ERROR("%s of boolean values not permitted\n", bogus);
break;
case OpUnaryPlus:
@ -475,7 +473,8 @@ ExprResolveBoolean(const ExprDef *expr, ExprResult *val_rtrn,
}
int
ExprResolveFloat(const ExprDef *expr, ExprResult *val_rtrn,
ExprResolveFloat(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
@ -487,7 +486,7 @@ ExprResolveFloat(const ExprDef *expr, ExprResult *val_rtrn,
case ExprValue:
if (expr->type == TypeString)
{
char *str;
register char *str;
str = XkbAtomGetString(NULL, expr->value.str);
if ((str != NULL) && (strlen(str) == 1))
{
@ -587,7 +586,8 @@ ExprResolveFloat(const ExprDef *expr, ExprResult *val_rtrn,
}
int
ExprResolveInteger(const ExprDef *expr, ExprResult *val_rtrn,
ExprResolveInteger(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
@ -599,7 +599,7 @@ ExprResolveInteger(const ExprDef *expr, ExprResult *val_rtrn,
case ExprValue:
if (expr->type == TypeString)
{
char *str;
register char *str;
str = XkbAtomGetString(NULL, expr->value.str);
if (str != NULL)
switch (strlen(str))
@ -707,7 +707,8 @@ ExprResolveInteger(const ExprDef *expr, ExprResult *val_rtrn,
}
int
ExprResolveString(const ExprDef *expr, ExprResult *val_rtrn,
ExprResolveString(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
@ -760,44 +761,36 @@ ExprResolveString(const ExprDef *expr, ExprResult *val_rtrn,
if (ExprResolveString(left, &leftRtrn, lookup, lookupPriv) &&
ExprResolveString(right, &rightRtrn, lookup, lookupPriv))
{
int len;
char *new;
#ifdef HAVE_ASPRINTF
if (asprintf(&new, "%s%s", leftRtrn.str, rightRtrn.str) < 0)
new = NULL;
#else
size_t len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
new = malloc(len);
#endif
len = strlen(leftRtrn.str) + strlen(rightRtrn.str) + 1;
new = (char *) uAlloc(len);
if (new)
{
#ifndef HAVE_ASPRINTF
snprintf(new, len, "%s%s", leftRtrn.str, rightRtrn.str);
#endif
val_rtrn->str = new;
return True;
}
}
return False;
case OpSubtract:
if (bogus == NULL)
bogus = "Subtraction";
goto string;
case OpMultiply:
if (bogus == NULL)
bogus = "Multiplication";
goto string;
case OpDivide:
if (bogus == NULL)
bogus = "Division";
goto string;
case OpAssign:
if (bogus == NULL)
bogus = "Assignment";
goto string;
case OpNegate:
if (bogus == NULL)
bogus = "Negation";
goto string;
case OpInvert:
if (bogus == NULL)
bogus = "Bitwise complement";
goto string;
string:
ERROR("%s of string values not permitted\n", bogus);
return False;
case OpNot:
@ -822,7 +815,8 @@ ExprResolveString(const ExprDef *expr, ExprResult *val_rtrn,
}
int
ExprResolveKeyName(const ExprDef *expr, ExprResult *val_rtrn,
ExprResolveKeyName(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
@ -864,27 +858,26 @@ ExprResolveKeyName(const ExprDef *expr, ExprResult *val_rtrn,
XkbAtomText(NULL, expr->value.field.field, XkbMessage));
return ok;
case OpAdd:
if (bogus == NULL)
bogus = "Addition";
goto keyname;
case OpSubtract:
if (bogus == NULL)
bogus = "Subtraction";
goto keyname;
case OpMultiply:
if (bogus == NULL)
bogus = "Multiplication";
goto keyname;
case OpDivide:
if (bogus == NULL)
bogus = "Division";
goto keyname;
case OpAssign:
if (bogus == NULL)
bogus = "Assignment";
goto keyname;
case OpNegate:
if (bogus == NULL)
bogus = "Negation";
goto keyname;
case OpInvert:
if (bogus == NULL)
bogus = "Bitwise complement";
goto keyname;
keyname:
ERROR("%s of key name values not permitted\n", bogus);
return False;
case OpNot:
@ -911,8 +904,7 @@ ExprResolveKeyName(const ExprDef *expr, ExprResult *val_rtrn,
/***====================================================================***/
int
ExprResolveEnum(const ExprDef *expr, ExprResult *val_rtrn,
const LookupEntry *values)
ExprResolveEnum(ExprDef * expr, ExprResult * val_rtrn, LookupEntry * values)
{
if (expr->op != ExprIdent)
{
@ -942,12 +934,13 @@ ExprResolveEnum(const ExprDef *expr, ExprResult *val_rtrn,
}
int
ExprResolveMask(const ExprDef *expr, ExprResult *val_rtrn,
ExprResolveMask(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
ExprResult leftRtrn, rightRtrn;
const ExprDef *left, *right;
ExprDef *left, *right;
const char *bogus = NULL;
switch (expr->op)
@ -986,11 +979,9 @@ ExprResolveMask(const ExprDef *expr, ExprResult *val_rtrn,
return ok;
case ExprArrayRef:
bogus = "array reference";
goto unexpected_mask;
case ExprActionDecl:
if (bogus == NULL)
bogus = "function use";
goto unexpected_mask;
unexpected_mask:
ERROR("Unexpected %s in mask expression\n", bogus);
ACTION("Expression ignored\n");
return False;
@ -1050,16 +1041,16 @@ ExprResolveMask(const ExprDef *expr, ExprResult *val_rtrn,
}
int
ExprResolveKeySym(const ExprDef *expr, ExprResult *val_rtrn,
ExprResolveKeySym(ExprDef * expr,
ExprResult * val_rtrn,
IdentLookupFunc lookup, XPointer lookupPriv)
{
int ok = 0;
KeySym sym;
if (expr->op == ExprIdent)
{
const char *str;
KeySym sym;
char *str;
str = XkbAtomGetString(NULL, expr->value.str);
if ((str != NULL) && ((sym = XStringToKeysym(str)) != NoSymbol))
{

View file

@ -35,14 +35,17 @@ typedef union _ExprResult
XkbKeyNameRec keyName;
} ExprResult;
typedef Bool(*IdentLookupFunc) (const XPointer /* priv */ ,
typedef Bool(*IdentLookupFunc) (XPointer /* priv */ ,
Atom /* elem */ ,
Atom /* field */ ,
unsigned /* type */ ,
ExprResult * /* val_rtrn */
);
extern int ExprResolveLhs(const ExprDef * /* expr */ ,
extern char *exprTypeText(unsigned /* type */
);
extern int ExprResolveLhs(ExprDef * /* expr */ ,
ExprResult * /* elem_rtrn */ ,
ExprResult * /* field_rtrn */ ,
ExprDef ** /* index_rtrn */
@ -72,81 +75,95 @@ typedef struct _LookupTable
extern char *exprOpText(unsigned /* type */
);
extern Bool RadioLookup(const XPointer /* priv */ ,
extern int RadioLookup(XPointer /* priv */ ,
Atom /* elem */ ,
Atom /* field */ ,
unsigned /* type */ ,
ExprResult * /* val_rtrn */
);
extern Bool SimpleLookup(const XPointer /* priv */ ,
extern int SimpleLookup(XPointer /* priv */ ,
Atom /* elem */ ,
Atom /* field */ ,
unsigned /* type */ ,
ExprResult * /* val_rtrn */
);
extern Bool LookupModIndex(const XPointer /* priv */ ,
extern int TableLookup(XPointer /* priv */ ,
Atom /* elem */ ,
Atom /* field */ ,
unsigned /* type */ ,
ExprResult * /* val_rtrn */
);
extern int ExprResolveModIndex(const ExprDef * /* expr */ ,
extern int LookupModIndex(XPointer /* priv */ ,
Atom /* elem */ ,
Atom /* field */ ,
unsigned /* type */ ,
ExprResult * /* val_rtrn */
);
extern int LookupModMask(XPointer /* priv */ ,
Atom /* elem */ ,
Atom /* field */ ,
unsigned /* type */ ,
ExprResult * /* val_rtrn */
);
extern int ExprResolveModIndex(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
XPointer /* lookupPriv */
);
extern int ExprResolveModMask(const ExprDef * /* expr */ ,
extern int ExprResolveModMask(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
XPointer /* priv */
);
extern int ExprResolveBoolean(const ExprDef * /* expr */ ,
extern int ExprResolveBoolean(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
XPointer /* lookupPriv */
);
extern int ExprResolveInteger(const ExprDef * /* expr */ ,
extern int ExprResolveInteger(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
XPointer /* lookupPriv */
);
extern int ExprResolveFloat(const ExprDef * /* expr */ ,
extern int ExprResolveFloat(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
XPointer /* lookupPriv */
);
extern int ExprResolveString(const ExprDef * /* expr */ ,
extern int ExprResolveString(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
XPointer /* lookupPriv */
);
extern int ExprResolveKeyName(const ExprDef * /* expr */ ,
extern int ExprResolveKeyName(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
XPointer /* lookupPriv */
);
extern int ExprResolveEnum(const ExprDef * /* expr */ ,
extern int ExprResolveEnum(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
const LookupEntry * /* values */
LookupEntry * /* values */
);
extern int ExprResolveMask(const ExprDef * /* expr */ ,
extern int ExprResolveMask(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
XPointer /* lookupPriv */
);
extern int ExprResolveKeySym(const ExprDef * /* expr */ ,
extern int ExprResolveKeySym(ExprDef * /* expr */ ,
ExprResult * /* val_rtrn */ ,
IdentLookupFunc /* lookup */ ,
XPointer /* lookupPriv */

View file

@ -247,7 +247,7 @@ typedef struct _GeometryInfo
} GeometryInfo;
static char *
ddText(Display *dpy, const DoodadInfo *di)
ddText(Display * dpy, DoodadInfo * di)
{
static char buf[64];
@ -269,7 +269,7 @@ ddText(Display *dpy, const DoodadInfo *di)
/***====================================================================***/
static void
InitPropertyInfo(PropertyInfo *pi, const GeometryInfo *info)
InitPropertyInfo(PropertyInfo * pi, GeometryInfo * info)
{
pi->defs.defined = 0;
pi->defs.fileID = info->fileID;
@ -291,17 +291,19 @@ FreeProperties(PropertyInfo * pi, GeometryInfo * info)
}
for (tmp = pi; tmp != NULL; tmp = next)
{
free(tmp->name);
free(tmp->value);
if (tmp->name)
uFree(tmp->name);
if (tmp->value)
uFree(tmp->value);
tmp->name = tmp->value = NULL;
next = (PropertyInfo *) tmp->defs.next;
free(tmp);
uFree(tmp);
}
return;
}
static void
InitKeyInfo(KeyInfo *key, RowInfo *row, const GeometryInfo *info)
InitKeyInfo(KeyInfo * key, RowInfo * row, GeometryInfo * info)
{
if (key != &row->dfltKey)
@ -313,14 +315,12 @@ InitKeyInfo(KeyInfo *key, RowInfo *row, const GeometryInfo *info)
else
{
bzero(key, sizeof(KeyInfo));
*key = (KeyInfo) {
.defs.defined = _GK_Default,
.defs.fileID = info->fileID,
.defs.merge = info->merge,
.defs.next = NULL,
.row = row
};
strcpy(key->name, "default");
key->defs.defined = _GK_Default;
key->defs.fileID = info->fileID;
key->defs.merge = info->merge;
key->defs.next = NULL;
key->row = row;
}
return;
}
@ -337,7 +337,7 @@ ClearKeyInfo(KeyInfo * key)
}
static void
FreeKeys(KeyInfo *key, RowInfo *row, const GeometryInfo *info)
FreeKeys(KeyInfo * key, RowInfo * row, GeometryInfo * info)
{
KeyInfo *tmp;
KeyInfo *next;
@ -351,13 +351,13 @@ FreeKeys(KeyInfo *key, RowInfo *row, const GeometryInfo *info)
{
ClearKeyInfo(tmp);
next = (KeyInfo *) tmp->defs.next;
free(tmp);
uFree(tmp);
}
return;
}
static void
InitRowInfo(RowInfo *row, SectionInfo *section, const GeometryInfo *info)
InitRowInfo(RowInfo * row, SectionInfo * section, GeometryInfo * info)
{
if (row != &section->dfltRow)
{
@ -380,7 +380,7 @@ InitRowInfo(RowInfo *row, SectionInfo *section, const GeometryInfo *info)
}
static void
ClearRowInfo(RowInfo *row, const GeometryInfo *info)
ClearRowInfo(RowInfo * row, GeometryInfo * info)
{
row->defs.defined &= ~_GR_Default;
row->top = row->left = 0;
@ -394,20 +394,21 @@ ClearRowInfo(RowInfo *row, const GeometryInfo *info)
}
static void
FreeRows(RowInfo *row, SectionInfo *section, const GeometryInfo *info)
FreeRows(RowInfo * row, SectionInfo * section, GeometryInfo * info)
{
RowInfo *next;
RowInfo *tmp;
if (row == section->rows)
{
section->nRows = 0;
section->rows = NULL;
}
for (RowInfo *tmp = row; tmp != NULL; tmp = next)
for (tmp = row; tmp != NULL; tmp = next)
{
ClearRowInfo(tmp, info);
next = (RowInfo *) tmp->defs.next;
free(tmp);
uFree(tmp);
}
return;
}
@ -526,7 +527,7 @@ FreeDoodads(DoodadInfo * di, SectionInfo * si, GeometryInfo * info)
{
next = (DoodadInfo *) tmp->defs.next;
ClearDoodadInfo(tmp);
free(tmp);
uFree(tmp);
}
return;
}
@ -557,8 +558,7 @@ InitSectionInfo(SectionInfo * si, GeometryInfo * info)
}
static void
DupSectionInfo(SectionInfo *into, const SectionInfo *from,
const GeometryInfo *info)
DupSectionInfo(SectionInfo * into, SectionInfo * from, GeometryInfo * info)
{
CommonInfo defs;
@ -617,7 +617,7 @@ FreeSections(SectionInfo * si, GeometryInfo * info)
{
ClearSectionInfo(tmp, info);
next = (SectionInfo *) tmp->defs.next;
free(tmp);
uFree(tmp);
}
return;
}
@ -637,24 +637,24 @@ FreeShapes(ShapeInfo * si, GeometryInfo * info)
{
if (tmp->outlines)
{
int i;
register int i;
for (i = 0; i < tmp->nOutlines; i++)
{
if (tmp->outlines[i].points != NULL)
{
free(tmp->outlines[i].points);
uFree(tmp->outlines[i].points);
tmp->outlines[i].num_points = 0;
tmp->outlines[i].points = NULL;
}
}
free(tmp->outlines);
uFree(tmp->outlines);
tmp->szOutlines = 0;
tmp->nOutlines = 0;
tmp->outlines = NULL;
tmp->primary = tmp->approx = NULL;
}
next = (ShapeInfo *) tmp->defs.next;
free(tmp);
uFree(tmp);
}
return;
}
@ -675,7 +675,8 @@ InitGeometryInfo(GeometryInfo * info, unsigned fileID, unsigned merge)
static void
ClearGeometryInfo(GeometryInfo * info)
{
free(info->name);
if (info->name)
uFree(info->name);
info->name = NULL;
if (info->props)
FreeProperties(info->props, info);
@ -700,9 +701,10 @@ NextProperty(GeometryInfo * info)
{
PropertyInfo *pi;
pi = calloc(1, sizeof(PropertyInfo));
pi = uTypedAlloc(PropertyInfo);
if (pi)
{
bzero((char *) pi, sizeof(PropertyInfo));
info->props = (PropertyInfo *) AddCommonInfo(&info->props->defs,
(CommonInfo *) pi);
info->nProps++;
@ -711,7 +713,7 @@ NextProperty(GeometryInfo * info)
}
static PropertyInfo *
FindProperty(const GeometryInfo *info, const char *name)
FindProperty(GeometryInfo * info, char *name)
{
PropertyInfo *old;
@ -747,7 +749,8 @@ AddProperty(GeometryInfo * info, PropertyInfo * new)
ACTION("Ignoring \"%s\", using \"%s\"\n", old->value,
new->value);
}
free(old->value);
if (old->value)
uFree(old->value);
old->value = uStringDup(new->value);
return True;
}
@ -776,9 +779,10 @@ NextShape(GeometryInfo * info)
{
ShapeInfo *si;
si = calloc(1, sizeof(ShapeInfo));
si = uTypedAlloc(ShapeInfo);
if (si)
{
bzero((char *) si, sizeof(ShapeInfo));
info->shapes = (ShapeInfo *) AddCommonInfo(&info->shapes->defs,
(CommonInfo *) si);
info->nShapes++;
@ -879,7 +883,7 @@ NextDfltDoodad(SectionInfo * si, GeometryInfo * info)
{
DoodadInfo *di;
di = calloc(1, sizeof(DoodadInfo));
di = uTypedCalloc(1, DoodadInfo);
if (!di)
return NULL;
if (si)
@ -902,7 +906,7 @@ NextDoodad(SectionInfo * si, GeometryInfo * info)
{
DoodadInfo *di;
di = calloc(1, sizeof(DoodadInfo));
di = uTypedCalloc(1, DoodadInfo);
if (di)
{
if (si)
@ -1043,7 +1047,7 @@ AddOverlay(SectionInfo * si, GeometryInfo * info, OverlayInfo * new)
return True;
}
old = new;
new = calloc(1, sizeof(OverlayInfo));
new = uTypedCalloc(1, OverlayInfo);
if (!new)
{
if (warningLevel > 0)
@ -1072,7 +1076,7 @@ NextSection(GeometryInfo * info)
{
SectionInfo *si;
si = malloc(sizeof(SectionInfo));
si = uTypedAlloc(SectionInfo);
if (si)
{
*si = info->dfltSection;
@ -1089,9 +1093,11 @@ NextSection(GeometryInfo * info)
}
static SectionInfo *
FindMatchingSection(GeometryInfo *info, const SectionInfo *new)
FindMatchingSection(GeometryInfo * info, SectionInfo * new)
{
for (SectionInfo *old = info->sections; old != NULL;
SectionInfo *old;
for (old = info->sections; old != NULL;
old = (SectionInfo *) old->defs.next)
{
if (new->name == old->name)
@ -1162,7 +1168,7 @@ NextRow(SectionInfo * si)
{
RowInfo *row;
row = malloc(sizeof(RowInfo));
row = uTypedAlloc(RowInfo);
if (row)
{
*row = si->dfltRow;
@ -1199,7 +1205,7 @@ NextKey(RowInfo * row)
{
KeyInfo *key;
key = malloc(sizeof(KeyInfo));
key = uTypedAlloc(KeyInfo);
if (key)
{
*key = row->dfltKey;
@ -1347,7 +1353,8 @@ HandleIncludeGeometry(IncludeStmt * stmt, XkbDescPtr xkb, GeometryInfo * info,
(*hndlr) (rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
free(included.name);
if (included.name != NULL)
uFree(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@ -1400,8 +1407,9 @@ HandleIncludeGeometry(IncludeStmt * stmt, XkbDescPtr xkb, GeometryInfo * info,
}
static int
SetShapeField(ShapeInfo *si, const char *field,
const ExprDef *arrayNdx, const ExprDef *value, GeometryInfo *info)
SetShapeField(ShapeInfo * si,
const char *field,
ExprDef * arrayNdx, ExprDef * value, GeometryInfo * info)
{
ExprResult tmp;
@ -1431,8 +1439,10 @@ SetShapeField(ShapeInfo *si, const char *field,
}
static int
SetShapeDoodadField(DoodadInfo *di, const char *field, const ExprDef *arrayNdx,
const ExprDef *value, SectionInfo *si, GeometryInfo *info)
SetShapeDoodadField(DoodadInfo * di,
const char *field,
ExprDef * arrayNdx,
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
ExprResult tmp;
const char *typeName;
@ -1499,8 +1509,10 @@ SetShapeDoodadField(DoodadInfo *di, const char *field, const ExprDef *arrayNdx,
#define FIELD_USHORT 2
static int
SetTextDoodadField(DoodadInfo *di, const char *field, const ExprDef *arrayNdx,
const ExprDef *value, SectionInfo *si, GeometryInfo *info)
SetTextDoodadField(DoodadInfo * di,
const char *field,
ExprDef * arrayNdx,
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
ExprResult tmp;
unsigned def;
@ -1647,8 +1659,10 @@ SetTextDoodadField(DoodadInfo *di, const char *field, const ExprDef *arrayNdx,
}
static int
SetIndicatorDoodadField(DoodadInfo * di, const char *field,
const ExprDef *arrayNdx, const ExprDef *value,
SetIndicatorDoodadField(DoodadInfo * di,
const char *field,
ExprDef * arrayNdx,
ExprDef * value,
SectionInfo * si, GeometryInfo * info)
{
ExprResult tmp;
@ -1690,8 +1704,10 @@ SetIndicatorDoodadField(DoodadInfo * di, const char *field,
}
static int
SetLogoDoodadField(DoodadInfo *di, const char *field, const ExprDef *arrayNdx,
const ExprDef *value, SectionInfo *si, GeometryInfo *info)
SetLogoDoodadField(DoodadInfo * di,
const char *field,
ExprDef * arrayNdx,
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
ExprResult tmp;
const char *typeName = "logo doodad";
@ -1769,9 +1785,10 @@ SetLogoDoodadField(DoodadInfo *di, const char *field, const ExprDef *arrayNdx,
}
static int
SetDoodadField(DoodadInfo *di, const char *field,
const ExprDef *arrayNdx, const ExprDef *value,
SectionInfo *si, GeometryInfo *info)
SetDoodadField(DoodadInfo * di,
const char *field,
ExprDef * arrayNdx,
ExprDef * value, SectionInfo * si, GeometryInfo * info)
{
ExprResult tmp;
@ -1871,9 +1888,9 @@ SetDoodadField(DoodadInfo *di, const char *field,
}
static int
SetSectionField(SectionInfo *si, const char *field,
const ExprDef *arrayNdx, const ExprDef *value,
GeometryInfo *info)
SetSectionField(SectionInfo * si,
const char *field,
ExprDef * arrayNdx, ExprDef * value, GeometryInfo * info)
{
unsigned short *pField;
unsigned def;
@ -1959,8 +1976,9 @@ SetSectionField(SectionInfo *si, const char *field,
}
static int
SetRowField(RowInfo *row, const char *field,
const ExprDef *arrayNdx, const ExprDef *value, GeometryInfo *info)
SetRowField(RowInfo * row,
const char *field,
ExprDef * arrayNdx, ExprDef * value, GeometryInfo * info)
{
ExprResult tmp;
@ -2024,8 +2042,9 @@ SetRowField(RowInfo *row, const char *field,
}
static int
SetKeyField(KeyInfo *key, const char *field,
const ExprDef *arrayNdx, const ExprDef *value, GeometryInfo *info)
SetKeyField(KeyInfo * key,
const char *field,
ExprDef * arrayNdx, ExprDef * value, GeometryInfo * info)
{
ExprResult tmp;
@ -2101,7 +2120,7 @@ SetKeyField(KeyInfo *key, const char *field,
}
static int
SetGeometryProperty(GeometryInfo *info, char *property, const ExprDef *value)
SetGeometryProperty(GeometryInfo * info, char *property, ExprDef * value)
{
PropertyInfo pi;
ExprResult result;
@ -2386,7 +2405,7 @@ HandleShapeBody(ShapeDef * def, ShapeInfo * si, unsigned merge,
return True;
}
si->nOutlines = def->nOutlines;
si->outlines = calloc(def->nOutlines, sizeof(XkbOutlineRec));
si->outlines = uTypedCalloc(def->nOutlines, XkbOutlineRec);
if (!si->outlines)
{
ERROR("Couldn't allocate outlines for \"%s\"\n",
@ -2407,7 +2426,7 @@ HandleShapeBody(ShapeDef * def, ShapeInfo * si, unsigned merge,
outline = &si->outlines[nOut++];
outline->num_points = ol->nPoints;
outline->corner_radius = si->dfltCornerRadius;
outline->points = calloc(ol->nPoints, sizeof(XkbPointRec));
outline->points = uTypedCalloc(ol->nPoints, XkbPointRec);
if (!outline->points)
{
ERROR("Can't allocate points for \"%s\"\n",
@ -2531,6 +2550,8 @@ static int
HandleOverlayDef(OverlayDef * def,
unsigned merge, SectionInfo * si, GeometryInfo * info)
{
OverlayKeyDef *keyDef;
OverlayKeyInfo *key;
OverlayInfo ol;
if ((def->nKeys < 1) && (warningLevel > 3))
@ -2544,23 +2565,20 @@ HandleOverlayDef(OverlayDef * def,
bzero(&ol, sizeof(OverlayInfo));
ol.name =
XkbInternAtom(info->dpy, XkbAtomGetString(NULL, def->name), False);
for (OverlayKeyDef *keyDef = def->keys; keyDef;
for (keyDef = def->keys; keyDef;
keyDef = (OverlayKeyDef *) keyDef->common.next)
{
OverlayKeyInfo *key = calloc(1, sizeof(OverlayKeyInfo));
if (!key)
{
if (warningLevel > 0)
key = uTypedCalloc(1, OverlayKeyInfo);
if ((!key) && warningLevel > 0)
{
WSGO("Couldn't allocate OverlayKeyInfo\n");
ACTION("Overlay %s for section %s will be incomplete\n",
XkbAtomText(info->dpy, ol.name, XkbMessage),
scText(info->dpy, si));
}
return False;
}
strncpy(key->over, keyDef->over, sizeof(key->over));
strncpy(key->under, keyDef->under, sizeof(key->under));
strncpy(key->over, keyDef->over, XkbKeyNameLength);
strncpy(key->under, keyDef->under, XkbKeyNameLength);
key->sectionRow = _GOK_UnknownRow;
key->overlayRow = _GOK_UnknownRow;
ol.keys = (OverlayKeyInfo *) AddCommonInfo(&ol.keys->defs,
@ -2578,10 +2596,11 @@ HandleOverlayDef(OverlayDef * def,
static Bool
HandleComplexKey(KeyDef * def, KeyInfo * key, GeometryInfo * info)
{
RowInfo *row = key->row;
RowInfo *row;
ExprDef *expr;
for (ExprDef *expr = def->expr; expr != NULL;
expr = (ExprDef *) expr->common.next)
row = key->row;
for (expr = def->expr; expr != NULL; expr = (ExprDef *) expr->common.next)
{
if (expr->op == OpAssign)
{
@ -2635,13 +2654,15 @@ static Bool
HandleRowBody(RowDef * def, RowInfo * row, unsigned merge,
GeometryInfo * info)
{
KeyDef *keyDef;
if ((def->nKeys < 1) && (warningLevel > 3))
{
ERROR("Row in section %s has no keys\n", rowText(info->dpy, row));
ACTION("Section ignored\n");
return True;
}
for (KeyDef *keyDef = def->keys; keyDef != NULL;
for (keyDef = def->keys; keyDef != NULL;
keyDef = (KeyDef *) keyDef->common.next)
{
if (keyDef->common.stmtType == StmtVarDef)
@ -2705,7 +2726,10 @@ static Bool
HandleSectionBody(SectionDef * def,
SectionInfo * si, unsigned merge, GeometryInfo * info)
{
for (RowDef *rowDef = def->rows; rowDef != NULL;
RowDef *rowDef;
DoodadInfo *di;
for (rowDef = def->rows; rowDef != NULL;
rowDef = (RowDef *) rowDef->common.next)
{
if (rowDef->common.stmtType == StmtVarDef)
@ -2713,8 +2737,6 @@ HandleSectionBody(SectionDef * def,
VarDef *var = (VarDef *) rowDef;
ExprResult elem, field;
ExprDef *ndx;
DoodadInfo *di;
if (ExprResolveLhs(var->name, &elem, &field, &ndx) == 0)
return 0; /* internal error, already reported */
if ((elem.str == NULL) || (uStrCaseCmp(elem.str, "section") == 0))
@ -2818,6 +2840,7 @@ HandleGeometryFile(XkbFile * file,
XkbDescPtr xkb, unsigned merge, GeometryInfo * info)
{
ParseCommon *stmt;
const char *failWhat;
if (merge == MergeDefault)
merge = MergeAugment;
@ -2825,8 +2848,7 @@ HandleGeometryFile(XkbFile * file,
stmt = file->defs;
while (stmt)
{
const char *failWhat = NULL;
failWhat = NULL;
switch (stmt->stmtType)
{
case StmtInclude:
@ -2859,18 +2881,17 @@ HandleGeometryFile(XkbFile * file,
info->errorCount++;
break;
case StmtVModDef:
if (!failWhat)
failWhat = "virtual modifier";
goto fail;
case StmtInterpDef:
if (!failWhat)
failWhat = "symbol interpretation";
goto fail;
case StmtGroupCompatDef:
if (!failWhat)
failWhat = "group compatibility map";
goto fail;
case StmtKeycodeDef:
if (!failWhat)
failWhat = "key name";
goto fail;
fail:
ERROR("Interpretation files may not include other types\n");
ACTION("Ignoring %s definition.\n", failWhat);
info->errorCount++;
@ -2898,9 +2919,9 @@ HandleGeometryFile(XkbFile * file,
static Bool
CopyShapeDef(Display * dpy, XkbGeometryPtr geom, ShapeInfo * si)
{
int n;
register int i, n;
XkbShapePtr shape;
XkbOutlinePtr old_outline;
XkbOutlinePtr old_outline, outline;
Atom name;
si->index = geom->num_shapes;
@ -2913,11 +2934,9 @@ CopyShapeDef(Display * dpy, XkbGeometryPtr geom, ShapeInfo * si)
return False;
}
old_outline = si->outlines;
for (int i = 0; i < si->nOutlines; i++, old_outline++)
for (i = 0; i < si->nOutlines; i++, old_outline++)
{
XkbOutlinePtr outline =
XkbAddGeomOutline(shape, old_outline->num_points);
outline = XkbAddGeomOutline(shape, old_outline->num_points);
if (!outline)
{
WSGO("Couldn't allocate outline in shape\n");
@ -3252,6 +3271,7 @@ FontFromParts(Atom fontTok,
Atom slantTok,
Atom setWidthTok, Atom varTok, int size, Atom encodingTok)
{
int totalSize;
const char *font, *weight, *slant, *setWidth, *variant, *encoding;
char *rtrn;
@ -3270,22 +3290,15 @@ FontFromParts(Atom fontTok,
None ? XkbAtomGetString(NULL, encodingTok) : DFLT_ENCODING);
if (size == 0)
size = DFLT_SIZE;
#ifdef HAVE_ASPRINTF
if (asprintf(&rtrn, FONT_TEMPLATE, font, weight, slant,
setWidth, variant, size, encoding) < 0)
rtrn = NULL;
#else
size_t totalSize =
totalSize =
strlen(FONT_TEMPLATE) + strlen(font) + strlen(weight) + strlen(slant);
totalSize += strlen(setWidth) + strlen(variant) + strlen(encoding);
rtrn = calloc(totalSize, 1);
rtrn = uCalloc(totalSize, 1);
if (rtrn)
{
snprintf(rtrn, totalSize, FONT_TEMPLATE, font, weight, slant,
setWidth, variant, size, encoding);
}
#endif
return rtrn;
}
@ -3388,7 +3401,8 @@ VerifyOverlayInfo(XkbGeometryPtr geom,
OverlayInfo * oi,
GeometryInfo * info, short rowMap[256], short rowSize[256])
{
OverlayKeyInfo *ki, *next;
register OverlayKeyInfo *ki, *next;
unsigned long oKey, uKey, sKey;
XkbRowPtr row;
XkbKeyPtr key;
int r, k;
@ -3396,16 +3410,15 @@ VerifyOverlayInfo(XkbGeometryPtr geom,
/* find out which row each key is in */
for (ki = oi->keys; ki != NULL; ki = (OverlayKeyInfo *) ki->defs.next)
{
unsigned long oKey = KeyNameToLong(ki->over);
unsigned long uKey = KeyNameToLong(ki->under);
oKey = KeyNameToLong(ki->over);
uKey = KeyNameToLong(ki->under);
for (r = 0, row = section->rows; (r < section->num_rows) && oKey;
r++, row++)
{
for (k = 0, key = row->keys; (k < row->num_keys) && oKey;
k++, key++)
{
unsigned long sKey = KeyNameToLong(key->name.name);
sKey = KeyNameToLong(key->name.name);
if (sKey == oKey)
{
if (warningLevel > 0)
@ -3442,7 +3455,7 @@ VerifyOverlayInfo(XkbGeometryPtr geom,
while ((oi->keys != NULL) && (oi->keys->sectionRow == _GOK_UnknownRow))
{
next = (OverlayKeyInfo *) oi->keys->defs.next;
free(oi->keys);
uFree(oi->keys);
oi->keys = next;
oi->nKeys--;
}
@ -3453,7 +3466,7 @@ VerifyOverlayInfo(XkbGeometryPtr geom,
{
ki->defs.next = next->defs.next;
oi->nKeys--;
free(next);
uFree(next);
next = (OverlayKeyInfo *) ki->defs.next;
}
}
@ -3488,7 +3501,11 @@ CopyOverlayDef(XkbGeometryPtr geom,
{
Atom name;
XkbOverlayPtr ol;
XkbOverlayRowPtr row;
XkbOverlayKeyPtr key;
OverlayKeyInfo *ki;
short rowMap[256], rowSize[256];
int i;
if (!VerifyOverlayInfo(geom, section, oi, info, rowMap, rowSize))
return False;
@ -3501,7 +3518,7 @@ CopyOverlayDef(XkbGeometryPtr geom,
XkbAtomText(info->dpy, section->name, XkbMessage));
return False;
}
for (int i = 0; i < oi->nRows; i++)
for (i = 0; i < oi->nRows; i++)
{
int tmp, row_under;
for (tmp = 0, row_under = -1;
@ -3519,11 +3536,10 @@ CopyOverlayDef(XkbGeometryPtr geom,
return False;
}
}
for (OverlayKeyInfo *ki = oi->keys; ki != NULL;
ki = (OverlayKeyInfo *) ki->defs.next)
for (ki = oi->keys; ki != NULL; ki = (OverlayKeyInfo *) ki->defs.next)
{
XkbOverlayRowPtr row = &ol->rows[ki->overlayRow];
XkbOverlayKeyPtr key = &row->keys[row->num_keys++];
row = &ol->rows[ki->overlayRow];
key = &row->keys[row->num_keys++];
bzero(key, sizeof(XkbOverlayKeyRec));
strncpy(key->over.name, ki->over, XkbKeyNameLength);
strncpy(key->under.name, ki->under, XkbKeyNameLength);
@ -3537,6 +3553,10 @@ static Bool
CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info)
{
XkbSectionPtr section;
XkbRowPtr row;
XkbKeyPtr key;
KeyInfo *ki;
RowInfo *ri;
Atom name;
name = XkbInternAtom(NULL, XkbAtomGetString(NULL, si->name), False);
@ -3554,9 +3574,9 @@ CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info)
section->height = si->height;
section->angle = si->angle;
section->priority = si->priority;
for (RowInfo *ri = si->rows; ri != NULL; ri = (RowInfo *) ri->defs.next)
for (ri = si->rows; ri != NULL; ri = (RowInfo *) ri->defs.next)
{
XkbRowPtr row = XkbAddGeomRow(section, ri->nKeys);
row = XkbAddGeomRow(section, ri->nKeys);
if (row == NULL)
{
WSGO("Couldn't allocate row in section\n");
@ -3566,9 +3586,8 @@ CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info)
row->top = ri->top;
row->left = ri->left;
row->vertical = ri->vertical;
for (KeyInfo *ki = ri->keys; ki != NULL; ki = (KeyInfo *) ki->defs.next)
for (ki = ri->keys; ki != NULL; ki = (KeyInfo *) ki->defs.next)
{
XkbKeyPtr key;
XkbColorPtr color;
if ((ki->defs.defined & _GK_Name) == 0)
{
@ -3609,15 +3628,16 @@ CopySectionDef(XkbGeometryPtr geom, SectionInfo * si, GeometryInfo * info)
}
if (si->doodads != NULL)
{
for (DoodadInfo *di = si->doodads; di != NULL;
di = (DoodadInfo *) di->defs.next)
DoodadInfo *di;
for (di = si->doodads; di != NULL; di = (DoodadInfo *) di->defs.next)
{
CopyDoodadDef(geom, section, di, info);
}
}
if (si->overlays != NULL)
{
for (OverlayInfo *oi = si->overlays; oi != NULL;
OverlayInfo *oi;
for (oi = si->overlays; oi != NULL;
oi = (OverlayInfo *) oi->defs.next)
{
CopyOverlayDef(geom, section, oi, info);
@ -3650,15 +3670,14 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge)
if (info.errorCount == 0)
{
XkbGeometryPtr geom;
XkbGeometrySizesRec sizes = {
.which = XkbGeomAllMask,
.num_properties = info.nProps,
.num_colors = 8,
.num_shapes = info.nShapes,
.num_sections = info.nSections,
.num_doodads = info.nDoodads
};
XkbGeometrySizesRec sizes;
bzero(&sizes, sizeof(sizes));
sizes.which = XkbGeomAllMask;
sizes.num_properties = info.nProps;
sizes.num_colors = 8;
sizes.num_shapes = info.nShapes;
sizes.num_sections = info.nSections;
sizes.num_doodads = info.nDoodads;
if (XkbAllocGeometry(xkb, &sizes) != Success)
{
WSGO("Couldn't allocate GeometryRec\n");
@ -3701,7 +3720,8 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge)
if (info.props)
{
for (PropertyInfo *pi = info.props; pi != NULL;
PropertyInfo *pi;
for (pi = info.props; pi != NULL;
pi = (PropertyInfo *) pi->defs.next)
{
if (!XkbAddGeomProperty(geom, pi->name, pi->value))
@ -3710,7 +3730,8 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge)
}
if (info.shapes)
{
for (ShapeInfo *si = info.shapes; si != NULL;
ShapeInfo *si;
for (si = info.shapes; si != NULL;
si = (ShapeInfo *) si->defs.next)
{
if (!CopyShapeDef(xkb->dpy, geom, si))
@ -3719,7 +3740,8 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge)
}
if (info.sections)
{
for (SectionInfo *si = info.sections; si != NULL;
SectionInfo *si;
for (si = info.sections; si != NULL;
si = (SectionInfo *) si->defs.next)
{
if (!CopySectionDef(geom, si, &info))
@ -3728,7 +3750,8 @@ CompileGeometry(XkbFile * file, XkbFileInfo * result, unsigned merge)
}
if (info.doodads)
{
for (DoodadInfo *di = info.doodads; di != NULL;
DoodadInfo *di;
for (di = info.doodads; di != NULL;
di = (DoodadInfo *) di->defs.next)
{
if (!CopyDoodadDef(geom, NULL, di, &info))

View file

@ -57,17 +57,16 @@ ClearIndicatorMapInfo(Display * dpy, LEDInfo * info)
}
LEDInfo *
AddIndicatorMap(LEDInfo *oldLEDs, const LEDInfo *new)
AddIndicatorMap(LEDInfo * oldLEDs, LEDInfo * new)
{
LEDInfo *old, *last;
unsigned collide;
last = NULL;
for (old = oldLEDs; old != NULL; old = (LEDInfo *) old->defs.next)
{
if (old->name == new->name)
{
unsigned collide;
if ((old->real_mods == new->real_mods) &&
(old->vmods == new->vmods) &&
(old->groups == new->groups) &&
@ -147,7 +146,7 @@ AddIndicatorMap(LEDInfo *oldLEDs, const LEDInfo *new)
last = old;
}
/* new definition */
old = malloc(sizeof(LEDInfo));
old = uTypedAlloc(LEDInfo);
if (!old)
{
WSGO("Couldn't allocate indicator map\n");
@ -199,8 +198,9 @@ static LookupEntry groupComponentNames[] = {
};
int
SetIndicatorMapField(LEDInfo *led, XkbDescPtr xkb, const char *field,
const ExprDef *arrayNdx, const ExprDef *value)
SetIndicatorMapField(LEDInfo * led,
XkbDescPtr xkb,
const char *field, ExprDef *arrayNdx, ExprDef *value)
{
ExprResult rtrn;
Bool ok;
@ -323,10 +323,12 @@ SetIndicatorMapField(LEDInfo *led, XkbDescPtr xkb, const char *field,
}
LEDInfo *
HandleIndicatorMapDef(IndicatorMapDef *def, XkbDescPtr xkb,
const LEDInfo *dflt, LEDInfo *oldLEDs, unsigned merge)
HandleIndicatorMapDef(IndicatorMapDef * def,
XkbDescPtr xkb,
LEDInfo * dflt, LEDInfo * oldLEDs, unsigned merge)
{
LEDInfo led;
LEDInfo led, *rtrn;
VarDef *var;
Bool ok;
if (def->merge != MergeDefault)
@ -337,8 +339,7 @@ HandleIndicatorMapDef(IndicatorMapDef *def, XkbDescPtr xkb,
led.name = def->name;
ok = True;
for (VarDef *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;
@ -363,7 +364,7 @@ HandleIndicatorMapDef(IndicatorMapDef *def, XkbDescPtr xkb,
}
if (ok)
{
LEDInfo *rtrn = AddIndicatorMap(oldLEDs, &led);
rtrn = AddIndicatorMap(oldLEDs, &led);
return rtrn;
}
return NULL;
@ -413,11 +414,11 @@ CopyIndicatorMapDefs(XkbFileInfo * result, LEDInfo * leds,
last = led;
}
else
free(led);
uFree(led);
}
else
{
XkbIndicatorMapPtr im;
register XkbIndicatorMapPtr im;
im = &xkb->indicators->maps[led->indicator - 1];
im->flags = led->flags;
im->which_groups = led->which_groups;
@ -429,7 +430,7 @@ CopyIndicatorMapDefs(XkbFileInfo * result, LEDInfo * leds,
im->ctrls = led->ctrls;
if (xkb->names != NULL)
xkb->names->indicators[led->indicator - 1] = led->name;
free(led);
uFree(led);
}
}
if (unboundRtrn != NULL)
@ -444,7 +445,8 @@ BindIndicators(XkbFileInfo * result,
Bool force, LEDInfo * unbound, LEDInfo ** unboundRtrn)
{
XkbDescPtr xkb;
LEDInfo *led, *next, *last;
register int i;
register LEDInfo *led, *next, *last;
xkb = result->xkb;
if (xkb->names != NULL)
@ -453,7 +455,7 @@ BindIndicators(XkbFileInfo * result,
{
if (led->indicator == _LED_NotBound)
{
for (int i = 0; i < XkbNumIndicators; i++)
for (i = 0; i < XkbNumIndicators; i++)
{
if (xkb->names->indicators[i] == led->name)
{
@ -469,7 +471,7 @@ BindIndicators(XkbFileInfo * result,
{
if (led->indicator == _LED_NotBound)
{
for (int i = 0; i < XkbNumIndicators; i++)
for (i = 0; i < XkbNumIndicators; i++)
{
if (xkb->names->indicators[i] == None)
{
@ -499,7 +501,7 @@ BindIndicators(XkbFileInfo * result,
if (force)
{
unbound = next;
free(led);
uFree(led);
}
else
{
@ -524,7 +526,7 @@ BindIndicators(XkbFileInfo * result,
led->indicator = _LED_NotBound;
if (force)
{
free(led);
uFree(led);
unbound = next;
}
else
@ -553,7 +555,7 @@ BindIndicators(XkbFileInfo * result,
else
unbound = next;
led->defs.next = NULL;
free(led);
uFree(led);
}
}
}
@ -566,7 +568,7 @@ BindIndicators(XkbFileInfo * result,
for (led = unbound; led != NULL; led = next)
{
next = (LEDInfo *) led->defs.next;
free(led);
uFree(led);
}
}
return True;

View file

@ -57,19 +57,19 @@ extern void ClearIndicatorMapInfo(Display * /* dpy */ ,
extern LEDInfo *AddIndicatorMap(LEDInfo * /* oldLEDs */ ,
const LEDInfo * /* newLED */
LEDInfo * /* newLED */
);
extern int SetIndicatorMapField(LEDInfo * /* led */ ,
XkbDescPtr /* xkb */ ,
const char * /* field */ ,
const ExprDef * /* arrayNdx */ ,
const ExprDef * /* value */
ExprDef * /* arrayNdx */ ,
ExprDef * /* value */
);
extern LEDInfo *HandleIndicatorMapDef(IndicatorMapDef * /* stmt */ ,
XkbDescPtr /* xkb */ ,
const LEDInfo * /* dflt */ ,
LEDInfo * /* dflt */ ,
LEDInfo * /* oldLEDs */ ,
unsigned /* mergeMode */
);

View file

@ -89,7 +89,7 @@ static void HandleKeycodesFile(XkbFile * file,
KeyNamesInfo * info);
static void
InitIndicatorNameInfo(IndicatorNameInfo *ii, const KeyNamesInfo *info)
InitIndicatorNameInfo(IndicatorNameInfo * ii, KeyNamesInfo * info)
{
ii->defs.defined = 0;
ii->defs.merge = info->merge;
@ -117,7 +117,7 @@ NextIndicatorName(KeyNamesInfo * info)
{
IndicatorNameInfo *ii;
ii = malloc(sizeof(IndicatorNameInfo));
ii = uTypedAlloc(IndicatorNameInfo);
if (ii)
{
InitIndicatorNameInfo(ii, info);
@ -130,7 +130,9 @@ NextIndicatorName(KeyNamesInfo * info)
static IndicatorNameInfo *
FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
{
for (IndicatorNameInfo *old = info->leds; old != NULL;
IndicatorNameInfo *old;
for (old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next)
{
if (old->ndx == ndx)
@ -142,7 +144,9 @@ FindIndicatorByIndex(KeyNamesInfo * info, int ndx)
static IndicatorNameInfo *
FindIndicatorByName(KeyNamesInfo * info, Atom name)
{
for (IndicatorNameInfo *old = info->leds; old != NULL;
IndicatorNameInfo *old;
for (old = info->leds; old != NULL;
old = (IndicatorNameInfo *) old->defs.next)
{
if (old->name == name)
@ -196,7 +200,9 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
info->leds = (IndicatorNameInfo *) old->defs.next;
else
{
for (IndicatorNameInfo *tmp = info->leds; tmp != NULL;
IndicatorNameInfo *tmp;
tmp = info->leds;
for (; tmp != NULL;
tmp = (IndicatorNameInfo *) tmp->defs.next)
{
if (tmp->defs.next == (CommonInfo *) old)
@ -206,7 +212,7 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
}
}
}
free(old);
uFree(old);
}
}
}
@ -270,15 +276,16 @@ AddIndicatorName(KeyNamesInfo * info, IndicatorNameInfo * new)
static void
ClearKeyNamesInfo(KeyNamesInfo * info)
{
free(info->name);
if (info->name != NULL)
uFree(info->name);
info->name = NULL;
info->computedMax = info->explicitMax = info->explicitMin = -1;
info->computedMin = 256;
info->effectiveMin = 8;
info->effectiveMax = 255;
bzero(info->names, sizeof(info->names));
bzero(info->files, sizeof(info->files));
bzero(info->has_alt_forms, sizeof(info->has_alt_forms));
bzero((char *) info->names, sizeof(info->names));
bzero((char *) info->files, sizeof(info->files));
bzero((char *) info->has_alt_forms, sizeof(info->has_alt_forms));
if (info->leds)
ClearIndicatorNameInfo(info->leds, info);
if (info->aliases)
@ -298,9 +305,11 @@ InitKeyNamesInfo(KeyNamesInfo * info)
}
static int
FindKeyByLong(const KeyNamesInfo *info, unsigned long name)
FindKeyByLong(KeyNamesInfo * info, unsigned long name)
{
for (int i = info->effectiveMin; i <= info->effectiveMax; i++)
register int i;
for (i = info->effectiveMin; i <= info->effectiveMax; i++)
{
if (info->names[i] == name)
return i;
@ -314,8 +323,9 @@ FindKeyByLong(const KeyNamesInfo *info, unsigned long name)
* Note that the key's name is stored as a long, the keycode is the index.
*/
static Bool
AddKeyName(KeyNamesInfo *info, int kc, const char *name,
unsigned merge, unsigned fileID, Bool reportCollisions)
AddKeyName(KeyNamesInfo * info,
int kc,
char *name, unsigned merge, unsigned fileID, Bool reportCollisions)
{
int old;
unsigned long lval;
@ -425,6 +435,9 @@ static void
MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
unsigned merge)
{
register int i;
char buf[5];
if (from->errorCount > 0)
{
into->errorCount += from->errorCount;
@ -435,11 +448,9 @@ MergeIncludedKeycodes(KeyNamesInfo * into, KeyNamesInfo * from,
into->name = from->name;
from->name = NULL;
}
for (int i = from->computedMin; i <= from->computedMax; i++)
for (i = from->computedMin; i <= from->computedMax; i++)
{
unsigned thisMerge;
char buf[5];
if (from->names[i] == 0)
continue;
LongToKeyName(from->names[i], buf);
@ -515,7 +526,8 @@ HandleIncludeKeycodes(IncludeStmt * stmt, XkbDescPtr xkb, KeyNamesInfo * info)
HandleKeycodesFile(rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
free(included.name);
if (included.name != NULL)
uFree(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@ -528,10 +540,11 @@ HandleIncludeKeycodes(IncludeStmt * stmt, XkbDescPtr xkb, KeyNamesInfo * info)
/* Do we have more than one include statement? */
if ((stmt->next != NULL) && (included.errorCount < 1))
{
IncludeStmt *next;
unsigned op;
KeyNamesInfo next_incl;
for (IncludeStmt *next = stmt->next; next != NULL; next = next->next)
for (next = stmt->next; next != NULL; next = next->next)
{
if ((next->file == NULL) && (next->map == NULL))
{
@ -568,7 +581,7 @@ HandleIncludeKeycodes(IncludeStmt * stmt, XkbDescPtr xkb, KeyNamesInfo * info)
* e.g. <ESC> = 9
*/
static int
HandleKeycodeDef(const KeycodeDef *stmt, unsigned merge, KeyNamesInfo *info)
HandleKeycodeDef(KeycodeDef * stmt, unsigned merge, KeyNamesInfo * info)
{
int code;
ExprResult result;
@ -609,7 +622,7 @@ HandleKeycodeDef(const KeycodeDef *stmt, unsigned merge, KeyNamesInfo *info)
* @return 1 on success, 0 otherwise.
*/
static int
HandleKeyNameVar(const VarDef *stmt, KeyNamesInfo *info)
HandleKeyNameVar(VarDef * stmt, KeyNamesInfo * info)
{
ExprResult tmp, field;
ExprDef *arrayNdx;
@ -707,7 +720,7 @@ HandleKeyNameVar(const VarDef *stmt, KeyNamesInfo *info)
}
static int
HandleIndicatorNameDef(const IndicatorNameDef *def,
HandleIndicatorNameDef(IndicatorNameDef * def,
unsigned merge, KeyNamesInfo * info)
{
IndicatorNameInfo ii;
@ -847,7 +860,7 @@ CompileKeycodes(XkbFile * file, XkbFileInfo * result, unsigned merge)
if (XkbAllocNames(xkb, XkbKeyNamesMask | XkbIndicatorNamesMask, 0, 0)
== Success)
{
int i;
register int i;
xkb->names->keycodes = XkbInternAtom(xkb->dpy, info.name, False);
uDEBUG2(1, "key range: %d..%d\n", xkb->min_key_code,
xkb->max_key_code);
@ -879,8 +892,8 @@ CompileKeycodes(XkbFile * file, XkbFileInfo * result, unsigned merge)
XkbAtomGetString(NULL, ii->name), False);
if (xkb->indicators != NULL)
{
unsigned bit = 1U << (ii->ndx - 1);
register unsigned bit;
bit = 1 << (ii->ndx - 1);
if (ii->virtual)
xkb->indicators->phys_indicators &= ~bit;
else

View file

@ -85,7 +85,7 @@ CompileKeymap(XkbFile * file, XkbFileInfo * result, unsigned merge)
while ((file) && (ok))
{
file->topName = mainName;
if ((have & (1U << file->type)) != 0)
if ((have & (1 << file->type)) != 0)
{
ERROR("More than one %s section in a %s file\n",
XkbConfigText(file->type, XkbMessage),
@ -93,7 +93,7 @@ CompileKeymap(XkbFile * file, XkbFileInfo * result, unsigned merge)
ACTION("All sections after the first ignored\n");
ok = False;
}
else if ((1U << file->type) & (~legal))
else if ((1 << file->type) & (~legal))
{
ERROR("Cannot define %s in a %s file\n",
XkbConfigText(file->type, XkbMessage),
@ -138,7 +138,7 @@ CompileKeymap(XkbFile * file, XkbFileInfo * result, unsigned merge)
break;
}
if (ok)
have |= (1U << file->type);
have |= (1 << file->type);
file = (XkbFile *) file->common.next;
}
/* compile the sections we have in the file one-by-one, or fail. */
@ -161,7 +161,7 @@ CompileKeymap(XkbFile * file, XkbFileInfo * result, unsigned merge)
result->defined = have;
if (required & (~have))
{
int i, bit;
register int i, bit;
unsigned missing;
missing = required & (~have);
for (i = 0, bit = 1; missing != 0; i++, bit <<= 1)

View file

@ -92,6 +92,27 @@ Atom tok_KEYPAD;
/***====================================================================***/
extern Bool AddMapEntry(XkbDescPtr /* xkb */ ,
KeyTypeInfo * /* type */ ,
XkbKTMapEntryPtr /* new */ ,
Bool /* clobber */ ,
Bool /* report */
);
extern Bool AddPreserve(XkbDescPtr /* xkb */ ,
KeyTypeInfo * /* type */ ,
PreserveInfo * /* new */ ,
Bool /* clobber */ ,
Bool /* report */
);
extern Bool AddLevelName(KeyTypeInfo * /* type */ ,
unsigned /* level */ ,
Atom /* name */ ,
Bool /* clobber */ ,
Bool /* report */
);
#define MapEntryTxt(t,x,e) \
XkbVModMaskText((t)->dpy,(x),(e)->mods.real_mods,(e)->mods.vmods,XkbMessage)
#define PreserveIndexTxt(t,x,p) \
@ -105,7 +126,7 @@ Atom tok_KEYPAD;
/***====================================================================***/
static void
InitKeyTypesInfo(KeyTypesInfo *info, XkbDescPtr xkb, const KeyTypesInfo *from)
InitKeyTypesInfo(KeyTypesInfo * info, XkbDescPtr xkb, KeyTypesInfo * from)
{
tok_ONE_LEVEL = XkbInternAtom(NULL, "ONE_LEVEL", False);
tok_TWO_LEVEL = XkbInternAtom(NULL, "TWO_LEVEL", False);
@ -138,8 +159,8 @@ InitKeyTypesInfo(KeyTypesInfo *info, XkbDescPtr xkb, const KeyTypesInfo *from)
info->dflt = from->dflt;
if (from->dflt.entries)
{
info->dflt.entries = calloc(from->dflt.szEntries,
sizeof(XkbKTMapEntryRec));
info->dflt.entries = uTypedCalloc(from->dflt.szEntries,
XkbKTMapEntryRec);
if (info->dflt.entries)
{
unsigned sz = from->dflt.nEntries * sizeof(XkbKTMapEntryRec);
@ -148,21 +169,21 @@ InitKeyTypesInfo(KeyTypesInfo *info, XkbDescPtr xkb, const KeyTypesInfo *from)
}
if (from->dflt.lvlNames)
{
info->dflt.lvlNames = calloc(from->dflt.szNames, sizeof(Atom));
info->dflt.lvlNames = uTypedCalloc(from->dflt.szNames, Atom);
if (info->dflt.lvlNames)
{
unsigned sz = from->dflt.szNames * sizeof(Atom);
register unsigned sz = from->dflt.szNames * sizeof(Atom);
memcpy(info->dflt.lvlNames, from->dflt.lvlNames, sz);
}
}
if (from->dflt.preserve)
{
PreserveInfo *last = NULL;
for (PreserveInfo *old = from->dflt.preserve;
old; old = (PreserveInfo *) old->defs.next)
PreserveInfo *old, *new, *last;
last = NULL;
old = from->dflt.preserve;
for (; old; old = (PreserveInfo *) old->defs.next)
{
PreserveInfo *new = malloc(sizeof(PreserveInfo));
new = uTypedAlloc(PreserveInfo);
if (!new)
return;
*new = *old;
@ -181,12 +202,16 @@ InitKeyTypesInfo(KeyTypesInfo *info, XkbDescPtr xkb, const KeyTypesInfo *from)
static void
FreeKeyTypeInfo(KeyTypeInfo * type)
{
free(type->entries);
if (type->entries != NULL)
{
uFree(type->entries);
type->entries = NULL;
free(type->lvlNames);
}
if (type->lvlNames != NULL)
{
uFree(type->lvlNames);
type->lvlNames = NULL;
}
if (type->preserve != NULL)
{
ClearCommonInfo(&type->preserve->defs);
@ -199,12 +224,13 @@ static void
FreeKeyTypesInfo(KeyTypesInfo * info)
{
info->dpy = NULL;
free(info->name);
if (info->name)
uFree(info->name);
info->name = NULL;
if (info->types)
{
for (KeyTypeInfo *type = info->types; type;
type = (KeyTypeInfo *) type->defs.next)
register KeyTypeInfo *type;
for (type = info->types; type; type = (KeyTypeInfo *) type->defs.next)
{
FreeKeyTypeInfo(type);
}
@ -219,9 +245,10 @@ NextKeyType(KeyTypesInfo * info)
{
KeyTypeInfo *type;
type = calloc(1, sizeof(KeyTypeInfo));
type = uTypedAlloc(KeyTypeInfo);
if (type != NULL)
{
bzero(type, sizeof(KeyTypeInfo));
type->defs.fileID = info->fileID;
type->dpy = info->dpy;
info->types = (KeyTypeInfo *) AddCommonInfo(&info->types->defs,
@ -232,10 +259,11 @@ NextKeyType(KeyTypesInfo * info)
}
static KeyTypeInfo *
FindMatchingKeyType(KeyTypesInfo *info, const KeyTypeInfo *new)
FindMatchingKeyType(KeyTypesInfo * info, KeyTypeInfo * new)
{
for (KeyTypeInfo *old = info->types; old;
old = (KeyTypeInfo *) old->defs.next)
KeyTypeInfo *old;
for (old = info->types; old; old = (KeyTypeInfo *) old->defs.next)
{
if (old->name == new->name)
return old;
@ -340,6 +368,8 @@ static void
MergeIncludedKeyTypes(KeyTypesInfo * into,
KeyTypesInfo * from, unsigned merge, XkbDescPtr xkb)
{
KeyTypeInfo *type;
if (from->errorCount > 0)
{
into->errorCount += from->errorCount;
@ -350,8 +380,7 @@ MergeIncludedKeyTypes(KeyTypesInfo * into,
into->name = from->name;
from->name = NULL;
}
for (KeyTypeInfo *type = from->types; type;
type = (KeyTypeInfo *) type->defs.next)
for (type = from->types; type; type = (KeyTypeInfo *) type->defs.next)
{
if (merge != MergeDefault)
type->defs.merge = merge;
@ -393,7 +422,8 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, newMerge, &included);
if (stmt->stmt != NULL)
{
free(included.name);
if (included.name != NULL)
uFree(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@ -405,10 +435,11 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
}
if ((stmt->next != NULL) && (included.errorCount < 1))
{
IncludeStmt *next;
unsigned op;
KeyTypesInfo next_incl;
for (IncludeStmt *next = stmt->next; next != NULL; next = next->next)
for (next = stmt->next; next != NULL; next = next->next)
{
if ((next->file == NULL) && (next->map == NULL))
{
@ -445,9 +476,9 @@ HandleIncludeKeyTypes(IncludeStmt * stmt,
/***====================================================================***/
static XkbKTMapEntryPtr
FindMatchingMapEntry(const KeyTypeInfo *type, unsigned mask, unsigned vmask)
FindMatchingMapEntry(KeyTypeInfo * type, unsigned mask, unsigned vmask)
{
int i;
register int i;
XkbKTMapEntryPtr entry;
for (i = 0, entry = type->entries; i < type->nEntries; i++, entry++)
@ -461,11 +492,13 @@ FindMatchingMapEntry(const KeyTypeInfo *type, unsigned mask, unsigned vmask)
static void
DeleteLevel1MapEntries(KeyTypeInfo * type)
{
for (int i = 0; i < type->nEntries; i++)
register int i, n;
for (i = 0; i < type->nEntries; i++)
{
if (type->entries[i].level == 0)
{
for (int n = i; n < type->nEntries - 1; n++)
for (n = i; n < type->nEntries - 1; n++)
{
type->entries[n] = type->entries[n + 1];
}
@ -484,7 +517,7 @@ NextMapEntry(KeyTypeInfo * type)
{
if (type->entries == NULL)
{
type->entries = calloc(2, sizeof(XkbKTMapEntryRec));
type->entries = uTypedCalloc(2, XkbKTMapEntryRec);
if (type->entries == NULL)
{
ERROR("Couldn't allocate map entries for %s\n", TypeTxt(type));
@ -497,9 +530,9 @@ NextMapEntry(KeyTypeInfo * type)
else if (type->nEntries >= type->szEntries)
{
type->szEntries *= 2;
type->entries = recallocarray(type->entries,
type->entries = uTypedRecalloc(type->entries,
type->nEntries, type->szEntries,
sizeof(XkbKTMapEntryRec));
XkbKTMapEntryRec);
if (type->entries == NULL)
{
ERROR("Couldn't reallocate map entries for %s\n", TypeTxt(type));
@ -510,7 +543,7 @@ NextMapEntry(KeyTypeInfo * type)
return &type->entries[type->nEntries++];
}
static Bool
Bool
AddPreserve(XkbDescPtr xkb,
KeyTypeInfo * type, PreserveInfo * new, Bool clobber, Bool report)
{
@ -560,7 +593,7 @@ AddPreserve(XkbDescPtr xkb,
}
return True;
}
old = malloc(sizeof(PreserveInfo));
old = uTypedAlloc(PreserveInfo);
if (!old)
{
WSGO("Couldn't allocate preserve in %s\n", TypeTxt(type));
@ -582,7 +615,7 @@ AddPreserve(XkbDescPtr xkb,
* @param clobber Overwrite existing entry.
* @param report True if a warning is to be printed on.
*/
static Bool
Bool
AddMapEntry(XkbDescPtr xkb,
KeyTypeInfo * type,
XkbKTMapEntryPtr new, Bool clobber, Bool report)
@ -648,8 +681,8 @@ static LookupEntry lnames[] = {
};
static Bool
SetMapEntry(KeyTypeInfo *type, XkbDescPtr xkb,
const ExprDef *arrayNdx, const ExprDef *value)
SetMapEntry(KeyTypeInfo * type,
XkbDescPtr xkb, ExprDef * arrayNdx, ExprDef * value)
{
ExprResult rtrn;
XkbKTMapEntryRec entry;
@ -695,8 +728,8 @@ SetMapEntry(KeyTypeInfo *type, XkbDescPtr xkb,
}
static Bool
SetPreserve(KeyTypeInfo *type, XkbDescPtr xkb,
const ExprDef *arrayNdx, const ExprDef *value)
SetPreserve(KeyTypeInfo * type,
XkbDescPtr xkb, ExprDef * arrayNdx, ExprDef * value)
{
ExprResult rtrn;
PreserveInfo new;
@ -733,7 +766,7 @@ SetPreserve(KeyTypeInfo *type, XkbDescPtr xkb,
new.preMods = rtrn.uval & 0xff;
new.preVMods = (rtrn.uval >> 16) & 0xffff;
if ((new.preMods & (~new.indexMods))
|| (new.preVMods & (~new.indexVMods)))
|| (new.preVMods && (~new.indexVMods)))
{
if (warningLevel > 0)
{
@ -753,14 +786,14 @@ SetPreserve(KeyTypeInfo *type, XkbDescPtr xkb,
/***====================================================================***/
static Bool
Bool
AddLevelName(KeyTypeInfo * type,
unsigned level, Atom name, Bool clobber, Bool report)
{
if ((type->lvlNames == NULL) || (type->szNames <= level))
{
type->lvlNames = recallocarray(type->lvlNames, type->szNames,
level + 1, sizeof(Atom));
type->lvlNames =
uTypedRecalloc(type->lvlNames, type->szNames, level + 1, Atom);
if (type->lvlNames == NULL)
{
ERROR("Couldn't allocate level names for type %s\n",
@ -805,7 +838,7 @@ AddLevelName(KeyTypeInfo * type,
}
static Bool
SetLevelName(KeyTypeInfo *type, const ExprDef *arrayNdx, const ExprDef *value)
SetLevelName(KeyTypeInfo * type, ExprDef * arrayNdx, ExprDef * value)
{
ExprResult rtrn;
unsigned level;
@ -844,15 +877,16 @@ SetLevelName(KeyTypeInfo *type, const ExprDef *arrayNdx, const ExprDef *value)
* @param field The field to parse (e.g. modifiers, map, level_name)
*/
static Bool
SetKeyTypeField(KeyTypeInfo * type, XkbDescPtr xkb, const char *field,
const ExprDef *arrayNdx, const ExprDef *value,
KeyTypesInfo *info)
{
if (uStrCaseCmp(field, "modifiers") == 0)
SetKeyTypeField(KeyTypeInfo * type,
XkbDescPtr xkb,
const char *field,
ExprDef * arrayNdx, ExprDef * value, KeyTypesInfo * info)
{
ExprResult tmp;
unsigned mods, vmods;
if (uStrCaseCmp(field, "modifiers") == 0)
{
unsigned mods, vmods;
if (arrayNdx != NULL)
{
WARN("The modifiers field of a key type is not an array\n");
@ -903,7 +937,7 @@ SetKeyTypeField(KeyTypeInfo * type, XkbDescPtr xkb, const char *field,
}
static Bool
HandleKeyTypeVar(const VarDef *stmt, XkbDescPtr xkb, KeyTypesInfo *info)
HandleKeyTypeVar(VarDef * stmt, XkbDescPtr xkb, KeyTypesInfo * info)
{
ExprResult elem, field;
ExprDef *arrayNdx;
@ -928,8 +962,8 @@ HandleKeyTypeVar(const VarDef *stmt, XkbDescPtr xkb, KeyTypesInfo *info)
}
static int
HandleKeyTypeBody(const VarDef *def, XkbDescPtr xkb,
KeyTypeInfo *type, KeyTypesInfo *info)
HandleKeyTypeBody(VarDef * def,
XkbDescPtr xkb, KeyTypeInfo * type, KeyTypesInfo * info)
{
int ok = 1;
ExprResult tmp, field;
@ -955,27 +989,30 @@ HandleKeyTypeBody(const VarDef *def, XkbDescPtr xkb,
*
*/
static int
HandleKeyTypeDef(const KeyTypeDef *def,
HandleKeyTypeDef(KeyTypeDef * def,
XkbDescPtr xkb, unsigned merge, KeyTypesInfo * info)
{
KeyTypeInfo type = {
.defs.defined = 0,
.defs.fileID = info->fileID,
.defs.merge = (def->merge != MergeDefault) ? def->merge : merge,
.defs.next = NULL,
.dpy = info->dpy,
.name = def->name,
.mask = info->dflt.mask,
.vmask = info->dflt.vmask,
.groupInfo = info->dflt.groupInfo,
.numLevels = 1,
.nEntries = 0,
.szEntries = 0,
.entries = NULL,
.preserve = NULL,
.szNames = 0,
.lvlNames = NULL
};
register int i;
KeyTypeInfo type;
if (def->merge != MergeDefault)
merge = def->merge;
type.defs.defined = 0;
type.defs.fileID = info->fileID;
type.defs.merge = merge;
type.defs.next = NULL;
type.dpy = info->dpy;
type.name = def->name;
type.mask = info->dflt.mask;
type.vmask = info->dflt.vmask;
type.groupInfo = info->dflt.groupInfo;
type.numLevels = 1;
type.nEntries = type.szEntries = 0;
type.entries = NULL;
type.szNames = 0;
type.lvlNames = NULL;
type.preserve = NULL;
/* Parse the actual content. */
if (!HandleKeyTypeBody(def->body, xkb, &type, info))
@ -986,7 +1023,7 @@ HandleKeyTypeDef(const KeyTypeDef *def,
/* now copy any appropriate map, preserve or level names from the */
/* default type */
for (int i = 0; i < info->dflt.nEntries; i++)
for (i = 0; i < info->dflt.nEntries; i++)
{
XkbKTMapEntryPtr dflt;
dflt = &info->dflt.entries[i];
@ -1009,7 +1046,7 @@ HandleKeyTypeDef(const KeyTypeDef *def,
dflt = (PreserveInfo *) dflt->defs.next;
}
}
for (int i = 0; i < info->dflt.szNames; i++)
for (i = 0; i < info->dflt.szNames; i++)
{
if ((i < type.numLevels) && (info->dflt.lvlNames[i] != None))
{
@ -1097,16 +1134,17 @@ HandleKeyTypesFile(XkbFile * file,
static Bool
CopyDefToKeyType(XkbDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
{
for (PreserveInfo *pre = def->preserve; pre != NULL;
register int i;
PreserveInfo *pre;
for (pre = def->preserve; pre != NULL;
pre = (PreserveInfo *) pre->defs.next)
{
XkbKTMapEntryPtr match;
XkbKTMapEntryRec tmp = {
.mods.real_mods = pre->indexMods,
.mods.vmods = pre->indexVMods,
.level = 0
};
XkbKTMapEntryRec tmp;
tmp.mods.real_mods = pre->indexMods;
tmp.mods.vmods = pre->indexVMods;
tmp.level = 0;
AddMapEntry(xkb, def, &tmp, False, False);
match = FindMatchingMapEntry(def, pre->indexMods, pre->indexVMods);
if (!match)
@ -1124,7 +1162,7 @@ CopyDefToKeyType(XkbDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
type->map = def->entries;
if (def->preserve)
{
type->preserve = calloc(type->map_count, sizeof(XkbModsRec));
type->preserve = uTypedCalloc(type->map_count, XkbModsRec);
if (!type->preserve)
{
WARN("Couldn't allocate preserve array in CopyDefToKeyType\n");
@ -1133,8 +1171,8 @@ CopyDefToKeyType(XkbDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
}
else
{
for (PreserveInfo *pre = def->preserve; pre != NULL;
pre = (PreserveInfo *) pre->defs.next)
pre = def->preserve;
for (; pre != NULL; pre = (PreserveInfo *) pre->defs.next)
{
int ndx = pre->matchingMapIndex;
type->preserve[ndx].mask = pre->preMods;
@ -1148,10 +1186,10 @@ CopyDefToKeyType(XkbDescPtr xkb, XkbKeyTypePtr type, KeyTypeInfo * def)
type->name = (Atom) def->name;
if (def->szNames > 0)
{
type->level_names = calloc(def->numLevels, sizeof(Atom));
type->level_names = uTypedCalloc(def->numLevels, Atom);
/* assert def->szNames<=def->numLevels */
for (int i = 0; i < def->szNames; i++)
for (i = 0; i < def->szNames; i++)
{
type->level_names[i] = (Atom) def->lvlNames[i];
}
@ -1179,9 +1217,9 @@ CompileKeyTypes(XkbFile * file, XkbFileInfo * result, unsigned merge)
if (info.errorCount == 0)
{
int i;
KeyTypeInfo *def;
XkbKeyTypePtr type, next;
register int i;
register KeyTypeInfo *def;
register XkbKeyTypePtr type, next;
if (info.name != NULL)
{

View file

@ -70,13 +70,16 @@ SOFTWARE.
******************************************************************/
#include "utils.h"
#include <stdio.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <X11/keysym.h>
#if defined(sgi)
#include <malloc.h>
#endif
#define DEBUG_VAR listingDebug
#include "xkbcomp.h"
#include <stdlib.h>
@ -123,9 +126,7 @@ SOFTWARE.
#define lowbit(x) ((x) & (-(x)))
#ifdef DEBUG
unsigned int listingDebug;
#endif
static int szListing = 0;
static int nListed = 0;
@ -154,7 +155,7 @@ AddMapOnly(char *map)
szMapOnly = 5;
else
szMapOnly *= 2;
mapOnly = reallocarray(list, szMapOnly, sizeof(char *));
mapOnly = uTypedRealloc(list, szMapOnly, char *);
if (!mapOnly)
{
WSGO("Couldn't allocate list of maps\n");
@ -165,7 +166,7 @@ AddMapOnly(char *map)
return 1;
}
static int
int
AddListing(char *file, char *map)
{
if (nListed >= szListing)
@ -174,7 +175,7 @@ AddListing(char *file, char *map)
szListing = 10;
else
szListing *= 2;
list = reallocarray(list, szListing, sizeof(Listing));
list = uTypedRealloc(list, szListing, Listing);
if (!list)
{
WSGO("Couldn't allocate list of files and maps\n");
@ -194,10 +195,10 @@ AddListing(char *file, char *map)
/***====================================================================***/
static void
ListFile(FILE *outFile, const char *fileName, XkbFile *map)
ListFile(FILE * outFile, char *fileName, XkbFile * map)
{
unsigned flags;
const char *mapName;
register unsigned flags;
char *mapName;
flags = map->flags;
if ((flags & XkbLC_Hidden) && (!(verboseLevel & WantHiddenMaps)))
@ -227,7 +228,7 @@ ListFile(FILE *outFile, const char *fileName, XkbFile *map)
mapName = NULL;
if (dirsToStrip > 0)
{
const char *tmp, *last;
char *tmp, *last;
int i;
for (i = 0, tmp = last = fileName; (i < dirsToStrip) && tmp; i++)
{
@ -302,33 +303,28 @@ AddDirectory(char *head, char *ptrn, char *rest, char *map)
{
char *tmp, *filename;
struct stat sbuf;
size_t tmpsize;
filename = FileName(file);
if (!filename || filename[0] == '.')
continue;
if (ptrn && (!XkbNameMatchesPattern(filename, ptrn)))
continue;
#ifdef HAVE_ASPRINTF
if (asprintf(&tmp, "%s%s%s",
(head ? head : ""), (head ? "/" : ""), filename) < 0)
continue;
#else
size_t tmpsize = (head ? strlen(head) : 0) + strlen(filename) + 2;
tmp = malloc(tmpsize);
tmpsize = (head ? strlen(head) : 0) + strlen(filename) + 2;
tmp = uAlloc(tmpsize);
if (!tmp)
continue;
snprintf(tmp, tmpsize, "%s%s%s",
(head ? head : ""), (head ? "/" : ""), filename);
#endif
if (stat(tmp, &sbuf) < 0)
{
free(tmp);
uFree(tmp);
continue;
}
if (((rest != NULL) && (!S_ISDIR(sbuf.st_mode))) ||
((map != NULL) && (S_ISDIR(sbuf.st_mode))))
{
free(tmp);
uFree(tmp);
continue;
}
if (S_ISDIR(sbuf.st_mode))
@ -404,11 +400,13 @@ AddMatchingFiles(char *head_in)
static Bool
MapMatches(char *mapToConsider, char *ptrn)
{
int i;
if (ptrn != NULL)
return XkbNameMatchesPattern(mapToConsider, ptrn);
if (nMapOnly < 1)
return True;
for (int i = 0; i < nMapOnly; i++)
for (i = 0; i < nMapOnly; i++)
{
if (XkbNameMatchesPattern(mapToConsider, mapOnly[i]))
return True;
@ -417,10 +415,13 @@ MapMatches(char *mapToConsider, char *ptrn)
}
int
GenerateListing(const char *out_name)
GenerateListing(char *out_name)
{
FILE *outFile;
XkbFile *rtrn;
int i;
FILE *inputFile, *outFile;
XkbFile *rtrn, *mapToUse;
unsigned oldWarningLevel;
char *mapName;
if (nFilesListed < 1)
{
@ -440,9 +441,8 @@ GenerateListing(const char *out_name)
if (warningLevel > 9)
fprintf(stderr, "should list:\n");
#endif
for (int i = 0; i < nListed; i++)
for (i = 0; i < nListed; i++)
{
unsigned oldWarningLevel;
#ifdef DEBUG
if (warningLevel > 9)
{
@ -455,7 +455,6 @@ GenerateListing(const char *out_name)
warningLevel = 0;
if (list[i].file)
{
FILE *inputFile;
struct stat sbuf;
if (stat(list[i].file, &sbuf) < 0)
@ -481,8 +480,8 @@ GenerateListing(const char *out_name)
setScanState(list[i].file, 1);
if (XKBParseFile(inputFile, &rtrn) && (rtrn != NULL))
{
char *mapName = list[i].map;
XkbFile *mapToUse = rtrn;
mapName = list[i].map;
mapToUse = rtrn;
for (; mapToUse; mapToUse = (XkbFile *) mapToUse->common.next)
{
if (!MapMatches(mapToUse->name, mapName))
@ -494,9 +493,5 @@ GenerateListing(const char *out_name)
}
warningLevel = oldWarningLevel;
}
if (outFile != stdout)
{
fclose(outFile);
}
return 1;
}

View file

@ -53,6 +53,7 @@ ProcessIncludeFile(IncludeStmt * stmt,
unsigned file_type,
XkbFile ** file_rtrn, unsigned *merge_rtrn)
{
FILE *file;
XkbFile *rtrn, *mapToUse;
char oldFile[1024] = {0};
int oldLine = lineNum;
@ -62,7 +63,7 @@ ProcessIncludeFile(IncludeStmt * stmt,
{
/* file not in cache, open it, parse it and store it in cache for next
time. */
FILE *file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
file = XkbFindFileInPath(stmt->file, file_type, &stmt->path);
if (file == NULL)
{
ERROR("Can't find file \"%s\" for %s include\n", stmt->file,
@ -73,10 +74,8 @@ ProcessIncludeFile(IncludeStmt * stmt,
strcpy(oldFile, scanFile);
oldLine = lineNum;
setScanState(stmt->file, 1);
#ifdef DEBUG
if (debugFlags & 2)
INFO("About to parse include file %s\n", stmt->file);
#endif
/* parse the file */
if ((XKBParseFile(file, &rtrn) == 0) || (rtrn == NULL))
{
@ -177,7 +176,6 @@ ReportBadType(const char *type, const char *field,
return False;
}
#if 0
int
ReportBadIndexType(char *type, char *field, char *name, char *wanted)
{
@ -185,7 +183,6 @@ ReportBadIndexType(char *type, char *field, char *name, char *wanted)
ACTION("Ignoring assignment to illegal field in %s\n", name);
return False;
}
#endif
int
ReportBadField(const char *type, const char *field, const char *name)
@ -195,7 +192,6 @@ ReportBadField(const char *type, const char *field, const char *name)
return False;
}
#if 0
int
ReportMultipleDefs(char *type, char *field, char *name)
{
@ -203,13 +199,12 @@ ReportMultipleDefs(char *type, char *field, char *name)
ACTION("Using last definition\n");
return False;
}
#endif
/***====================================================================***/
Bool
UseNewField(unsigned field, const CommonInfo *oldDefs,
const CommonInfo *newDefs, unsigned *pCollide)
UseNewField(unsigned field,
CommonInfo * oldDefs, CommonInfo * newDefs, unsigned *pCollide)
{
Bool useNew;
@ -232,10 +227,9 @@ UseNewField(unsigned field, const CommonInfo *oldDefs,
return useNew;
}
#if 0
static Bool
MergeNewField(unsigned field, const CommonInfo *oldDefs,
const CommonInfo *newDefs, unsigned *pCollide)
Bool
MergeNewField(unsigned field,
CommonInfo * oldDefs, CommonInfo * newDefs, unsigned *pCollide)
{
if ((oldDefs->defined & field) && (newDefs->defined & field))
{
@ -249,7 +243,6 @@ MergeNewField(unsigned field, const CommonInfo *oldDefs,
}
return False;
}
#endif
XPointer
ClearCommonInfo(CommonInfo * cmn)
@ -260,7 +253,7 @@ ClearCommonInfo(CommonInfo * cmn)
for (this = cmn; this != NULL; this = next)
{
next = this->next;
free(this);
uFree(this);
}
}
return NULL;
@ -296,140 +289,141 @@ typedef struct _KeyNameDesc
} KeyNameDesc;
static KeyNameDesc dfltKeys[] = {
{XK_Escape, NoSymbol, "ESC\0", 0},
{XK_quoteleft, XK_asciitilde, "TLDE", 0},
{XK_1, XK_exclam, "AE01", 0},
{XK_2, XK_at, "AE02", 0},
{XK_3, XK_numbersign, "AE03", 0},
{XK_4, XK_dollar, "AE04", 0},
{XK_5, XK_percent, "AE05", 0},
{XK_6, XK_asciicircum, "AE06", 0},
{XK_7, XK_ampersand, "AE07", 0},
{XK_8, XK_asterisk, "AE08", 0},
{XK_9, XK_parenleft, "AE09", 0},
{XK_0, XK_parenright, "AE10", 0},
{XK_minus, XK_underscore, "AE11", 0},
{XK_equal, XK_plus, "AE12", 0},
{XK_BackSpace, NoSymbol, "BKSP", 0},
{XK_Tab, NoSymbol, "TAB\0", 0},
{XK_q, XK_Q, "AD01", 0},
{XK_w, XK_W, "AD02", 0},
{XK_e, XK_E, "AD03", 0},
{XK_r, XK_R, "AD04", 0},
{XK_t, XK_T, "AD05", 0},
{XK_y, XK_Y, "AD06", 0},
{XK_u, XK_U, "AD07", 0},
{XK_i, XK_I, "AD08", 0},
{XK_o, XK_O, "AD09", 0},
{XK_p, XK_P, "AD10", 0},
{XK_bracketleft, XK_braceleft, "AD11", 0},
{XK_bracketright, XK_braceright, "AD12", 0},
{XK_Return, NoSymbol, "RTRN", 0},
{XK_Caps_Lock, NoSymbol, "CAPS", 0},
{XK_a, XK_A, "AC01", 0},
{XK_s, XK_S, "AC02", 0},
{XK_d, XK_D, "AC03", 0},
{XK_f, XK_F, "AC04", 0},
{XK_g, XK_G, "AC05", 0},
{XK_h, XK_H, "AC06", 0},
{XK_j, XK_J, "AC07", 0},
{XK_k, XK_K, "AC08", 0},
{XK_l, XK_L, "AC09", 0},
{XK_semicolon, XK_colon, "AC10", 0},
{XK_quoteright, XK_quotedbl, "AC11", 0},
{XK_Shift_L, NoSymbol, "LFSH", 0},
{XK_z, XK_Z, "AB01", 0},
{XK_x, XK_X, "AB02", 0},
{XK_c, XK_C, "AB03", 0},
{XK_v, XK_V, "AB04", 0},
{XK_b, XK_B, "AB05", 0},
{XK_n, XK_N, "AB06", 0},
{XK_m, XK_M, "AB07", 0},
{XK_comma, XK_less, "AB08", 0},
{XK_period, XK_greater, "AB09", 0},
{XK_slash, XK_question, "AB10", 0},
{XK_backslash, XK_bar, "BKSL", 0},
{XK_Control_L, NoSymbol, "LCTL", 0},
{XK_space, NoSymbol, "SPCE", 0},
{XK_Shift_R, NoSymbol, "RTSH", 0},
{XK_Alt_L, NoSymbol, "LALT", 0},
{XK_space, NoSymbol, "SPCE", 0},
{XK_Control_R, NoSymbol, "RCTL", 0},
{XK_Alt_R, NoSymbol, "RALT", 0},
{XK_F1, NoSymbol, "FK01", 0},
{XK_F2, NoSymbol, "FK02", 0},
{XK_F3, NoSymbol, "FK03", 0},
{XK_F4, NoSymbol, "FK04", 0},
{XK_F5, NoSymbol, "FK05", 0},
{XK_F6, NoSymbol, "FK06", 0},
{XK_F7, NoSymbol, "FK07", 0},
{XK_F8, NoSymbol, "FK08", 0},
{XK_F9, NoSymbol, "FK09", 0},
{XK_F10, NoSymbol, "FK10", 0},
{XK_F11, NoSymbol, "FK11", 0},
{XK_F12, NoSymbol, "FK12", 0},
{XK_Print, NoSymbol, "PRSC", 0},
{XK_Scroll_Lock, NoSymbol, "SCLK", 0},
{XK_Pause, NoSymbol, "PAUS", 0},
{XK_Insert, NoSymbol, "INS\0", 0},
{XK_Home, NoSymbol, "HOME", 0},
{XK_Prior, NoSymbol, "PGUP", 0},
{XK_Delete, NoSymbol, "DELE", 0},
{XK_End, NoSymbol, "END", 0},
{XK_Next, NoSymbol, "PGDN", 0},
{XK_Up, NoSymbol, "UP\0\0", 0},
{XK_Left, NoSymbol, "LEFT", 0},
{XK_Down, NoSymbol, "DOWN", 0},
{XK_Right, NoSymbol, "RGHT", 0},
{XK_Num_Lock, NoSymbol, "NMLK", 0},
{XK_KP_Divide, NoSymbol, "KPDV", 0},
{XK_KP_Multiply, NoSymbol, "KPMU", 0},
{XK_KP_Subtract, NoSymbol, "KPSU", 0},
{NoSymbol, XK_KP_7, "KP7\0", 0},
{NoSymbol, XK_KP_8, "KP8\0", 0},
{NoSymbol, XK_KP_9, "KP9\0", 0},
{XK_KP_Add, NoSymbol, "KPAD", 0},
{NoSymbol, XK_KP_4, "KP4\0", 0},
{NoSymbol, XK_KP_5, "KP5\0", 0},
{NoSymbol, XK_KP_6, "KP6\0", 0},
{NoSymbol, XK_KP_1, "KP1\0", 0},
{NoSymbol, XK_KP_2, "KP2\0", 0},
{NoSymbol, XK_KP_3, "KP3\0", 0},
{XK_KP_Enter, NoSymbol, "KPEN", 0},
{NoSymbol, XK_KP_0, "KP0\0", 0},
{XK_KP_Delete, NoSymbol, "KPDL", 0},
{XK_less, XK_greater, "LSGT", 0},
{XK_KP_Separator, NoSymbol, "KPCO", 0},
{XK_Find, NoSymbol, "FIND", 0},
{NoSymbol, NoSymbol, "\0\0\0\0", 0}
{XK_Escape, NoSymbol, "ESC\0"},
{XK_quoteleft, XK_asciitilde, "TLDE"},
{XK_1, XK_exclam, "AE01"},
{XK_2, XK_at, "AE02"},
{XK_3, XK_numbersign, "AE03"},
{XK_4, XK_dollar, "AE04"},
{XK_5, XK_percent, "AE05"},
{XK_6, XK_asciicircum, "AE06"},
{XK_7, XK_ampersand, "AE07"},
{XK_8, XK_asterisk, "AE08"},
{XK_9, XK_parenleft, "AE09"},
{XK_0, XK_parenright, "AE10"},
{XK_minus, XK_underscore, "AE11"},
{XK_equal, XK_plus, "AE12"},
{XK_BackSpace, NoSymbol, "BKSP"},
{XK_Tab, NoSymbol, "TAB\0"},
{XK_q, XK_Q, "AD01"},
{XK_w, XK_W, "AD02"},
{XK_e, XK_E, "AD03"},
{XK_r, XK_R, "AD04"},
{XK_t, XK_T, "AD05"},
{XK_y, XK_Y, "AD06"},
{XK_u, XK_U, "AD07"},
{XK_i, XK_I, "AD08"},
{XK_o, XK_O, "AD09"},
{XK_p, XK_P, "AD10"},
{XK_bracketleft, XK_braceleft, "AD11"},
{XK_bracketright, XK_braceright, "AD12"},
{XK_Return, NoSymbol, "RTRN"},
{XK_Caps_Lock, NoSymbol, "CAPS"},
{XK_a, XK_A, "AC01"},
{XK_s, XK_S, "AC02"},
{XK_d, XK_D, "AC03"},
{XK_f, XK_F, "AC04"},
{XK_g, XK_G, "AC05"},
{XK_h, XK_H, "AC06"},
{XK_j, XK_J, "AC07"},
{XK_k, XK_K, "AC08"},
{XK_l, XK_L, "AC09"},
{XK_semicolon, XK_colon, "AC10"},
{XK_quoteright, XK_quotedbl, "AC11"},
{XK_Shift_L, NoSymbol, "LFSH"},
{XK_z, XK_Z, "AB01"},
{XK_x, XK_X, "AB02"},
{XK_c, XK_C, "AB03"},
{XK_v, XK_V, "AB04"},
{XK_b, XK_B, "AB05"},
{XK_n, XK_N, "AB06"},
{XK_m, XK_M, "AB07"},
{XK_comma, XK_less, "AB08"},
{XK_period, XK_greater, "AB09"},
{XK_slash, XK_question, "AB10"},
{XK_backslash, XK_bar, "BKSL"},
{XK_Control_L, NoSymbol, "LCTL"},
{XK_space, NoSymbol, "SPCE"},
{XK_Shift_R, NoSymbol, "RTSH"},
{XK_Alt_L, NoSymbol, "LALT"},
{XK_space, NoSymbol, "SPCE"},
{XK_Control_R, NoSymbol, "RCTL"},
{XK_Alt_R, NoSymbol, "RALT"},
{XK_F1, NoSymbol, "FK01"},
{XK_F2, NoSymbol, "FK02"},
{XK_F3, NoSymbol, "FK03"},
{XK_F4, NoSymbol, "FK04"},
{XK_F5, NoSymbol, "FK05"},
{XK_F6, NoSymbol, "FK06"},
{XK_F7, NoSymbol, "FK07"},
{XK_F8, NoSymbol, "FK08"},
{XK_F9, NoSymbol, "FK09"},
{XK_F10, NoSymbol, "FK10"},
{XK_F11, NoSymbol, "FK11"},
{XK_F12, NoSymbol, "FK12"},
{XK_Print, NoSymbol, "PRSC"},
{XK_Scroll_Lock, NoSymbol, "SCLK"},
{XK_Pause, NoSymbol, "PAUS"},
{XK_Insert, NoSymbol, "INS\0"},
{XK_Home, NoSymbol, "HOME"},
{XK_Prior, NoSymbol, "PGUP"},
{XK_Delete, NoSymbol, "DELE"},
{XK_End, NoSymbol, "END"},
{XK_Next, NoSymbol, "PGDN"},
{XK_Up, NoSymbol, "UP\0\0"},
{XK_Left, NoSymbol, "LEFT"},
{XK_Down, NoSymbol, "DOWN"},
{XK_Right, NoSymbol, "RGHT"},
{XK_Num_Lock, NoSymbol, "NMLK"},
{XK_KP_Divide, NoSymbol, "KPDV"},
{XK_KP_Multiply, NoSymbol, "KPMU"},
{XK_KP_Subtract, NoSymbol, "KPSU"},
{NoSymbol, XK_KP_7, "KP7\0"},
{NoSymbol, XK_KP_8, "KP8\0"},
{NoSymbol, XK_KP_9, "KP9\0"},
{XK_KP_Add, NoSymbol, "KPAD"},
{NoSymbol, XK_KP_4, "KP4\0"},
{NoSymbol, XK_KP_5, "KP5\0"},
{NoSymbol, XK_KP_6, "KP6\0"},
{NoSymbol, XK_KP_1, "KP1\0"},
{NoSymbol, XK_KP_2, "KP2\0"},
{NoSymbol, XK_KP_3, "KP3\0"},
{XK_KP_Enter, NoSymbol, "KPEN"},
{NoSymbol, XK_KP_0, "KP0\0"},
{XK_KP_Delete, NoSymbol, "KPDL"},
{XK_less, XK_greater, "LSGT"},
{XK_KP_Separator, NoSymbol, "KPCO"},
{XK_Find, NoSymbol, "FIND"},
{NoSymbol, NoSymbol, "\0\0\0\0"}
};
Status
ComputeKbdDefaults(XkbDescPtr xkb)
{
int nUnknown;
Status rtrn;
register int i, tmp, nUnknown;
KeyNameDesc *name;
KeySym *syms;
char tmpname[XkbKeyNameLength + 1];
if ((xkb->names == NULL) || (xkb->names->keys == NULL))
{
Status rtrn;
if ((rtrn = XkbAllocNames(xkb, XkbKeyNamesMask, 0, 0)) != Success)
return rtrn;
}
for (KeyNameDesc *name = dfltKeys; (name->name[0] != '\0'); name++)
for (name = dfltKeys; (name->name[0] != '\0'); name++)
{
name->used = False;
}
nUnknown = 0;
for (int i = xkb->min_key_code; i <= xkb->max_key_code; i++)
for (i = xkb->min_key_code; i <= xkb->max_key_code; i++)
{
int tmp = XkbKeyNumSyms(xkb, i);
tmp = XkbKeyNumSyms(xkb, i);
if ((xkb->names->keys[i].name[0] == '\0') && (tmp > 0))
{
KeySym *syms;
tmp = XkbKeyGroupsWidth(xkb, i);
syms = XkbKeySymsPtr(xkb, i);
for (KeyNameDesc *name = dfltKeys; (name->name[0] != '\0'); name++)
for (name = dfltKeys; (name->name[0] != '\0'); name++)
{
Bool match = True;
if (((name->level1 != syms[0])
@ -450,8 +444,6 @@ ComputeKbdDefaults(XkbDescPtr xkb)
}
else
{
char tmpname[XkbKeyNameLength + 1];
if (warningLevel > 2)
{
WARN
@ -472,8 +464,6 @@ ComputeKbdDefaults(XkbDescPtr xkb)
{
if (warningLevel > 2)
{
char tmpname[XkbKeyNameLength + 1];
WARN("Key %d does not match any defaults\n", i);
ACTION("Using name <U%03d>\n", nUnknown);
snprintf(tmpname, sizeof(tmpname), "U%03d", nUnknown++);
@ -504,6 +494,8 @@ FindNamedKey(XkbDescPtr xkb,
unsigned int *kc_rtrn,
Bool use_aliases, Bool create, int start_from)
{
register unsigned n;
if (start_from < xkb->min_key_code)
{
start_from = xkb->min_key_code;
@ -516,7 +508,7 @@ FindNamedKey(XkbDescPtr xkb,
*kc_rtrn = 0; /* some callers rely on this */
if (xkb && xkb->names && xkb->names->keys)
{
for (unsigned n = start_from; n <= xkb->max_key_code; n++)
for (n = start_from; n <= xkb->max_key_code; n++)
{
unsigned long tmp;
tmp = KeyNameToLong(xkb->names->keys[n].name);
@ -554,7 +546,7 @@ FindNamedKey(XkbDescPtr xkb,
}
}
/* Find first unused keycode and store our key here */
for (unsigned n = xkb->min_key_code; n <= xkb->max_key_code; n++)
for (n = xkb->min_key_code; n <= xkb->max_key_code; n++)
{
if (xkb->names->keys[n].name[0] == '\0')
{
@ -573,6 +565,7 @@ Bool
FindKeyNameForAlias(XkbDescPtr xkb, unsigned long lname,
unsigned long *real_name)
{
register int i;
char name[XkbKeyNameLength + 1];
if (xkb && xkb->geom && xkb->geom->key_aliases)
@ -581,7 +574,7 @@ FindKeyNameForAlias(XkbDescPtr xkb, unsigned long lname,
a = xkb->geom->key_aliases;
LongToKeyName(lname, name);
name[XkbKeyNameLength] = '\0';
for (int i = 0; i < xkb->geom->num_key_aliases; i++, a++)
for (i = 0; i < xkb->geom->num_key_aliases; i++, a++)
{
if (strncmp(name, a->alias, XkbKeyNameLength) == 0)
{
@ -596,7 +589,7 @@ FindKeyNameForAlias(XkbDescPtr xkb, unsigned long lname,
a = xkb->names->key_aliases;
LongToKeyName(lname, name);
name[XkbKeyNameLength] = '\0';
for (int i = 0; i < xkb->names->num_key_aliases; i++, a++)
for (i = 0; i < xkb->names->num_key_aliases; i++, a++)
{
if (strncmp(name, a->alias, XkbKeyNameLength) == 0)
{

View file

@ -36,8 +36,14 @@ typedef struct _CommonInfo
} CommonInfo;
extern Bool UseNewField(unsigned /* field */ ,
const CommonInfo * /* oldDefs */ ,
const CommonInfo * /* newDefs */ ,
CommonInfo * /* oldDefs */ ,
CommonInfo * /* newDefs */ ,
unsigned * /* pCollide */
);
extern Bool MergeNewField(unsigned /* field */ ,
CommonInfo * /* oldDefs */ ,
CommonInfo * /* newDefs */ ,
unsigned * /* pCollide */
);

View file

@ -57,15 +57,13 @@ ExprDef *
ExprCreate(unsigned op, unsigned type)
{
ExprDef *expr;
expr = malloc(sizeof(ExprDef));
expr = uTypedAlloc(ExprDef);
if (expr)
{
*expr = (ExprDef) {
.common.stmtType = StmtExpr,
.common.next = NULL,
.op = op,
.type = type
};
expr->common.stmtType = StmtExpr;
expr->common.next = NULL;
expr->op = op;
expr->type = type;
}
else
{
@ -79,16 +77,14 @@ ExprDef *
ExprCreateUnary(unsigned op, unsigned type, ExprDef * child)
{
ExprDef *expr;
expr = malloc(sizeof(ExprDef));
expr = uTypedAlloc(ExprDef);
if (expr)
{
*expr = (ExprDef) {
.common.stmtType = StmtExpr,
.common.next = NULL,
.op = op,
.type = type,
.value.child = child
};
expr->common.stmtType = StmtExpr;
expr->common.next = NULL;
expr->op = op;
expr->type = type;
expr->value.child = child;
}
else
{
@ -102,22 +98,20 @@ ExprDef *
ExprCreateBinary(unsigned op, ExprDef * left, ExprDef * right)
{
ExprDef *expr;
expr = malloc(sizeof(ExprDef));
expr = uTypedAlloc(ExprDef);
if (expr)
{
*expr = (ExprDef) {
.common.stmtType = StmtExpr,
.common.next = NULL,
.op = op,
.type = TypeUnknown,
.value.binary.left = left,
.value.binary.right = right
};
expr->common.stmtType = StmtExpr;
expr->common.next = NULL;
expr->op = op;
if ((op == OpAssign) || (left->type == TypeUnknown))
expr->type = right->type;
else if ((left->type == right->type) || (right->type == TypeUnknown))
expr->type = left->type;
else
expr->type = TypeUnknown;
expr->value.binary.left = left;
expr->value.binary.right = right;
}
else
{
@ -128,20 +122,18 @@ ExprCreateBinary(unsigned op, ExprDef * left, ExprDef * right)
}
KeycodeDef *
KeycodeCreate(const char *name, ExprDef *value)
KeycodeCreate(char *name, ExprDef * value)
{
KeycodeDef *def;
def = malloc(sizeof(KeycodeDef));
def = uTypedAlloc(KeycodeDef);
if (def)
{
*def = (KeycodeDef) {
.common.stmtType = StmtKeycodeDef,
.common.next = NULL,
.value = value
};
def->common.stmtType = StmtKeycodeDef;
def->common.next = NULL;
strncpy(def->name, name, XkbKeyNameLength);
def->name[XkbKeyNameLength] = '\0';
def->value = value;
}
else
{
@ -152,17 +144,15 @@ KeycodeCreate(const char *name, ExprDef *value)
}
KeyAliasDef *
KeyAliasCreate(const char *alias, const char *real)
KeyAliasCreate(char *alias, char *real)
{
KeyAliasDef *def;
def = malloc(sizeof(KeyAliasDef));
def = uTypedAlloc(KeyAliasDef);
if (def)
{
*def = (KeyAliasDef) {
.common.stmtType = StmtKeyAliasDef,
.common.next = NULL,
};
def->common.stmtType = StmtKeyAliasDef;
def->common.next = NULL;
strncpy(def->alias, alias, XkbKeyNameLength);
def->alias[XkbKeyNameLength] = '\0';
strncpy(def->real, real, XkbKeyNameLength);
@ -180,15 +170,13 @@ VModDef *
VModCreate(Atom name, ExprDef * value)
{
VModDef *def;
def = malloc(sizeof(VModDef));
def = uTypedAlloc(VModDef);
if (def)
{
*def = (VModDef) {
.common.stmtType = StmtVModDef,
.common.next = NULL,
.name = name,
.value = value
};
def->common.stmtType = StmtVModDef;
def->common.next = NULL;
def->name = name;
def->value = value;
}
else
{
@ -202,15 +190,13 @@ VarDef *
VarCreate(ExprDef * name, ExprDef * value)
{
VarDef *def;
def = malloc(sizeof(VarDef));
def = uTypedAlloc(VarDef);
if (def)
{
*def = (VarDef) {
.common.stmtType = StmtVarDef,
.common.next = NULL,
.name = name,
.value = value
};
def->common.stmtType = StmtVarDef;
def->common.next = NULL;
def->name = name;
def->value = value;
}
else
{
@ -237,18 +223,16 @@ InterpCreate(const char *sym_str, ExprDef * match)
{
InterpDef *def;
def = malloc(sizeof(InterpDef));
def = uTypedAlloc(InterpDef);
if (def)
{
*def = (InterpDef) {
.common.stmtType = StmtInterpDef,
.common.next = NULL,
.match = match
};
def->common.stmtType = StmtInterpDef;
def->common.next = NULL;
if (LookupKeysym(sym_str, &def->sym) == 0)
def->ignore = True;
else
def->ignore = False;
def->match = match;
}
else
{
@ -263,16 +247,14 @@ KeyTypeCreate(Atom name, VarDef * body)
{
KeyTypeDef *def;
def = malloc(sizeof(KeyTypeDef));
def = uTypedAlloc(KeyTypeDef);
if (def)
{
*def = (KeyTypeDef) {
.common.stmtType = StmtKeyTypeDef,
.common.next = NULL,
.merge = MergeDefault,
.name = name,
.body = body
};
def->common.stmtType = StmtKeyTypeDef;
def->common.next = NULL;
def->merge = MergeDefault;
def->name = name;
def->body = body;
}
else
{
@ -287,17 +269,15 @@ SymbolsCreate(char *keyName, ExprDef * symbols)
{
SymbolsDef *def;
def = malloc(sizeof(SymbolsDef));
def = uTypedAlloc(SymbolsDef);
if (def)
{
*def = (SymbolsDef) {
.common.stmtType = StmtSymbolsDef,
.common.next = NULL,
.merge = MergeDefault,
.symbols = symbols
};
def->common.stmtType = StmtSymbolsDef;
def->common.next = NULL;
def->merge = MergeDefault;
bzero(def->keyName, 5);
strncpy(def->keyName, keyName, 4);
def->keyName[4] = 0;
def->symbols = symbols;
}
else
{
@ -312,16 +292,14 @@ GroupCompatCreate(int group, ExprDef * val)
{
GroupCompatDef *def;
def = malloc(sizeof(GroupCompatDef));
def = uTypedAlloc(GroupCompatDef);
if (def)
{
*def = (GroupCompatDef) {
.common.stmtType = StmtGroupCompatDef,
.common.next = NULL,
.merge = MergeDefault,
.group = group,
.def = val
};
def->common.stmtType = StmtGroupCompatDef;
def->common.next = NULL;
def->merge = MergeDefault;
def->group = group;
def->def = val;
}
else
{
@ -336,16 +314,14 @@ ModMapCreate(Atom modifier, ExprDef * keys)
{
ModMapDef *def;
def = malloc(sizeof(ModMapDef));
def = uTypedAlloc(ModMapDef);
if (def)
{
*def = (ModMapDef) {
.common.stmtType = StmtModMapDef,
.common.next = NULL,
.merge = MergeDefault,
.modifier = modifier,
.keys = keys
};
def->common.stmtType = StmtModMapDef;
def->common.next = NULL;
def->merge = MergeDefault;
def->modifier = modifier;
def->keys = keys;
}
else
{
@ -360,16 +336,14 @@ IndicatorMapCreate(Atom name, VarDef * body)
{
IndicatorMapDef *def;
def = malloc(sizeof(IndicatorMapDef));
def = uTypedAlloc(IndicatorMapDef);
if (def)
{
*def = (IndicatorMapDef) {
.common.stmtType = StmtIndicatorMapDef,
.common.next = NULL,
.merge = MergeDefault,
.name = name,
.body = body
};
def->common.stmtType = StmtIndicatorMapDef;
def->common.next = NULL;
def->merge = MergeDefault;
def->name = name;
def->body = body;
}
else
{
@ -384,17 +358,15 @@ IndicatorNameCreate(int ndx, ExprDef * name, Bool virtual)
{
IndicatorNameDef *def;
def = malloc(sizeof(IndicatorNameDef));
def = uTypedAlloc(IndicatorNameDef);
if (def)
{
*def = (IndicatorNameDef) {
.common.stmtType = StmtIndicatorNameDef,
.common.next = NULL,
.merge = MergeDefault,
.ndx = ndx,
.name = name,
.virtual = virtual
};
def->common.stmtType = StmtIndicatorNameDef;
def->common.next = NULL;
def->merge = MergeDefault;
def->ndx = ndx;
def->name = name;
def->virtual = virtual;
}
else
{
@ -409,16 +381,14 @@ ActionCreate(Atom name, ExprDef * args)
{
ExprDef *act;
act = malloc(sizeof(ExprDef));
act = uTypedAlloc(ExprDef);
if (act)
{
*act = (ExprDef) {
.common.stmtType = StmtExpr,
.common.next = NULL,
.op = ExprActionDecl,
.value.action.name = name,
.value.action.args = args
};
act->common.stmtType = StmtExpr;
act->common.next = NULL;
act->op = ExprActionDecl;
act->value.action.name = name;
act->value.action.args = args;
return act;
}
FATAL("Couldn't allocate ActionDef in parser\n");
@ -435,7 +405,7 @@ CreateKeysymList(char *sym)
{
def->value.list.nSyms = 1;
def->value.list.szSyms = 4;
def->value.list.syms = calloc(4, sizeof(char *));
def->value.list.syms = uTypedCalloc(4, char *);
if (def->value.list.syms != NULL)
{
def->value.list.syms[0] = sym;
@ -450,20 +420,19 @@ ShapeDef *
ShapeDeclCreate(Atom name, OutlineDef * outlines)
{
ShapeDef *shape;
OutlineDef *ol;
shape = calloc(1, sizeof(ShapeDef));
shape = uTypedAlloc(ShapeDef);
if (shape != NULL)
{
*shape = (ShapeDef) {
.common.stmtType = StmtShapeDef,
.common.next = NULL,
.merge = MergeDefault,
.name = name,
.nOutlines = 0,
.outlines = outlines
};
for (OutlineDef *ol = outlines; ol != NULL;
ol = (OutlineDef *) ol->common.next)
bzero(shape, sizeof(ShapeDef));
shape->common.stmtType = StmtShapeDef;
shape->common.next = NULL;
shape->merge = MergeDefault;
shape->name = name;
shape->nOutlines = 0;
shape->outlines = outlines;
for (ol = outlines; ol != NULL; ol = (OutlineDef *) ol->common.next)
{
if (ol->nPoints > 0)
shape->nOutlines++;
@ -476,25 +445,24 @@ OutlineDef *
OutlineCreate(Atom field, ExprDef * points)
{
OutlineDef *outline;
ExprDef *pt;
outline = calloc(1, sizeof(OutlineDef));
outline = uTypedAlloc(OutlineDef);
if (outline != NULL)
{
*outline = (OutlineDef) {
.common.stmtType = StmtOutlineDef,
.common.next = NULL,
.field = field,
.nPoints = 0,
.points = points
};
bzero(outline, sizeof(OutlineDef));
outline->common.stmtType = StmtOutlineDef;
outline->common.next = NULL;
outline->field = field;
outline->nPoints = 0;
if (points->op == ExprCoord)
{
for (ExprDef *pt = points; pt != NULL;
pt = (ExprDef *) pt->common.next)
for (pt = points; pt != NULL; pt = (ExprDef *) pt->common.next)
{
outline->nPoints++;
}
}
outline->points = points;
}
return outline;
}
@ -504,13 +472,12 @@ KeyDeclCreate(char *name, ExprDef * expr)
{
KeyDef *key;
key = calloc(1, sizeof(KeyDef));
key = uTypedAlloc(KeyDef);
if (key != NULL)
{
*key = (KeyDef) {
.common.stmtType = StmtKeyDef,
.common.next = NULL,
};
bzero(key, sizeof(KeyDef));
key->common.stmtType = StmtKeyDef;
key->common.next = NULL;
if (name)
key->name = name;
else
@ -519,33 +486,31 @@ KeyDeclCreate(char *name, ExprDef * expr)
return key;
}
#if 0
KeyDef *
KeyDeclMerge(KeyDef * into, KeyDef * from)
{
into->expr =
(ExprDef *) AppendStmt(&into->expr->common, &from->expr->common);
from->expr = NULL;
free(from);
uFree(from);
return into;
}
#endif
RowDef *
RowDeclCreate(KeyDef * keys)
{
RowDef *row;
KeyDef *key;
row = calloc(1, sizeof(RowDef));
row = uTypedAlloc(RowDef);
if (row != NULL)
{
*row = (RowDef) {
.common.stmtType = StmtRowDef,
.common.next = NULL,
.nKeys = 0,
.keys = keys
};
for (KeyDef *key = keys; key != NULL; key = (KeyDef *) key->common.next)
bzero(row, sizeof(RowDef));
row->common.stmtType = StmtRowDef;
row->common.next = NULL;
row->nKeys = 0;
row->keys = keys;
for (key = keys; key != NULL; key = (KeyDef *) key->common.next)
{
if (key->common.stmtType == StmtKeyDef)
row->nKeys++;
@ -558,18 +523,18 @@ SectionDef *
SectionDeclCreate(Atom name, RowDef * rows)
{
SectionDef *section;
RowDef *row;
section = calloc(1, sizeof(SectionDef));
section = uTypedAlloc(SectionDef);
if (section != NULL)
{
*section = (SectionDef) {
.common.stmtType = StmtSectionDef,
.common.next = NULL,
.name = name,
.nRows = 0,
.rows = rows
};
for (RowDef *row = rows; row != NULL; row = (RowDef *) row->common.next)
bzero(section, sizeof(SectionDef));
section->common.stmtType = StmtSectionDef;
section->common.next = NULL;
section->name = name;
section->nRows = 0;
section->rows = rows;
for (row = rows; row != NULL; row = (RowDef *) row->common.next)
{
if (row->common.stmtType == StmtRowDef)
section->nRows++;
@ -583,16 +548,15 @@ OverlayKeyCreate(char *under, char *over)
{
OverlayKeyDef *key;
key = calloc(1, sizeof(OverlayKeyDef));
key = uTypedAlloc(OverlayKeyDef);
if (key != NULL)
{
*key = (OverlayKeyDef) {
.common.stmtType = StmtOverlayKeyDef
};
bzero(key, sizeof(OverlayKeyDef));
key->common.stmtType = StmtOverlayKeyDef;
strncpy(key->over, over, XkbKeyNameLength);
strncpy(key->under, under, XkbKeyNameLength);
free(over);
free(under);
uFree(over);
uFree(under);
}
return key;
}
@ -601,16 +565,16 @@ OverlayDef *
OverlayDeclCreate(Atom name, OverlayKeyDef * keys)
{
OverlayDef *ol;
OverlayKeyDef *key;
ol = calloc(1, sizeof(OverlayDef));
ol = uTypedAlloc(OverlayDef);
if (ol != NULL)
{
*ol = (OverlayDef) {
.common.stmtType = StmtOverlayDef,
.name = name,
.keys = keys
};
for (OverlayKeyDef *key = keys; key != NULL;
bzero(ol, sizeof(OverlayDef));
ol->common.stmtType = StmtOverlayDef;
ol->name = name;
ol->keys = keys;
for (key = keys; key != NULL;
key = (OverlayKeyDef *) key->common.next)
{
ol->nKeys++;
@ -624,16 +588,15 @@ DoodadCreate(unsigned type, Atom name, VarDef * body)
{
DoodadDef *doodad;
doodad = calloc(1, sizeof(DoodadDef));
doodad = uTypedAlloc(DoodadDef);
if (doodad != NULL)
{
*doodad = (DoodadDef) {
.common.stmtType = StmtDoodadDef,
.common.next = NULL,
.type = type,
.name = name,
.body = body
};
bzero(doodad, sizeof(DoodadDef));
doodad->common.stmtType = StmtDoodadDef;
doodad->common.next = NULL;
doodad->type = type;
doodad->name = name;
doodad->body = body;
}
return doodad;
}
@ -644,10 +607,10 @@ AppendKeysymList(ExprDef * list, char *sym)
if (list->value.list.nSyms >= list->value.list.szSyms)
{
list->value.list.szSyms *= 2;
list->value.list.syms = recallocarray(list->value.list.syms,
list->value.list.syms = uTypedRecalloc(list->value.list.syms,
list->value.list.nSyms,
list->value.list.szSyms,
sizeof(char *));
char *);
if (list->value.list.syms == NULL)
{
FATAL("Couldn't resize list of symbols for append\n");
@ -662,6 +625,7 @@ int
LookupKeysym(const char *str, KeySym * sym_rtrn)
{
KeySym sym;
char *tmp;
if ((!str) || (uStrCaseCmp(str, "any") == 0)
|| (uStrCaseCmp(str, "nosymbol") == 0))
@ -682,8 +646,6 @@ LookupKeysym(const char *str, KeySym * sym_rtrn)
return 1;
}
if (strlen(str) > 2 && str[0] == '0' && str[1] == 'x') {
char *tmp;
sym = strtoul(str, &tmp, 16);
if (sym != ULONG_MAX && (!tmp || *tmp == '\0')) {
*sym_rtrn = sym;
@ -717,25 +679,23 @@ IncludeCreate(char *str, unsigned merge)
haveSelf = True;
}
if (first == NULL)
first = incl = malloc(sizeof(IncludeStmt));
first = incl = uTypedAlloc(IncludeStmt);
else
{
incl->next = malloc(sizeof(IncludeStmt));
incl->next = uTypedAlloc(IncludeStmt);
incl = incl->next;
}
if (incl)
{
*incl = (IncludeStmt) {
.common.stmtType = StmtInclude,
.common.next = NULL,
.merge = merge,
.stmt = NULL,
.file = file,
.map = map,
.modifier = extra_data,
.path = NULL,
.next = NULL
};
incl->common.stmtType = StmtInclude;
incl->common.next = NULL;
incl->merge = merge;
incl->stmt = NULL;
incl->file = file;
incl->map = map;
incl->modifier = extra_data;
incl->path = NULL;
incl->next = NULL;
}
else
{
@ -756,7 +716,7 @@ IncludeCreate(char *str, unsigned merge)
if (first)
first->stmt = stmt;
else if (stmt)
free(stmt);
uFree(stmt);
return first;
BAIL:
ERROR("Illegal include statement \"%s\"\n", stmt);
@ -764,16 +724,20 @@ IncludeCreate(char *str, unsigned merge)
while (first)
{
incl = first->next;
free(first->file);
free(first->map);
free(first->modifier);
free(first->path);
first->file = first->map = first->modifier = first->path = NULL;
free(first);
if (first->file)
uFree(first->file);
if (first->map)
uFree(first->map);
if (first->modifier)
uFree(first->modifier);
if (first->path)
uFree(first->path);
first->file = first->map = first->path = NULL;
uFree(first);
first = incl;
}
if (stmt)
free(stmt);
uFree(stmt);
return NULL;
}
@ -798,9 +762,10 @@ PrintStmtAddrs(ParseCommon * stmt)
static void
CheckDefaultMap(XkbFile * maps)
{
XkbFile *dflt = NULL;
XkbFile *dflt, *tmp;
for (XkbFile *tmp = maps; tmp != NULL;
dflt = NULL;
for (tmp = maps, dflt = NULL; tmp != NULL;
tmp = (XkbFile *) tmp->common.next)
{
if (tmp->flags & XkbLC_Default)
@ -851,19 +816,18 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags)
XkbFile *file;
static int fileID;
file = calloc(1, sizeof(XkbFile));
file = uTypedAlloc(XkbFile);
if (file)
{
XkbEnsureSafeMapName(name);
*file = (XkbFile) {
.type = type,
.topName = uStringDup(name),
.name = name,
.defs = defs,
.id = fileID++,
.compiled = False,
.flags = flags
};
bzero(file, sizeof(XkbFile));
file->type = type;
file->topName = uStringDup(name);
file->name = name;
file->defs = defs;
file->id = fileID++;
file->compiled = False;
file->flags = flags;
}
return file;
}

View file

@ -68,12 +68,12 @@ extern ExprDef *ExprCreateBinary(unsigned /* op */ ,
ExprDef * /* right */
);
extern KeycodeDef *KeycodeCreate(const char * /* name */ ,
extern KeycodeDef *KeycodeCreate(char * /* name */ ,
ExprDef * /* value */
);
extern KeyAliasDef *KeyAliasCreate(const char * /* alias */ ,
const char * /* real */
extern KeyAliasDef *KeyAliasCreate(char * /* alias */ ,
char * /* real */
);
extern VModDef *VModCreate(Atom /* name */ ,

View file

@ -81,6 +81,7 @@ typedef struct _KeyInfo
static void
InitKeyInfo(KeyInfo * info)
{
register int i;
static char dflt[4] = "*";
info->defs.defined = 0;
@ -90,7 +91,7 @@ InitKeyInfo(KeyInfo * info)
info->name = KeyNameToLong(dflt);
info->groupInfo = 0;
info->typesDefined = info->symsDefined = info->actsDefined = 0;
for (int i = 0; i < XkbNumKbdGroups; i++)
for (i = 0; i < XkbNumKbdGroups; i++)
{
info->numLevels[i] = 0;
info->types[i] = None;
@ -113,19 +114,23 @@ InitKeyInfo(KeyInfo * info)
static void
FreeKeyInfo(KeyInfo * info)
{
register int i;
info->defs.defined = 0;
info->defs.fileID = 0;
info->defs.merge = MergeOverride;
info->defs.next = NULL;
info->groupInfo = 0;
info->typesDefined = info->symsDefined = info->actsDefined = 0;
for (int i = 0; i < XkbNumKbdGroups; i++)
for (i = 0; i < XkbNumKbdGroups; i++)
{
info->numLevels[i] = 0;
info->types[i] = None;
free(info->syms[i]);
if (info->syms[i] != NULL)
uFree(info->syms[i]);
info->syms[i] = NULL;
free(info->acts[i]);
if (info->acts[i] != NULL)
uFree(info->acts[i]);
info->acts[i] = NULL;
}
info->dfltType = None;
@ -146,11 +151,13 @@ FreeKeyInfo(KeyInfo * info)
static Bool
CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
{
register int i;
*new = *old;
new->defs.next = NULL;
if (clearOld)
{
for (int i = 0; i < XkbNumKbdGroups; i++)
for (i = 0; i < XkbNumKbdGroups; i++)
{
old->numLevels[i] = 0;
old->syms[i] = NULL;
@ -159,29 +166,32 @@ CopyKeyInfo(KeyInfo * old, KeyInfo * new, Bool clearOld)
}
else
{
for (int i = 0; i < XkbNumKbdGroups; i++)
int width;
for (i = 0; i < XkbNumKbdGroups; i++)
{
int width = new->numLevels[i];
width = new->numLevels[i];
if (old->syms[i] != NULL)
{
new->syms[i] = calloc(width, sizeof(KeySym));
new->syms[i] = uTypedCalloc(width, KeySym);
if (!new->syms[i])
{
new->syms[i] = NULL;
new->numLevels[i] = 0;
return False;
}
memcpy(new->syms[i], old->syms[i], width * sizeof(KeySym));
memcpy((char *) new->syms[i], (char *) old->syms[i],
width * sizeof(KeySym));
}
if (old->acts[i] != NULL)
{
new->acts[i] = calloc(width, sizeof(XkbAction));
new->acts[i] = uTypedCalloc(width, XkbAction);
if (!new->acts[i])
{
new->acts[i] = NULL;
return False;
}
memcpy(new->acts[i], old->acts[i], width * sizeof(XkbAction));
memcpy((char *) new->acts[i], (char *) old->acts[i],
width * sizeof(XkbAction));
}
}
}
@ -227,6 +237,8 @@ typedef struct _SymbolsInfo
static void
InitSymbolsInfo(SymbolsInfo * info, XkbDescPtr xkb)
{
register int i;
tok_ONE_LEVEL = XkbInternAtom(NULL, "ONE_LEVEL", False);
tok_TWO_LEVEL = XkbInternAtom(NULL, "TWO_LEVEL", False);
tok_KEYPAD = XkbInternAtom(NULL, "KEYPAD", False);
@ -238,9 +250,9 @@ InitSymbolsInfo(SymbolsInfo * info, XkbDescPtr xkb)
info->groupInfo = 0;
info->szKeys = SYMBOLS_INIT_SIZE;
info->nKeys = 0;
info->keys = calloc(SYMBOLS_INIT_SIZE, sizeof(KeyInfo));
info->keys = uTypedCalloc(SYMBOLS_INIT_SIZE, KeyInfo);
info->modMap = NULL;
for (int i = 0; i < XkbNumKbdGroups; i++)
for (i = 0; i < XkbNumKbdGroups; i++)
info->groupNames[i] = None;
InitKeyInfo(&info->dflt);
InitVModInfo(&info->vmods, xkb);
@ -252,15 +264,18 @@ InitSymbolsInfo(SymbolsInfo * info, XkbDescPtr xkb)
static void
FreeSymbolsInfo(SymbolsInfo * info)
{
free(info->name);
register int i;
if (info->name)
uFree(info->name);
info->name = NULL;
if (info->keys)
{
for (int i = 0; i < info->nKeys; i++)
for (i = 0; i < info->nKeys; i++)
{
FreeKeyInfo(&info->keys[i]);
}
free(info->keys);
uFree(info->keys);
info->keys = NULL;
}
if (info->modMap)
@ -273,7 +288,7 @@ FreeSymbolsInfo(SymbolsInfo * info)
ClearAliases(&info->aliases);
info->aliases = NULL;
}
bzero(info, sizeof(SymbolsInfo));
bzero((char *) info, sizeof(SymbolsInfo));
return;
}
@ -292,18 +307,18 @@ ResizeKeyGroup(KeyInfo * key,
if ((key->syms[group] == NULL) || tooSmall)
{
key->syms[group] = recallocarray(key->syms[group],
key->syms[group] = uTypedRecalloc(key->syms[group],
key->numLevels[group], newWidth,
sizeof(KeySym));
KeySym);
if (!key->syms[group])
return False;
}
if (((forceActions) && (tooSmall || (key->acts[group] == NULL))) ||
(tooSmall && (key->acts[group] != NULL)))
{
key->acts[group] = recallocarray(key->acts[group],
key->acts[group] = uTypedRecalloc(key->acts[group],
key->numLevels[group], newWidth,
sizeof(XkbAction));
XkbAction);
if (!key->acts[group])
return False;
}
@ -318,6 +333,7 @@ MergeKeyGroups(SymbolsInfo * info,
KeySym *resultSyms;
XkbAction *resultActs;
int resultWidth;
register int i;
Bool report, clobber;
clobber = (from->defs.merge != MergeAugment);
@ -338,7 +354,7 @@ MergeKeyGroups(SymbolsInfo * info,
}
if (resultSyms == NULL)
{
resultSyms = calloc(resultWidth, sizeof(KeySym));
resultSyms = uTypedCalloc(resultWidth, KeySym);
if (!resultSyms)
{
WSGO("Could not allocate symbols for group merge\n");
@ -349,7 +365,7 @@ MergeKeyGroups(SymbolsInfo * info,
}
if ((resultActs == NULL) && (into->acts[group] || from->acts[group]))
{
resultActs = calloc(resultWidth, sizeof(XkbAction));
resultActs = uTypedCalloc(resultWidth, XkbAction);
if (!resultActs)
{
WSGO("Could not allocate actions for group merge\n");
@ -358,7 +374,7 @@ MergeKeyGroups(SymbolsInfo * info,
return False;
}
}
for (int i = 0; i < resultWidth; i++)
for (i = 0; i < resultWidth; i++)
{
KeySym fromSym, toSym;
if (from->syms[group] && (i < from->numLevels[group]))
@ -439,39 +455,42 @@ MergeKeyGroups(SymbolsInfo * info,
}
}
if ((into->syms[group] != NULL) && (resultSyms != into->syms[group]))
free(into->syms[group]);
uFree(into->syms[group]);
if ((from->syms[group] != NULL) && (resultSyms != from->syms[group]))
free(from->syms[group]);
uFree(from->syms[group]);
if ((into->acts[group] != NULL) && (resultActs != into->acts[group]))
free(into->acts[group]);
uFree(into->acts[group]);
if ((from->acts[group] != NULL) && (resultActs != from->acts[group]))
free(from->acts[group]);
uFree(from->acts[group]);
into->numLevels[group] = resultWidth;
into->syms[group] = resultSyms;
from->syms[group] = NULL;
into->acts[group] = resultActs;
from->acts[group] = NULL;
into->symsDefined |= (1U << group);
from->symsDefined &= ~(1U << group);
into->actsDefined |= (1U << group);
from->actsDefined &= ~(1U << group);
into->symsDefined |= (1 << group);
from->symsDefined &= ~(1 << group);
into->actsDefined |= (1 << group);
from->actsDefined &= ~(1 << group);
return True;
}
static Bool
MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
{
register int i;
unsigned collide = 0;
Bool report;
if (from->defs.merge == MergeReplace)
{
for (int i = 0; i < XkbNumKbdGroups; i++)
for (i = 0; i < XkbNumKbdGroups; i++)
{
if (into->numLevels[i] != 0)
{
free(into->syms[i]);
free(into->acts[i]);
if (into->syms[i])
uFree(into->syms[i]);
if (into->acts[i])
uFree(into->acts[i]);
}
}
*into = *from;
@ -481,7 +500,7 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
report = ((warningLevel > 9) ||
((into->defs.fileID == from->defs.fileID)
&& (warningLevel > 0)));
for (int i = 0; i < XkbNumKbdGroups; i++)
for (i = 0; i < XkbNumKbdGroups; i++)
{
if (from->numLevels[i] > 0)
{
@ -490,11 +509,11 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
into->numLevels[i] = from->numLevels[i];
into->syms[i] = from->syms[i];
into->acts[i] = from->acts[i];
into->symsDefined |= (1U << i);
into->symsDefined |= (1 << i);
from->syms[i] = NULL;
from->acts[i] = NULL;
from->numLevels[i] = 0;
from->symsDefined &= ~(1U << i);
from->symsDefined &= ~(1 << i);
if (into->syms[i])
into->defs.defined |= _Key_Syms;
if (into->acts[i])
@ -582,16 +601,17 @@ MergeKeys(SymbolsInfo * info, KeyInfo * into, KeyInfo * from)
static Bool
AddKeySymbols(SymbolsInfo * info, KeyInfo * key, XkbDescPtr xkb)
{
register int i;
unsigned long real_name;
for (int i = 0; i < info->nKeys; i++)
for (i = 0; i < info->nKeys; i++)
{
if (info->keys[i].name == key->name)
return MergeKeys(info, &info->keys[i], key);
}
if (FindKeyNameForAlias(xkb, key->name, &real_name))
{
for (int i = 0; i < info->nKeys; i++)
for (i = 0; i < info->nKeys; i++)
{
if (info->keys[i].name == real_name)
return MergeKeys(info, &info->keys[i], key);
@ -600,8 +620,8 @@ AddKeySymbols(SymbolsInfo * info, KeyInfo * key, XkbDescPtr xkb)
if (info->nKeys >= info->szKeys)
{
info->szKeys += SYMBOLS_CHUNK;
info->keys = recallocarray(info->keys, info->nKeys, info->szKeys,
sizeof(KeyInfo));
info->keys =
uTypedRecalloc(info->keys, info->nKeys, info->szKeys, KeyInfo);
if (!info->keys)
{
WSGO("Could not allocate key symbols descriptions\n");
@ -624,10 +644,9 @@ AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
if (new->haveSymbol && mm->haveSymbol
&& (new->u.keySym == mm->u.keySym))
{
unsigned use, ignore;
if (mm->modifier != new->modifier)
{
unsigned use, ignore;
if (clobber)
{
use = new->modifier;
@ -651,10 +670,9 @@ AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
if ((!new->haveSymbol) && (!mm->haveSymbol) &&
(new->u.keyName == mm->u.keyName))
{
unsigned use, ignore;
if (mm->modifier != new->modifier)
{
unsigned use, ignore;
if (clobber)
{
use = new->modifier;
@ -675,7 +693,7 @@ AddModMapEntry(SymbolsInfo * info, ModMapEntry * new)
return True;
}
}
mm = malloc(sizeof(ModMapEntry));
mm = uTypedAlloc(ModMapEntry);
if (mm == NULL)
{
WSGO("Could not allocate modifier map entry\n");
@ -695,7 +713,7 @@ static void
MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
unsigned merge, XkbDescPtr xkb)
{
int i;
register int i;
KeyInfo *key;
if (from->errorCount > 0)
@ -733,7 +751,7 @@ MergeIncludedSymbols(SymbolsInfo * into, SymbolsInfo * from,
if (!AddModMapEntry(into, mm))
into->errorCount++;
next = (ModMapEntry *) mm->defs.next;
free(mm);
uFree(mm);
}
from->modMap = NULL;
}
@ -780,7 +798,8 @@ HandleIncludeSymbols(IncludeStmt * stmt,
(*hndlr) (rtrn, xkb, MergeOverride, &included);
if (stmt->stmt != NULL)
{
free(included.name);
if (included.name != NULL)
uFree(included.name);
included.name = stmt->stmt;
stmt->stmt = NULL;
}
@ -855,8 +874,8 @@ static LookupEntry groupNames[] = {
#define ACTIONS 2
static Bool
GetGroupIndex(KeyInfo *key, const ExprDef *arrayNdx,
unsigned what, unsigned *ndx_rtrn)
GetGroupIndex(KeyInfo * key,
ExprDef * arrayNdx, unsigned what, unsigned *ndx_rtrn)
{
const char *name;
ExprResult tmp;
@ -868,15 +887,16 @@ GetGroupIndex(KeyInfo *key, const ExprDef *arrayNdx,
if (arrayNdx == NULL)
{
register int i;
unsigned defined;
if (what == SYMBOLS)
defined = key->symsDefined;
else
defined = key->actsDefined;
for (int i = 0; i < XkbNumKbdGroups; i++)
for (i = 0; i < XkbNumKbdGroups; i++)
{
if ((defined & (1U << i)) == 0)
if ((defined & (1 << i)) == 0)
{
*ndx_rtrn = i;
return True;
@ -907,17 +927,19 @@ GetGroupIndex(KeyInfo *key, const ExprDef *arrayNdx,
}
static Bool
AddSymbolsToKey(KeyInfo *key, XkbDescPtr xkb, const char *field,
const ExprDef *arrayNdx, const ExprDef *value,
SymbolsInfo *info)
AddSymbolsToKey(KeyInfo * key,
XkbDescPtr xkb,
const char *field,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{
unsigned ndx, nSyms;
int i;
if (!GetGroupIndex(key, arrayNdx, SYMBOLS, &ndx))
return False;
if (value == NULL)
{
key->symsDefined |= (1U << ndx);
key->symsDefined |= (1 << ndx);
return True;
}
if (value->op != ExprKeysymList)
@ -943,8 +965,8 @@ AddSymbolsToKey(KeyInfo *key, XkbDescPtr xkb, const char *field,
ACTION("Symbols lost\n");
return False;
}
key->symsDefined |= (1U << ndx);
for (int i = 0; i < nSyms; i++) {
key->symsDefined |= (1 << ndx);
for (i = 0; i < nSyms; i++) {
if (!LookupKeysym(value->value.list.syms[i], &key->syms[ndx][i])) {
if (warningLevel > 0)
{
@ -954,7 +976,7 @@ AddSymbolsToKey(KeyInfo *key, XkbDescPtr xkb, const char *field,
key->syms[ndx][i] = NoSymbol;
}
}
for (int i = key->numLevels[ndx] - 1;
for (i = key->numLevels[ndx] - 1;
(i >= 0) && (key->syms[ndx][i] == NoSymbol); i--)
{
key->numLevels[ndx]--;
@ -963,10 +985,12 @@ AddSymbolsToKey(KeyInfo *key, XkbDescPtr xkb, const char *field,
}
static Bool
AddActionsToKey(KeyInfo *key, XkbDescPtr xkb, const char *field,
const ExprDef *arrayNdx, const ExprDef *value,
SymbolsInfo *info)
AddActionsToKey(KeyInfo * key,
XkbDescPtr xkb,
const char *field,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{
register int i;
unsigned ndx, nActs;
ExprDef *act;
XkbAnyAction *toAct;
@ -976,7 +1000,7 @@ AddActionsToKey(KeyInfo *key, XkbDescPtr xkb, const char *field,
if (value == NULL)
{
key->actsDefined |= (1U << ndx);
key->actsDefined |= (1 << ndx);
return True;
}
if (value->op != ExprActionList)
@ -1009,11 +1033,11 @@ AddActionsToKey(KeyInfo *key, XkbDescPtr xkb, const char *field,
ACTION("Actions lost\n");
return False;
}
key->actsDefined |= (1U << ndx);
key->actsDefined |= (1 << ndx);
toAct = (XkbAnyAction *) key->acts[ndx];
act = value->value.child;
for (int i = 0; i < nActs; i++, toAct++)
for (i = 0; i < nActs; i++, toAct++)
{
if (!HandleActionDef(act, xkb, toAct, MergeOverride, info->action))
{
@ -1027,7 +1051,7 @@ AddActionsToKey(KeyInfo *key, XkbDescPtr xkb, const char *field,
}
static int
SetAllowNone(KeyInfo *key, const ExprDef *arrayNdx, const ExprDef *value)
SetAllowNone(KeyInfo * key, ExprDef * arrayNdx, ExprDef * value)
{
ExprResult tmp;
unsigned radio_groups = 0;
@ -1052,7 +1076,7 @@ SetAllowNone(KeyInfo *key, const ExprDef *arrayNdx, const ExprDef *value)
tmp.uval);
return False;
}
radio_groups |= (1U << (tmp.uval - 1));
radio_groups |= (1 << (tmp.uval - 1));
}
if (!ExprResolveBoolean(value, &tmp, NULL, NULL))
{
@ -1097,9 +1121,10 @@ static LookupEntry rgEntries[] = {
};
static Bool
SetSymbolsField(KeyInfo *key, XkbDescPtr xkb, const char *field,
const ExprDef *arrayNdx, const ExprDef *value,
SymbolsInfo *info)
SetSymbolsField(KeyInfo * key,
XkbDescPtr xkb,
const char *field,
ExprDef * arrayNdx, ExprDef * value, SymbolsInfo * info)
{
Bool ok = True;
ExprResult tmp;
@ -1137,7 +1162,7 @@ SetSymbolsField(KeyInfo *key, XkbDescPtr xkb, const char *field,
else
{
key->types[ndx.uval - 1] = XkbInternAtom(NULL, tmp.str, False);
key->typesDefined |= (1U << (ndx.uval - 1));
key->typesDefined |= (1 << (ndx.uval - 1));
}
}
else if (uStrCaseCmp(field, "symbols") == 0)
@ -1203,7 +1228,7 @@ SetSymbolsField(KeyInfo *key, XkbDescPtr xkb, const char *field,
key->behavior.type =
XkbKB_RadioGroup | (permanent ? XkbKB_Permanent : 0);
key->behavior.data = tmp.uval - 1;
if (key->allowNone & (1U << (tmp.uval - 1)))
if (key->allowNone & (1 << (tmp.uval - 1)))
key->behavior.data |= XkbKB_RGAllowNone;
key->defs.defined |= _Key_Behavior;
}
@ -1345,7 +1370,7 @@ SetSymbolsField(KeyInfo *key, XkbDescPtr xkb, const char *field,
}
static int
SetGroupName(SymbolsInfo *info, const ExprDef *arrayNdx,const ExprDef *value)
SetGroupName(SymbolsInfo * info, ExprDef * arrayNdx, ExprDef * value)
{
ExprResult tmp, name;
@ -1468,6 +1493,8 @@ HandleSymbolsBody(VarDef * def,
XkbDescPtr xkb, KeyInfo * key, SymbolsInfo * info)
{
Bool ok = True;
ExprResult tmp, field;
ExprDef *arrayNdx;
for (; def != NULL; def = (VarDef *) def->common.next)
{
@ -1478,9 +1505,6 @@ HandleSymbolsBody(VarDef * def,
}
else
{
ExprResult tmp, field;
ExprDef *arrayNdx;
if (def->name == NULL)
{
if ((def->value == NULL)
@ -1512,6 +1536,7 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
if ((key->typesDefined | key->symsDefined | key->actsDefined) & ~1)
{
int i;
if (warningLevel > 0)
{
WARN("For map %s an explicit group is specified\n", info->name);
@ -1519,17 +1544,19 @@ SetExplicitGroup(SymbolsInfo * info, KeyInfo * key)
longText(key->name, XkbMessage));
ACTION("All groups except first one will be ignored\n");
}
for (int i = 1; i < XkbNumKbdGroups; i++)
for (i = 1; i < XkbNumKbdGroups; i++)
{
key->numLevels[i] = 0;
free(key->syms[i]);
if (key->syms[i] != NULL)
uFree(key->syms[i]);
key->syms[i] = (KeySym *) NULL;
free(key->acts[i]);
if (key->acts[i] != NULL)
uFree(key->acts[i]);
key->acts[i] = (XkbAction *) NULL;
key->types[i] = (Atom) 0;
}
}
key->typesDefined = key->symsDefined = key->actsDefined = 1U << group;
key->typesDefined = key->symsDefined = key->actsDefined = 1 << group;
key->numLevels[group] = key->numLevels[0];
key->numLevels[0] = 0;
@ -1576,6 +1603,7 @@ static Bool
HandleModMapDef(ModMapDef * def,
XkbDescPtr xkb, unsigned merge, SymbolsInfo * info)
{
ExprDef *key;
ModMapEntry tmp;
ExprResult rtrn;
Bool ok;
@ -1589,8 +1617,7 @@ HandleModMapDef(ModMapDef * def,
}
ok = True;
tmp.modifier = rtrn.uval;
for (ExprDef *key = def->keys; key != NULL;
key = (ExprDef *) key->common.next)
for (key = def->keys; key != NULL; key = (ExprDef *) key->common.next)
{
if ((key->op == ExprValue) && (key->type == TypeKeyName))
{
@ -1679,14 +1706,14 @@ HandleSymbolsFile(XkbFile * file,
static Bool
FindKeyForSymbol(XkbDescPtr xkb, KeySym sym, unsigned int *kc_rtrn)
{
int j;
Bool gotOne;
register int i, j;
register Bool gotOne;
j = 0;
do
{
gotOne = False;
for (int i = xkb->min_key_code; i <= (int) xkb->max_key_code; i++)
for (i = xkb->min_key_code; i <= (int) xkb->max_key_code; i++)
{
if (j < (int) XkbKeyNumSyms(xkb, i))
{
@ -1713,11 +1740,13 @@ FindKeyForSymbol(XkbDescPtr xkb, KeySym sym, unsigned int *kc_rtrn)
* @return True if found, False otherwise.
*/
static Bool
FindNamedType(const XkbDescPtr xkb, Atom name, unsigned *type_rtrn)
FindNamedType(XkbDescPtr xkb, Atom name, unsigned *type_rtrn)
{
register unsigned n;
if (xkb && xkb->map && xkb->map->types)
{
for (unsigned n = 0; n < xkb->map->num_types; n++)
for (n = 0; n < xkb->map->num_types; n++)
{
if (xkb->map->types[n].name == (Atom) name)
{
@ -1761,15 +1790,15 @@ KSIsUpper(KeySym ks)
* - TWO_LEVEL for other 2 shift level keys.
* and the same for four level keys.
*
* @param width Number of syms in syms.
* @param width Number of sysms in syms.
* @param syms The keysyms for the given key (must be size width).
* @param typeNameRtrn Set to the Atom of the type name.
*
* @returns True if a type could be found, False otherwise.
*/
static Bool
FindAutomaticType(int width, const KeySym *syms,
Atom *typeNameRtrn, Bool *autoType)
FindAutomaticType(int width, KeySym * syms, Atom * typeNameRtrn,
Bool * autoType)
{
*autoType = False;
if ((width == 1) || (width == 0))
@ -1821,14 +1850,14 @@ FindAutomaticType(int width, const KeySym *syms,
static void
PrepareKeyDef(KeyInfo * key)
{
int i, defined, lastGroup;
int i, j, width, defined, lastGroup;
Bool identical;
defined = key->symsDefined | key->actsDefined | key->typesDefined;
/* get highest group number */
for (i = XkbNumKbdGroups - 1; i >= 0; i--)
{
if (defined & (1U << i))
if (defined & (1 << i))
break;
}
lastGroup = i;
@ -1841,34 +1870,34 @@ PrepareKeyDef(KeyInfo * key)
/* We can make a wrong assumption here. But leaving gaps is worse. */
for (i = lastGroup; i > 0; i--)
{
int width;
if (defined & (1U << i))
if (defined & (1 << i))
continue;
width = key->numLevels[0];
if (key->typesDefined & 1)
{
for (int j = 0; j < width; j++)
for (j = 0; j < width; j++)
{
key->types[i] = key->types[0];
}
key->typesDefined |= 1U << i;
key->typesDefined |= 1 << i;
}
if ((key->actsDefined & 1) && key->acts[0])
{
key->acts[i] = calloc(width, sizeof(XkbAction));
key->acts[i] = uTypedCalloc(width, XkbAction);
if (key->acts[i] == NULL)
continue;
memcpy(key->acts[i], key->acts[0], width * sizeof(XkbAction));
key->actsDefined |= 1U << i;
memcpy((void *) key->acts[i], (void *) key->acts[0],
width * sizeof(XkbAction));
key->actsDefined |= 1 << i;
}
if ((key->symsDefined & 1) && key->syms[0])
{
key->syms[i] = calloc(width, sizeof(KeySym));
key->syms[i] = uTypedCalloc(width, KeySym);
if (key->syms[i] == NULL)
continue;
memcpy(key->syms[i], key->syms[0], width * sizeof(KeySym));
key->symsDefined |= 1U << i;
memcpy((void *) key->syms[i], (void *) key->syms[0],
width * sizeof(KeySym));
key->symsDefined |= 1 << i;
}
if (defined & 1)
{
@ -1908,9 +1937,11 @@ PrepareKeyDef(KeyInfo * key)
for (i = lastGroup; i > 0; i--)
{
key->numLevels[i] = 0;
free(key->syms[i]);
if (key->syms[i] != NULL)
uFree(key->syms[i]);
key->syms[i] = (KeySym *) NULL;
free(key->acts[i]);
if (key->acts[i] != NULL)
uFree(key->acts[i]);
key->acts[i] = (XkbAction *) NULL;
key->types[i] = (Atom) 0;
}
@ -1929,8 +1960,8 @@ PrepareKeyDef(KeyInfo * key)
static Bool
CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
{
int i;
unsigned kc, width, nGroups;
register int i;
unsigned okc, kc, width, tmp, nGroups;
XkbKeyTypePtr type;
Bool haveActions, autoType, useAlias;
KeySym *outSyms;
@ -1959,8 +1990,8 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
for (i = width = nGroups = 0; i < XkbNumKbdGroups; i++)
{
if (((i + 1) > nGroups)
&& (((key->symsDefined | key->actsDefined) & (1U << i))
|| (key->typesDefined) & (1U << i)))
&& (((key->symsDefined | key->actsDefined) & (1 << i))
|| (key->typesDefined) & (1 << i)))
nGroups = i + 1;
if (key->acts[i])
haveActions = True;
@ -1990,7 +2021,7 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
if (FindNamedType(xkb, key->types[i], &types[i]))
{
if (!autoType || key->numLevels[i] > 2)
xkb->server->explicit[kc] |= (1U << i);
xkb->server->explicit[kc] |= (1 << i);
}
else
{
@ -2069,7 +2100,7 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
if (key->syms[i] != NULL)
{
/* fill key to "width" symbols*/
for (unsigned tmp = 0; tmp < width; tmp++)
for (tmp = 0; tmp < width; tmp++)
{
if (tmp < key->numLevels[i])
outSyms[tmp] = key->syms[i][tmp];
@ -2094,8 +2125,6 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
break;
case XkbKB_Overlay1:
case XkbKB_Overlay2:
{
unsigned okc;
/* find key by name! */
if (!FindNamedKey(xkb, key->nameForOverlayKey, &okc, True,
CreateKeyNames(xkb), 0))
@ -2111,7 +2140,6 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
break;
}
key->behavior.data = okc;
}
default:
xkb->server->behaviors[kc] = key->behavior;
xkb->server->explicit[kc] |= XkbExplicitBehaviorMask;
@ -2125,9 +2153,9 @@ CopySymbolsDef(XkbFileInfo * result, KeyInfo * key, int start_from)
if (key->repeat != RepeatUndefined)
{
if (key->repeat == RepeatYes)
xkb->ctrls->per_key_repeat[kc / 8] |= (1U << (kc % 8));
xkb->ctrls->per_key_repeat[kc / 8] |= (1 << (kc % 8));
else
xkb->ctrls->per_key_repeat[kc / 8] &= ~(1U << (kc % 8));
xkb->ctrls->per_key_repeat[kc / 8] &= ~(1 << (kc % 8));
xkb->server->explicit[kc] |= XkbExplicitAutoRepeatMask;
}
@ -2171,7 +2199,7 @@ CopyModMapDef(XkbFileInfo * result, ModMapEntry * entry)
}
return False;
}
xkb->map->modmap[kc] |= (1U << entry->modifier);
xkb->map->modmap[kc] |= (1 << entry->modifier);
return True;
}
@ -2185,6 +2213,7 @@ CopyModMapDef(XkbFileInfo * result, ModMapEntry * entry)
Bool
CompileSymbols(XkbFile * file, XkbFileInfo * result, unsigned merge)
{
register int i;
SymbolsInfo info;
XkbDescPtr xkb;
@ -2198,7 +2227,6 @@ CompileSymbols(XkbFile * file, XkbFileInfo * result, unsigned merge)
return True;
if (info.errorCount == 0)
{
int i;
KeyInfo *key;
/* alloc memory in the xkb struct */

View file

@ -30,41 +30,73 @@
#include <stdlib.h>
#include <stdarg.h>
/***====================================================================***/
Opaque
uAlloc(unsigned size)
{
return ((Opaque) malloc(size));
}
/***====================================================================***/
#ifndef HAVE_RECALLOCARRAY
void *
uRecalloc(void *old, size_t nOld, size_t nNew, size_t itemSize)
Opaque
uCalloc(unsigned n, unsigned size)
{
return ((Opaque) calloc(n, size));
}
/***====================================================================***/
Opaque
uRealloc(Opaque old, unsigned newSize)
{
if (old == NULL)
return ((Opaque) malloc(newSize));
else
return ((Opaque) realloc((char *) old, newSize));
}
/***====================================================================***/
Opaque
uRecalloc(Opaque old, unsigned nOld, unsigned nNew, unsigned itemSize)
{
char *rtrn;
if (old == NULL)
rtrn = calloc(nNew, itemSize);
rtrn = (char *) calloc(nNew, itemSize);
else
{
rtrn = reallocarray(old, nNew, itemSize);
rtrn = (char *) realloc((char *) old, nNew * itemSize);
if ((rtrn) && (nNew > nOld))
{
bzero(&rtrn[nOld * itemSize], (nNew - nOld) * itemSize);
}
}
return (void *) rtrn;
return (Opaque) rtrn;
}
#endif
/***====================================================================***/
/*** DEBUG FUNCTIONS ***/
void
uFree(Opaque ptr)
{
if (ptr != (Opaque) NULL)
free((char *) ptr);
return;
}
/***====================================================================***/
/*** PRINT FUNCTIONS ***/
/***====================================================================***/
#ifdef DEBUG
static FILE *uDebugFile = NULL;
FILE *uDebugFile = NULL;
int uDebugIndentLevel = 0;
static const int uDebugIndentSize = 4;
int uDebugIndentSize = 4;
Boolean
uSetDebugFile(const char *name)
uSetDebugFile(char *name)
{
if ((uDebugFile != NULL) && (uDebugFile != stderr))
{
@ -84,11 +116,12 @@ uSetDebugFile(const char *name)
}
void
uDebug(const char *s, ...)
uDebug(char *s, ...)
{
int i;
va_list args;
for (int i = (uDebugIndentLevel * uDebugIndentSize); i > 0; i--)
for (i = (uDebugIndentLevel * uDebugIndentSize); i > 0; i--)
{
putc(' ', uDebugFile);
}
@ -97,18 +130,28 @@ uDebug(const char *s, ...)
va_end(args);
fflush(uDebugFile);
}
#endif
void
uDebugNOI(char *s, ...)
{
va_list args;
va_start(args, s);
vfprintf(uDebugFile, s, args);
va_end(args);
fflush(uDebugFile);
}
/***====================================================================***/
static FILE *errorFile = NULL;
static int outCount = 0;
static const char *preMsg = NULL;
static const char *postMsg = NULL;
static const char *prefix = NULL;
static char *preMsg = NULL;
static char *postMsg = NULL;
static char *prefix = NULL;
Boolean
uSetErrorFile(const char *name)
uSetErrorFile(char *name)
{
if ((errorFile != NULL) && (errorFile != stderr))
{
@ -234,7 +277,7 @@ uInternalError(const char *s, ...)
}
void
uSetPreErrorMessage(const char *msg)
uSetPreErrorMessage(char *msg)
{
outCount = 0;
preMsg = msg;
@ -242,14 +285,14 @@ uSetPreErrorMessage(const char *msg)
}
void
uSetPostErrorMessage(const char *msg)
uSetPostErrorMessage(char *msg)
{
postMsg = msg;
return;
}
void
uSetErrorPrefix(const char *pre)
uSetErrorPrefix(char *pre)
{
prefix = pre;
return;
@ -273,7 +316,7 @@ uStringDup(const char *str)
if (str == NULL)
return NULL;
rtrn = malloc(strlen(str) + 1);
rtrn = (char *) uAlloc(strlen(str) + 1);
strcpy(rtrn, str);
return rtrn;
}
@ -285,7 +328,7 @@ uStrCaseCmp(const char *str1, const char *str2)
{
char buf1[512], buf2[512];
char c, *s;
int n;
register int n;
for (n = 0, s = buf1; (c = *str1++); n++)
{
@ -309,7 +352,7 @@ uStrCaseCmp(const char *str1, const char *str2)
}
int
uStrCasePrefix(const char *my_prefix, const char *str)
uStrCasePrefix(const char *my_prefix, char *str)
{
char c1;
char c2;

View file

@ -29,17 +29,15 @@
/***====================================================================***/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <X11/Xos.h>
#include <X11/Xfuncproto.h>
#include <X11/Xfuncs.h>
#include <stddef.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef NUL
#define NUL '\0'
@ -47,6 +45,13 @@
/***====================================================================***/
#ifndef OPAQUE_DEFINED
typedef void *Opaque;
#endif
#ifndef NullOpaque
#define NullOpaque ((Opaque)NULL)
#endif
#ifndef BOOLEAN_DEFINED
typedef char Boolean;
#endif
@ -69,23 +74,37 @@ typedef int Comparison;
/***====================================================================***/
#ifndef HAVE_REALLOCARRAY
#define reallocarray(p, n, s) realloc(p, (n) * (s))
#endif
#ifndef HAVE_RECALLOCARRAY
#define recallocarray uRecalloc
extern void *uRecalloc(void * /* old */ ,
size_t /* nOld */ ,
size_t /* nNew */ ,
size_t /* newSize */
extern Opaque uAlloc(unsigned /* size */
);
extern Opaque uCalloc(unsigned /* n */ ,
unsigned /* size */
);
extern Opaque uRealloc(Opaque /* old */ ,
unsigned /* newSize */
);
extern Opaque uRecalloc(Opaque /* old */ ,
unsigned /* nOld */ ,
unsigned /* nNew */ ,
unsigned /* newSize */
);
extern void uFree(Opaque /* ptr */
);
#define uTypedAlloc(t) ((t *)uAlloc((unsigned)sizeof(t)))
#define uTypedCalloc(n,t) ((t *)uCalloc((unsigned)n,(unsigned)sizeof(t)))
#define uTypedRealloc(pO,n,t) ((t *)uRealloc((Opaque)pO,((unsigned)n)*sizeof(t)))
#define uTypedRecalloc(pO,o,n,t) ((t *)uRecalloc((Opaque)pO,((unsigned)o),((unsigned)n),sizeof(t)))
#if (defined mdHasAlloca) && (mdHasAlloca)
#define uTmpAlloc(n) ((Opaque)alloca((unsigned)n))
#define uTmpFree(p)
#else
#define uTmpAlloc(n) uAlloc(n)
#define uTmpFree(p) uFree(p)
#endif
/***====================================================================***/
extern Boolean uSetErrorFile(const char * /* name */
extern Boolean uSetErrorFile(char * /* name */
);
#define INFO uInformation
@ -120,13 +139,13 @@ uInformation(const char * /* s */ , ...
extern void uInternalError(const char * /* s */ , ...
) _X_ATTRIBUTE_PRINTF(1, 2);
extern void uSetPreErrorMessage(const char * /* msg */
extern void uSetPreErrorMessage(char * /* msg */
);
extern void uSetPostErrorMessage(const char * /* msg */
extern void uSetPostErrorMessage(char * /* msg */
);
extern void uSetErrorPrefix(const char * /* void */
extern void uSetErrorPrefix(char * /* void */
);
extern void uFinishUp(void);
@ -164,28 +183,40 @@ uInformation(const char * /* s */ , ...
/***====================================================================***/
#ifdef DEBUG
#ifndef DEBUG_VAR
#define DEBUG_VAR debugFlags
#endif
extern unsigned int DEBUG_VAR;
extern
unsigned int DEBUG_VAR;
extern void uDebug(const char *, ...) _X_ATTRIBUTE_PRINTF(1, 2);
extern void uDebug(char * /* s */ , ...
) _X_ATTRIBUTE_PRINTF(1, 2);
extern Boolean uSetDebugFile(const char *name);
extern void uDebugNOI( /* no indent */
char * /* s */ , ...
) _X_ATTRIBUTE_PRINTF(1, 2);
extern Boolean uSetDebugFile(char *name);
extern FILE *uDebugFile;
extern int uDebugIndentLevel;
extern int uDebugIndentSize;
#define uDebugIndent(l) (uDebugIndentLevel+=(l))
#define uDebugOutdent(l) (uDebugIndentLevel-=(l))
#ifdef DEBUG
#define uDEBUG(f,s) { if (DEBUG_VAR&(f)) uDebug(s);}
#define uDEBUG1(f,s,a) { if (DEBUG_VAR&(f)) uDebug(s,a);}
#define uDEBUG2(f,s,a,b) { if (DEBUG_VAR&(f)) uDebug(s,a,b);}
#define uDEBUG3(f,s,a,b,c) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c);}
#define uDEBUG4(f,s,a,b,c,d) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d);}
#define uDEBUG5(f,s,a,b,c,d,e) { if (DEBUG_VAR&(f)) uDebug(s,a,b,c,d,e);}
#define uDEBUG_NOI(f,s) { if (DEBUG_VAR&(f)) uDebug(s);}
#define uDEBUG_NOI1(f,s,a) { if (DEBUG_VAR&(f)) uDebugNOI(s,a);}
#define uDEBUG_NOI2(f,s,a,b) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b);}
#define uDEBUG_NOI3(f,s,a,b,c) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c);}
#define uDEBUG_NOI4(f,s,a,b,c,d) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d);}
#define uDEBUG_NOI5(f,s,a,b,c,d,e) { if (DEBUG_VAR&(f)) uDebugNOI(s,a,b,c,d,e);}
#else
#define uDEBUG(f,s)
#define uDEBUG1(f,s,a)
@ -193,6 +224,12 @@ extern int uDebugIndentLevel;
#define uDEBUG3(f,s,a,b,c)
#define uDEBUG4(f,s,a,b,c,d)
#define uDEBUG5(f,s,a,b,c,d,e)
#define uDEBUG_NOI(f,s)
#define uDEBUG_NOI1(f,s,a)
#define uDEBUG_NOI2(f,s,a,b)
#define uDEBUG_NOI3(f,s,a,b,c)
#define uDEBUG_NOI4(f,s,a,b,c,d)
#define uDEBUG_NOI5(f,s,a,b,c,d,e)
#endif
#endif /* UTILS_H */

View file

@ -47,6 +47,8 @@ InitVModInfo(VModInfo * info, XkbDescPtr xkb)
void
ClearVModInfo(VModInfo * info, XkbDescPtr xkb)
{
register int i;
if (XkbAllocNames(xkb, XkbVirtualModNamesMask, 0, 0) != Success)
return;
if (XkbAllocServerMap(xkb, XkbVirtualModsMask, 0) != Success)
@ -55,8 +57,7 @@ ClearVModInfo(VModInfo * info, XkbDescPtr xkb)
info->newlyDefined = info->defined = info->available = 0;
if (xkb && xkb->names)
{
int i, bit;
register int bit;
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
{
if (xkb->names->vmods[i] != None)
@ -77,9 +78,9 @@ ClearVModInfo(VModInfo * info, XkbDescPtr xkb)
* @param mergeMode Merge strategy (e.g. MergeOverride)
*/
Bool
HandleVModDef(const VModDef *stmt, unsigned mergeMode, VModInfo *info)
HandleVModDef(VModDef * stmt, unsigned mergeMode, VModInfo * info)
{
int i, bit, nextFree;
register int i, bit, nextFree;
ExprResult mod;
XkbServerMapPtr srv;
XkbNamesPtr names;
@ -137,9 +138,9 @@ HandleVModDef(const VModDef *stmt, unsigned mergeMode, VModInfo *info)
ACTION("Exiting\n");
return False;
}
info->defined |= (1U << nextFree);
info->newlyDefined |= (1U << nextFree);
info->available |= (1U << nextFree);
info->defined |= (1 << nextFree);
info->newlyDefined |= (1 << nextFree);
info->available |= (1 << nextFree);
names->vmods[nextFree] = stmtName;
if (stmt->value == NULL)
return True;
@ -165,12 +166,13 @@ HandleVModDef(const VModDef *stmt, unsigned mergeMode, VModInfo *info)
* @return True on success, False otherwise. If False is returned, val_rtrn is
* undefined.
*/
static int
int
LookupVModIndex(XPointer priv,
Atom elem, Atom field, unsigned type, ExprResult * val_rtrn)
{
int i;
char *fieldStr;
register int i;
register char *fieldStr;
register char *modStr;
XkbDescPtr xkb;
xkb = (XkbDescPtr) priv;
@ -190,7 +192,7 @@ LookupVModIndex(XPointer priv,
*/
for (i = 0; i < XkbNumVirtualMods; i++)
{
char *modStr = XkbAtomGetString(xkb->dpy, xkb->names->vmods[i]);
modStr = XkbAtomGetString(xkb->dpy, xkb->names->vmods[i]);
if ((modStr != NULL) && (uStrCaseCmp(fieldStr, modStr) == 0))
{
val_rtrn->uval = i;
@ -216,8 +218,8 @@ LookupVModMask(XPointer priv,
{
if (LookupVModIndex(priv, elem, field, type, val_rtrn))
{
unsigned ndx = val_rtrn->uval;
val_rtrn->uval = (1U << (XkbNumModifiers + ndx));
register unsigned ndx = val_rtrn->uval;
val_rtrn->uval = (1 << (XkbNumModifiers + ndx));
return True;
}
return False;
@ -226,28 +228,26 @@ LookupVModMask(XPointer priv,
int
FindKeypadVMod(XkbDescPtr xkb)
{
if (xkb) {
Atom name = XkbInternAtom(xkb->dpy, "NumLock", False);
Atom name;
ExprResult rtrn;
if (LookupVModIndex((XPointer) xkb, None, name, TypeInt, &rtrn))
name = XkbInternAtom(xkb->dpy, "NumLock", False);
if ((xkb) && LookupVModIndex((XPointer) xkb, None, name, TypeInt, &rtrn))
{
return rtrn.ival;
}
}
return -1;
}
Bool
ResolveVirtualModifier(const ExprDef *def, ExprResult *val_rtrn,
const VModInfo *info)
ResolveVirtualModifier(ExprDef * def, ExprResult * val_rtrn, VModInfo * info)
{
XkbNamesPtr names;
names = info->xkb->names;
if (def->op == ExprIdent)
{
int i, bit;
register int i, bit;
for (i = 0, bit = 1; i < XkbNumVirtualMods; i++, bit <<= 1)
{
char *str1, *str2;

View file

@ -44,7 +44,7 @@ extern void ClearVModInfo(VModInfo * /* info */ ,
XkbDescPtr /* xkb */
);
extern Bool HandleVModDef(const VModDef * /* stmt */ ,
extern Bool HandleVModDef(VModDef * /* stmt */ ,
unsigned /* mergeMode */ ,
VModInfo * /* info */
);
@ -53,6 +53,13 @@ extern Bool ApplyVModDefs(VModInfo * /* info */ ,
XkbDescPtr /* xkb */
);
extern int LookupVModIndex(XPointer /* priv */ ,
Atom /* elem */ ,
Atom /* field */ ,
unsigned /* type */ ,
ExprResult * /* val_rtrn */
);
extern int LookupVModMask(XPointer /* priv */ ,
Atom /* elem */ ,
Atom /* field */ ,
@ -63,9 +70,9 @@ extern int LookupVModMask(XPointer /* priv */ ,
extern int FindKeypadVMod(XkbDescPtr /* xkb */
);
extern Bool ResolveVirtualModifier(const ExprDef * /* def */ ,
extern Bool ResolveVirtualModifier(ExprDef * /* def */ ,
ExprResult * /* value_rtrn */ ,
const VModInfo * /* info */
VModInfo * /* info */
);
#endif /* VMOD_H */

View file

@ -24,7 +24,6 @@
********************************************************/
#include "utils.h"
#include <stdio.h>
#include <ctype.h>
#include <X11/keysym.h>
@ -35,6 +34,10 @@
#include <unistd.h>
/* end BR */
#if defined(sgi)
#include <malloc.h>
#endif
#define DEBUG_VAR debugFlags
#include "xkbcomp.h"
#include <stdlib.h>
@ -67,9 +70,7 @@
#define INPUT_XKB 1
#define INPUT_XKM 2
#ifdef DEBUG
unsigned int debugFlags;
#endif
static const char *fileTypeExt[] = {
"XXX",
@ -80,12 +81,12 @@ static const char *fileTypeExt[] = {
};
static unsigned inputFormat, outputFormat;
static const char *rootDir;
char *rootDir;
static char *inputFile;
static const char *inputMap;
static char *inputMap;
static char *outputFile;
static const char *inDpyName;
static const char *outDpyName;
static char *inDpyName;
static char *outDpyName;
static Display *inDpy;
static Display *outDpy;
static Bool showImplicit = False;
@ -95,10 +96,10 @@ static Bool xkblist = False;
unsigned warningLevel = 5;
unsigned verboseLevel = 0;
unsigned dirsToStrip = 0;
static unsigned optionalParts = 0;
static const char *preErrorMsg = NULL;
static const char *postErrorMsg = NULL;
static const char *errorPrefix = NULL;
unsigned optionalParts = 0;
static char *preErrorMsg = NULL;
static char *postErrorMsg = NULL;
static char *errorPrefix = NULL;
static unsigned int device_id = XkbUseCoreKbd;
/***====================================================================***/
@ -177,7 +178,7 @@ Usage(int argc, char *argv[])
/***====================================================================***/
static void
setVerboseFlags(const char *str)
setVerboseFlags(char *str)
{
for (; *str; str++)
{
@ -213,7 +214,7 @@ setVerboseFlags(const char *str)
static Bool
parseArgs(int argc, char *argv[])
{
int i, tmp;
register int i, tmp;
i = strlen(argv[0]);
tmp = strlen("xkblist");
@ -464,7 +465,8 @@ parseArgs(int argc, char *argv[])
}
else
{
for (const char *tmp2 = argv[i]; (*tmp2 != '\0'); tmp2++)
char *tmp2;
for (tmp2 = argv[i]; (*tmp2 != '\0'); tmp2++)
{
switch (*tmp2)
{
@ -565,7 +567,7 @@ parseArgs(int argc, char *argv[])
}
else if (strncmp(argv[i], "-v", 2) == 0)
{
const char *str;
char *str;
if (argv[i][2] != '\0')
str = &argv[i][2];
else if ((i < (argc - 1)) && (argv[i + 1][0] != '-'))
@ -758,25 +760,20 @@ parseArgs(int argc, char *argv[])
}
else if ((!outputFile) && (inputFile) && (strcmp(inputFile, "-") == 0))
{
#ifdef HAVE_ASPRINTF
if (asprintf(&outputFile, "stdin.%s", fileTypeExt[outputFormat]) < 0)
#else
size_t len = strlen("stdin") + strlen(fileTypeExt[outputFormat]) + 2;
outputFile = calloc(len, sizeof(char));
if (outputFile != NULL)
snprintf(outputFile, len, "stdin.%s", fileTypeExt[outputFormat]);
else
#endif
int len = strlen("stdin") + strlen(fileTypeExt[outputFormat]) + 2;
outputFile = uTypedCalloc(len, char);
if (outputFile == NULL)
{
WSGO("Cannot allocate space for output file name\n");
ACTION("Exiting\n");
exit(1);
}
snprintf(outputFile, len, "stdin.%s", fileTypeExt[outputFormat]);
}
else if ((outputFile == NULL) && (inputFile != NULL))
{
int len;
const char *base, *ext;
char *base, *ext;
if (inputMap == NULL)
{
@ -790,7 +787,7 @@ parseArgs(int argc, char *argv[])
base = inputMap;
len = strlen(base) + strlen(fileTypeExt[outputFormat]) + 2;
outputFile = calloc(len, sizeof(char));
outputFile = uTypedCalloc(len, char);
if (outputFile == NULL)
{
WSGO("Cannot allocate space for output file name\n");
@ -809,15 +806,14 @@ parseArgs(int argc, char *argv[])
else if (outputFile == NULL)
{
int len;
char *ch, buf[128];
const char *name = buf;
char *ch, *name, buf[128];
if (inDpyName[0] == ':')
snprintf(buf, sizeof(buf), "server%s", inDpyName);
snprintf(name = buf, sizeof(buf), "server%s", inDpyName);
else
name = inDpyName;
len = strlen(name) + strlen(fileTypeExt[outputFormat]) + 2;
outputFile = calloc(len, sizeof(char));
outputFile = uTypedCalloc(len, char);
if (outputFile == NULL)
{
WSGO("Cannot allocate space for output file name\n");
@ -852,7 +848,7 @@ parseArgs(int argc, char *argv[])
}
static Display *
GetDisplay(const char *program, const char *dpyName)
GetDisplay(char *program, char *dpyName)
{
int mjr, mnr, error;
Display *dpy;
@ -908,9 +904,7 @@ main(int argc, char *argv[])
Status status;
scan_set_file(stdin);
#ifdef DEBUG
uSetDebugFile(NullString);
#endif
uSetErrorFile(NullString);
XkbInitIncludePath();
@ -1028,7 +1022,7 @@ main(int argc, char *argv[])
}
}
}
bzero(&result, sizeof(result));
bzero((char *) &result, sizeof(result));
result.type = mapToUse->type;
if ((result.xkb = XkbAllocKeyboard()) == NULL)
{
@ -1072,7 +1066,7 @@ main(int argc, char *argv[])
else if (inputFormat == INPUT_XKM) /* parse xkm file */
{
unsigned tmp;
bzero(&result, sizeof(result));
bzero((char *) &result, sizeof(result));
if ((result.xkb = XkbAllocKeyboard()) == NULL)
{
WSGO("Cannot allocate keyboard description\n");
@ -1094,7 +1088,7 @@ main(int argc, char *argv[])
}
else if (inDpy != NULL)
{
bzero(&result, sizeof(result));
bzero((char *) &result, sizeof(result));
result.type = XkmKeymapFile;
result.xkb = XkbGetMap(inDpy, XkbAllMapComponentsMask, device_id);
if (result.xkb == NULL)

View file

@ -31,10 +31,6 @@
#define DEBUG_VAR debugFlags
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
@ -114,6 +110,7 @@ typedef struct _ParseCommon
#define CreateKeyNames(x) ((x)->flags&AutoKeyNames)
extern unsigned warningLevel;
extern unsigned optionalParts;
typedef struct _IncludeStmt
{
@ -171,7 +168,7 @@ typedef struct _Expr
unsigned uval;
int ival;
char keyName[5];
void *ptr;
Opaque ptr;
} value;
} ExprDef;
@ -363,7 +360,7 @@ extern Bool CompileKeyTypes(XkbFile * /* file */ ,
typedef struct _LEDInfo *LEDInfoPtr;
extern Bool CompileCompatMap(const XkbFile * /* file */ ,
extern Bool CompileCompatMap(XkbFile * /* file */ ,
XkbFileInfo * /* result */ ,
unsigned /* merge */ ,
LEDInfoPtr * /* unboundLEDs */
@ -380,16 +377,21 @@ extern Bool CompileSymbols(XkbFile * /* file */ ,
#define WantFullNames (1<<3)
#define ListRecursive (1<<4)
extern char *rootDir;
extern unsigned verboseLevel;
extern unsigned dirsToStrip;
extern Bool AddListing(char * /* file */ ,
char * /* map */
);
extern Bool AddMatchingFiles(char * /* head_in */
);
extern int AddMapOnly(char * /* map */
);
extern int GenerateListing(const char * /* filename */
extern int GenerateListing(char * /* filename */
);
#endif /* XKBCOMP_H */

View file

@ -91,14 +91,15 @@
%{
#ifdef DEBUG
#define YYDEBUG 1
#define DEBUG_VAR parseDebug
unsigned int parseDebug;
#endif
#define DEBUG_VAR parseDebug
#include "parseutils.h"
#include <X11/keysym.h>
#include <X11/extensions/XKBgeom.h>
#include <stdlib.h>
unsigned int parseDebug;
%}
%right EQUALS
%left PLUS MINUS

View file

@ -123,7 +123,7 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
}
else if (str[0] == '(')
{
free(*extra_data);
uFree(*extra_data);
return False;
}
else
@ -134,8 +134,8 @@ XkbParseIncludeMap(char **str_inout, char **file_rtrn, char **map_rtrn,
tmp = strchr(str, ')');
if ((tmp == NULL) || (tmp[1] != '\0'))
{
free(*file_rtrn);
free(*extra_data);
uFree(*file_rtrn);
uFree(*extra_data);
return False;
}
*tmp++ = '\0';
@ -175,16 +175,21 @@ XkbAddDefaultDirectoriesToPath(void)
/**
* Remove all entries from the global includePath.
*/
static void
void
XkbClearIncludePath(void)
{
register int i;
if (szPath > 0)
{
for (int i = 0; i < nPathEntries; i++)
for (i = 0; i < nPathEntries; i++)
{
free(includePath[i]);
if (includePath[i] != NULL)
{
uFree(includePath[i]);
includePath[i] = NULL;
}
}
nPathEntries = 0;
}
noDefaultPath = True;
@ -213,24 +218,22 @@ XkbAddDirectoryToPath(const char *dir)
}
if (nPathEntries >= szPath)
{
char **new;
szPath += PATH_CHUNK;
new = (char **) realloc(includePath, szPath * sizeof(char *));
if (new == NULL)
includePath = (char **) realloc(includePath, szPath * sizeof(char *));
if (includePath == NULL)
{
WSGO("Allocation failed (includePath)\n");
return False;
}
else
includePath = new;
}
includePath[nPathEntries] = strdup(dir);
includePath[nPathEntries] =
(char *) calloc(strlen(dir) + 1, sizeof(char));
if (includePath[nPathEntries] == NULL)
{
WSGO("Allocation failed (includePath[%d])\n", nPathEntries);
return False;
}
nPathEntries++;
strcpy(includePath[nPathEntries++], dir);
return True;
}
@ -283,7 +286,7 @@ XkbDirectoryForInclude(unsigned type)
typedef struct _FileCacheEntry
{
const char *name;
char *name;
unsigned type;
char *path;
void *data;
@ -305,7 +308,7 @@ static FileCacheEntry *fileCache;
* @return The data from the overwritten file or NULL.
*/
void *
XkbAddFileToCache(const char *name, unsigned type, char *path, void *data)
XkbAddFileToCache(char *name, unsigned type, char *path, void *data)
{
FileCacheEntry *entry;
@ -320,16 +323,14 @@ XkbAddFileToCache(const char *name, unsigned type, char *path, void *data)
return old;
}
}
entry = malloc(sizeof(FileCacheEntry));
entry = uTypedAlloc(FileCacheEntry);
if (entry != NULL)
{
*entry = (FileCacheEntry) {
.name = name,
.type = type,
.path = path,
.data = data,
.next = fileCache
};
entry->name = name;
entry->type = type;
entry->path = path;
entry->data = data;
entry->next = fileCache;
fileCache = entry;
}
return NULL;
@ -345,7 +346,7 @@ XkbAddFileToCache(const char *name, unsigned type, char *path, void *data)
* @return the data from the cache entry or NULL if no matching entry was found.
*/
void *
XkbFindFileInCache(const char *name, unsigned type, char **pathRtrn)
XkbFindFileInCache(char *name, unsigned type, char **pathRtrn)
{
FileCacheEntry *entry;
@ -373,19 +374,19 @@ XkbFindFileInCache(const char *name, unsigned type, char **pathRtrn)
* pathRtrn is undefined.
*/
FILE *
XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
XkbFindFileInPath(char *name, unsigned type, char **pathRtrn)
{
register int i;
FILE *file = NULL;
int nameLen, typeLen;
char buf[PATH_MAX];
const char *typeDir;
int nameLen, typeLen, pathLen;
char buf[PATH_MAX], *typeDir;
typeDir = XkbDirectoryForInclude(type);
nameLen = strlen(name);
typeLen = strlen(typeDir);
for (int i = 0; i < nPathEntries; i++)
for (i = 0; i < nPathEntries; i++)
{
int pathLen = strlen(includePath[i]);
pathLen = strlen(includePath[i]);
if (typeLen < 1)
continue;
@ -404,7 +405,9 @@ XkbFindFileInPath(const char *name, unsigned type, char **pathRtrn)
if ((file != NULL) && (pathRtrn != NULL))
{
*pathRtrn = strdup(buf);
*pathRtrn = (char *) calloc(strlen(buf) + 1, sizeof(char));
if (*pathRtrn != NULL)
strcpy(*pathRtrn, buf);
}
return file;
}

View file

@ -29,6 +29,8 @@
extern Bool XkbInitIncludePath(void);
extern void XkbClearIncludePath(void);
extern void XkbAddDefaultDirectoriesToPath(void);
extern Bool XkbAddDirectoryToPath(const char * /* dir */
@ -37,18 +39,18 @@ extern Bool XkbAddDirectoryToPath(const char * /* dir */
extern char *XkbDirectoryForInclude(unsigned /* type */
);
extern FILE *XkbFindFileInPath(const char * /* name */ ,
extern FILE *XkbFindFileInPath(char * /* name */ ,
unsigned /* type */ ,
char ** /* pathRtrn */
);
extern void *XkbAddFileToCache(const char * /* name */ ,
extern void *XkbAddFileToCache(char * /* name */ ,
unsigned /* type */ ,
char * /* path */ ,
void * /* data */
);
extern void *XkbFindFileInCache(const char * /* name */ ,
extern void *XkbFindFileInCache(char * /* name */ ,
unsigned /* type */ ,
char ** /* pathRtrn */
);

View file

@ -36,9 +36,7 @@
#include "utils.h"
#include "parseutils.h"
#ifdef DEBUG
unsigned int scanDebug;
#endif
static FILE *yyin;
@ -578,7 +576,7 @@ static int numKeywords = sizeof(keywords) / sizeof(struct _Keyword);
static int
yyGetIdent(int first)
{
int ch, j, found;
int ch, i, j, found;
int rtrn = IDENT;
scanBuf[0] = first;
@ -591,7 +589,7 @@ yyGetIdent(int first)
scanBuf[j++] = '\0';
found = 0;
for (int i = 0; (!found) && (i < numKeywords); i++)
for (i = 0; (!found) && (i < numKeywords); i++)
{
if (uStrCaseCmp(scanBuf, keywords[i].keyword) == 0)
{