From 3acc72f842a021ffcff8809c1f245ca614f68598 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Wed, 15 Nov 2017 16:33:06 +0100 Subject: reset colour at comma, like mIRC Fixes #742 and #740 --- src/fe-common/core/formats.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/fe-common/core') diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c index 005e6fb7..a340bffa 100644 --- a/src/fe-common/core/formats.c +++ b/src/fe-common/core/formats.c @@ -1072,7 +1072,8 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret) fg = fg_ret == NULL ? -1 : *fg_ret; bg = bg_ret == NULL ? -1 : *bg_ret; - if (!i_isdigit(**str) && **str != ',') { + if (!i_isdigit(**str)) { + /* turn off color */ fg = -1; bg = -1; } else { @@ -1085,11 +1086,8 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret) (*str)++; } } - if (**str == ',') { + if ((*str)[0] == ',' && i_isdigit((*str)[1])) { /* background color */ - if (!i_isdigit((*str)[1])) - bg = -1; - else { (*str)++; bg = **str-'0'; (*str)++; @@ -1097,7 +1095,6 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret) bg = bg*10 + (**str-'0'); (*str)++; } - } } } -- cgit v1.2.3 From 47400d405a0680bfe4d69ce8b06ecbfd09931999 Mon Sep 17 00:00:00 2001 From: ailin-nemui Date: Mon, 20 Nov 2017 14:17:15 +0100 Subject: Update formats.c remove now useless check for , --- src/fe-common/core/formats.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/fe-common/core') diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c index a340bffa..37db6f7c 100644 --- a/src/fe-common/core/formats.c +++ b/src/fe-common/core/formats.c @@ -1078,23 +1078,22 @@ static void get_mirc_color(const char **str, int *fg_ret, int *bg_ret) bg = -1; } else { /* foreground color */ - if (**str != ',') { - fg = **str-'0'; + fg = **str-'0'; + (*str)++; + if (i_isdigit(**str)) { + fg = fg*10 + (**str-'0'); (*str)++; - if (i_isdigit(**str)) { - fg = fg*10 + (**str-'0'); - (*str)++; - } } + if ((*str)[0] == ',' && i_isdigit((*str)[1])) { /* background color */ + (*str)++; + bg = **str-'0'; + (*str)++; + if (i_isdigit(**str)) { + bg = bg*10 + (**str-'0'); (*str)++; - bg = **str-'0'; - (*str)++; - if (i_isdigit(**str)) { - bg = bg*10 + (**str-'0'); - (*str)++; - } + } } } -- cgit v1.2.3