mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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
This commit is contained in:
parent
34a542cb70
commit
10d2b5ec46
4 changed files with 26 additions and 5 deletions
|
@ -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>
|
Tue Jan 15 16:30:29 2013 KOSAKI Motohiro <kosaki.motohiro@gmail.com>
|
||||||
|
|
||||||
* thread_pthread.c (gvl_init): Reset gvl.wait_yield explicitly when
|
* thread_pthread.c (gvl_init): Reset gvl.wait_yield explicitly when
|
||||||
|
|
4
dir.c
4
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;
|
struct glob_pattern *list, *tmp, **tail = &list;
|
||||||
int dirsep = 0; /* pattern is terminated with '/' */
|
int dirsep = 0; /* pattern is terminated with '/' */
|
||||||
|
int recursive = 0;
|
||||||
|
|
||||||
while (p < e && *p) {
|
while (p < e && *p) {
|
||||||
tmp = GLOB_ALLOC(struct glob_pattern);
|
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->type = RECURSIVE;
|
||||||
tmp->str = 0;
|
tmp->str = 0;
|
||||||
dirsep = 1;
|
dirsep = 1;
|
||||||
|
recursive = 1;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const char *m = find_dirsep(p, e, flags, enc);
|
const char *m = find_dirsep(p, e, flags, enc);
|
||||||
int magic = has_magic(p, m, flags, enc);
|
int magic = has_magic(p, m, flags, enc);
|
||||||
char *buf;
|
char *buf;
|
||||||
|
|
||||||
if (!magic && *m) {
|
if (!magic && !recursive && *m) {
|
||||||
const char *m2;
|
const char *m2;
|
||||||
while (!has_magic(m+1, m2 = find_dirsep(m+1, e, flags, enc), flags, enc) &&
|
while (!has_magic(m+1, m2 = find_dirsep(m+1, e, flags, enc), flags, enc) &&
|
||||||
*m2) {
|
*m2) {
|
||||||
|
|
|
@ -171,6 +171,20 @@ class TestDir < Test::Unit::TestCase
|
||||||
assert_raise(Encoding::CompatibilityError) {Dir.glob(m.new)}
|
assert_raise(Encoding::CompatibilityError) {Dir.glob(m.new)}
|
||||||
end
|
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
|
def test_foreach
|
||||||
assert_equal(Dir.foreach(@root).to_a.sort, %w(. ..) + (?a..?z).to_a)
|
assert_equal(Dir.foreach(@root).to_a.sort, %w(. ..) + (?a..?z).to_a)
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#define RUBY_VERSION "1.9.3"
|
#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_YEAR 2013
|
||||||
#define RUBY_RELEASE_MONTH 1
|
#define RUBY_RELEASE_MONTH 2
|
||||||
#define RUBY_RELEASE_DAY 18
|
#define RUBY_RELEASE_DAY 6
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue