summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSebastien Helleu <flashcode@flashtux.org>2005-07-19 19:50:10 +0000
committerSebastien Helleu <flashcode@flashtux.org>2005-07-19 19:50:10 +0000
commitc36f08d7d780b117622a11bb96f7963e5038bf35 (patch)
tree9a7252c0a78357e1b1a9fd3bb2617f0802dbbcce /src
parent1230735c5faf5445bd7583798a27bb8a17e6d743 (diff)
downloadweechat-c36f08d7d780b117622a11bb96f7963e5038bf35.zip
Highlights with "irc_highlight" setting now case insensitive
Diffstat (limited to 'src')
-rw-r--r--src/common/weeconfig.c2
-rw-r--r--src/irc/irc-recv.c29
2 files changed, 27 insertions, 4 deletions
diff --git a/src/common/weeconfig.c b/src/common/weeconfig.c
index 334a8afac..6ca137449 100644
--- a/src/common/weeconfig.c
+++ b/src/common/weeconfig.c
@@ -557,7 +557,7 @@ t_config_option weechat_options_irc[] =
OPTION_TYPE_BOOLEAN, BOOL_FALSE, BOOL_TRUE, BOOL_FALSE,
NULL, NULL, &cfg_irc_fifo_pipe, NULL, config_change_fifo_pipe },
{ "irc_highlight", N_("list of words to highlight"),
- N_("comma separated list of words to highlight (case sensitive comparison)"),
+ N_("comma separated list of words to highlight (case insensitive comparison)"),
OPTION_TYPE_STRING, 0, 0, 0,
"", NULL, NULL, &cfg_irc_highlight, config_change_noop },
{ NULL, NULL, NULL, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL }
diff --git a/src/irc/irc-recv.c b/src/irc/irc-recv.c
index 9faa298b5..e71211f13 100644
--- a/src/irc/irc-recv.c
+++ b/src/irc/irc-recv.c
@@ -29,6 +29,7 @@
#include <unistd.h>
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#include <sys/time.h>
#include <time.h>
#include <sys/utsname.h>
@@ -50,7 +51,7 @@
int
irc_is_highlight (char *message, char *nick)
{
- char *highlight, *pos, *pos_end;
+ char *msg, *highlight, *pos, *pos_end;
int end, length;
/* empty message ? */
@@ -65,9 +66,28 @@ irc_is_highlight (char *message, char *nick)
if (!cfg_irc_highlight || !cfg_irc_highlight[0])
return 0;
- /* look in "irc_highlight" for highlight */
+ /* convert both strings to lower case */
+ if ((msg = strdup (message)) == NULL)
+ return 0;
if ((highlight = strdup (cfg_irc_highlight)) == NULL)
+ {
+ free (msg);
return 0;
+ }
+ pos = msg;
+ while (pos[0])
+ {
+ pos[0] = tolower (pos[0]);
+ pos++;
+ }
+ pos = highlight;
+ while (pos[0])
+ {
+ pos[0] = tolower (pos[0]);
+ pos++;
+ }
+
+ /* look in "irc_highlight" for highlight */
pos = highlight;
end = 0;
while (!end)
@@ -81,6 +101,7 @@ irc_is_highlight (char *message, char *nick)
/* error parsing string! */
if (!pos_end)
{
+ free (msg);
free (highlight);
return 0;
}
@@ -90,8 +111,9 @@ irc_is_highlight (char *message, char *nick)
if (length > 0)
{
/* highlight found! */
- if (strstr (message, pos))
+ if (strstr (msg, pos))
{
+ free (msg);
free (highlight);
return 1;
}
@@ -102,6 +124,7 @@ irc_is_highlight (char *message, char *nick)
}
/* no highlight found with "irc_highlight" list */
+ free (msg);
free (highlight);
return 0;
}