[libgweather] LocationEntry: fix database matching in the presence of whitespace
- From: Giovanni Campagna <gcampagna src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgweather] LocationEntry: fix database matching in the presence of whitespace
- Date: Fri, 17 Apr 2015 00:46:43 +0000 (UTC)
commit 152dd92bd8fc97d7226b0d8f340a04d53b34f18b
Author: Giovanni Campagna <gcampagna src gnome org>
Date: Thu Apr 16 17:45:26 2015 -0700
LocationEntry: fix database matching in the presence of whitespace
Trailing whitespace should prevent prefix matches but not cause
matching failures altoghether (trying to call find_word with
a length of 0)
libgweather/gweather-location-entry.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/libgweather/gweather-location-entry.c b/libgweather/gweather-location-entry.c
index 5eeda3e..5d6b8b1 100644
--- a/libgweather/gweather-location-entry.c
+++ b/libgweather/gweather-location-entry.c
@@ -678,6 +678,9 @@ match_compare_name (const char *key, const char *name)
gboolean is_first_word = TRUE;
int len;
+ /* Ignore whitespace before the string */
+ key += strspn (key, " ");
+
/* All but the last word in KEY must match a full word from NAME,
* in order (but possibly skipping some words from NAME).
*/
@@ -698,7 +701,13 @@ match_compare_name (const char *key, const char *name)
}
/* The last word in KEY must match a prefix of a following word in NAME */
- return find_word (name, key, strlen (key), FALSE, is_first_word) != NULL;
+ if (len == 0) {
+ return TRUE;
+ } else {
+ // if we get here, key[len] == 0, so...
+ g_assert (len == strlen(key));
+ return find_word (name, key, len, FALSE, is_first_word) != NULL;
+ }
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]