aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@gnome.org>2004-02-11 23:21:18 +0800
committerMarco Pesenti Gritti <marco@src.gnome.org>2004-02-11 23:21:18 +0800
commit1e23dc1c811a619678c6b2f8876a8c30066b7654 (patch)
treed18ebcf28533fd4f0738cee00e0ff5a12e6c9109 /lib
parenta4e3a5f2856a8c2d9e200d94b7b9154b1a76434b (diff)
downloadgsoc2013-epiphany-1e23dc1c811a619678c6b2f8876a8c30066b7654.tar
gsoc2013-epiphany-1e23dc1c811a619678c6b2f8876a8c30066b7654.tar.gz
gsoc2013-epiphany-1e23dc1c811a619678c6b2f8876a8c30066b7654.tar.bz2
gsoc2013-epiphany-1e23dc1c811a619678c6b2f8876a8c30066b7654.tar.lz
gsoc2013-epiphany-1e23dc1c811a619678c6b2f8876a8c30066b7654.tar.xz
gsoc2013-epiphany-1e23dc1c811a619678c6b2f8876a8c30066b7654.tar.zst
gsoc2013-epiphany-1e23dc1c811a619678c6b2f8876a8c30066b7654.zip
Better keyword matching function. Should match only words (not middle
2004-02-11 Marco Pesenti Gritti <marco@gnome.org> * lib/widgets/ephy-location-entry.c: (keyword_match), (completion_func): Better keyword matching function. Should match only words (not middle parts of them) and maybe be a bit faster.
Diffstat (limited to 'lib')
-rw-r--r--lib/widgets/ephy-location-entry.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/lib/widgets/ephy-location-entry.c b/lib/widgets/ephy-location-entry.c
index 36b1b4d8c..cee04febb 100644
--- a/lib/widgets/ephy-location-entry.c
+++ b/lib/widgets/ephy-location-entry.c
@@ -193,6 +193,41 @@ entry_button_press_cb (GtkWidget *entry, GdkEventButton *event, EphyLocationEntr
}
static gboolean
+keyword_match (const char *list,
+ const char *keyword)
+{
+ const char *p;
+ gsize keyword_len;
+
+ p = list;
+ keyword_len = strlen (keyword);
+
+ while (*p)
+ {
+ int i;
+
+ for (i = 0; i < keyword_len; i++)
+ {
+ if (p[i] == ' ')
+ goto next_char;
+
+ if (p[i] != keyword[i])
+ goto next_token;
+ }
+
+ return TRUE;
+
+ next_token:
+ while (*p != ' ') p++;
+
+ next_char:
+ if (*p) p++;
+ }
+
+ return FALSE;
+}
+
+static gboolean
completion_func (GtkEntryCompletion *completion,
const char *key,
GtkTreeIter *iter,
@@ -216,7 +251,7 @@ completion_func (GtkEntryCompletion *completion,
{
ret = TRUE;
}
- else if (strstr (keywords, key))
+ else if (keyword_match (keywords, key))
{
ret = TRUE;
}