From 00c8439b57b74ab77a8e7127f391e88e2cc753ed Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Tue, 17 Nov 2015 16:21:30 +0100 Subject: [PATCH] Small fix --- source/helper.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/source/helper.c b/source/helper.c index 1553dd89..b7e003eb 100644 --- a/source/helper.c +++ b/source/helper.c @@ -207,18 +207,18 @@ char **tokenize ( const char *input, int case_sensitive ) for ( token = strtok_r ( str, " ", &saveptr ); token != NULL; token = strtok_r ( NULL, " ", &saveptr ) ) { retv = g_realloc ( retv, sizeof ( char* ) * ( num_tokens + 2 ) ); if ( config.glob ) { - char *t = token_collate_key ( token, case_sensitive ); - char *str = g_strdup_printf ( "*%s*", input ); - retv[num_tokens] = (char *) g_pattern_spec_new ( str ); + char *str = g_strdup_printf ( "*%s*", token); + char *t = token_collate_key ( str, case_sensitive ); + retv[num_tokens] = (char *) g_pattern_spec_new ( t ); g_free ( t ); g_free ( str ); } else if ( config.regex ) { GError *error = NULL; - retv[num_tokens] = (char *) g_regex_new ( token, case_sensitive ? 0 : G_REGEX_CASELESS, 0, &error ); + retv[num_tokens] = (char *) g_regex_new ( token, case_sensitive?0:G_REGEX_CASELESS, 0, &error); if ( retv[num_tokens] == NULL ) { fprintf ( stderr, "Failed to parse: '%s'\n", error->message ); - g_error_free ( error ); + g_error_free(error); num_tokens--; } } @@ -459,7 +459,7 @@ static int regex_token_match ( char **tokens, const char *input, G_GNUC_UNUSED i static int glob_token_match ( char **tokens, const char *input, int not_ascii, int case_sensitive ) { int match = 1; - char *compk = not_ascii ? token_collate_key ( input, case_sensitive ) : (char *) input; + char *compk = not_ascii ? token_collate_key ( input, case_sensitive ) : g_ascii_strdown(input,-1); // Do a tokenized match. if ( tokens ) { @@ -467,9 +467,7 @@ static int glob_token_match ( char **tokens, const char *input, int not_ascii, i match = g_pattern_match_string ( (GPatternSpec *) tokens[j], compk ); } } - if ( not_ascii ) { - g_free ( compk ); - } + g_free ( compk ); return match; }