From eb4174ee1eabbee37622e8eb827719a16007f11f Mon Sep 17 00:00:00 2001 From: vague666 Date: Fri, 23 Oct 2020 21:49:09 +0200 Subject: [PATCH 1/5] Make hilight priority work --- src/fe-common/core/hilight-text.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 2fe6068b..22e46ffa 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -244,6 +244,8 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel, GSList *tmp; CHANNEL_REC *chanrec; NICK_REC *nickrec; + HILIGHT_REC *tmprec; + int priority = -1; g_return_val_if_fail(str != NULL, NULL); @@ -274,11 +276,14 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel, hilight_match_channel(rec, channel) && (rec->servertag == NULL || (server != NULL && g_ascii_strcasecmp(rec->servertag, server->tag) == 0)) && - hilight_match_text(rec, str, match_beg, match_end)) - return rec; + hilight_match_text(rec, str, match_beg, match_end) && + rec->priority > priority) { + tmprec = rec; + priority = rec->priority; + } } - return NULL; + return tmprec; } static char *hilight_get_act_color(HILIGHT_REC *rec) From 4fb10322d1a4ba8617dd6f53eda5f5002158d659 Mon Sep 17 00:00:00 2001 From: vague666 Date: Mon, 26 Oct 2020 10:57:05 +0100 Subject: [PATCH 2/5] Optimize execution --- src/fe-common/core/hilight-text.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 22e46ffa..fc213533 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -272,12 +272,11 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel, for (tmp = hilights; tmp != NULL; tmp = tmp->next) { HILIGHT_REC *rec = tmp->data; - if (!rec->nickmask && hilight_match_level(rec, level) && - hilight_match_channel(rec, channel) && + if (rec->priority > priority && !rec->nickmask && + hilight_match_level(rec, level) && hilight_match_channel(rec, channel) && (rec->servertag == NULL || (server != NULL && g_ascii_strcasecmp(rec->servertag, server->tag) == 0)) && - hilight_match_text(rec, str, match_beg, match_end) && - rec->priority > priority) { + hilight_match_text(rec, str, match_beg, match_end)) { tmprec = rec; priority = rec->priority; } From 8f4f0be6d48b169f20389d73f3d7cd3259d6f5a9 Mon Sep 17 00:00:00 2001 From: vague666 Date: Mon, 26 Oct 2020 11:01:03 +0100 Subject: [PATCH 3/5] Add prio check to hilight_nick_cache also --- src/fe-common/core/hilight-text.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index fc213533..4e971d75 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -674,6 +674,7 @@ static void hilight_nick_cache(GHashTable *list, CHANNEL_REC *channel, HILIGHT_REC *match; char *nickmask; int len, best_match; + int priority = -1; if (nick->host == NULL) return; /* don't check until host is known */ @@ -684,11 +685,12 @@ static void hilight_nick_cache(GHashTable *list, CHANNEL_REC *channel, for (tmp = hilights; tmp != NULL; tmp = tmp->next) { HILIGHT_REC *rec = tmp->data; - if (rec->nickmask && + if (rec->priority > priority && rec->nickmask && hilight_match_channel(rec, channel->name) && match_wildcards(rec->text, nickmask)) { len = strlen(rec->text); if (best_match < len) { + priority = rec->priority; best_match = len; match = rec; } From 323b60f339bd9b139bbcb9a5cd07747bc10a9b84 Mon Sep 17 00:00:00 2001 From: vague666 Date: Tue, 27 Oct 2020 09:49:54 +0100 Subject: [PATCH 4/5] Initialize tmprec --- src/fe-common/core/hilight-text.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index 4e971d75..b3247efc 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -248,6 +248,7 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel, int priority = -1; g_return_val_if_fail(str != NULL, NULL); + tmprec = NULL; if ((never_hilight_level & level) == level) return NULL; From 69396482be83b51af1817c308eead76e1ca57f31 Mon Sep 17 00:00:00 2001 From: vague666 Date: Wed, 2 Dec 2020 14:33:23 +0100 Subject: [PATCH 5/5] style format change --- src/fe-common/core/hilight-text.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c index b3247efc..153a7a15 100644 --- a/src/fe-common/core/hilight-text.c +++ b/src/fe-common/core/hilight-text.c @@ -273,14 +273,14 @@ HILIGHT_REC *hilight_match(SERVER_REC *server, const char *channel, for (tmp = hilights; tmp != NULL; tmp = tmp->next) { HILIGHT_REC *rec = tmp->data; - if (rec->priority > priority && !rec->nickmask && - hilight_match_level(rec, level) && hilight_match_channel(rec, channel) && - (rec->servertag == NULL || - (server != NULL && g_ascii_strcasecmp(rec->servertag, server->tag) == 0)) && - hilight_match_text(rec, str, match_beg, match_end)) { - tmprec = rec; - priority = rec->priority; - } + if (rec->priority > priority && !rec->nickmask && hilight_match_level(rec, level) && + hilight_match_channel(rec, channel) && + (rec->servertag == NULL || + (server != NULL && g_ascii_strcasecmp(rec->servertag, server->tag) == 0)) && + hilight_match_text(rec, str, match_beg, match_end)) { + tmprec = rec; + priority = rec->priority; + } } return tmprec; @@ -687,8 +687,8 @@ static void hilight_nick_cache(GHashTable *list, CHANNEL_REC *channel, HILIGHT_REC *rec = tmp->data; if (rec->priority > priority && rec->nickmask && - hilight_match_channel(rec, channel->name) && - match_wildcards(rec->text, nickmask)) { + hilight_match_channel(rec, channel->name) && + match_wildcards(rec->text, nickmask)) { len = strlen(rec->text); if (best_match < len) { priority = rec->priority;