From 01b13de655cae6cd619bf872d16f82600ff6081e Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Aug 2021 17:36:03 +0000 Subject: [PATCH 1/3] Fill colour palette correctly from option for new panes, GitHub issue 2831. --- window.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/window.c b/window.c index 446898cb..584dbf9c 100644 --- a/window.c +++ b/window.c @@ -924,6 +924,8 @@ window_pane_create(struct window *w, u_int sx, u_int sy, u_int hlimit) wp->pipe_fd = -1; colour_palette_init(&wp->palette); + colour_palette_from_option(&wp->palette, wp->options); + screen_init(&wp->base, sx, sy, hlimit); wp->screen = &wp->base; From e463e8622dff28394145868a124b10101afc2269 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Aug 2021 17:50:42 +0000 Subject: [PATCH 2/3] Remove stray spaces after function names. --- cmd-list-keys.c | 5 ++--- format.c | 7 +++---- input-keys.c | 2 +- mode-tree.c | 2 +- names.c | 2 +- screen.c | 2 +- server-client.c | 2 +- status.c | 4 ++-- window-copy.c | 6 +++--- 9 files changed, 15 insertions(+), 17 deletions(-) diff --git a/cmd-list-keys.c b/cmd-list-keys.c index 91715f93..dbb510fb 100644 --- a/cmd-list-keys.c +++ b/cmd-list-keys.c @@ -211,7 +211,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) repeat = 0; tablewidth = keywidth = 0; - table = key_bindings_first_table (); + table = key_bindings_first_table(); while (table != NULL) { if (tablename != NULL && strcmp(table->name, tablename) != 0) { table = key_bindings_next_table(table); @@ -243,8 +243,7 @@ cmd_list_keys_exec(struct cmd *self, struct cmdq_item *item) tmpsize = 256; tmp = xmalloc(tmpsize); - - table = key_bindings_first_table (); + table = key_bindings_first_table(); while (table != NULL) { if (tablename != NULL && strcmp(table->name, tablename) != 0) { table = key_bindings_next_table(table); diff --git a/format.c b/format.c index 9ef4e6e9..1cf852c5 100644 --- a/format.c +++ b/format.c @@ -4078,8 +4078,7 @@ format_replace(struct format_expand_state *es, const char *key, size_t keylen, case 's': if (fm->argc < 2) break; - sub = xreallocarray (sub, nsub + 1, - sizeof *sub); + sub = xreallocarray(sub, nsub + 1, sizeof *sub); sub[nsub++] = fm; break; case '=': @@ -4188,7 +4187,7 @@ format_replace(struct format_expand_state *es, const char *key, size_t keylen, value = xstrdup(""); else xasprintf(&value, "%c", c); - free (new); + free(new); goto done; } @@ -4752,7 +4751,7 @@ format_defaults(struct format_tree *ft, struct client *c, struct session *s, if (wp != NULL) format_defaults_pane(ft, wp); - pb = paste_get_top (NULL); + pb = paste_get_top(NULL); if (pb != NULL) format_defaults_paste_buffer(ft, pb); } diff --git a/input-keys.c b/input-keys.c index d6f48e6c..c2f2fe19 100644 --- a/input-keys.c +++ b/input-keys.c @@ -334,7 +334,7 @@ input_key_cmp(struct input_key_entry *ike1, struct input_key_entry *ike2) /* Look for key in tree. */ static struct input_key_entry * -input_key_get (key_code key) +input_key_get(key_code key) { struct input_key_entry entry = { .key = key }; diff --git a/mode-tree.c b/mode-tree.c index 807c1dcb..c92f7cff 100644 --- a/mode-tree.c +++ b/mode-tree.c @@ -922,7 +922,7 @@ mode_tree_menu_callback(__unused struct menu *menu, __unused u_int idx, if (mti->itemdata != mtm->itemdata) goto out; mtd->current = mtm->line; - mtd->menucb (mtd->modedata, mtm->c, key); + mtd->menucb(mtd->modedata, mtm->c, key); out: mode_tree_remove_ref(mtd); diff --git a/names.c b/names.c index 09b33082..aeb67338 100644 --- a/names.c +++ b/names.c @@ -146,7 +146,7 @@ parse_window_name(const char *in) name = copy = xstrdup(in); if (*name == '"') name++; - name[strcspn (name, "\"")] = '\0'; + name[strcspn(name, "\"")] = '\0'; if (strncmp(name, "exec ", (sizeof "exec ") - 1) == 0) name = name + (sizeof "exec ") - 1; diff --git a/screen.c b/screen.c index e7ee1df9..a7801f45 100644 --- a/screen.c +++ b/screen.c @@ -698,6 +698,6 @@ screen_mode_to_string(int mode) strlcat(tmp, "CRLF,", sizeof tmp); if (mode & MODE_KEXTENDED) strlcat(tmp, "KEXTENDED,", sizeof tmp); - tmp[strlen (tmp) - 1] = '\0'; + tmp[strlen(tmp) - 1] = '\0'; return (tmp); } diff --git a/server-client.c b/server-client.c index 08584e7b..f957e0b1 100644 --- a/server-client.c +++ b/server-client.c @@ -2378,7 +2378,7 @@ server_client_set_flags(struct client *c, const char *flags) uint64_t flag; int not; - s = copy = xstrdup (flags); + s = copy = xstrdup(flags); while ((next = strsep(&s, ",")) != NULL) { not = (*next == '!'); if (not) diff --git a/status.c b/status.c index 853f46d3..b442e85d 100644 --- a/status.c +++ b/status.c @@ -1413,7 +1413,7 @@ process_key: break; if (c->prompt_buffer[0].size == 0) { prefix = '='; - free (c->prompt_buffer); + free(c->prompt_buffer); c->prompt_buffer = utf8_fromcstr(c->prompt_last); c->prompt_index = utf8_strlen(c->prompt_buffer); } else @@ -1424,7 +1424,7 @@ process_key: break; if (c->prompt_buffer[0].size == 0) { prefix = '='; - free (c->prompt_buffer); + free(c->prompt_buffer); c->prompt_buffer = utf8_fromcstr(c->prompt_last); c->prompt_index = utf8_strlen(c->prompt_buffer); } else diff --git a/window-copy.c b/window-copy.c index 951d7581..c3b1a66b 100644 --- a/window-copy.c +++ b/window-copy.c @@ -2226,7 +2226,7 @@ window_copy_cmd_search_backward_incremental(struct window_copy_cmd_state *cs) data->timeout = 0; - log_debug ("%s: %s", __func__, argument); + log_debug("%s: %s", __func__, argument); prefix = *argument++; if (data->searchx == -1 || data->searchy == -1) { @@ -2281,7 +2281,7 @@ window_copy_cmd_search_forward_incremental(struct window_copy_cmd_state *cs) data->timeout = 0; - log_debug ("%s: %s", __func__, argument); + log_debug("%s: %s", __func__, argument); prefix = *argument++; if (data->searchx == -1 || data->searchy == -1) { @@ -2859,7 +2859,7 @@ window_copy_command(struct window_mode_entry *wme, struct client *c, args->argc - 1 > window_copy_cmd_table[i].maxargs) break; clear = window_copy_cmd_table[i].clear; - action = window_copy_cmd_table[i].f (&cs); + action = window_copy_cmd_table[i].f(&cs); break; } } From 6cbc83c6a64f272575aac1ee32cc0a0b1cb75c7b Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 20 Aug 2021 17:53:54 +0000 Subject: [PATCH 3/3] Add a way to create an empty arguments set. --- arguments.c | 14 ++++++++++++-- cmd-find-window.c | 4 ++-- tmux.h | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/arguments.c b/arguments.c index dd92a952..91141b99 100644 --- a/arguments.c +++ b/arguments.c @@ -64,6 +64,17 @@ args_find(struct args *args, u_char flag) return (RB_FIND(args_tree, &args->tree, &entry)); } +/* Create an empty arguments set. */ +struct args * +args_create(void) +{ + struct args *args; + + args = xcalloc(1, sizeof *args); + RB_INIT(&args->tree); + return (args); +} + /* Parse an argv and argc into a new argument set. */ struct args * args_parse(const char *template, int argc, char **argv) @@ -71,12 +82,11 @@ args_parse(const char *template, int argc, char **argv) struct args *args; int opt; - args = xcalloc(1, sizeof *args); - optreset = 1; optind = 1; optarg = NULL; + args = args_create(); while ((opt = getopt(argc, argv, template)) != -1) { if (opt < 0) continue; diff --git a/cmd-find-window.c b/cmd-find-window.c index 4cd155e4..43f5f9be 100644 --- a/cmd-find-window.c +++ b/cmd-find-window.c @@ -48,7 +48,7 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item) struct cmd_find_state *target = cmdq_get_target(item); struct window_pane *wp = target->wp; const char *s = args->argv[0], *suffix = ""; - char *filter, *argv = { NULL }; + char *filter; int C, N, T; C = args_has(args, 'C'); @@ -91,7 +91,7 @@ cmd_find_window_exec(struct cmd *self, struct cmdq_item *item) else xasprintf(&filter, "#{m%s:*%s*,#{pane_title}}", suffix, s); - new_args = args_parse("", 1, &argv); + new_args = args_create(); if (args_has(args, 'Z')) args_set(new_args, 'Z', NULL); args_set(new_args, 'f', filter); diff --git a/tmux.h b/tmux.h index e6ba8e86..26f9dc3e 100644 --- a/tmux.h +++ b/tmux.h @@ -2182,6 +2182,7 @@ int tty_keys_next(struct tty *); /* arguments.c */ void args_set(struct args *, u_char, const char *); +struct args *args_create(void); struct args *args_parse(const char *, int, char **); void args_free(struct args *); char *args_print(struct args *);