[PATCH libxkbcommon 3/4] makekeys: Receive the keysym files as arguments

Ran Benita ran234 at gmail.com
Sat Feb 25 14:25:49 PST 2012


This integrates part of libX11 commit
00175397480b76d32bf82b0c7c94c91a2a95954e
    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: Daniel Stone <daniel at fooishbar.org>
    Reviewed-by: Alan Coopersmith <alan.coopersmith at oracle.com>

Signed-off-by: Ran Benita <ran234 at gmail.com>
---
 configure.ac         |   25 ++++++++--------
 makekeys/Makefile.am |    3 ++
 makekeys/makekeys.c  |   78 ++++++++++++++++++++++++++++----------------------
 src/Makefile.am      |    4 +--
 4 files changed, 61 insertions(+), 49 deletions(-)

diff --git a/configure.ac b/configure.ac
index e6a8f15..786556c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,19 +77,18 @@ AC_MSG_CHECKING([for X11 includedir])
 includex11dir="`$PKG_CONFIG --variable=includex11dir xproto`"
 AC_MSG_RESULT([$includex11dir])
 
-# Obtain full path for keysymdef header file
-AC_MSG_CHECKING([for keysymdef.h])
-KEYSYMDEF_H="$includex11dir/keysymdef.h"
-test -f "$KEYSYMDEF_H" || AC_MSG_ERROR([can't locate keysymdef.h in $includex11dir])
-AC_MSG_RESULT([$KEYSYMDEF_H])
-AC_SUBST([KEYSYMDEF_H])
-
-# Obtain full path for XF86keysym header file
-AC_MSG_CHECKING([for XF86keysym.h])
-XF86KEYSYM_H="$includex11dir/XF86keysym.h"
-test -f "$XF86KEYSYM_H" || AC_MSG_ERROR([can't locate XF86keysym.h in $includex11dir])
-AC_MSG_RESULT([$XF86KEYSYM_H])
-AC_SUBST([XF86KEYSYM_H])
+AC_MSG_CHECKING([keysym definitions])
+KEYSYMDEFDIR=`$PKG_CONFIG --variable=includedir xproto`/X11
+FILES="keysymdef.h XF86keysym.h Sunkeysym.h DECkeysym.h HPkeysym.h"
+for i in $FILES; do
+    if test -f "$KEYSYMDEFDIR/$i"; then
+            KEYSYMDEFS="$KEYSYMDEFS $KEYSYMDEFDIR/$i"
+    elif test "x$i" = "xkeysymdef.h"; then
+            AC_MSG_ERROR([Cannot find keysymdef.h])
+    fi
+done
+AC_MSG_RESULT([$KEYSYMDEFS])
+AC_SUBST(KEYSYMDEFS)
 
 # Define a configuration option for the XKB config root
 xkb_base=`$PKG_CONFIG --variable=xkb_base xkeyboard-config`
diff --git a/makekeys/Makefile.am b/makekeys/Makefile.am
index 75ed164..a7ef6e0 100644
--- a/makekeys/Makefile.am
+++ b/makekeys/Makefile.am
@@ -2,4 +2,7 @@ AM_CFLAGS = $(X11_CFLAGS) $(CWARNFLAGS)
 
 # need to use build-native compiler
 CC = $(CC_FOR_BUILD)
+CPPFLAGS = $(CPPFLAGS_FOR_BUILD)
+CFLAGS = $(CFLAGS_FOR_BUILD)
+LDFLAGS = $(LDFLAGS_FOR_BUILD)
 noinst_PROGRAMS = makekeys
diff --git a/makekeys/makekeys.c b/makekeys/makekeys.c
index fdccaf0..1334e15 100644
--- a/makekeys/makekeys.c
+++ b/makekeys/makekeys.c
@@ -170,9 +170,10 @@ int
 main(int argc, char *argv[])
 {
     int ksnum = 0;
+    FILE *fptr;
     int max_rehash;
     Signature sig;
-    int i, j, k, z;
+    int i, j, k, l, z;
     char *name;
     char c;
     int first;
@@ -183,45 +184,54 @@ main(int argc, char *argv[])
     char key[128];
     char buf[1024];
 
+    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)) {
-        int ret;
+        while (fgets(buf, sizeof(buf), fptr)) {
+            int ret;
 
-        /* Manage keysyms from keysymdef.h */
-        ret = get_keysym(buf, key, ksnum);
-        if (!ret) {
-            ret = get_keysym_alias(buf, key, ksnum);
-            if (ret == -1)
-                continue;
-        }
+            /* Manage keysyms from keysymdef.h */
+            ret = get_keysym(buf, key, ksnum);
+            if (!ret) {
+                ret = get_keysym_alias(buf, key, ksnum);
+                if (ret == -1)
+                    continue;
+            }
+
+            /* Manage keysyms from XF86keysym.h */
+            if (!ret)
+                ret = get_xf86_keysym(buf, key, sizeof(key), ksnum);
+            if (!ret) {
+                ret = get_xf86_keysym_alias(buf, key, sizeof(key), ksnum);
+                if (ret < 1)
+                    continue;
+            }
 
-        /* Manage keysyms from XF86keysym.h */
-        if (!ret)
-            ret = get_xf86_keysym(buf, key, sizeof(key), ksnum);
-        if (!ret) {
-            ret = get_xf86_keysym_alias(buf, key, sizeof(key), ksnum);
-            if (ret < 1)
+            if (info[ksnum].val > 0x1fffffff) {
+                fprintf(stderr,
+                        "ignoring illegal keysym (%s), remove it from .h file!\n",
+                        key);
                 continue;
+            }
+            name = malloc((unsigned)strlen(key) + 1);
+            if (!name) {
+                fprintf(stderr, "makekeys: out of memory!\n");
+                exit(1);
+            }
+            (void)strcpy(name, key);
+            info[ksnum].name = name;
+            ksnum++;
+            if (ksnum == KTNUM) {
+                fprintf(stderr, "makekeys: too many keysyms!\n");
+                exit(1);
+            }
         }
 
-        if (info[ksnum].val > 0x1fffffff) {
-            fprintf(stderr,
-                    "ignoring illegal keysym (%s), remove it from .h file!\n",
-                    key);
-            continue;
-        }
-        name = malloc((unsigned)strlen(key) + 1);
-        if (!name) {
-            fprintf(stderr, "makekeys: out of memory!\n");
-            exit(1);
-        }
-        (void)strcpy(name, key);
-        info[ksnum].name = name;
-        ksnum++;
-        if (ksnum == KTNUM) {
-            fprintf(stderr, "makekeys: too many keysyms!\n");
-            exit(1);
-        }
+        fclose(fptr);
     }
 
     /* Special case NoSymbol. */
diff --git a/src/Makefile.am b/src/Makefile.am
index b9a12b9..9df6f81 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -26,5 +26,5 @@ libxkbcommon_la_SOURCES = \
 BUILT_SOURCES = ks_tables.h
 CLEANFILES = $(BUILT_SOURCES)
 
-ks_tables.h: $(top_builddir)/makekeys/makekeys$(EXEEXT) $(KEYSYMDEF_H) $(XF86KEYSYM_H)
-	$(AM_V_GEN)cat $(KEYSYMDEF_H) $(XF86KEYSYM_H) | $(top_builddir)/makekeys/makekeys$(EXEEXT) > $@
+ks_tables.h: $(KEYSYMDEFS) $(top_builddir)/makekeys/makekeys$(EXEEXT)
+	$(top_builddir)/makekeys/makekeys $(KEYSYMDEFS) > $@
-- 
1.7.9.2



More information about the xorg-devel mailing list