Patterns searching
[mdictionary] / src / plugins / stardict / src / engine_stardict.c
index 9bbbda9..c86e187 100755 (executable)
@@ -368,7 +368,10 @@ void sd_engine_search_word_list(Engine* engine, gchar* pattern)
        gint offset = 0;
        gchar* tmp = NULL;
        guint len = 0;
-       guint pl = strlen(pattern);
+//     guint pl = strlen(pattern);
+       GPatternSpec* regex;
+       regex = g_pattern_spec_new (pattern);
+       
        gboolean further = FALSE;
        guint count = 0;
        GArray* result = g_array_new(TRUE, TRUE, sizeof(gchar*));
@@ -397,7 +400,7 @@ void sd_engine_search_word_list(Engine* engine, gchar* pattern)
                while(i<min)
                {
                        // check next words
-                       if(g_ascii_strncasecmp(tmp,pattern,pl) == 0)
+                       if(g_pattern_match_string (regex, tmp) == TRUE)
                        {
                                gchar* new = g_strdup(tmp);
                                g_array_append_val(result,new);
@@ -437,6 +440,7 @@ void sd_engine_search_word_list(Engine* engine, gchar* pattern)
                g_free(g_array_index(result, gchar*, i));
        }
        g_array_free(result, TRUE);
+       g_pattern_spec_free (regex);
 }
 //------------------------------------------------------------------------------
 /** \brief Search translation of word in dictionary.