rcfile: report the first bad color element, not a later one that is okay

This fixes https://savannah.gnu.org/bugs/?58605.

Bug existed since commit c275c515 from several days ago.
master
Benno Schulenberg 2020-06-17 16:50:17 +02:00
parent 69a90dd7af
commit 61c94c2f81
1 changed files with 11 additions and 9 deletions

View File

@ -1066,17 +1066,10 @@ bool parse_combination(char *combostr, short *fg, short *bg, int *attributes)
comma = strchr(combostr, ',');
if (comma != NULL) {
*bg = color_to_short(comma + 1, &vivid, &thick);
if (*bg == BAD_COLOR)
return FALSE;
if (vivid && COLORS > 8)
*bg += 8;
if (comma)
*comma = '\0';
} else
*bg = USE_THE_DEFAULT;
if (comma != combostr) {
if (!comma || comma > combostr) {
*fg = color_to_short(combostr, &vivid, &thick);
if (*fg == BAD_COLOR)
return FALSE;
@ -1087,6 +1080,15 @@ bool parse_combination(char *combostr, short *fg, short *bg, int *attributes)
} else
*fg = USE_THE_DEFAULT;
if (comma) {
*bg = color_to_short(comma + 1, &vivid, &thick);
if (*bg == BAD_COLOR)
return FALSE;
if (vivid && COLORS > 8)
*bg += 8;
} else
*bg = USE_THE_DEFAULT;
return TRUE;
}