Don't do case-sensitive searches
This commit is contained in:
parent
110f2523d3
commit
c430b6d7f8
|
@ -74,8 +74,7 @@ stream_read_string (GDataInputStream *dis, GError **error)
|
||||||
static inline gint
|
static inline gint
|
||||||
stardict_strcmp (const gchar *s1, const gchar *s2)
|
stardict_strcmp (const gchar *s1, const gchar *s2)
|
||||||
{
|
{
|
||||||
gint a;
|
gint a = g_ascii_strcasecmp (s1, s2);
|
||||||
a = g_ascii_strcasecmp (s1, s2);
|
|
||||||
return a ? a : strcmp (s1, s2);
|
return a ? a : strcmp (s1, s2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -727,11 +726,11 @@ error:
|
||||||
gchar **
|
gchar **
|
||||||
stardict_dict_get_synonyms (StardictDict *sd, const gchar *word)
|
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))
|
g_array_index (sd->synonyms, StardictSynonymEntry, imid).word))
|
||||||
|
|
||||||
// Back off to the first matching entry
|
// 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));
|
g_array_index (sd->synonyms, StardictSynonymEntry, --imid).word));
|
||||||
|
|
||||||
GPtrArray *array = g_ptr_array_new ();
|
GPtrArray *array = g_ptr_array_new ();
|
||||||
|
@ -759,9 +758,14 @@ stardict_dict_get_synonyms (StardictDict *sd, const gchar *word)
|
||||||
StardictIterator *
|
StardictIterator *
|
||||||
stardict_dict_search (StardictDict *sd, const gchar *word, gboolean *success)
|
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))
|
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;
|
if (success) *success = TRUE;
|
||||||
return stardict_iterator_new (sd, imid);
|
return stardict_iterator_new (sd, imid);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue