* dir.c (glob_helper): Dir.glob('**/') did not work.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
208adf5c1f
commit
3a8647ea9f
59
dir.c
59
dir.c
@ -994,7 +994,8 @@ glob_make_pattern(p, flags)
|
|||||||
while (*p) {
|
while (*p) {
|
||||||
tmp = ALLOC(struct glob_pattern);
|
tmp = ALLOC(struct glob_pattern);
|
||||||
if (p[0] == '*' && p[1] == '*' && p[2] == '/') {
|
if (p[0] == '*' && p[1] == '*' && p[2] == '/') {
|
||||||
do { p += 3; } while (p[0] == '*' && p[1] == '*' && p[2] == '/'); /* fold continuous RECURSIVEs */
|
/* fold continuous RECURSIVEs */
|
||||||
|
do { p += 3; } while (p[0] == '*' && p[1] == '*' && p[2] == '/');
|
||||||
tmp->type = RECURSIVE;
|
tmp->type = RECURSIVE;
|
||||||
tmp->str = 0;
|
tmp->str = 0;
|
||||||
dirsep = 1;
|
dirsep = 1;
|
||||||
@ -1149,38 +1150,40 @@ glob_helper(path, dirsep, exist, isdir, beg, end, flags, func, arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (match_all && exist == UNKNOWN) {
|
if (*path) {
|
||||||
if (do_lstat(path, &st) == 0) {
|
if (match_all && exist == UNKNOWN) {
|
||||||
exist = YES;
|
if (do_lstat(path, &st) == 0) {
|
||||||
isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO;
|
exist = YES;
|
||||||
|
isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
exist = NO;
|
||||||
|
isdir = NO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
exist = NO;
|
|
||||||
isdir = NO;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (match_dir && isdir == UNKNOWN) {
|
if (match_dir && isdir == UNKNOWN) {
|
||||||
if (do_stat(path, &st) == 0) {
|
if (do_stat(path, &st) == 0) {
|
||||||
exist = YES;
|
exist = YES;
|
||||||
isdir = S_ISDIR(st.st_mode) ? YES : NO;
|
isdir = S_ISDIR(st.st_mode) ? YES : NO;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
exist = NO;
|
||||||
|
isdir = NO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
exist = NO;
|
if (match_all && exist == YES) {
|
||||||
isdir = NO;
|
status = glob_call_func(func, path, arg);
|
||||||
|
if (status) return status;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (match_all && exist == YES) {
|
if (match_dir && isdir == YES) {
|
||||||
status = glob_call_func(func, path, arg);
|
char *buf = join_path(path, dirsep, "");
|
||||||
if (status) return status;
|
status = glob_call_func(func, buf, arg);
|
||||||
}
|
free(buf);
|
||||||
|
if (status) return status;
|
||||||
if (match_dir && isdir == YES) {
|
}
|
||||||
char *buf = join_path(path, dirsep, "");
|
|
||||||
status = glob_call_func(func, buf, arg);
|
|
||||||
free(buf);
|
|
||||||
if (status) return status;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exist == NO || isdir == NO) return 0;
|
if (exist == NO || isdir == NO) return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user