Fix bug with replacement char in API function string_remove_color (bug #30296)

This commit is contained in:
Sebastien Helleu 2010-07-07 15:44:02 +02:00
parent 869e4448b9
commit 46fdee19b0
2 changed files with 36 additions and 40 deletions

View File

@ -1,7 +1,7 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.3.3-dev, 2010-07-06
v0.3.3-dev, 2010-07-07
Version 0.3.3 (under dev!)
@ -17,6 +17,8 @@ Version 0.3.3 (under dev!)
process)
* core: fix display bug with attributes like underlined in bars (bug #29889)
* core: add hashtables with new functions in plugin API
* api: fix bug with replacement char in function string_remove_color
(bug #30296)
* api: add function "string_expand_home", fix bug with replacement of home in
paths
* irc: fix display of local SSL certificate when it is sent to server

View File

@ -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++;