diff options
author | nicm <nicm> | 2015-02-18 15:32:37 +0000 |
---|---|---|
committer | nicm <nicm> | 2015-02-18 15:32:37 +0000 |
commit | 568f5ef3c6263004c5f6f1278346e18c66d02be3 (patch) | |
tree | 0e670c4522242212288dfa731c8ef0e14616beb8 /options.c | |
parent | 4d05d8830482f8d5b5f812d082f1332090fcf027 (diff) | |
download | rtmux-568f5ef3c6263004c5f6f1278346e18c66d02be3.tar.gz rtmux-568f5ef3c6263004c5f6f1278346e18c66d02be3.tar.bz2 rtmux-568f5ef3c6263004c5f6f1278346e18c66d02be3.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 'options.c')
-rw-r--r-- | options.c | 18 |
1 files changed, 12 insertions, 6 deletions
@@ -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); } |