diff options
author | Tiago Cunha <tcunha@gmx.com> | 2010-07-02 02:43:01 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2010-07-02 02:43:01 +0000 |
commit | 03c1c1cd9f731a8a5a066855077e91e31d2baf34 (patch) | |
tree | 832957257356595b9739132bd7d72aeea410f7a7 /cmd-bind-key.c | |
parent | 0e70c8801cc4143b9100c860df1f2e3aac368d0a (diff) | |
download | rtmux-03c1c1cd9f731a8a5a066855077e91e31d2baf34.tar.gz rtmux-03c1c1cd9f731a8a5a066855077e91e31d2baf34.tar.bz2 rtmux-03c1c1cd9f731a8a5a066855077e91e31d2baf34.zip |
Sync OpenBSD patchset 727:
Setting the cmdlist pointer in the bind-key to NULL to prevent it being freed
after the command is executing is bogus because it may still be needed if the
same command is going to be executed again (for example if you "bind-key a
bind-key b ..."). Making a copy is hard, so instead add a reference count to
the cmd_list.
While here, also print bind-key -n and the rest of the flags properly.
Fixes problem reported by mcbride@.
Diffstat (limited to 'cmd-bind-key.c')
-rw-r--r-- | cmd-bind-key.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/cmd-bind-key.c b/cmd-bind-key.c index 3bb613eb..c5440b48 100644 --- a/cmd-bind-key.c +++ b/cmd-bind-key.c @@ -1,4 +1,4 @@ -/* $Id: cmd-bind-key.c,v 1.28 2010-01-25 17:12:44 tcunha Exp $ */ +/* $Id: cmd-bind-key.c,v 1.29 2010-07-02 02:43:01 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -130,7 +130,7 @@ cmd_bind_key_exec(struct cmd *self, unused struct cmd_ctx *ctx) return (cmd_bind_key_table(self, ctx)); key_bindings_add(data->key, data->can_repeat, data->cmdlist); - data->cmdlist = NULL; /* avoid free */ + data->cmdlist->references++; return (0); } @@ -192,8 +192,17 @@ cmd_bind_key_print(struct cmd *self, char *buf, size_t len) off += xsnprintf(buf, len, "%s", self->entry->name); if (data == NULL) return (off); + + if (off < len && data->command_key) + off += xsnprintf(buf + off, len - off, " -c"); + if (off < len && !(data->key & KEYC_PREFIX)) + off += xsnprintf(buf + off, len - off, " -n"); + if (off < len && data->can_repeat) + off += xsnprintf(buf + off, len - off, " -r"); + if (off < len && data->tablename != NULL) + off += cmd_prarg(buf + off, len - off, " -t ", data->tablename); if (off < len) { - skey = key_string_lookup_key(data->key); + skey = key_string_lookup_key(data->key & ~KEYC_PREFIX); off += xsnprintf(buf + off, len - off, " %s ", skey); } if (off < len) |