mirror of
https://github.com/tmux/tmux.git
synced 2025-09-02 13:37:12 +00:00
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.
This commit is contained in:
23
format.c
23
format.c
@ -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
|
||||
},
|
||||
|
Reference in New Issue
Block a user