From 8af914fb6d17b149199e03bb6f5d4ad7e9ffc3c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 28 Apr 2017 20:14:18 +0200 Subject: ui: ignore whitespace when parsing style options --- ui-terminal.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ui-terminal.c b/ui-terminal.c index e790785..6a4331f 100644 --- a/ui-terminal.c +++ b/ui-terminal.c @@ -154,12 +154,16 @@ static bool ui_style_define(UiWin *w, int id, const char *style) { if (!style) return true; CellStyle cell_style = tui->styles[win->id * UI_STYLE_MAX + UI_STYLE_DEFAULT]; - char *style_copy = strdup(style), *option = style_copy, *next, *p; + char *style_copy = strdup(style), *option = style_copy; while (option) { - if ((next = strchr(option, ','))) + while (*option == ' ') + option++; + char *next = strchr(option, ','); + if (next) *next++ = '\0'; - if ((p = strchr(option, ':'))) - *p++ = '\0'; + char *value = strchr(option, ':'); + if (value) + for (*value++ = '\0'; *value == ' '; value++); if (!strcasecmp(option, "reverse")) { cell_style.attr |= CELL_ATTR_REVERSE; } else if (!strcasecmp(option, "bold")) { @@ -179,9 +183,9 @@ static bool ui_style_define(UiWin *w, int id, const char *style) { } else if (!strcasecmp(option, "notblink")) { cell_style.attr &= ~CELL_ATTR_BLINK; } else if (!strcasecmp(option, "fore")) { - color_fromstring(win->ui, &cell_style.fg, p); + color_fromstring(win->ui, &cell_style.fg, value); } else if (!strcasecmp(option, "back")) { - color_fromstring(win->ui, &cell_style.bg, p); + color_fromstring(win->ui, &cell_style.bg, value); } option = next; } -- cgit v1.2.3