summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2015-10-26 22:03:04 +0000
committernicm <nicm@openbsd.org>2015-10-26 22:03:04 +0000
commitaa60fd48f9c224fe43fa9d6fd7d5e3ce80f807b4 (patch)
tree59bbf9d2d15c9c58e8dce4bcc09b3de4cb007be7
parentremove the profiling and debugging ifdefs; ok zhuk@ (diff)
downloadwireguard-openbsd-aa60fd48f9c224fe43fa9d6fd7d5e3ce80f807b4.tar.xz
wireguard-openbsd-aa60fd48f9c224fe43fa9d6fd7d5e3ce80f807b4.zip
Handle unknown keys more gracefully, return a string instead of NULL.
-rw-r--r--usr.bin/tmux/cmd-list-keys.c10
-rw-r--r--usr.bin/tmux/key-string.c8
2 files changed, 6 insertions, 12 deletions
diff --git a/usr.bin/tmux/cmd-list-keys.c b/usr.bin/tmux/cmd-list-keys.c
index fc6f19ec28e..fcc428cb779 100644
--- a/usr.bin/tmux/cmd-list-keys.c
+++ b/usr.bin/tmux/cmd-list-keys.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-list-keys.c,v 1.26 2015/04/20 15:34:56 nicm Exp $ */
+/* $OpenBSD: cmd-list-keys.c,v 1.27 2015/10/26 22:03:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -77,8 +77,6 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
continue;
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
key = key_string_lookup_key(bd->key);
- if (key == NULL)
- continue;
if (bd->can_repeat)
repeat = 1;
@@ -97,8 +95,6 @@ cmd_list_keys_exec(struct cmd *self, struct cmd_q *cmdq)
continue;
RB_FOREACH(bd, key_bindings, &table->key_bindings) {
key = key_string_lookup_key(bd->key);
- if (key == NULL)
- continue;
if (!repeat)
r = "";
@@ -140,8 +136,6 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
any_mode = 0;
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
key = key_string_lookup_key(mbind->key);
- if (key == NULL)
- continue;
if (mbind->mode != 0)
any_mode = 1;
@@ -153,8 +147,6 @@ cmd_list_keys_table(struct cmd *self, struct cmd_q *cmdq)
RB_FOREACH(mbind, mode_key_tree, mtab->tree) {
key = key_string_lookup_key(mbind->key);
- if (key == NULL)
- continue;
mode = "";
if (mbind->mode != 0)
diff --git a/usr.bin/tmux/key-string.c b/usr.bin/tmux/key-string.c
index b8e68b298de..80f7396c018 100644
--- a/usr.bin/tmux/key-string.c
+++ b/usr.bin/tmux/key-string.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: key-string.c,v 1.26 2015/04/19 21:34:21 nicm Exp $ */
+/* $OpenBSD: key-string.c,v 1.27 2015/10/26 22:03:04 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -238,8 +238,10 @@ key_string_lookup_key(int key)
}
/* Invalid keys are errors. */
- if (key == 127 || key > 255)
- return (NULL);
+ if (key == 127 || key > 255) {
+ snprintf(out, sizeof out, "<INVALID#%04x>", key);
+ return (out);
+ }
/* Check for standard or control key. */
if (key >= 0 && key <= 32) {