aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2012-04-11 08:55:08 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2012-04-11 08:55:08 +0000
commit1f25de69bdd24951e4e1952319d6fa305cc22794 (patch)
treedeb9703c0ecf0de1ad5bf197f3383ce768b6beab
parent048e578942e72b7d5d00b3e6117bc35ff72fadb1 (diff)
src/addr_compl.c: also match to the subsequent part of the name of contacts (Bug #51).
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@3038 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog5
-rw-r--r--src/addr_compl.c26
2 files changed, 31 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index e95de3fd..f573d35c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2012-04-11
+ * src/addr_compl.c: also match to the subsequent part of the name of
+ contacts (Bug #51).
+
+2012-04-11
+
* nsis/sylpheed-defs.nsh
nsis/sylpheed.nsi
nsis/english.nsh
diff --git a/src/addr_compl.c b/src/addr_compl.c
index 8a1fbeca..90a73428 100644
--- a/src/addr_compl.c
+++ b/src/addr_compl.c
@@ -2,6 +2,7 @@
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
*
* Copyright (C) 2000-2005 by Alfons Hoogervorst & The Sylpheed Claws Team.
+ * Copyright (C) 1999-2012 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -108,10 +109,35 @@ static gchar *completion_func(gpointer data)
return ((completion_entry *)data)->string;
}
+static gint compare_func(const gchar *s1, const gchar *s2, gsize n)
+{
+ const gchar *p = s2;
+ gint ret = 1;
+
+ g_return_val_if_fail(s1 != NULL && s2 != NULL, 1);
+
+ while (*p) {
+ ret = strncmp(s1, p, n);
+ if (ret == 0)
+ return ret;
+ while (*p && *p != '-' && *p != '.' && *p != '@' &&
+ !g_ascii_isspace(*p))
+ p++;
+ /* don't compare the domain part */
+ if (*p == '@')
+ break;
+ while (*p == '-' || *p == '.' || g_ascii_isspace(*p))
+ p++;
+ }
+
+ return ret;
+}
+
static void init_all(void)
{
completion = g_completion_new(completion_func);
g_return_if_fail(completion != NULL);
+ g_completion_set_compare(completion, compare_func);
}
static void free_all(void)