From 163908fe8a0af8cf2d24510415bd4f81ace3a4d1 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 12 Aug 2021 08:05:11 +0000 Subject: Move hook format setup earlier and add a hook_client, GitHub issue 2809. --- format.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'format.c') diff --git a/format.c b/format.c index 479b97c4..b5f09649 100644 --- a/format.c +++ b/format.c @@ -929,6 +929,9 @@ format_cb_pane_fg(struct format_tree *ft) struct window_pane *wp = ft->wp; struct grid_cell gc; + if (wp == NULL) + return (NULL); + tty_default_colours(&gc, wp); return (xstrdup(colour_tostring(gc.fg))); } @@ -940,6 +943,9 @@ format_cb_pane_bg(struct format_tree *ft) struct window_pane *wp = ft->wp; struct grid_cell gc; + if (wp == NULL) + return (NULL); + tty_default_colours(&gc, wp); return (xstrdup(colour_tostring(gc.bg))); } @@ -3079,6 +3085,22 @@ format_free(struct format_tree *ft) free(ft); } +/* Log each format. */ +static void +format_log_debug_cb(const char *key, const char *value, void *arg) +{ + const char *prefix = arg; + + log_debug("%s: %s=%s", prefix, key, value); +} + +/* Log a format tree. */ +void +format_log_debug(struct format_tree *ft, const char *prefix) +{ + format_each(ft, format_log_debug_cb, prefix); +} + /* Walk each format. */ void format_each(struct format_tree *ft, void (*cb)(const char *, const char *, -- cgit From 26773ea9efd3b555833618719446309cf7a024de Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 12 Aug 2021 08:10:20 +0000 Subject: Do not dereference pane when it is NULL, fixes a crash when creating a hook from the config, GitHub issue 2820. --- format.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'format.c') diff --git a/format.c b/format.c index b5f09649..5a295198 100644 --- a/format.c +++ b/format.c @@ -3098,7 +3098,7 @@ format_log_debug_cb(const char *key, const char *value, void *arg) void format_log_debug(struct format_tree *ft, const char *prefix) { - format_each(ft, format_log_debug_cb, prefix); + format_each(ft, format_log_debug_cb, (void *)prefix); } /* Walk each format. */ -- cgit