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 # X.Org maintained modules
# #
@ -45,7 +45,7 @@ app/xgc 1.0.6
app/xhost 1.0.9 app/xhost 1.0.9
app/xinit 1.4.2 app/xinit 1.4.2
app/xinput 1.6.4 app/xinput 1.6.4
app/xkbcomp 1.4.7 app/xkbcomp 1.4.7 reverted
app/xkbevd 1.1.5 app/xkbevd 1.1.5
app/xkbprint 1.0.6 app/xkbprint 1.0.6
app/xkbutils 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 commit 7bac6a25bb44d39710f1b2b5fdad56d7f4c01c39
Author: Alan Coopersmith <alan.coopersmith@oracle.com> Author: Alan Coopersmith <alan.coopersmith@oracle.com>
Date: Wed Dec 7 17:53:16 2022 -0800 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> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
commit a0a4f112c5858ac2b932247dba2d85061bb59145 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 Date: Mon Jul 6 07:48:48 2020 +0200
Fix lockdevbtn to be XkbSA_LockDeviceBtn action 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> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
commit 9edd61b91a02bda31fc6edd2c32c553e872b6ea2 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 Date: Fri Jan 18 20:01:01 2019 +0100
Fix invalid error report on F_Accel field Fix invalid error report on F_Accel field
@ -2349,7 +1956,7 @@ Date: Fri Oct 14 00:25:46 2005 +0000
Use sed to fill in variables in man page Use sed to fill in variables in man page
commit 8c0d310c1acccc424dae29554a5075f9b339e95f commit 8c0d310c1acccc424dae29554a5075f9b339e95f
Author: Kristian Høgsberg <krh@redhat.com> Author: Kristian Høgsberg <krh@redhat.com>
Date: Thu Sep 1 19:37:02 2005 +0000 Date: Thu Sep 1 19:37:02 2005 +0000
Define DFLT_XKB_CONFIG_ROOT to $(datadir)/X11/xkb so we look in the right Define DFLT_XKB_CONFIG_ROOT to $(datadir)/X11/xkb so we look in the right
@ -2390,13 +1997,13 @@ Date: Wed Jul 20 19:31:57 2005 +0000
configure cache, you cache it, and the cached value is probably wrong. configure cache, you cache it, and the cached value is probably wrong.
commit 8335e5fa471e25675c6a369ec2348883953fcdd0 commit 8335e5fa471e25675c6a369ec2348883953fcdd0
Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk> Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
Date: Sat Jul 16 20:56:47 2005 +0000 Date: Sat Jul 16 20:56:47 2005 +0000
Add xkbcomp data to symlink.sh. Some fixes to xkbcomp/Makefile.am Add xkbcomp data to symlink.sh. Some fixes to xkbcomp/Makefile.am
commit d7b3354575f31caa9044b6c5f7aee4f010f6192a commit d7b3354575f31caa9044b6c5f7aee4f010f6192a
Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk> Author: Søren Sandmann Pedersen <sandmann@daimi.au.dk>
Date: Fri Jul 15 18:02:35 2005 +0000 Date: Fri Jul 15 18:02:35 2005 +0000
Build system for xkbcomp Build system for xkbcomp

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,20 +1,8 @@
/* config.h.in. Generated from configure.ac by autoheader. */ /* 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. */ /* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H #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. */ /* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H #undef HAVE_STDINT_H
@ -45,9 +33,6 @@
/* Define to 1 if you have the <unistd.h> header file. */ /* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H #undef HAVE_UNISTD_H
/* Define to 1 if you have the <wchar.h> header file. */
#undef HAVE_WCHAR_H
/* Name of package */ /* Name of package */
#undef PACKAGE #undef PACKAGE
@ -83,94 +68,6 @@
backward compatibility; new code need not use it. */ backward compatibility; new code need not use it. */
#undef STDC_HEADERS #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 */ /* Version number of package */
#undef VERSION #undef VERSION

8296
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. dnl Process this file with autoconf to create configure.
# Initialize Autoconf # Initialize Autoconf
AC_PREREQ([2.70]) AC_PREREQ([2.60])
AC_INIT([xkbcomp], [1.4.7], AC_INIT([xkbcomp], [1.4.6],
[https://gitlab.freedesktop.org/xorg/app/xkbcomp/-/issues], [xkbcomp]) [https://gitlab.freedesktop.org/xorg/app/xkbcomp/-/issues], [xkbcomp])
AC_CONFIG_SRCDIR([Makefile.am]) AC_CONFIG_SRCDIR([Makefile.am])
AC_CONFIG_HEADERS([config.h]) 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 # Initialize Automake
AM_INIT_AUTOMAKE([foreign dist-xz]) AM_INIT_AUTOMAKE([foreign dist-xz])
@ -50,7 +45,7 @@ if test ! -f "$srcdir/xkbparse.c"; then
fi fi
fi fi
AC_CHECK_FUNCS([asprintf reallocarray recallocarray strdup strcasecmp]) AC_CHECK_FUNCS([strdup strcasecmp])
# Checks for pkg-config packages # Checks for pkg-config packages
PKG_CHECK_MODULES(XKBCOMP, [x11 xkbfile xproto >= 7.0.17]) PKG_CHECK_MODULES(XKBCOMP, [x11 xkbfile xproto >= 7.0.17])

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -36,11 +36,17 @@ typedef struct _CommonInfo
} CommonInfo; } CommonInfo;
extern Bool UseNewField(unsigned /* field */ , extern Bool UseNewField(unsigned /* field */ ,
const CommonInfo * /* oldDefs */ , CommonInfo * /* oldDefs */ ,
const CommonInfo * /* newDefs */ , CommonInfo * /* newDefs */ ,
unsigned * /* pCollide */ unsigned * /* pCollide */
); );
extern Bool MergeNewField(unsigned /* field */ ,
CommonInfo * /* oldDefs */ ,
CommonInfo * /* newDefs */ ,
unsigned * /* pCollide */
);
extern XPointer ClearCommonInfo(CommonInfo * /* cmn */ extern XPointer ClearCommonInfo(CommonInfo * /* cmn */
); );

View file

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

View file

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

View file

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

View file

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

View file

@ -29,17 +29,15 @@
/***====================================================================***/ /***====================================================================***/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <X11/Xos.h> #include <X11/Xos.h>
#include <X11/Xfuncproto.h> #include <X11/Xfuncproto.h>
#include <X11/Xfuncs.h> #include <X11/Xfuncs.h>
#include <stddef.h> #include <stddef.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifndef NUL #ifndef NUL
#define NUL '\0' #define NUL '\0'
@ -47,6 +45,13 @@
/***====================================================================***/ /***====================================================================***/
#ifndef OPAQUE_DEFINED
typedef void *Opaque;
#endif
#ifndef NullOpaque
#define NullOpaque ((Opaque)NULL)
#endif
#ifndef BOOLEAN_DEFINED #ifndef BOOLEAN_DEFINED
typedef char Boolean; typedef char Boolean;
#endif #endif
@ -69,23 +74,37 @@ typedef int Comparison;
/***====================================================================***/ /***====================================================================***/
#ifndef HAVE_REALLOCARRAY extern Opaque uAlloc(unsigned /* size */
#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 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 #endif
/***====================================================================***/ /***====================================================================***/
extern Boolean uSetErrorFile(const char * /* name */ extern Boolean uSetErrorFile(char * /* name */
); );
#define INFO uInformation #define INFO uInformation
@ -120,13 +139,13 @@ uInformation(const char * /* s */ , ...
extern void uInternalError(const char * /* s */ , ... extern void uInternalError(const char * /* s */ , ...
) _X_ATTRIBUTE_PRINTF(1, 2); ) _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); extern void uFinishUp(void);
@ -164,28 +183,40 @@ uInformation(const char * /* s */ , ...
/***====================================================================***/ /***====================================================================***/
#ifdef DEBUG
#ifndef DEBUG_VAR #ifndef DEBUG_VAR
#define DEBUG_VAR debugFlags #define DEBUG_VAR debugFlags
#endif #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 int uDebugIndentLevel; extern Boolean uSetDebugFile(char *name);
extern FILE *uDebugFile;
extern int uDebugIndentLevel;
extern int uDebugIndentSize;
#define uDebugIndent(l) (uDebugIndentLevel+=(l)) #define uDebugIndent(l) (uDebugIndentLevel+=(l))
#define uDebugOutdent(l) (uDebugIndentLevel-=(l)) #define uDebugOutdent(l) (uDebugIndentLevel-=(l))
#ifdef DEBUG
#define uDEBUG(f,s) { if (DEBUG_VAR&(f)) uDebug(s);} #define uDEBUG(f,s) { if (DEBUG_VAR&(f)) uDebug(s);}
#define uDEBUG1(f,s,a) { if (DEBUG_VAR&(f)) uDebug(s,a);} #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 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 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 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 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 #else
#define uDEBUG(f,s) #define uDEBUG(f,s)
#define uDEBUG1(f,s,a) #define uDEBUG1(f,s,a)
@ -193,6 +224,12 @@ extern int uDebugIndentLevel;
#define uDEBUG3(f,s,a,b,c) #define uDEBUG3(f,s,a,b,c)
#define uDEBUG4(f,s,a,b,c,d) #define uDEBUG4(f,s,a,b,c,d)
#define uDEBUG5(f,s,a,b,c,d,e) #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
#endif /* UTILS_H */ #endif /* UTILS_H */

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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