Reset foreground and background while no color code is specified

This commit is contained in:
Shengyu Zhang 2017-08-31 18:25:22 +08:00
commit ccd33d46d4

View file

@ -1067,8 +1067,9 @@ static const char *get_ansi_color(THEME_REC *theme, const char *str,
/* parse MIRC color string */ /* parse MIRC color string */
static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret) static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
{ {
int fg, bg; int fg, bg, hasfg;
hasfg = 0;
fg = fg_ret == NULL ? -1 : *fg_ret; fg = fg_ret == NULL ? -1 : *fg_ret;
bg = bg_ret == NULL ? -1 : *bg_ret; bg = bg_ret == NULL ? -1 : *bg_ret;
@ -1078,6 +1079,7 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
} else { } else {
/* foreground color */ /* foreground color */
if (**str != ',') { if (**str != ',') {
hasfg = 1;
fg = **str-'0'; fg = **str-'0';
(*str)++; (*str)++;
if (i_isdigit(**str)) { if (i_isdigit(**str)) {
@ -1087,8 +1089,12 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret)
} }
if (**str == ',') { if (**str == ',') {
/* background color */ /* background color */
if (!i_isdigit((*str)[1])) if (!i_isdigit((*str)[1])) {
bg = -1; bg = -1;
if (!hasfg) {
fg = -1;
}
}
else { else {
(*str)++; (*str)++;
bg = **str-'0'; bg = **str-'0';