diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-03-21 03:41:45 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-03-21 03:41:45 +0000 |
commit | 9910feef4fc251419dc31cd2e022f81375bcad23 (patch) | |
tree | 3fabd7a3d793d999f1f4e116a9e95ad1adcb582d /dir.c | |
parent | 98e25a542aec760aed724bd7152ba86a96b3eeb8 (diff) |
* gc.c (id2ref): sometimes confused symbol and reference.
* dir.c (glob_helper): breaks loop after calling recusive
glob_helper; all wild cards should be consumed; no need for
further match.
* dir.c (dir_s_glob): gives warning if no match found.
* object.c (sym_inspect): did allocate extra byte space.
* marshal.c (shortlen): shortlen should return number of bytes
written.
* eval.c (ev_const_defined): need not to check if cbase->nd_class
is rb_cObject.
* eval.c (ev_const_get): ditto.
* time.c (time_zone): return "UTC" for UTC time objects.
* eval.c (THREAD_ALLOC): flags should be initialized.
* signal.c (rb_f_kill): should use FIX2INT, not FIX2UINT.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1267 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 60 |
1 files changed, 32 insertions, 28 deletions
@@ -62,7 +62,7 @@ char *strchr _((char*,char)); #include <ctype.h> #ifndef HAVE_LSTAT -#define lstat stat +#define lstat rb_sys_stat #endif #define FNM_NOESCAPE 0x01 @@ -610,8 +610,6 @@ remove_backslashes(p) # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) #endif -#define GLOB_RECURSIVE 0x10 - static void glob_helper(path, flag, func, arg) char *path; @@ -624,10 +622,10 @@ glob_helper(path, flag, func, arg) if (!has_magic(path, 0)) { remove_backslashes(path); - if (stat(path, &st) == 0) { + if (rb_sys_stat(path, &st) == 0) { (*func)(path, arg); } - else if (!(flag & GLOB_RECURSIVE)) { + else if (errno != ENOENT) { /* In case stat error is other than ENOENT and we may want to know what is wrong. */ rb_sys_warning(path); @@ -655,8 +653,8 @@ glob_helper(path, flag, func, arg) else dir = base; magic = extract_elem(p); - if (stat(dir, &st) < 0) { - rb_sys_warning(dir); + if (rb_sys_stat(dir, &st) < 0) { + if (errno != ENOENT) rb_sys_warning(dir); free(base); break; } @@ -665,7 +663,7 @@ glob_helper(path, flag, func, arg) recursive = 1; buf = ALLOC_N(char, strlen(base)+strlen(m)+3); sprintf(buf, "%s%s", base, *base ? m : m+1); - glob_helper(buf, flag|GLOB_RECURSIVE, func, arg); + glob_helper(buf, flag, func, arg); free(buf); } dirp = opendir(dir); @@ -693,13 +691,13 @@ glob_helper(path, flag, func, arg) buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6); sprintf(buf, "%s%s%s", base, (BASE)?"/":"", dp->d_name); if (lstat(buf, &st) < 0) { - rb_sys_warning(buf); + if (errno != ENOENT) rb_sys_warning(buf); continue; } if (S_ISDIR(st.st_mode)) { strcat(buf, "/**"); strcat(buf, m); - glob_helper(buf, flag|GLOB_RECURSIVE, func, arg); + glob_helper(buf, flag, func, arg); } free(buf); continue; @@ -721,25 +719,28 @@ glob_helper(path, flag, func, arg) closedir(dirp); free(base); free(magic); - while (link) { - if (stat(link->path, &st) == 0) { - if (S_ISDIR(st.st_mode)) { - int len = strlen(link->path); - int mlen = strlen(m); - char *t = ALLOC_N(char, len+mlen+1); - - sprintf(t, "%s%s", link->path, m); - glob_helper(t, flag|GLOB_RECURSIVE, func, arg); - free(t); + if (link) { + while (link) { + if (rb_sys_stat(link->path, &st) == 0) { + if (S_ISDIR(st.st_mode)) { + int len = strlen(link->path); + int mlen = strlen(m); + char *t = ALLOC_N(char, len+mlen+1); + + sprintf(t, "%s%s", link->path, m); + glob_helper(t, flag, func, arg); + free(t); + } + tmp = link; + link = link->next; + free(tmp->path); + free(tmp); + } + else { + rb_sys_warning(link->path); } - tmp = link; - link = link->next; - free(tmp->path); - free(tmp); - } - else { - rb_sys_warning(link->path); } + break; } } p = m; @@ -756,7 +757,7 @@ rb_glob(path, func, arg) } void -rb_iglob(path, func, arg) +rb_globi(path, func, arg) char *path; void (*func)(); VALUE arg; @@ -886,6 +887,9 @@ dir_s_glob(dir, str) } if (buf != buffer) free(buf); + if (ary && RARRAY(ary)->len == 0) { + rb_warning("no matches found: %s", RSTRING(str)->ptr); + } return ary; } |