From eff1c53873e1190b703ee5f84b4240f070dd0927 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Sat, 28 Mar 2009 19:00:13 -0700 Subject: [PATCH] Copy XkbEnsureSafeMapName from xkbfile --- include/X11/extensions/XKBcommon.h | 3 +++ src/misc.c | 24 ++++++++++++++++++++++++ src/xkbcomp/parseutils.c | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/X11/extensions/XKBcommon.h b/include/X11/extensions/XKBcommon.h index e29d5c7..37a098c 100644 --- a/include/X11/extensions/XKBcommon.h +++ b/include/X11/extensions/XKBcommon.h @@ -305,6 +305,9 @@ extern Bool XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type, unsigned char *map_rtrn); +extern void +XkbcEnsureSafeMapName(char *name); + _XFUNCPROTOEND #endif /* _XKBCOMMON_H_ */ diff --git a/src/misc.c b/src/misc.c index f294d69..5c8e19a 100644 --- a/src/misc.c +++ b/src/misc.c @@ -160,3 +160,27 @@ XkbcVirtualModsToReal(XkbcDescPtr xkb, unsigned virtual_mask, *mask_rtrn = mask; return True; } + +/* + * All latin-1 alphanumerics, plus parens, slash, minus, underscore and + * wildcards. + */ +static unsigned char componentSpecLegal[] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0xa7, 0xff, 0x83, + 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x07, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x7f, 0xff, 0xff, 0xff, 0x7f, 0xff +}; + +void +XkbcEnsureSafeMapName(char *name) +{ + if (!name) + return; + + while (*name!='\0') { + if ((componentSpecLegal[(*name) / 8] & (1 << ((*name) % 8))) == 0) + *name= '_'; + name++; + } +} diff --git a/src/xkbcomp/parseutils.c b/src/xkbcomp/parseutils.c index 2e10798..cbb35d9 100644 --- a/src/xkbcomp/parseutils.c +++ b/src/xkbcomp/parseutils.c @@ -809,7 +809,7 @@ CreateXKBFile(int type, char *name, ParseCommon * defs, unsigned flags) file = uTypedAlloc(XkbFile); if (file) { - XkbEnsureSafeMapName(name); + XkbcEnsureSafeMapName(name); bzero(file, sizeof(XkbFile)); file->type = type; file->topName = uStringDup(name); -- 2.7.4