diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-22 06:59:54 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-10-22 06:59:54 +0000 |
commit | f57c988e343a4d682d3a988127b0552dde3caf3e (patch) | |
tree | f1992e7887b122a0297c6a44bf741e48c3cbe2a6 /dir.c | |
parent | 4ae79ade414c7e54a6b044e5569233bd688d7b97 (diff) | |
download | ruby-f57c988e343a4d682d3a988127b0552dde3caf3e.tar.gz |
dir.c: DOTMATCH to current directory
* dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH
is given. [ruby-core:53108] [Bug #8006]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -1406,12 +1406,20 @@ glob_helper( enum answer new_isdir = UNKNOWN; const char *name; size_t namlen; + int dotfile = 0; IF_HAVE_HFS(VALUE utf8str = Qnil); if (recursive && dp->d_name[0] == '.') { - /* 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; + ++dotfile; + if (!dp->d_name[1]) { + /* unless DOTMATCH, skip current directories not to recurse infinitely */ + if (!(flags & FNM_DOTMATCH)) continue; + ++dotfile; + } + else if (dp->d_name[1] == '.' && !dp->d_name[2]) { + /* always skip parent directories not to recurse infinitely */ + continue; + } } name = dp->d_name; @@ -1430,7 +1438,7 @@ glob_helper( break; } name = buf + pathlen + (dirsep != 0); - if (recursive && ((flags & FNM_DOTMATCH) || dp->d_name[0] != '.')) { + if (recursive && dotfile < ((flags & FNM_DOTMATCH) ? 2 : 1)) { /* RECURSIVE never match dot files unless FNM_DOTMATCH is set */ #ifndef _WIN32 if (do_lstat(buf, &st, flags) == 0) |