summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-20 14:40:53 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-20 14:40:53 +0000
commit80ecaa17776de97d8f7d9c256830edb45917987a (patch)
treed88ec0fbe5083628d38719678753d163ec2cc3e3
parent62ff805f22bc23ddb4ba621588c43b97f902f546 (diff)
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
-rw-r--r--ChangeLog6
-rw-r--r--dir.c6
-rw-r--r--test/ruby/test_dir.rb9
-rw-r--r--version.h2
4 files changed, 18 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 71538b4d8c..2238dbd4f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat Apr 20 23:32:06 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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]
+
Sat Apr 20 02:37:33 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ext/curses/curses.c (Init_curses): fix implementation function,
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;
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index 21902298c0..1c8f73e20c 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -177,6 +177,15 @@ class TestDir < Test::Unit::TestCase
assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/?/e/f"), bug6977)
assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/**/d/e/f"), bug6977)
assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/c/**/d/e/f"), bug6977)
+
+ bug8283 = '[ruby-core:54387] [Bug #8283]'
+ dirs = ["a/.x", "a/b/.y"]
+ FileUtils.mkdir_p(dirs)
+ dirs.map {|dir| open("#{dir}/z", "w") {}}
+ assert_equal([], Dir.glob("a/**/z").sort, bug8283)
+ assert_equal(["a/.x/z"], Dir.glob("a/**/.x/z"), bug8283)
+ assert_equal(["a/.x/z"], Dir.glob("a/.x/**/z"), bug8283)
+ assert_equal(["a/b/.y/z"], Dir.glob("a/**/.y/z"), bug8283)
end
end
diff --git a/version.h b/version.h
index d03d2c4174..3c2d3be590 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.0.0"
#define RUBY_RELEASE_DATE "2013-04-20"
-#define RUBY_PATCHLEVEL 155
+#define RUBY_PATCHLEVEL 156
#define RUBY_RELEASE_YEAR 2013
#define RUBY_RELEASE_MONTH 4