diff options
author | 2015-02-18 15:32:37 +0000 | |
---|---|---|
committer | 2015-02-18 15:32:37 +0000 | |
commit | 156ea095e4a62ba65f4295245f20a2454b976f15 (patch) | |
tree | 25613bfb57c6b232ff02cf53f6a830396ace0d0b /usr.bin/tmux/options.c | |
parent | Make sure to replace an existing /usr/include/ssl symlink, otherwise repeated (diff) | |
download | wireguard-openbsd-156ea095e4a62ba65f4295245f20a2454b976f15.tar.xz wireguard-openbsd-156ea095e4a62ba65f4295245f20a2454b976f15.zip |
When given an invalid style, don't set the option to the default. Fix
from J Raynor. Also make style_parse not alter the grid_cell when it
fails.
Diffstat (limited to 'usr.bin/tmux/options.c')
-rw-r--r-- | usr.bin/tmux/options.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/usr.bin/tmux/options.c b/usr.bin/tmux/options.c index 5562002d490..506a819dfda 100644 --- a/usr.bin/tmux/options.c +++ b/usr.bin/tmux/options.c @@ -1,4 +1,4 @@ -/* $OpenBSD: options.c,v 1.11 2014/10/20 23:57:14 nicm Exp $ */ +/* $OpenBSD: options.c,v 1.12 2015/02/18 15:32:37 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicm@users.sourceforge.net> @@ -167,20 +167,26 @@ options_set_style(struct options *oo, const char *name, const char *value, int append) { struct options_entry *o; + struct grid_cell tmpgc; - if ((o = options_find1(oo, name)) == NULL) { + o = options_find1(oo, name); + if (o == NULL || !append) + memcpy(&tmpgc, &grid_default_cell, sizeof tmpgc); + else + memcpy(&tmpgc, &o->style, sizeof tmpgc); + + if (style_parse(&grid_default_cell, &tmpgc, value) == -1) + return (NULL); + + if (o == NULL) { o = xmalloc(sizeof *o); o->name = xstrdup(name); RB_INSERT(options_tree, &oo->tree, o); } else if (o->type == OPTIONS_STRING) free(o->str); - if (!append) - memcpy(&o->style, &grid_default_cell, sizeof o->style); - o->type = OPTIONS_STYLE; - if (style_parse(&grid_default_cell, &o->style, value) == -1) - return (NULL); + memcpy(&o->style, &tmpgc, sizeof o->style); return (o); } |