From 90c99339b486ebf5d587e33e0d9d406deac9ea2d Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Fri, 29 Oct 2010 23:21:57 +0200 Subject: [PATCH] Return empty string in API function weechat_color when color is unknown --- src/gui/gui-color.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/gui/gui-color.c b/src/gui/gui-color.c index f053ced2e..5e170d214 100644 --- a/src/gui/gui-color.c +++ b/src/gui/gui-color.c @@ -208,23 +208,32 @@ gui_color_get_custom (const char *color_name) { fg = gui_color_search (str_fg); bg = gui_color_search (pos_bg); - snprintf (color[index_color], sizeof (color[index_color]), - "%s*%02d,%02d", - GUI_COLOR_COLOR_STR, fg, bg); + if ((fg >= 0) && (bg >= 0)) + { + snprintf (color[index_color], sizeof (color[index_color]), + "%s*%02d,%02d", + GUI_COLOR_COLOR_STR, fg, bg); + } } else if (str_fg && !pos_bg) { fg = gui_color_search (str_fg); - snprintf (color[index_color], sizeof (color[index_color]), - "%sF%02d", - GUI_COLOR_COLOR_STR, fg); + if (fg >= 0) + { + snprintf (color[index_color], sizeof (color[index_color]), + "%sF%02d", + GUI_COLOR_COLOR_STR, fg); + } } else if (!str_fg && pos_bg) { bg = gui_color_search (pos_bg); - snprintf (color[index_color], sizeof (color[index_color]), - "%sB%02d", - GUI_COLOR_COLOR_STR, bg); + if (bg >= 0) + { + snprintf (color[index_color], sizeof (color[index_color]), + "%sB%02d", + GUI_COLOR_COLOR_STR, bg); + } } if (str_fg)