commit cbf226476df3747aa25520800c69b12606f6b304
parent 9fcfee18e87e8eed8e15077bc91717b1ce9c5ade
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Fri, 30 Mar 2018 10:20:41 +0200
rcfile: skip color commands where some color name is invalid
That is, do not fall back to the default background color when the
name for the background color is invalid, but reject the entire
color command, just like for an invalid foreground color.
Diffstat:
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/rcfile.c b/src/rcfile.c
@@ -736,7 +736,8 @@ void parse_colors(char *ptr, int rex_flags)
}
}
-/* Parse the color name, or pair of color names, in combostr. */
+/* Parse the color name (or pair of color names) in the given string.
+ * Return FALSE when any color name is invalid; otherwise return TRUE. */
bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
{
char *comma = strchr(combostr, ',');
@@ -747,22 +748,19 @@ bool parse_color_names(char *combostr, short *fg, short *bg, bool *bright)
rcfile_error(N_("A background color cannot be bright"));
return FALSE;
}
+ if (*bg == -2)
+ return FALSE;
*comma = '\0';
} else
*bg = -1;
if (comma != combostr) {
*fg = color_to_short(combostr, bright);
-
- /* If the specified foreground color is bad, ignore the regexes. */
if (*fg == -2)
return FALSE;
} else
*fg = -1;
- if (*bg == -2)
- *bg = -1;
-
return TRUE;
}