]> git.proxmox.com Git - qemu.git/blobdiff - ui/keymaps.c
rng-egd: remove redundant free
[qemu.git] / ui / keymaps.c
index f54a11437b96761840a39eda1a2ec2a3ddaae382..80d658d907d3d5671ccc7c5c3ceb21f587eea56d 100644 (file)
@@ -23,7 +23,7 @@
  */
 
 #include "keymaps.h"
-#include "sysemu.h"
+#include "sysemu/sysemu.h"
 
 static int get_keysym(const name2keysym_t *table,
                      const char *name)
@@ -33,6 +33,12 @@ static int get_keysym(const name2keysym_t *table,
         if (!strcmp(p->name, name))
             return p->keysym;
     }
+    if (name[0] == 'U' && strlen(name) == 5) { /* try unicode Uxxxx */
+        char *end;
+        int ret = (int)strtoul(name + 1, &end, 16);
+        if (*end == '\0' && ret > 0)
+          return ret;
+    }
     return 0;
 }
 
@@ -92,15 +98,17 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
     int len;
 
     filename = qemu_find_file(QEMU_FILE_TYPE_KEYMAP, language);
-
-    if (!k)
-       k = g_malloc0(sizeof(kbd_layout_t));
-    if (!(filename && (f = fopen(filename, "r")))) {
+    f = filename ? fopen(filename, "r") : NULL;
+    g_free(filename);
+    if (!f) {
        fprintf(stderr,
                "Could not read keymap file: '%s'\n", language);
        return NULL;
     }
-    g_free(filename);
+
+    if (!k)
+       k = g_malloc0(sizeof(kbd_layout_t));
+
     for(;;) {
        if (fgets(line, 1024, f) == NULL)
             break;
@@ -125,25 +133,27 @@ static kbd_layout_t *parse_keyboard_layout(const name2keysym_t *table,
                     //             fprintf(stderr, "Warning: unknown keysym %s\n", line);
                } else {
                    const char *rest = end_of_keysym + 1;
-                   char *rest2;
-                   int keycode = strtol(rest, &rest2, 0);
+                    int keycode = strtol(rest, NULL, 0);
 
-                   if (rest && strstr(rest, "numlock")) {
+                    if (strstr(rest, "numlock")) {
                        add_to_key_range(&k->keypad_range, keycode);
                        add_to_key_range(&k->numlock_range, keysym);
                        //fprintf(stderr, "keypad keysym %04x keycode %d\n", keysym, keycode);
                    }
 
-                   if (rest && strstr(rest, "shift"))
+                    if (strstr(rest, "shift")) {
                        keycode |= SCANCODE_SHIFT;
-                   if (rest && strstr(rest, "altgr"))
+                    }
+                    if (strstr(rest, "altgr")) {
                        keycode |= SCANCODE_ALTGR;
-                   if (rest && strstr(rest, "ctrl"))
+                    }
+                    if (strstr(rest, "ctrl")) {
                        keycode |= SCANCODE_CTRL;
+                    }
 
                    add_keysym(line, keysym, keycode, k);
 
-                   if (rest && strstr(rest, "addupper")) {
+                    if (strstr(rest, "addupper")) {
                        char *c;
                        for (c = line; *c; c++)
                            *c = qemu_toupper(*c);