Patchwork [3/3] qemu-char: add support for U-prefixed symbols

login
register
mail settings
Submitter Jan Krupa
Date Aug. 27, 2013, 3:14 p.m.
Message ID <1377616488-16491-4-git-send-email-JKrupa@suse.com>
Download mbox | patch
Permalink /patch/270142/
State New
Headers show

Comments

Jan Krupa - Aug. 27, 2013, 3:14 p.m.
This patch adds support for Unicode symbols in keymap files. This
feature was already used in some keyboard layouts in QEMU generated
from XKB (e.g. Arabic) but it wasn't implemented in QEMU source code.

Signed-off-by: Jan Krupa <jkrupa@suse.com>
---
 ui/keymaps.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Michael Tokarev - Sept. 1, 2013, 3:23 p.m.
27.08.2013 19:14, Jan Krupa wrote:
> This patch adds support for Unicode symbols in keymap files. This
> feature was already used in some keyboard layouts in QEMU generated
> from XKB (e.g. Arabic) but it wasn't implemented in QEMU source code.
>
> Signed-off-by: Jan Krupa <jkrupa@suse.com>
> ---
>   ui/keymaps.c |    3 +++
>   1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/ui/keymaps.c b/ui/keymaps.c
> index f373cc5..426a893 100644
> --- a/ui/keymaps.c
> +++ b/ui/keymaps.c
> @@ -33,6 +33,9 @@ static int get_keysym(const name2keysym_t *table,
>           if (!strcmp(p->name, name))
>               return p->keysym;
>       }
> +    if (strlen(name) == 5 && name[0] == 'U') {
> +        return (int)strtol(name + 1, NULL, 16);
> +    }

How about something like

   if (sscanf(name, "U%04x", &temp) == 1)

instead, to ensure it actually is a valid hex number?
Because this code will behave in interesting way
given, eg, "U" or "UU"... ;)  But I don't think this
really matters much...

Thanks,

Patch

diff --git a/ui/keymaps.c b/ui/keymaps.c
index f373cc5..426a893 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -33,6 +33,9 @@  static int get_keysym(const name2keysym_t *table,
         if (!strcmp(p->name, name))
             return p->keysym;
     }
+    if (strlen(name) == 5 && name[0] == 'U') {
+        return (int)strtol(name + 1, NULL, 16);
+    }
     return 0;
 }