diff options
author | Sebastien Helleu <flashcode@flashtux.org> | 2010-07-07 15:44:02 +0200 |
---|---|---|
committer | Sebastien Helleu <flashcode@flashtux.org> | 2010-07-07 15:44:02 +0200 |
commit | 46fdee19b05ea9e775e46a67f0b31207cead009a (patch) | |
tree | 7ceddd29165ab5568164e90d2dc786a51e78e78e /src/gui | |
parent | 869e4448b944c0cca0601588126f7a5e400b856e (diff) | |
download | weechat-46fdee19b05ea9e775e46a67f0b31207cead009a.zip |
Fix bug with replacement char in API function string_remove_color (bug #30296)
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/gui-color.c | 72 |
1 files changed, 33 insertions, 39 deletions
diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index ef873bffc..f053ced2e 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -267,59 +267,53 @@ gui_color_decode (const char *string, const char *replacement) { case GUI_COLOR_COLOR_CHAR: ptr_string++; + switch (ptr_string[0]) + { + case GUI_COLOR_FG_CHAR: + case GUI_COLOR_BG_CHAR: + if (ptr_string[1] && ptr_string[2]) + ptr_string += 3; + break; + case GUI_COLOR_FG_BG_CHAR: + if (ptr_string[1] && ptr_string[2] && (ptr_string[3] == ',') + && ptr_string[4] && ptr_string[5]) + ptr_string += 6; + break; + case GUI_COLOR_BAR_CHAR: + ptr_string++; + switch (ptr_string[0]) + { + case GUI_COLOR_BAR_FG_CHAR: + case GUI_COLOR_BAR_BG_CHAR: + case GUI_COLOR_BAR_DELIM_CHAR: + case GUI_COLOR_BAR_START_INPUT_CHAR: + case GUI_COLOR_BAR_START_INPUT_HIDDEN_CHAR: + case GUI_COLOR_BAR_MOVE_CURSOR_CHAR: + ptr_string++; + break; + } + break; + default: + if (isdigit (ptr_string[0]) && isdigit (ptr_string[1])) + ptr_string += 2; + break; + } if (replacement && replacement[0]) { out[out_pos] = replacement[0]; out_pos++; } - else - { - switch (ptr_string[0]) - { - case GUI_COLOR_FG_CHAR: - case GUI_COLOR_BG_CHAR: - if (ptr_string[1] && ptr_string[2]) - ptr_string += 3; - break; - case GUI_COLOR_FG_BG_CHAR: - if (ptr_string[1] && ptr_string[2] && (ptr_string[3] == ',') - && ptr_string[4] && ptr_string[5]) - ptr_string += 6; - break; - case GUI_COLOR_BAR_CHAR: - ptr_string++; - switch (ptr_string[0]) - { - case GUI_COLOR_BAR_FG_CHAR: - case GUI_COLOR_BAR_BG_CHAR: - case GUI_COLOR_BAR_DELIM_CHAR: - case GUI_COLOR_BAR_START_INPUT_CHAR: - case GUI_COLOR_BAR_START_INPUT_HIDDEN_CHAR: - case GUI_COLOR_BAR_MOVE_CURSOR_CHAR: - ptr_string++; - break; - } - break; - default: - if (isdigit (ptr_string[0]) && isdigit (ptr_string[1])) - ptr_string += 2; - break; - } - } break; case GUI_COLOR_SET_WEECHAT_CHAR: case GUI_COLOR_REMOVE_WEECHAT_CHAR: ptr_string++; + if (ptr_string[0]) + ptr_string++; if (replacement && replacement[0]) { out[out_pos] = replacement[0]; out_pos++; } - else - { - if (ptr_string[0]) - ptr_string++; - } break; case GUI_COLOR_RESET_CHAR: ptr_string++; |