From 19acf8121fc55eff7b74e819a5d24298e3b9a3e0 Mon Sep 17 00:00:00 2001 From: Sebastien Helleu Date: Thu, 21 Mar 2013 20:16:49 +0100 Subject: [PATCH] irc: fix prefix color for nick when the prefix is not in irc.color.nick_prefixes: use default color (key "*") Problem was happening on a server which has "PREFIX=(Yqaohv)!~&@%+". Users with prefix "!" were displayed as lightred (color for "~") instead of lightblue (default key "*"). When a prefix was not found, WeeChat was looping on other prefixes (in order). Now if color is not found, WeeChat uses immediately the fallback color. --- ChangeLog | 4 +++- src/plugins/irc/irc-nick.c | 28 ++++++++++++---------------- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index be230b9d3..c1b06c7cc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,7 @@ WeeChat ChangeLog ================= Sébastien Helleu -v0.4.1-dev, 2013-03-17 +v0.4.1-dev, 2013-03-21 This document lists all changes for each version. @@ -44,6 +44,8 @@ Version 0.4.1 (under dev!) list with arguments inside), guile >= 2.0 is now required (bug #38350) * guile: fix crash on calls to callbacks during load of script (bug #38343) * guile: fix compilation with guile 2.0 +* irc: fix prefix color for nick when the prefix is not in + irc.color.nick_prefixes: use default color (key "*") * irc: add option irc.look.pv_buffer: automatically merge private buffers (optionally by server) (task #11924) * irc: rename option irc.network.lag_disconnect to irc.network.lag_reconnect, diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c index a3573fb80..6cd62860f 100644 --- a/src/plugins/irc/irc-nick.c +++ b/src/plugins/irc/irc-nick.c @@ -430,34 +430,30 @@ irc_nick_get_prefix_color_name (struct t_irc_server *server, char prefix) static char *default_color = ""; const char *prefix_modes, *color; char mode[2]; - int i, index; + int index; if (irc_config_hashtable_nick_prefixes) { + mode[0] = ' '; + mode[1] = '\0'; + index = irc_server_get_prefix_char_index (server, prefix); if (index >= 0) { - mode[0] = ' '; - mode[1] = '\0'; prefix_modes = irc_server_get_prefix_modes (server); - for (i = index; prefix_modes[i]; i++) - { - mode[0] = prefix_modes[i]; - color = weechat_hashtable_get (irc_config_hashtable_nick_prefixes, - mode); - if (color) - return color; - } - /* - * no color found with mode (and following modes)? - * => fallback to "*" - */ - mode[0] = '*'; + mode[0] = prefix_modes[index]; color = weechat_hashtable_get (irc_config_hashtable_nick_prefixes, mode); if (color) return color; } + + /* fallback to "*" if no color is found with mode */ + mode[0] = '*'; + color = weechat_hashtable_get (irc_config_hashtable_nick_prefixes, + mode); + if (color) + return color; } /* no color by default */