From 487ac0a011655b78de5b41bf2c8c68143f9b9bf2 Mon Sep 17 00:00:00 2001 From: RichardHitt Date: Fri, 11 Jan 2013 01:39:21 -0800 Subject: Correct nick recognition. Closes 372. --- src/common/url.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/common/url.c b/src/common/url.c index 0ee09988..873878ac 100644 --- a/src/common/url.c +++ b/src/common/url.c @@ -188,6 +188,16 @@ static int laststart = 0; static int lastend = 0; static int lasttype = 0; +static int +strchrs (char c, char *s) +{ + while (*s) + if (c == *s++) + return TRUE; + return FALSE; +} + +#define NICKPRE "~+!@%%&" int url_check_word (const char *word) { @@ -196,11 +206,15 @@ url_check_word (const char *word) { switch (lasttype) { + char *str; + case WORD_NICK: - if (!isalnum (word[laststart])) + if (strchrs (word[laststart], NICKPRE)) laststart++; - if (!userlist_find (current_sess, &word[laststart])) + str = strndup (&word[laststart], lastend - laststart); + if (!userlist_find (current_sess, str)) lasttype = 0; + free (str); return lasttype; case WORD_EMAIL: if (!isalnum (word[laststart])) @@ -448,7 +462,7 @@ re_email (void) } /* NICK description --- */ -#define NICKPRE "~+!@%%&" +/* For NICKPRE see before url_check_word() */ #define NICKHYP "-" #define NICKLET "a-z" #define NICKDIG "0-9" -- cgit 1.4.1 From 6c7346cdbedc0dd775c028fd5a0394db05d5fd30 Mon Sep 17 00:00:00 2001 From: RichardHitt Date: Fri, 11 Jan 2013 02:38:11 -0800 Subject: Correct nick recognition in mainurl.c as well. Closes #372. --- src/fe-gtk/maingui.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/fe-gtk/maingui.c b/src/fe-gtk/maingui.c index 2dfb7b8d..a5ea0b66 100644 --- a/src/fe-gtk/maingui.c +++ b/src/fe-gtk/maingui.c @@ -2311,7 +2311,9 @@ mg_word_clicked (GtkWidget *xtext, char *word, GdkEventButton *even) menu_urlmenu (even, word); break; case WORD_NICK: - menu_nickmenu (sess, even, word + (ispunct (*word)? 1: 0), FALSE); + word[end] = 0; + word += start; + menu_nickmenu (sess, even, word, FALSE); break; case WORD_CHANNEL: menu_chanmenu (sess, even, word); -- cgit 1.4.1 From 07b69fd2f8236d05191b8ceff86db74a0509249c Mon Sep 17 00:00:00 2001 From: RichardHitt Date: Fri, 11 Jan 2013 16:12:52 -0800 Subject: Oops, Windows doesn't offer strndup(). Use g_strndup(). --- src/common/url.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/url.c b/src/common/url.c index 873878ac..f22da931 100644 --- a/src/common/url.c +++ b/src/common/url.c @@ -211,10 +211,10 @@ url_check_word (const char *word) case WORD_NICK: if (strchrs (word[laststart], NICKPRE)) laststart++; - str = strndup (&word[laststart], lastend - laststart); + str = g_strndup (&word[laststart], lastend - laststart); if (!userlist_find (current_sess, str)) lasttype = 0; - free (str); + g_free (str); return lasttype; case WORD_EMAIL: if (!isalnum (word[laststart])) -- cgit 1.4.1