Patchwork [v2,3/6] rename keyname '<' to 'less'

login
register
mail settings
Submitter Amos Kong
Date June 1, 2012, 10:54 p.m.
Message ID <1338591268-23962-4-git-send-email-akong@redhat.com>
Download mbox | patch
Permalink /patch/162387/
State New
Headers show

Comments

Amos Kong - June 1, 2012, 10:54 p.m.
There are many maps of keycode 0x56 in pc-bios/keymaps/*
  pc-bios/keymaps/common:less 0x56
  pc-bios/keymaps/common:greater 0x56 shift
  pc-bios/keymaps/common:bar 0x56 altgr
  pc-bios/keymaps/common:brokenbar 0x56 shift altgr

This patch just rename '<' to 'less', QAPI might add new
variable by adding a prefix to keyname, '$PREFIX_<' is not
available, '$PREFIX_less' is ok.

For compatibility, convert user inputted '<' to 'less'.

Signed-off-by: Amos Kong <akong@redhat.com>
---
 monitor.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
Luiz Capitulino - June 6, 2012, 6:22 p.m.
On Sat,  2 Jun 2012 06:54:25 +0800
Amos Kong <akong@redhat.com> wrote:

> There are many maps of keycode 0x56 in pc-bios/keymaps/*
>   pc-bios/keymaps/common:less 0x56
>   pc-bios/keymaps/common:greater 0x56 shift
>   pc-bios/keymaps/common:bar 0x56 altgr
>   pc-bios/keymaps/common:brokenbar 0x56 shift altgr
> 
> This patch just rename '<' to 'less', QAPI might add new
> variable by adding a prefix to keyname, '$PREFIX_<' is not
> available, '$PREFIX_less' is ok.
> 
> For compatibility, convert user inputted '<' to 'less'.
> 
> Signed-off-by: Amos Kong <akong@redhat.com>
> ---
>  monitor.c |    9 ++++++++-
>  1 files changed, 8 insertions(+), 1 deletions(-)
> 
> diff --git a/monitor.c b/monitor.c
> index 12a6fe2..ecfcaa4 100644
> --- a/monitor.c
> +++ b/monitor.c
> @@ -1302,7 +1302,7 @@ static const KeyDef key_defs[] = {
>      { 0x48, "kp_8" },
>      { 0x49, "kp_9" },
>  
> -    { 0x56, "<" },
> +    { 0x56, "less" },
>  
>      { 0x57, "f11" },
>      { 0x58, "f12" },
> @@ -1406,6 +1406,13 @@ static void do_sendkey(Monitor *mon, const QDict *qdict)
>                  monitor_printf(mon, "too many keys\n");
>                  return;
>              }
> +
> +            /* Be compatible with old interface, convert user inputted "<" */
> +            if (!strcmp(keyname_buf, "<")) {
> +                pstrcpy(keyname_buf, sizeof(keyname_buf), "less");
> +                keyname_len = 4;
> +            }

I'm not against this change, but it breaks 'sendkey <-a'

> +
>              keyname_buf[keyname_len] = 0;
>              keycode = get_keycode(keyname_buf);
>              if (keycode < 0) {
Amos Kong - June 6, 2012, 11:12 p.m.
----- Original Message -----
> On Sat,  2 Jun 2012 06:54:25 +0800
> Amos Kong <akong@redhat.com> wrote:
> 
> > There are many maps of keycode 0x56 in pc-bios/keymaps/*
> >   pc-bios/keymaps/common:less 0x56
> >   pc-bios/keymaps/common:greater 0x56 shift
> >   pc-bios/keymaps/common:bar 0x56 altgr
> >   pc-bios/keymaps/common:brokenbar 0x56 shift altgr
> > 
> > This patch just rename '<' to 'less', QAPI might add new
> > variable by adding a prefix to keyname, '$PREFIX_<' is not
> > available, '$PREFIX_less' is ok.
> > 
> > For compatibility, convert user inputted '<' to 'less'.
> > 
> > Signed-off-by: Amos Kong <akong@redhat.com>
> > ---
> >  monitor.c |    9 ++++++++-
> >  1 files changed, 8 insertions(+), 1 deletions(-)
> > 
> > diff --git a/monitor.c b/monitor.c
> > index 12a6fe2..ecfcaa4 100644
> > --- a/monitor.c
> > +++ b/monitor.c
> > @@ -1302,7 +1302,7 @@ static const KeyDef key_defs[] = {
> >      { 0x48, "kp_8" },
> >      { 0x49, "kp_9" },
> >  
> > -    { 0x56, "<" },
> > +    { 0x56, "less" },
> >  
> >      { 0x57, "f11" },
> >      { 0x58, "f12" },
> > @@ -1406,6 +1406,13 @@ static void do_sendkey(Monitor *mon, const
> > QDict *qdict)
> >                  monitor_printf(mon, "too many keys\n");
> >                  return;
> >              }
> > +
> > +            /* Be compatible with old interface, convert user
> > inputted "<" */
> > +            if (!strcmp(keyname_buf, "<")) {
> > +                pstrcpy(keyname_buf, sizeof(keyname_buf), "less");
> > +                keyname_len = 4;
> > +            }
> 
> I'm not against this change, but it breaks 'sendkey <-a'

Thanks for catching this, already fixed:

@@ -978,7 +1141,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict)
         pstrcpy(keyname_buf, sizeof(keyname_buf), keys);
 
         /* Be compatible with old interface, convert user inputted "<" */
-        if (!strcmp(keyname_buf, "<")) {
+        if (!strncmp(keyname_buf, "<", 1) && keyname_len == 1) {
             pstrcpy(keyname_buf, sizeof(keyname_buf), "less");
             keyname_len = 4;
         }


> 
> > +
> >              keyname_buf[keyname_len] = 0;
> >              keycode = get_keycode(keyname_buf);
> >              if (keycode < 0) {
> 
> 
>

Patch

diff --git a/monitor.c b/monitor.c
index 12a6fe2..ecfcaa4 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1302,7 +1302,7 @@  static const KeyDef key_defs[] = {
     { 0x48, "kp_8" },
     { 0x49, "kp_9" },
 
-    { 0x56, "<" },
+    { 0x56, "less" },
 
     { 0x57, "f11" },
     { 0x58, "f12" },
@@ -1406,6 +1406,13 @@  static void do_sendkey(Monitor *mon, const QDict *qdict)
                 monitor_printf(mon, "too many keys\n");
                 return;
             }
+
+            /* Be compatible with old interface, convert user inputted "<" */
+            if (!strcmp(keyname_buf, "<")) {
+                pstrcpy(keyname_buf, sizeof(keyname_buf), "less");
+                keyname_len = 4;
+            }
+
             keyname_buf[keyname_len] = 0;
             keycode = get_keycode(keyname_buf);
             if (keycode < 0) {