=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/key-string.c,v retrieving revision 1.32 retrieving revision 1.33 diff -c -r1.32 -r1.33 *** src/usr.bin/tmux/key-string.c 2015/11/14 11:45:43 1.32 --- src/usr.bin/tmux/key-string.c 2015/12/12 18:19:00 1.33 *************** *** 1,4 **** ! /* $OpenBSD: key-string.c,v 1.32 2015/11/14 11:45:43 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: key-string.c,v 1.33 2015/12/12 18:19:00 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 22,29 **** #include "tmux.h" ! key_code key_string_search_table(const char *); ! key_code key_string_get_modifiers(const char **); const struct { const char *string; --- 22,29 ---- #include "tmux.h" ! static key_code key_string_search_table(const char *); ! static key_code key_string_get_modifiers(const char **); const struct { const char *string; *************** *** 98,104 **** }; /* Find key string in table. */ ! key_code key_string_search_table(const char *string) { u_int i; --- 98,104 ---- }; /* Find key string in table. */ ! static key_code key_string_search_table(const char *string) { u_int i; *************** *** 107,117 **** if (strcasecmp(string, key_string_table[i].string) == 0) return (key_string_table[i].key); } ! return (KEYC_NONE); } /* Find modifiers. */ ! key_code key_string_get_modifiers(const char **string) { key_code modifiers; --- 107,117 ---- if (strcasecmp(string, key_string_table[i].string) == 0) return (key_string_table[i].key); } ! return (KEYC_UNKNOWN); } /* Find modifiers. */ ! static key_code key_string_get_modifiers(const char **string) { key_code modifiers; *************** *** 150,159 **** u_int i; enum utf8_state more; /* 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); } --- 150,163 ---- u_int i; enum utf8_state more; + /* Is this no key? */ + if (strcasecmp(string, "None") == 0) + return (KEYC_NONE); + /* 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_UNKNOWN); return (u); } *************** *** 165,194 **** } modifiers |= key_string_get_modifiers(&string); if (string[0] == '\0') ! return (KEYC_NONE); /* Is this a standard ASCII key? */ if (string[1] == '\0' && (u_char)string[0] <= 127) { key = (u_char)string[0]; if (key < 32 || key == 127) ! return (KEYC_NONE); } else { /* Try as a UTF-8 key. */ if ((more = utf8_open(&ud, (u_char)*string)) == UTF8_MORE) { if (strlen(string) != ud.size) ! return (KEYC_NONE); for (i = 1; i < ud.size; i++) more = utf8_append(&ud, (u_char)string[i]); if (more != UTF8_DONE) ! return (KEYC_NONE); key = utf8_combine(&ud); return (key | modifiers); } /* Otherwise look the key up in the table. */ key = key_string_search_table(string); ! if (key == KEYC_NONE) ! return (KEYC_NONE); } /* Convert the standard control keys. */ --- 169,198 ---- } modifiers |= key_string_get_modifiers(&string); if (string[0] == '\0') ! return (KEYC_UNKNOWN); /* Is this a standard ASCII key? */ if (string[1] == '\0' && (u_char)string[0] <= 127) { key = (u_char)string[0]; if (key < 32 || key == 127) ! return (KEYC_UNKNOWN); } else { /* Try as a UTF-8 key. */ if ((more = utf8_open(&ud, (u_char)*string)) == UTF8_MORE) { if (strlen(string) != ud.size) ! return (KEYC_UNKNOWN); for (i = 1; i < ud.size; i++) more = utf8_append(&ud, (u_char)string[i]); if (more != UTF8_DONE) ! return (KEYC_UNKNOWN); key = utf8_combine(&ud); return (key | modifiers); } /* Otherwise look the key up in the table. */ key = key_string_search_table(string); ! if (key == KEYC_UNKNOWN) ! return (KEYC_UNKNOWN); } /* Convert the standard control keys. */ *************** *** 202,208 **** else if (key == 63) key = KEYC_BSPACE; else ! return (KEYC_NONE); modifiers &= ~KEYC_CTRL; } --- 206,212 ---- else if (key == 63) key = KEYC_BSPACE; else ! return (KEYC_UNKNOWN); modifiers &= ~KEYC_CTRL; } *************** *** 222,230 **** /* Handle no key. */ if (key == KEYC_NONE) ! return (""); if (key == KEYC_MOUSE) ! return (""); /* * Special case: display C-@ as C-Space. Could do this below in --- 226,238 ---- /* Handle no key. */ if (key == KEYC_NONE) ! return ("None"); ! ! /* Handle special keys. */ ! if (key == KEYC_UNKNOWN) ! return ("Unknown"); if (key == KEYC_MOUSE) ! return ("Mouse"); /* * Special case: display C-@ as C-Space. Could do this below in *************** *** 265,271 **** /* Invalid keys are errors. */ if (key == 127 || key > 255) { ! snprintf(out, sizeof out, "", key); return (out); } --- 273,279 ---- /* Invalid keys are errors. */ if (key == 127 || key > 255) { ! snprintf(out, sizeof out, "Invalid#%llx", key); return (out); }