Commit c98265ab authored by Daniel Stone's avatar Daniel Stone Committed by Ulrich Sibiller

makekeys: Scan vendor keysyms as well as core

Since we can't really live without vendor keysyms, scan them all in to generate ks_tables.h, rather than only doing the core ones, and leaving the vendor syms to be manually synchronised with XKeysymDB. Signed-off-by: 's avatarDaniel Stone <daniel@fooishbar.org> Reviewed-by: 's avatarAlan Coopersmith <alan.coopersmith@oracle.com>
parent 70327993
...@@ -51,63 +51,102 @@ static unsigned short offsets[KTNUM]; ...@@ -51,63 +51,102 @@ static unsigned short offsets[KTNUM];
static unsigned short indexes[KTNUM]; static unsigned short indexes[KTNUM];
static KeySym values[KTNUM]; static KeySym values[KTNUM];
static char buf[1024]; static char buf[1024];
static int ksnum = 0;
static int
parse_line(const char *buf, char *key, KeySym *val, char *prefix)
{
int i;
char alias[128];
char *tmp, *tmpa;
/* See if we can catch a straight XK_foo 0x1234-style definition first;
* the trickery around tmp is to account for prefices. */
i = sscanf(buf, "#define %127s 0x%lx", key, val);
if (i == 2 && (tmp = strstr(key, "XK_"))) {
memcpy(prefix, key, tmp - key);
prefix[tmp - key] = '\0';
tmp += 3;
memmove(key, tmp, strlen(tmp) + 1);
return 1;
}
/* Now try to catch alias (XK_foo XK_bar) definitions, and resolve them
* immediately: if the target is in the form XF86XK_foo, we need to
* canonicalise this to XF86foo before we do the lookup. */
i = sscanf(buf, "#define %127s %127s", key, alias);
if (i == 2 && (tmp = strstr(key, "XK_")) && (tmpa = strstr(alias, "XK_"))) {
memcpy(prefix, key, tmp - key);
prefix[tmp - key] = '\0';
tmp += 3;
memmove(key, tmp, strlen(tmp) + 1);
memmove(tmpa, tmpa + 3, strlen(tmpa + 3) + 1);
for (i = ksnum - 1; i >= 0; i--) {
if (strcmp(info[i].name, alias) == 0) {
*val = info[i].val;
return 1;
}
}
fprintf(stderr, "can't find matching definition %s for keysym %s%s\n",
alias, prefix, key);
}
return 0;
}
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
int ksnum = 0;
int max_rehash; int max_rehash;
Signature sig; Signature sig;
register int i, j, k, z; int i, j, k, l, z;
register char *name; FILE *fptr;
register char c; char *name;
char c;
int first; int first;
int best_max_rehash; int best_max_rehash;
int best_z = 0; int best_z = 0;
int num_found; int num_found;
KeySym val; KeySym val;
char key[128]; char key[128], prefix[128];
char alias[128];
for (l = 1; l < argc; l++) {
fptr = fopen(argv[l], "r");
if (!fptr) {
fprintf(stderr, "couldn't open %s\n", argv[l]);
continue;
}
while (fgets(buf, sizeof(buf), stdin)) { while (fgets(buf, sizeof(buf), fptr)) {
i = sscanf(buf, "#define XK_%127s 0x%lx", key, &info[ksnum].val); if (!parse_line(buf, key, &val, prefix))
if (i != 2) { continue;
i = sscanf(buf, "#define XK_%127s XK_%127s", key, alias);
if (i != 2) if (val == XK_VoidSymbol)
continue; val = 0;
for (i = ksnum - 1; i >= 0; i--) { if (val > 0x1fffffff) {
if (strcmp(info[i].name, alias) == 0) { fprintf(stderr, "ignoring illegal keysym (%s, %lx)\n", key,
info[ksnum].val = info[i].val; val);
break; continue;
} }
}
if (i < 0) { /* Didn't find a match */ name = malloc(strlen(prefix) + strlen(key) + 1);
fprintf(stderr, if (!name) {
"can't find matching definition %s for keysym %s\n", fprintf(stderr, "makekeys: out of memory!\n");
alias, key); exit(1);
continue; }
} sprintf(name, "%s%s", prefix, key);
} info[ksnum].name = name;
if (info[ksnum].val == XK_VoidSymbol) info[ksnum].val = val;
info[ksnum].val = 0; ksnum++;
if (info[ksnum].val > 0x1fffffff) { if (ksnum == KTNUM) {
fprintf(stderr, fprintf(stderr, "makekeys: too many keysyms!\n");
"ignoring illegal keysym (%s), remove it from .h file!\n", exit(1);
key); }
continue; }
}
name = strdup(key); fclose(fptr);
if (!name) {
fprintf(stderr, "makekeys: out of memory!\n");
exit(1);
}
info[ksnum].name = name;
ksnum++;
if (ksnum == KTNUM) {
fprintf(stderr, "makekeys: too many keysyms!\n");
exit(1);
}
} }
printf("/* This file is generated from keysymdef.h. */\n"); printf("/* This file is generated from keysymdef.h. */\n");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment