summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authorocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-08 01:07:09 +0000
committerocean <ocean@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-02-08 01:07:09 +0000
commit3a8647ea9f91ea12a624c3e297f55ec4235a6c37 (patch)
treeea066f7e4804775788455b46fc0d75e957d14fea /dir.c
parent208adf5c1f8eb2698c80e4944f097d444214a35a (diff)
* 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
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c59
1 files changed, 31 insertions, 28 deletions
diff --git a/dir.c b/dir.c
index 7e8eb4d365..5e8ecfa449 100644
--- a/dir.c
+++ b/dir.c
@@ -994,7 +994,8 @@ glob_make_pattern(p, flags)
while (*p) {
tmp = ALLOC(struct glob_pattern);
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->str = 0;
dirsep = 1;
@@ -1149,38 +1150,40 @@ glob_helper(path, dirsep, exist, isdir, beg, end, flags, func, arg)
}
}
- if (match_all && exist == UNKNOWN) {
- if (do_lstat(path, &st) == 0) {
- exist = YES;
- isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO;
- }
- else {
- exist = NO;
- isdir = NO;
+ if (*path) {
+ if (match_all && exist == UNKNOWN) {
+ if (do_lstat(path, &st) == 0) {
+ exist = YES;
+ isdir = S_ISDIR(st.st_mode) ? YES : S_ISLNK(st.st_mode) ? UNKNOWN : NO;
+ }
+ else {
+ exist = NO;
+ isdir = NO;
+ }
}
- }
- if (match_dir && isdir == UNKNOWN) {
- if (do_stat(path, &st) == 0) {
- exist = YES;
- isdir = S_ISDIR(st.st_mode) ? YES : NO;
- }
- else {
- exist = NO;
- isdir = NO;
+ if (match_dir && isdir == UNKNOWN) {
+ if (do_stat(path, &st) == 0) {
+ exist = YES;
+ isdir = S_ISDIR(st.st_mode) ? YES : NO;
+ }
+ else {
+ exist = NO;
+ isdir = NO;
+ }
}
- }
- if (match_all && exist == YES) {
- status = glob_call_func(func, path, arg);
- if (status) return status;
- }
+ if (match_all && exist == YES) {
+ status = glob_call_func(func, path, arg);
+ 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 (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;