diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-02-22 08:18:14 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2021-02-22 08:18:14 +0000 |
commit | a487f8d1ddefa1dc94be7981ef06590f7d6b38e4 (patch) | |
tree | f86494d186eaacb1c3c61e650940a360f5e9776a /usr.bin/tmux/format.c | |
parent | b9dba9d4c945300dc2fdfb409cf88d94d2030dfd (diff) |
Move config file path expansion much earlier, keep the list of paths
around rather than freeing later, and add a config_files format variable
containing it. Suggested by kn@ a while back.
Diffstat (limited to 'usr.bin/tmux/format.c')
-rw-r--r-- | usr.bin/tmux/format.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c index d15c0cc513d..98bf7b02f41 100644 --- a/usr.bin/tmux/format.c +++ b/usr.bin/tmux/format.c @@ -1,4 +1,4 @@ -/* $OpenBSD: format.c,v 1.275 2021/02/22 07:09:06 nicm Exp $ */ +/* $OpenBSD: format.c,v 1.276 2021/02/22 08:18:13 nicm Exp $ */ /* * Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1412,6 +1412,26 @@ format_cb_client_written(struct format_tree *ft) return (NULL); } +/* Callback for config_files. */ +static void * +format_cb_config_files(__unused struct format_tree *ft) +{ + char *s = NULL; + size_t slen = 0; + u_int i; + size_t n; + + for (i = 0; i < cfg_nfiles; i++) { + n = strlen(cfg_files[i]) + 1; + s = xrealloc(s, slen + n + 1); + slen += xsnprintf(s + slen, n + 1, "%s,", cfg_files[i]); + } + if (s == NULL) + return (xstrdup("")); + s[slen - 1] = '\0'; + return (s); +} + /* Callback for cursor_flag. */ static void * format_cb_cursor_flag(struct format_tree *ft) @@ -2569,6 +2589,9 @@ static const struct format_table_entry format_table[] = { { "client_written", FORMAT_TABLE_STRING, format_cb_client_written }, + { "config_files", FORMAT_TABLE_STRING, + format_cb_config_files + }, { "cursor_character", FORMAT_TABLE_STRING, format_cb_cursor_character }, |