diff options
author | QC <qball@gmpclient.org> | 2015-10-02 20:39:57 +0200 |
---|---|---|
committer | QC <qball@gmpclient.org> | 2015-10-02 20:39:57 +0200 |
commit | 5de38cd7558711ab5ca90452e85bed6f8a08f8e8 (patch) | |
tree | 9aebe5f45ab66a85c7edcb6c3f11dffc980de7f9 /source/helper.c | |
parent | e3115be103d9350596c0aec628c121e045b356e0 (diff) |
Add glob version for testing.
Diffstat (limited to 'source/helper.c')
-rw-r--r-- | source/helper.c | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/source/helper.c b/source/helper.c index 94b90a28..18270e9c 100644 --- a/source/helper.c +++ b/source/helper.c @@ -345,11 +345,28 @@ static int normal_token_match ( char **tokens, const char *input, int case_sensi g_free ( compk ); return match; } +static int glob_token_match ( char **tokens, const char *input, int case_sensitive ) +{ + int match = 1; + char *compk = token_collate_key ( input, case_sensitive ); + + // Do a tokenized match. + if ( tokens ) { + for ( int j = 0; match && tokens[j]; j++ ) { + match = g_pattern_match_simple ( tokens[j], compk ); + } + } + g_free ( compk ); + return match; +} int token_match ( char **tokens, const char *input, int case_sensitive, __attribute__( ( unused ) ) unsigned int index, __attribute__( ( unused ) ) Switcher *data ) { - if ( config.fuzzy ) { + if ( config.glob ) { + return glob_token_match ( tokens, input, case_sensitive ); + } + else if ( config.fuzzy ) { return fuzzy_token_match ( tokens, input, case_sensitive ); } return normal_token_match ( tokens, input, case_sensitive ); |