summaryrefslogtreecommitdiff
path: root/usr.bin/tmux/format.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2017-01-15 20:48:42 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2017-01-15 20:48:42 +0000
commitca8adffa790e1b516dbf00f246cca1cbb811080a (patch)
tree2a831f70e9e63f965a9e055e8d493ae6639fafbc /usr.bin/tmux/format.c
parentaf17aec37b4f471c7f1d2d1c72a1486b282c9fc9 (diff)
Major tidy up and rework of options tree and set-option/show-options
commands this pushes more of the code into options.c and ties it more closely to the options table rather than having an unnecessary split. Also add support for array options (will be used later). Only (intentional) user visible change is that show-options output is now passed through vis(3) with VIS_DQ so quotes are escaped.
Diffstat (limited to 'usr.bin/tmux/format.c')
-rw-r--r--usr.bin/tmux/format.c32
1 files changed, 11 insertions, 21 deletions
diff --git a/usr.bin/tmux/format.c b/usr.bin/tmux/format.c
index 1f025c87666..5b095b29274 100644
--- a/usr.bin/tmux/format.c
+++ b/usr.bin/tmux/format.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: format.c,v 1.115 2017/01/11 16:09:57 nicm Exp $ */
+/* $OpenBSD: format.c,v 1.116 2017/01/15 20:48:41 nicm Exp $ */
/*
* Copyright (c) 2011 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -620,39 +620,29 @@ static char *
format_find(struct format_tree *ft, const char *key, int modifiers)
{
struct format_entry *fe, fe_find;
- struct options_entry *o;
struct environ_entry *envent;
static char s[64];
+ struct option *o;
const char *found;
+ int idx;
char *copy, *saved;
- found = NULL;
-
if (~modifiers & FORMAT_TIMESTRING) {
- o = options_find(global_options, key);
+ o = options_parse_get(global_options, key, &idx, 0);
if (o == NULL && ft->w != NULL)
- o = options_find(ft->w->options, key);
+ o = options_parse_get(ft->w->options, key, &idx, 0);
if (o == NULL)
- o = options_find(global_w_options, key);
+ o = options_parse_get(global_w_options, key, &idx, 0);
if (o == NULL && ft->s != NULL)
- o = options_find(ft->s->options, key);
+ o = options_parse_get(ft->s->options, key, &idx, 0);
if (o == NULL)
- o = options_find(global_s_options, key);
+ o = options_parse_get(global_s_options, key, &idx, 0);
if (o != NULL) {
- switch (o->type) {
- case OPTIONS_STRING:
- found = o->str;
- goto found;
- case OPTIONS_NUMBER:
- xsnprintf(s, sizeof s, "%lld", o->num);
- found = s;
- goto found;
- case OPTIONS_STYLE:
- found = style_tostring(&o->style);
- goto found;
- }
+ found = options_tostring(o, idx);
+ goto found;
}
}
+ found = NULL;
fe_find.key = (char *) key;
fe = RB_FIND(format_entry_tree, &ft->tree, &fe_find);