Copy XkbEnsureSafeMapName from xkbfile
authorDan Nicholson <dbn.lists@gmail.com>
Sun, 29 Mar 2009 02:00:13 +0000 (19:00 -0700)
committerDan Nicholson <dbn.lists@gmail.com>
Sun, 29 Mar 2009 02:00:13 +0000 (19:00 -0700)
include/X11/extensions/XKBcommon.h
src/misc.c
src/xkbcomp/parseutils.c

index e29d5c7..37a098c 100644 (file)
@@ -305,6 +305,9 @@ extern Bool
 XkbcComputeEffectiveMap(XkbcDescPtr xkb, XkbKeyTypePtr type,
                         unsigned char *map_rtrn);
 
+extern void
+XkbcEnsureSafeMapName(char *name);
+
 _XFUNCPROTOEND
 
 #endif /* _XKBCOMMON_H_ */
index f294d69..5c8e19a 100644 (file)
@@ -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++;
+    }
+}
index 2e10798..cbb35d9 100644 (file)
@@ -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);