[前][次][番号順一覧][スレッド一覧]

ruby-changes:28342

From: nagachika <ko1@a...>
Date: Sat, 20 Apr 2013 23:41:04 +0900 (JST)
Subject: [ruby-changes:28342] nagachika:r40394 (ruby_2_0_0): merge revision(s) 40345: [Backport #8283]

nagachika	2013-04-20 23:40:53 +0900 (Sat, 20 Apr 2013)

  New Revision: 40394

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=40394

  Log:
    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]

  Modified directories:
    branches/ruby_2_0_0/
  Modified files:
    branches/ruby_2_0_0/ChangeLog
    branches/ruby_2_0_0/dir.c
    branches/ruby_2_0_0/test/ruby/test_dir.rb
    branches/ruby_2_0_0/version.h

Index: ruby_2_0_0/ChangeLog
===================================================================
--- ruby_2_0_0/ChangeLog	(revision 40393)
+++ ruby_2_0_0/ChangeLog	(revision 40394)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Sat Apr 20 23:32:06 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@r...>
 
 	* ext/curses/curses.c (Init_curses): fix implementation function,
Index: ruby_2_0_0/dir.c
===================================================================
--- ruby_2_0_0/dir.c	(revision 40393)
+++ ruby_2_0_0/dir.c	(revision 40394)
@@ -1386,9 +1386,6 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/dir.c#L1386
 	    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( https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/dir.c#L1396
 		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;
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 40393)
+++ ruby_2_0_0/version.h	(revision 40394)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #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
Index: ruby_2_0_0/test/ruby/test_dir.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_dir.rb	(revision 40393)
+++ ruby_2_0_0/test/ruby/test_dir.rb	(revision 40394)
@@ -177,6 +177,15 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_dir.rb#L177
       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
 

Property changes on: ruby_2_0_0
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r40345


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]