diff options
author | Přemysl Janouch <p.janouch@gmail.com> | 2013-05-19 01:24:30 +0200 |
---|---|---|
committer | Přemysl Janouch <p.janouch@gmail.com> | 2013-05-19 01:29:04 +0200 |
commit | c430b6d7f89deaee45eaee350ef88a440b34cb29 (patch) | |
tree | 84f55862cbf9d490790176b7edbb4506ed747929 /src | |
parent | 110f2523d37658081761c08714fffc421144e6f4 (diff) | |
download | tdv-c430b6d7f89deaee45eaee350ef88a440b34cb29.tar.gz tdv-c430b6d7f89deaee45eaee350ef88a440b34cb29.tar.xz tdv-c430b6d7f89deaee45eaee350ef88a440b34cb29.zip |
Don't do case-sensitive searches
Diffstat (limited to 'src')
-rw-r--r-- | src/stardict.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/stardict.c b/src/stardict.c index 92250c7..5361c5e 100644 --- a/src/stardict.c +++ b/src/stardict.c @@ -74,8 +74,7 @@ stream_read_string (GDataInputStream *dis, GError **error) static inline gint stardict_strcmp (const gchar *s1, const gchar *s2) { - gint a; - a = g_ascii_strcasecmp (s1, s2); + gint a = g_ascii_strcasecmp (s1, s2); return a ? a : strcmp (s1, s2); } @@ -727,11 +726,11 @@ error: gchar ** stardict_dict_get_synonyms (StardictDict *sd, const gchar *word) { - BINARY_SEARCH_BEGIN (sd->synonyms->len - 1, stardict_strcmp (word, + BINARY_SEARCH_BEGIN (sd->synonyms->len - 1, g_ascii_strcasecmp (word, g_array_index (sd->synonyms, StardictSynonymEntry, imid).word)) // Back off to the first matching entry - while (imid > 0 && !stardict_strcmp (word, + while (imid > 0 && !g_ascii_strcasecmp (word, g_array_index (sd->synonyms, StardictSynonymEntry, --imid).word)); GPtrArray *array = g_ptr_array_new (); @@ -759,9 +758,14 @@ stardict_dict_get_synonyms (StardictDict *sd, const gchar *word) StardictIterator * stardict_dict_search (StardictDict *sd, const gchar *word, gboolean *success) { - BINARY_SEARCH_BEGIN (sd->index->len - 1, stardict_strcmp (word, + BINARY_SEARCH_BEGIN (sd->index->len - 1, g_ascii_strcasecmp (word, g_array_index (sd->index, StardictIndexEntry, imid).name)) + // Back off to the first matching entry + while (imid > 0 && !g_ascii_strcasecmp (word, + g_array_index (sd->index, StardictIndexEntry, imid - 1).name)) + imid--; + if (success) *success = TRUE; return stardict_iterator_new (sd, imid); |