Open irssibot opened 19 years ago
You're right about -mask -line not working (and -mask -word, but that doesn't make any sense anyways), but the default (without -nick or -line) works just fine here.
I've actually seen this problem in the code before, but apperantly didn't conclude that this would trigger the bug. The cause is (to quote the last part of my comment to bug 131): There is the hilight_update_text_dest in sig_print_text in hilight-text.c that looks like it should have done the job (because it is before the "if(nick_match)return;"), but the hilight_match there can't find the HILIGHT_REC back, because he doesn't know the nick and address there.
To make it a bit more clear: hilight checking happens at two different 'layers':
I think it should be fixed by putting the HILIGHT_REC in the TEXT_DEST_REC in fe_messages, so the sig_print_text can just get that hilight back, and do its thing if it's a -line. And although it sounds like a cludge if I read that sentense back, it really makes sense to me, attaching a "apply this hilighting rule"-reminder to the message. And it already has hilight_priority and hilight_color anyways.
I might implement this later, but don't have the time for it now.
I would really like to see this bug get fixed, alternative ways to achieve the same would also suffice
A possible fix
fix_linehilight.patch
diff --git a/src/fe-common/core/fe-messages.c b/src/fe-common/core/fe-messages.c
index d9f77e2..b2ab52a 100644
--- a/src/fe-common/core/fe-messages.c
+++ b/src/fe-common/core/fe-messages.c
@@ -172,6 +172,7 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
int for_me, print_channel, level;
char *nickmode, *color, *freemsg = NULL;
HILIGHT_REC *hilight;
+ int match_beg = 0, match_end = 0;
/* NOTE: this may return NULL if some channel is just closed with
/WINDOW CLOSE and server still sends the few last messages */
@@ -182,8 +183,8 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
for_me = !settings_get_bool("hilight_nick_matches") ? FALSE :
nick_match_msg(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);
+ hilight_match(server, target, nick, address, MSGLEVEL_PUBLIC, msg, &match_beg, &match_end);
+ color = (hilight == NULL || !hilight->nick) ? NULL : hilight_get_color(hilight);
print_channel = chanrec == NULL ||
!window_item_is_active((WI_ITEM_REC *) chanrec);
@@ -206,10 +207,13 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
if (printnick == NULL)
printnick = nick;
+ TEXT_DEST_REC dest;
+ format_create_dest(&dest, server, target, level, NULL);
+ dest.hilight = hilight;
+ dest.match_beg = match_beg;
+ dest.match_end = match_end;
if (color != NULL) {
/* highlighted nick */
- TEXT_DEST_REC dest;
- format_create_dest(&dest, server, target, level, NULL);
hilight_update_text_dest(&dest,hilight);
if (!print_channel) /* message to active channel in window */
printformat_dest(&dest, TXT_PUBMSG_HILIGHT, color,
@@ -220,11 +224,11 @@ static void sig_message_public(SERVER_REC *server, const char *msg,
nickmode);
} else {
if (!print_channel)
- printformat(server, target, level,
+ printformat_dest(&dest,
for_me ? TXT_PUBMSG_ME : TXT_PUBMSG,
printnick, msg, nickmode);
else
- printformat(server, target, level,
+ printformat_dest(&dest,
for_me ? TXT_PUBMSG_ME_CHANNEL :
TXT_PUBMSG_CHANNEL,
printnick, target, msg, nickmode);
diff --git a/src/fe-common/core/formats.c b/src/fe-common/core/formats.c
index 93ee621..1cc4fbc 100644
--- a/src/fe-common/core/formats.c
+++ b/src/fe-common/core/formats.c
@@ -294,6 +294,8 @@ void format_create_dest_tag(TEXT_DEST_REC *dest, void *server,
dest->server_tag = server != NULL ? SERVER(server)->tag : server_tag;
dest->target = target;
dest->level = level;
+ dest->match_beg = 0;
+ dest->match_end = 0;
dest->window = window != NULL ? window :
window_find_closest(server, target, level);
}
diff --git a/src/fe-common/core/formats.h b/src/fe-common/core/formats.h
index 7dbdd90..77ceec8 100644
--- a/src/fe-common/core/formats.h
+++ b/src/fe-common/core/formats.h
@@ -43,6 +43,9 @@ struct _FORMAT_REC {
#define PRINT_FLAG_SET_SERVERTAG 0x0010
#define PRINT_FLAG_UNSET_SERVERTAG 0x0020
+// FIXME: sould use better
+typedef struct _HILIGHT_REC HILIGHT_REC;
+
typedef struct _TEXT_DEST_REC {
WINDOW_REC *window;
SERVER_REC *server;
@@ -50,6 +53,9 @@ typedef struct _TEXT_DEST_REC {
const char *target;
int level;
+ HILIGHT_REC *hilight;
+ int match_beg;
+ int match_end;
int hilight_priority;
char *hilight_color;
int flags;
diff --git a/src/fe-common/core/hilight-text.c b/src/fe-common/core/hilight-text.c
index 8805558..da09987 100644
--- a/src/fe-common/core/hilight-text.c
+++ b/src/fe-common/core/hilight-text.c
@@ -318,11 +318,10 @@ static void sig_print_text(TEXT_DEST_REC *dest, const char *text,
if (dest->level & MSGLEVEL_NOHILIGHT)
return;
- hilight_start = hilight_end = 0;
- hilight = hilight_match(dest->server, dest->target,
- NULL, NULL, dest->level, stripped,
- &hilight_start,
- &hilight_end);
+ hilight_start = dest->match_beg;
+ hilight_end = dest->match_end;
+ hilight = dest->hilight;
+
if (hilight == NULL)
return;
diff --git a/src/fe-common/core/hilight-text.h b/src/fe-common/core/hilight-text.h
index 74c5878..638fbf2 100644
--- a/src/fe-common/core/hilight-text.h
+++ b/src/fe-common/core/hilight-text.h
@@ -7,7 +7,7 @@
#include "formats.h"
-typedef struct _HILIGHT_REC HILIGHT_REC;
+//typedef struct _HILIGHT_REC HILIGHT_REC;
struct _HILIGHT_REC {
char *text;
Elbandi's patch seems to work for me.
Using the cmd /hilight -mask -line nick!@ doesn't produce a highlighted line. However, /hilight -mask -nick nick!@ highlights just the nick, and "-nick" must be specified for this to work at all. Would be good if -nick or a functional -line were default for -mask.