Browse files

-G option should only match file names, not directories. Fixes #35.

  • Loading branch information...
1 parent c67cb79 commit eacd08a55a7a55a99f37480e3587a11b3e99decc @ggreer committed May 24, 2012
Showing with 9 additions and 9 deletions.
  1. +9 −9 src/search.c
View
18 src/search.c
@@ -284,15 +284,6 @@ void search_dir(const pcre *re, const pcre_extra *re_extra, const char* path, co
log_debug("dir %s type %i", dir_full_path, dir->d_type);
- if (opts.file_search_regex) {
- rc = pcre_exec(opts.file_search_regex, NULL, dir_full_path, strlen(dir_full_path),
- 0, 0, offset_vector, 3);
- if (rc < 0) { /* no match */
- log_debug("Skipping %s due to file_search_regex.", dir_full_path);
- goto cleanup;
- }
- }
-
/* TODO: scan files in current dir before going deeper */
if (dir->d_type == DT_DIR) {
if (opts.recurse_dirs) {
@@ -307,6 +298,15 @@ void search_dir(const pcre *re, const pcre_extra *re_extra, const char* path, co
goto cleanup;
}
+ if (opts.file_search_regex) {
+ rc = pcre_exec(opts.file_search_regex, NULL, dir_full_path, strlen(dir_full_path),
+ 0, 0, offset_vector, 3);
+ if (rc < 0) { /* no match */
+ log_debug("Skipping %s due to file_search_regex.", dir_full_path);
+ goto cleanup;
+ }
+ }
+
search_file(re, re_extra, dir_full_path);
cleanup:

0 comments on commit eacd08a

Please sign in to comment.