<p>On Nov 1, 2012 2:16 AM, "Daniel Stone" <<a href="mailto:daniel@fooishbar.org">daniel@fooishbar.org</a>> wrote:<br>
><br>
> No-one uses this - not xkbcomp, not GNOME, not KDE. The preferred way<br>
> to deal with component listing (which gives you RMLVO rather than<br>
> KcCGST) is to use the XML files on the client side.<br>
><br>
> Indeed, a couple of hours after making this commit, it emerged that all<br>
> *.dir files built with xkbcomp 1.1.1 (released two years ago) and later<br>
> have been catastrophically broken and nearly empty. So I think that's<br>
> reasonable proof that no-one uses them.<br>
><br>
> Signed-off-by: Daniel Stone <<a href="mailto:daniel@fooishbar.org">daniel@fooishbar.org</a>><br>
> ---<br>
> include/xkbsrv.h | 17 ---<br>
> xkb/Makefile.am | 3 +-<br>
> xkb/ddxList.c | 304 ------------------------------------------------------<br>
> xkb/xkb.c | 42 +++-----<br>
> 4 files changed, 13 insertions(+), 353 deletions(-)<br>
> delete mode 100644 xkb/ddxList.c<br>
><br>
> diff --git a/include/xkbsrv.h b/include/xkbsrv.h<br>
> index d584785..2b926a9 100644<br>
> --- a/include/xkbsrv.h<br>
> +++ b/include/xkbsrv.h<br>
> @@ -835,23 +835,6 @@ extern void XkbFakeDeviceButton(DeviceIntPtr /* dev */ ,<br>
> #define _XkbListGeometry 4<br>
> #define _XkbListNumComponents 5<br>
><br>
> -typedef struct _XkbSrvListInfo {<br>
> - int szPool;<br>
> - int nPool;<br>
> - char *pool;<br>
> -<br>
> - int maxRtrn;<br>
> - int nTotal;<br>
> -<br>
> - char *pattern[_XkbListNumComponents];<br>
> - int nFound[_XkbListNumComponents];<br>
> -} XkbSrvListInfoRec, *XkbSrvListInfoPtr;<br>
> -<br>
> -extern _X_EXPORT Status XkbDDXList(DeviceIntPtr /* dev */ ,<br>
> - XkbSrvListInfoPtr /* listing */ ,<br>
> - ClientPtr /* client */<br>
> - );<br>
> -<br>
> extern _X_EXPORT unsigned int XkbDDXLoadKeymapByNames(DeviceIntPtr /* keybd */ ,<br>
> XkbComponentNamesPtr<br>
> /* names */ ,<br>
> diff --git a/xkb/Makefile.am b/xkb/Makefile.am<br>
> index fb3ccbf..e386ce5 100644<br>
> --- a/xkb/Makefile.am<br>
> +++ b/xkb/Makefile.am<br>
> @@ -6,8 +6,7 @@ DDX_SRCS = \<br>
> ddxBeep.c \<br>
> ddxCtrls.c \<br>
> ddxLEDs.c \<br>
> - ddxLoad.c \<br>
> - ddxList.c<br>
> + ddxLoad.c<br>
><br>
> DIX_SRCS = \<br>
> xkb.c \<br>
> diff --git a/xkb/ddxList.c b/xkb/ddxList.c<br>
> deleted file mode 100644<br>
> index 79f4637..0000000<br>
> --- a/xkb/ddxList.c<br>
> +++ /dev/null<br>
> @@ -1,304 +0,0 @@<br>
> -/************************************************************<br>
> -Copyright (c) 1995 by Silicon Graphics Computer Systems, Inc.<br>
> -<br>
> -Permission to use, copy, modify, and distribute this<br>
> -software and its documentation for any purpose and without<br>
> -fee is hereby granted, provided that the above copyright<br>
> -notice appear in all copies and that both that copyright<br>
> -notice and this permission notice appear in supporting<br>
> -documentation, and that the name of Silicon Graphics not be<br>
> -used in advertising or publicity pertaining to distribution<br>
> -of the software without specific prior written permission.<br>
> -Silicon Graphics makes no representation about the suitability<br>
> -of this software for any purpose. It is provided "as is"<br>
> -without any express or implied warranty.<br>
> -<br>
> -SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS<br>
> -SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY<br>
> -AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON<br>
> -GRAPHICS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL<br>
> -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,<br>
> -DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE<br>
> -OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH<br>
> -THE USE OR PERFORMANCE OF THIS SOFTWARE.<br>
> -<br>
> -********************************************************/<br>
> -<br>
> -#ifdef HAVE_DIX_CONFIG_H<br>
> -#include <dix-config.h><br>
> -#endif<br>
> -<br>
> -#include <stdio.h><br>
> -#include <ctype.h><br>
> -#include <X11/X.h><br>
> -#include <X11/Xos.h><br>
> -#include <X11/Xproto.h><br>
> -#include <X11/keysym.h><br>
> -#include <X11/extensions/XKM.h><br>
> -#include "inputstr.h"<br>
> -#include "scrnintstr.h"<br>
> -#include "windowstr.h"<br>
> -#define XKBSRV_NEED_FILE_FUNCS<br>
> -#include <xkbsrv.h><br>
> -#include <X11/extensions/XI.h><br>
> -<br>
> -#ifdef WIN32<br>
> -/* from ddxLoad.c */<br>
> -#define W32_tmparg " '%s'"<br>
> -#define W32_tmpfile ,tmpname<br>
> -#define W32_tmplen strlen(tmpname)+3<br>
> -#else<br>
> -#define W32_tmparg<br>
> -#define W32_tmpfile<br>
> -#define W32_tmplen 0<br>
> -#endif<br>
> -<br>
> -/***====================================================================***/<br>
> -<br>
> -static const char *componentDirs[_XkbListNumComponents] = {<br>
> - "keycodes", "types", "compat", "symbols", "geometry"<br>
> -};<br>
> -<br>
> -/***====================================================================***/<br>
> -<br>
> -static Status<br>
> -_AddListComponent(XkbSrvListInfoPtr list,<br>
> - int what, unsigned flags, char *str, ClientPtr client)<br>
> -{<br>
> - int slen, wlen;<br>
> - unsigned char *wire8;<br>
> - unsigned short *wire16;<br>
> - char *tmp;<br>
> -<br>
> - if (list->nTotal >= list->maxRtrn) {<br>
> - list->nTotal++;<br>
> - return Success;<br>
> - }<br>
> - tmp = strchr(str, ')');<br>
> - if ((tmp == NULL) && ((tmp = strchr(str, '(')) == NULL)) {<br>
> - slen = strlen(str);<br>
> - while ((slen > 0) && isspace(str[slen - 1])) {<br>
> - slen--;<br>
> - }<br>
> - }<br>
> - else {<br>
> - slen = (tmp - str + 1);<br>
> - }<br>
> - wlen = (((slen + 1) / 2) * 2) + 4; /* four bytes for flags and length, pad to */<br>
> - /* 2-byte boundary */<br>
> - if ((list->szPool - list->nPool) < wlen) {<br>
> - if (wlen > 1024)<br>
> - list->szPool += XkbPaddedSize(wlen * 2);<br>
> - else<br>
> - list->szPool += 1024;<br>
> - list->pool = realloc(list->pool, list->szPool * sizeof(char));<br>
> - if (!list->pool)<br>
> - return BadAlloc;<br>
> - }<br>
> - wire16 = (unsigned short *) &list->pool[list->nPool];<br>
> - wire8 = (unsigned char *) &wire16[2];<br>
> - wire16[0] = flags;<br>
> - wire16[1] = slen;<br>
> - memcpy(wire8, str, slen);<br>
> - if (client->swapped) {<br>
> - swaps(&wire16[0]);<br>
> - swaps(&wire16[1]);<br>
> - }<br>
> - list->nPool += wlen;<br>
> - list->nFound[what]++;<br>
> - list->nTotal++;<br>
> - return Success;<br>
> -}<br>
> -<br>
> -/***====================================================================***/<br>
> -static Status<br>
> -XkbDDXListComponent(DeviceIntPtr dev,<br>
> - int what, XkbSrvListInfoPtr list, ClientPtr client)<br>
> -{<br>
> - char *file, *map, *tmp, *buf = NULL;<br>
> - FILE *in;<br>
> - Status status;<br>
> - Bool haveDir;<br>
> -<br>
> -#ifdef WIN32<br>
> - char tmpname[PATH_MAX];<br>
> -#else<br>
> - int rval;<br>
> -#endif<br>
> -<br>
> - if ((list->pattern[what] == NULL) || (list->pattern[what][0] == '\0'))<br>
> - return Success;<br>
> - file = list->pattern[what];<br>
> - map = strrchr(file, '(');<br>
> - if (map != NULL) {<br>
> - char *tmp;<br>
> -<br>
> - map++;<br>
> - tmp = strrchr(map, ')');<br>
> - if ((tmp == NULL) || (tmp[1] != '\0')) {<br>
> - /* illegal pattern. No error, but no match */<br>
> - return Success;<br>
> - }<br>
> - }<br>
> -<br>
> - in = NULL;<br>
> - haveDir = TRUE;<br>
> -#ifdef WIN32<br>
> - strcpy(tmpname, Win32TempDir());<br>
> - strcat(tmpname, "\\xkb_XXXXXX");<br>
> - (void) mktemp(tmpname);<br>
> -#endif<br>
> - if (XkbBaseDirectory != NULL) {<br>
> - if ((list->pattern[what][0] == '*') && (list->pattern[what][1] == '\0')) {<br>
> - if (asprintf(&buf, "%s/%s.dir", XkbBaseDirectory,<br>
> - componentDirs[what]) == -1)<br>
> - buf = NULL;<br>
> - else<br>
> - in = fopen(buf, "r");<br>
> - }<br>
> - if (!in) {<br>
> - haveDir = FALSE;<br>
> - free(buf);<br>
> - if (asprintf<br>
> - (&buf,<br>
> - "'%s/xkbcomp' '-R%s/%s' -w %ld -l -vlfhpR '%s'" W32_tmparg,<br>
> - XkbBinDirectory, XkbBaseDirectory, componentDirs[what],<br>
> - (long) ((xkbDebugFlags < 2) ? 1 :<br>
> - ((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),<br>
> - file W32_tmpfile) == -1)<br>
> - buf = NULL;<br>
> - }<br>
> - }<br>
> - else {<br>
> - if ((list->pattern[what][0] == '*') && (list->pattern[what][1] == '\0')) {<br>
> - if (asprintf(&buf, "%s.dir", componentDirs[what]) == -1)<br>
> - buf = NULL;<br>
> - else<br>
> - in = fopen(buf, "r");<br>
> - }<br>
> - if (!in) {<br>
> - haveDir = FALSE;<br>
> - free(buf);<br>
> - if (asprintf<br>
> - (&buf,<br>
> - "xkbcomp -R%s -w %ld -l -vlfhpR '%s'" W32_tmparg,<br>
> - componentDirs[what],<br>
> - (long) ((xkbDebugFlags < 2) ? 1 :<br>
> - ((xkbDebugFlags > 10) ? 10 : xkbDebugFlags)),<br>
> - file W32_tmpfile) == -1)<br>
> - buf = NULL;<br>
> - }<br>
> - }<br>
> - status = Success;<br>
> - if (!haveDir) {<br>
> -#ifndef WIN32<br>
> - in = Popen(buf, "r");<br>
> -#else<br>
> - if (xkbDebugFlags)<br>
> - DebugF("[xkb] xkbList executes: %s\n", buf);<br>
> - if (System(buf) < 0)<br>
> - ErrorF("[xkb] Could not invoke keymap compiler\n");<br>
> - else<br>
> - in = fopen(tmpname, "r");<br>
> -#endif<br>
> - }<br>
> - if (!in) {<br>
> - free(buf);<br>
> -#ifdef WIN32<br>
> - unlink(tmpname);<br>
> -#endif<br>
> - return BadImplementation;<br>
> - }<br>
> - list->nFound[what] = 0;<br>
> - free(buf);<br>
> - buf = malloc(PATH_MAX * sizeof(char));<br>
> - if (!buf) {<br>
> - fclose(in);<br>
> -#ifdef WIN32<br>
> - unlink(tmpname);<br>
> -#endif<br>
> - return BadAlloc;<br>
> - }<br>
> - while ((status == Success) && ((tmp = fgets(buf, PATH_MAX, in)) != NULL)) {<br>
> - unsigned flags;<br>
> - register unsigned int i;<br>
> -<br>
> - if (*tmp == '#') /* comment, skip it */<br>
> - continue;<br>
> - if (!strncmp(tmp, "Warning:", 8) || !strncmp(tmp, " ", 8))<br>
> - /* skip warnings too */<br>
> - continue;<br>
> - flags = 0;<br>
> - /* each line in the listing is supposed to start with two */<br>
> - /* groups of eight characters, which specify the general */<br>
> - /* flags and the flags that are specific to the component */<br>
> - /* if they're missing, fail with BadImplementation */<br>
> - for (i = 0; (i < 8) && (status == Success); i++) { /* read the general flags */<br>
> - if (isalpha(*tmp))<br>
> - flags |= (1L << i);<br>
> - else if (*tmp != '-')<br>
> - status = BadImplementation;<br>
> - tmp++;<br>
> - }<br>
> - if (status != Success)<br>
> - break;<br>
> - if (!isspace(*tmp)) {<br>
> - status = BadImplementation;<br>
> - break;<br>
> - }<br>
> - else<br>
> - tmp++;<br>
> - for (i = 0; (i < 8) && (status == Success); i++) { /* read the component flags */<br>
> - if (isalpha(*tmp))<br>
> - flags |= (1L << (i + 8));<br>
> - else if (*tmp != '-')<br>
> - status = BadImplementation;<br>
> - tmp++;<br>
> - }<br>
> - if (status != Success)<br>
> - break;<br>
> - if (isspace(*tmp)) {<br>
> - while (isspace(*tmp)) {<br>
> - tmp++;<br>
> - }<br>
> - }<br>
> - else {<br>
> - status = BadImplementation;<br>
> - break;<br>
> - }<br>
> - status = _AddListComponent(list, what, flags, tmp, client);<br>
> - }<br>
> -#ifndef WIN32<br>
> - if (haveDir)<br>
> - fclose(in);<br>
> - else if ((rval = Pclose(in)) != 0) {<br>
> - if (xkbDebugFlags)<br>
> - ErrorF("[xkb] xkbcomp returned exit code %d\n", rval);<br>
> - }<br>
> -#else<br>
> - fclose(in);<br>
> - unlink(tmpname);<br>
> -#endif<br>
> - free(buf);<br>
> - return status;<br>
> -}<br>
> -<br>
> -/***====================================================================***/<br>
> -<br>
> -/* ARGSUSED */<br>
> -Status<br>
> -XkbDDXList(DeviceIntPtr dev, XkbSrvListInfoPtr list, ClientPtr client)<br>
> -{<br>
> - Status status;<br>
> -<br>
> - status = XkbDDXListComponent(dev, _XkbListKeycodes, list, client);<br>
> - if (status == Success)<br>
> - status = XkbDDXListComponent(dev, _XkbListTypes, list, client);<br>
> - if (status == Success)<br>
> - status = XkbDDXListComponent(dev, _XkbListCompat, list, client);<br>
> - if (status == Success)<br>
> - status = XkbDDXListComponent(dev, _XkbListSymbols, list, client);<br>
> - if (status == Success)<br>
> - status = XkbDDXListComponent(dev, _XkbListGeometry, list, client);<br>
> - return status;<br>
> -}<br>
> diff --git a/xkb/xkb.c b/xkb/xkb.c<br>
> index 4440a98..0d3bda3 100644<br>
> --- a/xkb/xkb.c<br>
> +++ b/xkb/xkb.c<br>
> @@ -5621,9 +5621,9 @@ ProcXkbListComponents(ClientPtr client)<br>
> DeviceIntPtr dev;<br>
> xkbListComponentsReply rep;<br>
> unsigned len;<br>
> - int status;<br>
> unsigned char *str;<br>
> - XkbSrvListInfoRec list;<br>
> + uint8_t size;<br>
> + int i;<br>
><br>
> REQUEST(xkbListComponentsReq);<br>
> REQUEST_AT_LEAST_SIZE(xkbListComponentsReq);<br>
> @@ -5633,40 +5633,27 @@ ProcXkbListComponents(ClientPtr client)<br>
><br>
> CHK_KBD_DEVICE(dev, stuff->deviceSpec, client, DixGetAttrAccess);<br>
><br>
> - status = Success;<br>
> str = (unsigned char *) &stuff[1];<br>
> - memset(&list, 0, sizeof(XkbSrvListInfoRec));<br>
> - list.maxRtrn = stuff->maxNames;<br>
> - list.pattern[_XkbListKeycodes] = GetComponentSpec(&str, FALSE, &status);<br>
> - list.pattern[_XkbListTypes] = GetComponentSpec(&str, FALSE, &status);<br>
> - list.pattern[_XkbListCompat] = GetComponentSpec(&str, FALSE, &status);<br>
> - list.pattern[_XkbListSymbols] = GetComponentSpec(&str, FALSE, &status);<br>
> - list.pattern[_XkbListGeometry] = GetComponentSpec(&str, FALSE, &status);<br>
> - if (status != Success)<br>
> - return status;<br>
> + for (i = 0; i < _XkbListNumComponents; i++) {<br>
> + size = *((uint8_t *)str);<br>
> + str += (size + 1);<br>
> + }</p>
<p>This seems wrong, although I'm not extremely familiar with how the server writes things on the wire. Overall, I agree with your assessment of the usefulness of this code. It's far more correct to do this from the XML on the client side.</p>
<p>Acked-by: Dan Nicholson <<a href="mailto:dbn.lists@gmail.com">dbn.lists@gmail.com</a>></p>