From 80ecaa17776de97d8f7d9c256830edb45917987a Mon Sep 17 00:00:00 2001 From: nagachika Date: Sat, 20 Apr 2013 14:40:53 +0000 Subject: merge revision(s) 40345: [Backport #8283] * dir.c (glob_helper): should skip dot directories only for recursion, but should not if matching to the given pattern. [ruby-core:54387] [Bug #8283] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@40394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- dir.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index 8b1b09e6d7..bc51e5025e 100644 --- a/dir.c +++ b/dir.c @@ -1386,9 +1386,6 @@ glob_helper( enum answer new_isdir = UNKNOWN; if (recursive && dp->d_name[0] == '.') { - /* RECURSIVE never match dot files unless FNM_DOTMATCH is set */ - if (!(flags & FNM_DOTMATCH)) continue; - /* always skip current and parent directories not to recurse infinitely */ if (!dp->d_name[1]) continue; if (dp->d_name[1] == '.' && !dp->d_name[2]) continue; @@ -1399,7 +1396,8 @@ glob_helper( status = -1; break; } - if (recursive) { + if (recursive && ((flags & FNM_DOTMATCH) || dp->d_name[0] != '.')) { + /* RECURSIVE never match dot files unless FNM_DOTMATCH is set */ #ifndef _WIN32 if (do_lstat(buf, &st, flags) == 0) new_isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO; -- cgit v1.2.3