SF.net SVN: geany:[5793] branches/0.20.1
colombanw at users.sourceforge.net
colombanw at xxxxx
Mon May 9 17:41:30 UTC 2011
Revision: 5793
http://geany.svn.sourceforge.net/geany/?rev=5793&view=rev
Author: colombanw
Date: 2011-05-09 17:41:30 +0000 (Mon, 09 May 2011)
Log Message:
-----------
Fix pattern filtering when not searching in subdirectories
grep's --include option doesn't filter files passed explicitly to grep,
so when we build the file list to search in, take the filters into
account.
Also drop the --include options in this case since they aren't useful.
Modified Paths:
--------------
branches/0.20.1/ChangeLog
branches/0.20.1/src/search.c
Modified: branches/0.20.1/ChangeLog
===================================================================
--- branches/0.20.1/ChangeLog 2011-05-09 17:41:08 UTC (rev 5792)
+++ branches/0.20.1/ChangeLog 2011-05-09 17:41:30 UTC (rev 5793)
@@ -37,6 +37,8 @@
Avoid changing the tag tree if it's not the one of the current
document, fixing showing the wrong tag list when reloading
configuration files.
+ * src/search.c:
+ Fix pattern filtering when not searching in subdirectories.
2011-05-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
Modified: branches/0.20.1/src/search.c
===================================================================
--- branches/0.20.1/src/search.c 2011-05-09 17:41:08 UTC (rev 5792)
+++ branches/0.20.1/src/search.c 2011-05-09 17:41:30 UTC (rev 5793)
@@ -1514,14 +1514,27 @@
}
+static gboolean pattern_list_match(GSList *patterns, const gchar *str)
+{
+ GSList *item;
+
+ foreach_slist(item, patterns)
+ {
+ if (g_pattern_match_string(item->data, str))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
/* Creates an argument vector of strings, copying argv_prefix[] values for
* the first arguments, then followed by filenames found in dir.
* Returns NULL if no files were found, otherwise returned vector should be fully freed. */
static gchar **search_get_argv(const gchar **argv_prefix, const gchar *dir)
{
- guint prefix_len, list_len, i;
+ guint prefix_len, list_len, i, j;
gchar **argv;
- GSList *list, *item;
+ GSList *list, *item, *patterns = NULL;
GError *error = NULL;
g_return_val_if_fail(dir != NULL, NULL);
@@ -1539,13 +1552,40 @@
argv = g_new(gchar*, prefix_len + list_len + 1);
- for (i = 0; i < prefix_len; i++)
- argv[i] = g_strdup(argv_prefix[i]);
+ for (i = 0, j = 0; i < prefix_len; i++)
+ {
+ if (g_str_has_prefix(argv_prefix[i], "--include="))
+ {
+ const gchar *pat = &(argv_prefix[i][10]); /* the pattern part of the argument */
- foreach_slist(item, list)
- argv[i++] = item->data;
+ patterns = g_slist_prepend(patterns, g_pattern_spec_new(pat));
+ }
+ else
+ argv[j++] = g_strdup(argv_prefix[i]);
+ }
- argv[i] = NULL;
+ if (patterns)
+ {
+ GSList *pat;
+
+ foreach_slist(item, list)
+ {
+ if (pattern_list_match(patterns, item->data))
+ argv[j++] = item->data;
+ else
+ g_free(item->data);
+ }
+ foreach_slist(pat, patterns)
+ g_pattern_spec_free(pat->data);
+ g_slist_free(patterns);
+ }
+ else
+ {
+ foreach_slist(item, list)
+ argv[j++] = item->data;
+ }
+
+ argv[j] = NULL;
g_slist_free(list);
return argv;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Commits
mailing list