Fix two problems with the keymap auto-conversion patch
authorMichael Schutte <michi@uiae.at>
Sat, 25 Apr 2009 14:41:41 +0000 (16:41 +0200)
committerMichael Schutte <michi@uiae.at>
Sun, 26 Apr 2009 09:22:11 +0000 (11:22 +0200)
* Correctly resolve plain ASCII characters in codetoksym.  The original
  auto-conversion patch handles keysyms smaller than 0x80 incorrectly if
  prefer_unicode is set.

* Avoid a memory leak in set_charset.

Signed-off-by: Michael Schutte <michi@uiae.at>
src/ksyms.c

index 36196f1..cf8ae24 100644 (file)
@@ -1,6 +1,7 @@
 #include <linux/keyboard.h>
 #include <stdio.h>
 #include <string.h>
+#include <stdlib.h>
 #include "ksyms.h"
 #include "nls.h"
 
@@ -1645,7 +1646,7 @@ struct cs {
 /* Functions for both dumpkeys and loadkeys. */
 
 int prefer_unicode = 0;
-static const char *chosen_charset = NULL;
+static char *chosen_charset = NULL;
 
 void
 list_charsets(FILE *f) {
@@ -1695,6 +1696,8 @@ set_charset(const char *charset) {
                                if(p->name[0])
                                        syms[0].table[i] = p->name;
                        }
+                       if (chosen_charset)
+                               free(chosen_charset);
                        chosen_charset = strdup(charset);
                        return 0;
                }
@@ -1714,6 +1717,8 @@ codetoksym(int code) {
                return NULL;
 
        if (code < 0x1000) {    /* "traditional" keysym */
+               if (code < 0x80)
+                       return iso646_syms[code];
                if (KTYP(code) == KT_META)
                        return NULL;
                if (KTYP(code) == KT_LETTER)