From 5a4be0f4f5f36787e98215d87b88a50a5f7e7e01 Mon Sep 17 00:00:00 2001 From: Jari Matilainen Date: Tue, 22 Sep 2015 22:39:44 +0200 Subject: [PATCH 1/3] Add new setting to optionally modify behaviour of hilight_nick_matches Fix indentation Remove unused variables that crept into the nick_match_msg_everywhere function --- src/core/nicklist.c | 9 +++++++++ src/core/nicklist.h | 1 + src/fe-common/core/fe-messages.c | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/nicklist.c b/src/core/nicklist.c index a96b8a9e..c88f5d6d 100644 --- a/src/core/nicklist.c +++ b/src/core/nicklist.c @@ -21,6 +21,7 @@ #include "module.h" #include "signals.h" #include "misc.h" +#include "settings.h" #include "servers.h" #include "channels.h" @@ -571,6 +572,14 @@ int nick_match_msg(CHANNEL_REC *channel, const char *msg, const char *nick) } } +int nick_match_msg_everywhere(CHANNEL_REC *channel, const char *msg, const char *nick) +{ + g_return_val_if_fail(nick != NULL, FALSE); + g_return_val_if_fail(msg != NULL, FALSE); + + return stristr_full(msg, nick); +} + void nicklist_init(void) { signal_add_first("channel created", (SIGNAL_FUNC) sig_channel_created); diff --git a/src/core/nicklist.h b/src/core/nicklist.h index 55dfd5ef..5e0f4f75 100644 --- a/src/core/nicklist.h +++ b/src/core/nicklist.h @@ -55,6 +55,7 @@ int nicklist_compare(NICK_REC *p1, NICK_REC *p2, const char *nick_prefix); /* Check is `msg' is meant for `nick'. */ int nick_match_msg(CHANNEL_REC *channel, const char *msg, const char *nick); +int nick_match_msg_everywhere(CHANNEL_REC *channel, const char *msg, const char *nick); void nicklist_init(void); void nicklist_deinit(void); diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c index 3bd2b666..d09c1b0b 100644 --- a/src/fe-common/core/fe-messages.c +++ b/src/fe-common/core/fe-messages.c @@ -183,7 +183,9 @@ static void sig_message_public(SERVER_REC *server, const char *msg, nickrec = nicklist_find(chanrec, nick); for_me = !settings_get_bool("hilight_nick_matches") ? FALSE : - nick_match_msg(chanrec, msg, server->nick); + !settings_get_bool("hilight_nick_matches_everywhere") ? + nick_match_msg(chanrec, msg, server->nick) : + nick_match_msg_everywhere(chanrec, msg, server->nick); hilight = for_me ? NULL : hilight_match_nick(server, target, nick, address, MSGLEVEL_PUBLIC, msg); color = (hilight == NULL) ? NULL : hilight_get_color(hilight); @@ -694,6 +696,7 @@ void fe_messages_init(void) (GCompareFunc) g_direct_equal); settings_add_bool("lookandfeel", "hilight_nick_matches", TRUE); + settings_add_bool("lookandfeel", "hilight_nick_matches_everywhere", FALSE); settings_add_bool("lookandfeel", "emphasis", TRUE); settings_add_bool("lookandfeel", "emphasis_replace", FALSE); settings_add_bool("lookandfeel", "emphasis_multiword", FALSE); From b5c3e90802e926e35ad9a4f1f02403578a3ff392 Mon Sep 17 00:00:00 2001 From: Jari Matilainen Date: Tue, 22 Sep 2015 23:09:55 +0200 Subject: [PATCH 2/3] Fix return value from nick_match_msg_everywhere --- src/core/nicklist.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/nicklist.c b/src/core/nicklist.c index c88f5d6d..160deb6a 100644 --- a/src/core/nicklist.c +++ b/src/core/nicklist.c @@ -577,7 +577,12 @@ int nick_match_msg_everywhere(CHANNEL_REC *channel, const char *msg, const char g_return_val_if_fail(nick != NULL, FALSE); g_return_val_if_fail(msg != NULL, FALSE); - return stristr_full(msg, nick); + char *ret = stristr_full(msg, nick); + + if (ret != NULL) + return TRUE; + + return FALSE; } void nicklist_init(void) From 3f2eaf1d3a67eddd42dd88eccb39402d45297fcb Mon Sep 17 00:00:00 2001 From: Jari Matilainen Date: Tue, 22 Sep 2015 23:16:41 +0200 Subject: [PATCH 3/3] Fix return value from nick_match_msg_everywhere, remove #include 'settings.h' --- src/core/nicklist.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/core/nicklist.c b/src/core/nicklist.c index 160deb6a..770b0afc 100644 --- a/src/core/nicklist.c +++ b/src/core/nicklist.c @@ -21,7 +21,6 @@ #include "module.h" #include "signals.h" #include "misc.h" -#include "settings.h" #include "servers.h" #include "channels.h" @@ -577,12 +576,7 @@ int nick_match_msg_everywhere(CHANNEL_REC *channel, const char *msg, const char g_return_val_if_fail(nick != NULL, FALSE); g_return_val_if_fail(msg != NULL, FALSE); - char *ret = stristr_full(msg, nick); - - if (ret != NULL) - return TRUE; - - return FALSE; + return stristr_full(msg, nick) != NULL; } void nicklist_init(void)