From 52756fb3c5376e8f59607de328f92f7f681d3972 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 6 Feb 2015 23:28:52 +0000 Subject: [PATCH 1/7] Use the same time for both calls to format_expand_time. --- status.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/status.c b/status.c index e7714a00..5f8895fb 100644 --- a/status.c +++ b/status.c @@ -758,9 +758,9 @@ status_prompt_set(struct client *c, const char *msg, const char *input, status_message_clear(c); status_prompt_clear(c); - c->prompt_string = format_expand_time(ft, msg, time(NULL)); + c->prompt_string = format_expand_time(ft, msg, t); - c->prompt_buffer = format_expand_time(ft, input, time(NULL)); + c->prompt_buffer = format_expand_time(ft, input, t); c->prompt_index = strlen(c->prompt_buffer); c->prompt_callbackfn = callbackfn; @@ -817,10 +817,10 @@ status_prompt_update(struct client *c, const char *msg, const char *input) t = time(NULL); free(c->prompt_string); - c->prompt_string = format_expand_time(ft, msg, time(NULL)); + c->prompt_string = format_expand_time(ft, msg, t); free(c->prompt_buffer); - c->prompt_buffer = format_expand_time(ft, input, time(NULL)); + c->prompt_buffer = format_expand_time(ft, input, t); c->prompt_index = strlen(c->prompt_buffer); c->prompt_hindex = 0; From f28032b03127557377a75d12457fd9a0222843bb Mon Sep 17 00:00:00 2001 From: nicm Date: Sat, 7 Feb 2015 23:43:41 +0000 Subject: [PATCH 2/7] Check for \0 in the right place, from J Raynor. --- colour.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/colour.c b/colour.c index 9e90596f..b5efd6f1 100644 --- a/colour.c +++ b/colour.c @@ -236,28 +236,28 @@ colour_fromstring(const char *s) if (strcasecmp(s, "default") == 0 || (s[0] == '8' && s[1] == '\0')) return (8); if (strcasecmp(s, "brightblack") == 0 || - (s[0] == '9' && s[1] == '0' && s[1] == '\0')) + (s[0] == '9' && s[1] == '0' && s[2] == '\0')) return (90); if (strcasecmp(s, "brightred") == 0 || - (s[0] == '9' && s[1] == '1' && s[1] == '\0')) + (s[0] == '9' && s[1] == '1' && s[2] == '\0')) return (91); if (strcasecmp(s, "brightgreen") == 0 || - (s[0] == '9' && s[1] == '2' && s[1] == '\0')) + (s[0] == '9' && s[1] == '2' && s[2] == '\0')) return (92); if (strcasecmp(s, "brightyellow") == 0 || - (s[0] == '9' && s[1] == '3' && s[1] == '\0')) + (s[0] == '9' && s[1] == '3' && s[2] == '\0')) return (93); if (strcasecmp(s, "brightblue") == 0 || - (s[0] == '9' && s[1] == '4' && s[1] == '\0')) + (s[0] == '9' && s[1] == '4' && s[2] == '\0')) return (94); if (strcasecmp(s, "brightmagenta") == 0 || - (s[0] == '9' && s[1] == '5' && s[1] == '\0')) + (s[0] == '9' && s[1] == '5' && s[2] == '\0')) return (95); if (strcasecmp(s, "brightcyan") == 0 || - (s[0] == '9' && s[1] == '6' && s[1] == '\0')) + (s[0] == '9' && s[1] == '6' && s[2] == '\0')) return (96); if (strcasecmp(s, "brightwhite") == 0 || - (s[0] == '9' && s[1] == '7' && s[1] == '\0')) + (s[0] == '9' && s[1] == '7' && s[2] == '\0')) return (97); return (-1); } From 1b2c62afe9ba0e52bbbcf002d5c4992976d6b4ec Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 9 Feb 2015 12:47:18 +0000 Subject: [PATCH 3/7] Entries in the window list can be NULL, prompted by a crash seen by Ben Boeckel. --- window.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/window.c b/window.c index 0206c6cc..6a742a2e 100644 --- a/window.c +++ b/window.c @@ -263,7 +263,7 @@ window_find_by_id(u_int id) for (i = 0; i < ARRAY_LENGTH(&windows); i++) { w = ARRAY_ITEM(&windows, i); - if (w->id == id) + if (w != NULL && w->id == id) return (w); } return (NULL); From 9ae2284726a8fd37f73cf98b6e78dd7540e023af Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 9 Feb 2015 23:18:19 +0000 Subject: [PATCH 4/7] Merge clock-mode command into copy-mode. --- Makefile | 1 - cmd-clock-mode.c | 49 ------------------------------------------------ cmd-copy-mode.c | 15 ++++++++++++++- 3 files changed, 14 insertions(+), 51 deletions(-) delete mode 100644 cmd-clock-mode.c diff --git a/Makefile b/Makefile index 67b39bb2..a719eaf1 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,6 @@ SRCS= arguments.c \ cmd-choose-client.c \ cmd-choose-tree.c \ cmd-clear-history.c \ - cmd-clock-mode.c \ cmd-command-prompt.c \ cmd-confirm-before.c \ cmd-copy-mode.c \ diff --git a/cmd-clock-mode.c b/cmd-clock-mode.c deleted file mode 100644 index 80835813..00000000 --- a/cmd-clock-mode.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $OpenBSD$ */ - -/* - * Copyright (c) 2009 Nicholas Marriott - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER - * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include - -#include "tmux.h" - -/* - * Enter clock mode. - */ - -enum cmd_retval cmd_clock_mode_exec(struct cmd *, struct cmd_q *); - -const struct cmd_entry cmd_clock_mode_entry = { - "clock-mode", NULL, - "t:", 0, 0, - CMD_TARGET_PANE_USAGE, - 0, - cmd_clock_mode_exec -}; - -enum cmd_retval -cmd_clock_mode_exec(struct cmd *self, struct cmd_q *cmdq) -{ - struct args *args = self->args; - struct window_pane *wp; - - if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL) - return (CMD_RETURN_ERROR); - - window_pane_set_mode(wp, &window_clock_mode); - - return (CMD_RETURN_NORMAL); -} diff --git a/cmd-copy-mode.c b/cmd-copy-mode.c index 89335296..b46a5a46 100644 --- a/cmd-copy-mode.c +++ b/cmd-copy-mode.c @@ -21,7 +21,7 @@ #include "tmux.h" /* - * Enter copy mode. + * Enter copy or clock mode. */ enum cmd_retval cmd_copy_mode_exec(struct cmd *, struct cmd_q *); @@ -34,6 +34,14 @@ const struct cmd_entry cmd_copy_mode_entry = { cmd_copy_mode_exec }; +const struct cmd_entry cmd_clock_mode_entry = { + "clock-mode", NULL, + "t:", 0, 0, + CMD_TARGET_PANE_USAGE, + 0, + cmd_copy_mode_exec +}; + enum cmd_retval cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq) { @@ -43,6 +51,11 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq) if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL) return (CMD_RETURN_ERROR); + if (self->entry == &cmd_clock_mode_entry) { + window_pane_set_mode(wp, &window_clock_mode); + return (CMD_RETURN_NORMAL); + } + if (wp->mode != &window_copy_mode) { if (window_pane_set_mode(wp, &window_copy_mode) != 0) return (CMD_RETURN_NORMAL); From 4d05d8830482f8d5b5f812d082f1332090fcf027 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 12 Feb 2015 09:56:19 +0000 Subject: [PATCH 5/7] Take a reference to prevent cmdq being freed during the command. Can happen to cfg_cmd_q (possibly others) when source-file recurses into cmdq_continue. Fixes bug reported by Ismail Donmez and Theo Buehler. --- cmd-queue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd-queue.c b/cmd-queue.c index 58282c8f..6be532a8 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -163,6 +163,7 @@ cmdq_continue(struct cmd_q *cmdq) int empty, flags; char s[1024]; + cmdq->references++; notify_disable(); empty = TAILQ_EMPTY(&cmdq->queue); @@ -220,11 +221,13 @@ empty: if (cmdq->client_exit > 0) cmdq->client->flags |= CLIENT_EXIT; if (cmdq->emptyfn != NULL) - cmdq->emptyfn(cmdq); /* may free cmdq */ + cmdq->emptyfn(cmdq); empty = 1; out: notify_enable(); + cmdq_free(cmdq); + return (empty); } From c2bbaab2ac06420fa56c872294a9f8d7b326571e Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sun, 15 Feb 2015 20:07:48 +0000 Subject: [PATCH 6/7] Add -Wno-format-nonliteral to Makefile.am Shut GCC up about non-literal arguments to functions which make use of placeholder expansions (printf, strftime, etc.) --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index 63e20b17..ccb3c2ad 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,7 +32,7 @@ CFLAGS += -Wno-long-long -Wall -W -Wnested-externs -Wformat=2 CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align -CFLAGS += -Wdeclaration-after-statement +CFLAGS += -Wdeclaration-after-statement -Wno-format-nonliteral CPPFLAGS += -DDEBUG endif if IS_GCC4 From be6dc83277c49c8f7db30cc363134463af0aa596 Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Sun, 15 Feb 2015 21:19:51 +0000 Subject: [PATCH 7/7] Revert "Add -Wno-format-nonliteral to Makefile.am" Oh well. This will hide legitimate programming errors, which I knew, so I'll just have to accept that when looking through the compiler output. This reverts commit c2bbaab2ac06420fa56c872294a9f8d7b326571e. --- Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.am b/Makefile.am index ccb3c2ad..63e20b17 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,7 +32,7 @@ CFLAGS += -Wno-long-long -Wall -W -Wnested-externs -Wformat=2 CFLAGS += -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations CFLAGS += -Wwrite-strings -Wshadow -Wpointer-arith -Wsign-compare CFLAGS += -Wundef -Wbad-function-cast -Winline -Wcast-align -CFLAGS += -Wdeclaration-after-statement -Wno-format-nonliteral +CFLAGS += -Wdeclaration-after-statement CPPFLAGS += -DDEBUG endif if IS_GCC4