summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-06 05:06:20 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-06 05:06:20 +0000
commit10d2b5ec466d321ab7e4662088c9e2d285266c04 (patch)
treee5ccea3c1db97484de69a4631053d1709c523f4b
parent34a542cb70a59a40f5819dbb9d73e744d1bb5b2f (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@39090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--dir.c4
-rw-r--r--test/ruby/test_dir.rb14
-rw-r--r--version.h8
4 files changed, 26 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 24861a3078..4dc08a3175 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Feb 6 14:05:09 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@gmail.com>
* thread_pthread.c (gvl_init): Reset gvl.wait_yield explicitly when
diff --git a/dir.c b/dir.c
index 387a2490b6..4246b10c9d 100644
--- a/dir.c
+++ b/dir.c
@@ -1175,6 +1175,7 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc)
{
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 char *e, int flags, rb_encoding *enc)
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) {
diff --git a/test/ruby/test_dir.rb b/test/ruby/test_dir.rb
index 236fd991db..b688cc4dd0 100644
--- a/test/ruby/test_dir.rb
+++ b/test/ruby/test_dir.rb
@@ -171,6 +171,20 @@ class TestDir < Test::Unit::TestCase
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
diff --git a/version.h b/version.h
index cbc6a0fa54..e58c538381 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#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"