Looks good, thanks! On Sun, Mar 4, 2012 at 12:40 PM, Nicholas Marriott <nicholas.marri...@gmail.com> wrote: > Going with this instead which allows any size. > > Index: key-string.c > =================================================================== > RCS file: /cvs/src/usr.bin/tmux/key-string.c,v > retrieving revision 1.22 > diff -u -p -r1.22 key-string.c > --- key-string.c 21 Jan 2012 08:40:09 -0000 1.22 > +++ key-string.c 4 Mar 2012 20:39:34 -0000 > @@ -137,6 +137,15 @@ int > key_string_lookup_string(const char *string) > { > int key, modifiers; > + u_short u; > + int size; > + > + /* Is this a hexadecimal value? */ > + if (string[0] == '0' && string[1] == 'x') { > + if (sscanf(string + 2, "%hx%n", &u, &size) != 1 || size > 4) > + return (KEYC_NONE); > + return (u); > + } > > /* Check for modifiers. */ > modifiers = 0; > > > > On Sun, Mar 04, 2012 at 11:52:58AM -0800, George Nachman wrote: >> It's a little inefficient when sending a lot of keys, but it's a much >> cleaner solution. The only thing I'd change is to also accept size == >> 4. >> >> Index: key-string.c >> =================================================================== >> --- key-string.c (revision 2710) >> +++ key-string.c (working copy) >> @@ -136,8 +136,17 @@ >> int >> key_string_lookup_string(const char *string) >> { >> + size_t size; >> int key, modifiers; >> + u_short u; >> >> + /* Is this a hexadecimal value? */ >> + size = strlen(string); >> + if (string[0] == '0' && string[1] == 'x' && (size == 4 || size == 6)) { >> + if (sscanf(string + 2, "%04hx", &u) != 1) >> + return (KEYC_NONE); >> + return (u); >> + } >> /* Check for modifiers. */ >> modifiers = 0; >> if (string[0] == '^' && string[1] != '\0') {
------------------------------------------------------------------------------ Keep Your Developer Skills Current with LearnDevNow! The most comprehensive online learning library for Microsoft developers is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3, Metro Style Apps, more. Free future releases when you subscribe now! http://p.sf.net/sfu/learndevnow-d2d _______________________________________________ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users