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

ruby-changes:32818

From: nagachika <ko1@a...>
Date: Mon, 10 Feb 2014 00:15:23 +0900 (JST)
Subject: [ruby-changes:32818] nagachika:r44897 (ruby_2_0_0): merge revision(s) 43385: [Backport #8006]

nagachika	2014-02-10 00:15:17 +0900 (Mon, 10 Feb 2014)

  New Revision: 44897

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

  Log:
    merge revision(s) 43385: [Backport #8006]
    
    * dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH
      is given.  [ruby-core:53108] [Bug #8006]

  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 44896)
+++ ruby_2_0_0/ChangeLog	(revision 44897)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/ChangeLog#L1
+Mon Feb 10 00:02:18 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* dir.c (glob_helper): don't skip current directories if FNM_DOTMATCH
+	  is given.  [ruby-core:53108] [Bug #8006]
+
 Wed Feb  5 23:39:36 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* parse.y (intern_str): sigil only names are junk, at least one
Index: ruby_2_0_0/dir.c
===================================================================
--- ruby_2_0_0/dir.c	(revision 44896)
+++ ruby_2_0_0/dir.c	(revision 44897)
@@ -1388,11 +1388,19 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/dir.c#L1388
 	while (READDIR(dirp, enc, &STRUCT_DIRENT(entry), dp)) {
 	    char *buf;
 	    enum answer new_isdir = UNKNOWN;
+	    int dotfile = 0;
 
 	    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;
+		}
 	    }
 
 	    buf = join_path(path, dirsep, dp->d_name, NAMLEN(dp));
@@ -1400,7 +1408,7 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/dir.c#L1408
 		status = -1;
 		break;
 	    }
-	    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)
Index: ruby_2_0_0/version.h
===================================================================
--- ruby_2_0_0/version.h	(revision 44896)
+++ ruby_2_0_0/version.h	(revision 44897)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/version.h#L1
 #define RUBY_VERSION "2.0.0"
-#define RUBY_RELEASE_DATE "2014-02-05"
-#define RUBY_PATCHLEVEL 396
+#define RUBY_RELEASE_DATE "2014-02-10"
+#define RUBY_PATCHLEVEL 397
 
 #define RUBY_RELEASE_YEAR 2014
 #define RUBY_RELEASE_MONTH 2
-#define RUBY_RELEASE_DAY 5
+#define RUBY_RELEASE_DAY 10
 
 #include "ruby/version.h"
 
Index: ruby_2_0_0/test/ruby/test_dir.rb
===================================================================
--- ruby_2_0_0/test/ruby/test_dir.rb	(revision 44896)
+++ ruby_2_0_0/test/ruby/test_dir.rb	(revision 44897)
@@ -168,7 +168,10 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_2_0_0/test/ruby/test_dir.rb#L168
 
   def test_glob_recursive
     bug6977 = '[ruby-core:47418]'
+    bug8006 = '[ruby-core:53108] [Bug #8006]'
     Dir.chdir(@root) do
+      assert_include(Dir.glob("a/**/*", File::FNM_DOTMATCH), "a/.", bug8006)
+
       FileUtils.mkdir_p("a/b/c/d/e/f")
       assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/e/f"), bug6977)
       assert_equal(["a/b/c/d/e/f"], Dir.glob("a/**/d/e/f"), bug6977)

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


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

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