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

ruby-changes:27038

From: usa <ko1@a...>
Date: Wed, 6 Feb 2013 14:07:27 +0900 (JST)
Subject: [ruby-changes:27038] usa:r39090 (ruby_1_9_3): merge revision(s) 36905: [Backport #6977]

usa	2013-02-06 14:06:20 +0900 (Wed, 06 Feb 2013)

  New Revision: 39090

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

  Log:
    merge revision(s) 36905: [Backport #6977]
    
    * dir.c (glob_make_pattern): names under recursive need to be single
      basenames to match for each name.  [ruby-core:47418] [Bug #6977]

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

Index: ruby_1_9_3/ChangeLog
===================================================================
--- ruby_1_9_3/ChangeLog	(revision 39089)
+++ ruby_1_9_3/ChangeLog	(revision 39090)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/ChangeLog#L1
+Wed Feb  6 14:05:09 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* dir.c (glob_make_pattern): names under recursive need to be single
+	  basenames to match for each name.  [ruby-core:47418] [Bug #6977]
+
 Tue Jan 15 16:30:29 2013  KOSAKI Motohiro  <kosaki.motohiro@g...>
 
 	* thread_pthread.c (gvl_init): Reset gvl.wait_yield explicitly when
Index: ruby_1_9_3/dir.c
===================================================================
--- ruby_1_9_3/dir.c	(revision 39089)
+++ ruby_1_9_3/dir.c	(revision 39090)
@@ -1175,6 +1175,7 @@ glob_make_pattern(const char *p, const c https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/dir.c#L1175
 {
     struct glob_pattern *list, *tmp, **tail = &list;
     int dirsep = 0; /* pattern is terminated with '/' */
+    int recursive = 0;
 
     while (p < e && *p) {
 	tmp = GLOB_ALLOC(struct glob_pattern);
@@ -1185,13 +1186,14 @@ glob_make_pattern(const char *p, const c https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/dir.c#L1186
 	    tmp->type = RECURSIVE;
 	    tmp->str = 0;
 	    dirsep = 1;
+	    recursive = 1;
 	}
 	else {
 	    const char *m = find_dirsep(p, e, flags, enc);
 	    int magic = has_magic(p, m, flags, enc);
 	    char *buf;
 
-	    if (!magic && *m) {
+	    if (!magic && !recursive && *m) {
 		const char *m2;
 		while (!has_magic(m+1, m2 = find_dirsep(m+1, e, flags, enc), flags, enc) &&
 		       *m2) {
Index: ruby_1_9_3/version.h
===================================================================
--- ruby_1_9_3/version.h	(revision 39089)
+++ ruby_1_9_3/version.h	(revision 39090)
@@ -1,10 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/version.h#L1
 #define RUBY_VERSION "1.9.3"
-#define RUBY_PATCHLEVEL 375
+#define RUBY_PATCHLEVEL 376
 
-#define RUBY_RELEASE_DATE "2013-01-18"
+#define RUBY_RELEASE_DATE "2013-02-06"
 #define RUBY_RELEASE_YEAR 2013
-#define RUBY_RELEASE_MONTH 1
-#define RUBY_RELEASE_DAY 18
+#define RUBY_RELEASE_MONTH 2
+#define RUBY_RELEASE_DAY 6
 
 #include "ruby/version.h"
 
Index: ruby_1_9_3/test/ruby/test_dir.rb
===================================================================
--- ruby_1_9_3/test/ruby/test_dir.rb	(revision 39089)
+++ ruby_1_9_3/test/ruby/test_dir.rb	(revision 39090)
@@ -171,6 +171,20 @@ class TestDir < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/ruby_1_9_3/test/ruby/test_dir.rb#L171
     assert_raise(Encoding::CompatibilityError) {Dir.glob(m.new)}
   end
 
+  def test_glob_recursive
+    bug6977 = '[ruby-core:47418]'
+    Dir.chdir(@root) do
+      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)
+      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/**/b/c/d/e/f"), bug6977)
+      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)
+    end
+  end
+
   def test_foreach
     assert_equal(Dir.foreach(@root).to_a.sort, %w(. ..) + (?a..?z).to_a)
   end

Property changes on: ruby_1_9_3
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r36905


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

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