From 1a14d6d2e1c2a23544eefa6e5e65e05ee7e1aca7 Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 14 Nov 2023 15:38:33 +0000 Subject: [PATCH 1/2] Use SM 2026 for Sync which is more widely supported now. --- tty-features.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tty-features.c b/tty-features.c index e3293872..42f83f41 100644 --- a/tty-features.c +++ b/tty-features.c @@ -216,7 +216,7 @@ static const struct tty_feature tty_feature_strikethrough = { /* Terminal supports synchronized updates. */ static const char *const tty_feature_sync_capabilities[] = { - "Sync=\\EP=%p1%ds\\E\\\\", + "Sync=\\E[?2026%?%p1%{1}%-%tl%eh%;", NULL }; static const struct tty_feature tty_feature_sync = { From 88fd1f00b8e2c2455df9d15bd0b0e0d0ef5044ac Mon Sep 17 00:00:00 2001 From: nicm Date: Tue, 14 Nov 2023 15:59:49 +0000 Subject: [PATCH 2/2] Handle NULL client (in config file) when showing a status message; also copy the file when processing if-shell since it may be freed. GitHub issue 3746. --- arguments.c | 5 ++++- status.c | 25 +++++++++++++++++-------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/arguments.c b/arguments.c index 3bc888a2..289662d5 100644 --- a/arguments.c +++ b/arguments.c @@ -761,6 +761,7 @@ args_make_commands_prepare(struct cmd *self, struct cmdq_item *item, u_int idx, struct args_value *value; struct args_command_state *state; const char *cmd; + const char *file; state = xcalloc(1, sizeof *state); @@ -787,7 +788,8 @@ args_make_commands_prepare(struct cmd *self, struct cmdq_item *item, u_int idx, if (wait) state->pi.item = item; - cmd_get_source(self, &state->pi.file, &state->pi.line); + cmd_get_source(self, &file, &state->pi.line); + state->pi.file = xstrdup(file); state->pi.c = tc; if (state->pi.c != NULL) state->pi.c->references++; @@ -842,6 +844,7 @@ args_make_commands_free(struct args_command_state *state) cmd_list_free(state->cmdlist); if (state->pi.c != NULL) server_client_unref(state->pi.c); + free((void *)state->pi.file); free(state->cmd); free(state); } diff --git a/status.c b/status.c index a15981e9..a11cc8b8 100644 --- a/status.c +++ b/status.c @@ -472,17 +472,26 @@ void status_message_set(struct client *c, int delay, int ignore_styles, int ignore_keys, const char *fmt, ...) { - struct timeval tv; - va_list ap; + struct timeval tv; + va_list ap; + char *s; + + va_start(ap, fmt); + xvasprintf(&s, fmt, ap); + va_end(ap); + + log_debug("%s: %s", __func__, s); + + if (c == NULL) { + server_add_message("message: %s", s); + free(s); + return; + } status_message_clear(c); status_push_screen(c); - - va_start(ap, fmt); - xvasprintf(&c->message_string, fmt, ap); - va_end(ap); - - server_add_message("%s message: %s", c->name, c->message_string); + c->message_string = s; + server_add_message("%s message: %s", c->name, s); /* * With delay -1, the display-time option is used; zero means wait for