Permalink
Browse files

* dir.c (glob_helper): replace lstat() by stat() to follow symlink

  in the case like 'symlink/*'.

* dir.c (glob_helper): gave warning too much.


git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@1261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent d97ac44 commit 5ab2b8a553950333ff98642a4e4c8d8d3d87f4b8 matz committed Mar 19, 2001
Showing with 106 additions and 63 deletions.
  1. +32 −0 .cvsignore
  2. +12 −0 ChangeLog
  3. +1 −0 ToDo
  4. +22 −21 dir.c
  5. +11 −10 eval.c
  6. +5 −5 file.c
  7. +12 −12 gc.c
  8. +2 −2 intern.h
  9. +0 −4 ruby.h
  10. +5 −5 variable.c
  11. +2 −2 version.h
  12. +2 −2 win32/win32.h
View
@@ -3,17 +3,49 @@
*.rej
*.sav
*~
+.ccmalloc
+.ppack
+COPYING.LIB
+ChangeLog.pre-alpha
+ChangeLog.pre1_1
Makefile
README.fat-patch
+README.v6
+a.rb
archive
+automake
+beos
config.cache
config.h
+config.h.in
config.log
config.status
configure
+foo.rb
miniruby
+miniruby.elhash
+miniruby.elhash2
+miniruby.orig2
+miniruby.plhash
+miniruby.plhash2
+modex.rb
+newdate.rb
newver.rb
parse.c
+parse.y.try
+pitest.rb
ppack
rbconfig.rb
+rename2.h
+repack
+riscos
+rubicon
ruby
+ruby-man.rd.gz
+rubyunit
+st.c.power
+this that
+tmp
+web
+y.output
+y.tab.c
View
@@ -1,3 +1,10 @@
+Mon Mar 19 10:55:10 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (glob_helper): replace lstat() by stat() to follow symlink
+ in the case like 'symlink/*'.
+
+ * dir.c (glob_helper): gave warning too much.
+
Sun Mar 18 08:58:18 2001 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/net/cgi.rb: // === '' --> //.match('')
@@ -13,6 +20,11 @@ Sun Mar 18 08:58:18 2001 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/net/cgi.rb: cgi#header(): bug fix.
thanks to IWATSUKI Hiroyuki <don@na.rim.or.jp>.
+Sat Mar 17 11:11:24 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * dir.c (glob_helper): * should follow symlink, whereas ** should
+ not follow.
+
Thu Mar 15 01:28:02 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* dir.c (dir_s_chdir): block form of Dir.chdir. (RCR#U016).
View
@@ -25,6 +25,7 @@ Language Spec.
* unify == and eql? again
* to_i returns nil if str contains no digit.
* raise exception by `` error
+* jar like combined library package.
Hacking Interpreter
View
@@ -45,7 +45,7 @@
# include <ndir.h>
# endif
# if defined(NT) && defined(_MSC_VER)
-# include "missing/dir.h"
+# include "win32/dir.h"
# endif
#endif
@@ -62,7 +62,7 @@ char *strchr _((char*,char));
#include <ctype.h>
#ifndef HAVE_LSTAT
-#define lstat rb_sys_stat
+#define lstat stat
#endif
#define FNM_NOESCAPE 0x01
@@ -610,9 +610,10 @@ remove_backslashes(p)
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
#endif
+#define GLOB_RECURSIVE 0x10
-void
-rb_glob_helper(path, flag, func, arg)
+static void
+glob_helper(path, flag, func, arg)
char *path;
int flag;
void (*func)();
@@ -623,10 +624,10 @@ rb_glob_helper(path, flag, func, arg)
if (!has_magic(path, 0)) {
remove_backslashes(path);
- if (rb_sys_stat(path, &st) == 0) {
+ if (stat(path, &st) == 0) {
(*func)(path, arg);
}
- else {
+ else if (!(flag & GLOB_RECURSIVE)) {
/* In case stat error is other than ENOENT and
we may want to know what is wrong. */
rb_sys_warning(path);
@@ -654,7 +655,7 @@ rb_glob_helper(path, flag, func, arg)
else dir = base;
magic = extract_elem(p);
- if (lstat(dir, &st) < 0) {
+ if (stat(dir, &st) < 0) {
rb_sys_warning(dir);
free(base);
break;
@@ -664,15 +665,15 @@ rb_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);
- rb_glob_helper(buf, flag, func, arg);
+ glob_helper(buf, flag|GLOB_RECURSIVE, func, arg);
free(buf);
}
- dirp = opendir(dir);
- if (dirp == NULL) {
- rb_sys_warning(dir);
- free(base);
- break;
- }
+ dirp = opendir(dir);
+ if (dirp == NULL) {
+ rb_sys_warning(dir);
+ free(base);
+ break;
+ }
}
else {
free(base);
@@ -690,15 +691,15 @@ rb_glob_helper(path, flag, func, arg)
if (strcmp(".", dp->d_name) == 0 || strcmp("..", dp->d_name) == 0)
continue;
buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6);
- sprintf(buf, "%s%s%s/", base, (BASE)?"/":"", dp->d_name);
+ sprintf(buf, "%s%s%s", base, (BASE)?"/":"", dp->d_name);
if (lstat(buf, &st) < 0) {
rb_sys_warning(buf);
continue;
}
if (S_ISDIR(st.st_mode)) {
- strcat(buf, "**");
+ strcat(buf, "/**");
strcat(buf, m);
- rb_glob_helper(buf, flag, func, arg);
+ glob_helper(buf, flag|GLOB_RECURSIVE, func, arg);
}
free(buf);
continue;
@@ -721,14 +722,14 @@ rb_glob_helper(path, flag, func, arg)
free(base);
free(magic);
while (link) {
- if (lstat(link->path, &st) == 0) {
+ 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);
- rb_glob_helper(t, flag, func, arg);
+ glob_helper(t, flag|GLOB_RECURSIVE, func, arg);
free(t);
}
tmp = link;
@@ -751,7 +752,7 @@ rb_glob(path, func, arg)
void (*func)();
VALUE arg;
{
- rb_glob_helper(path, FNM_PERIOD|FNM_PATHNAME, func, arg);
+ glob_helper(path, FNM_PERIOD|FNM_PATHNAME, func, arg);
}
void
@@ -760,7 +761,7 @@ rb_iglob(path, func, arg)
void (*func)();
VALUE arg;
{
- rb_glob_helper(path, FNM_PERIOD|FNM_PATHNAME|FNM_NOCASE, func, arg);
+ glob_helper(path, FNM_PERIOD|FNM_PATHNAME|FNM_NOCASE, func, arg);
}
static void
View
@@ -5956,13 +5956,13 @@ blk_mark(data)
{
while (data) {
rb_gc_mark_frame(&data->frame);
- rb_gc_mark(data->scope);
- rb_gc_mark(data->var);
- rb_gc_mark(data->body);
- rb_gc_mark(data->self);
- rb_gc_mark(data->dyna_vars);
- rb_gc_mark(data->klass);
- rb_gc_mark(data->tag);
+ rb_gc_mark((VALUE)data->scope);
+ rb_gc_mark((VALUE)data->var);
+ rb_gc_mark((VALUE)data->body);
+ rb_gc_mark((VALUE)data->self);
+ rb_gc_mark((VALUE)data->dyna_vars);
+ rb_gc_mark((VALUE)data->klass);
+ rb_gc_mark((VALUE)data->tag);
data = data->prev;
}
}
@@ -6456,7 +6456,7 @@ bm_mark(data)
rb_gc_mark(data->oklass);
rb_gc_mark(data->klass);
rb_gc_mark(data->recv);
- rb_gc_mark(data->body);
+ rb_gc_mark((VALUE)data->body);
}
static VALUE
@@ -6916,8 +6916,8 @@ thread_mark(th)
rb_gc_mark(th->klass);
rb_gc_mark(th->wrapper);
- rb_gc_mark(th->scope);
- rb_gc_mark(th->dyna_vars);
+ rb_gc_mark((VALUE)th->scope);
+ rb_gc_mark((VALUE)th->dyna_vars);
rb_gc_mark(th->errinfo);
rb_gc_mark(th->last_line);
rb_gc_mark(th->last_match);
@@ -7910,6 +7910,7 @@ rb_thread_abort_exc_set(thread, val)
\
th->status = THREAD_RUNNABLE;\
th->result = 0;\
+ th->flags = 0;\
\
th->stk_ptr = 0;\
th->stk_len = 0;\
View
@@ -67,7 +67,7 @@ char *strrchr _((const char*,const char));
#include <sys/stat.h>
#ifndef HAVE_LSTAT
-#define lstat rb_sys_stat
+#define lstat stat
#endif
VALUE rb_cFile;
@@ -313,7 +313,7 @@ rb_stat(file, st)
#if defined DJGPP
if (RSTRING(file)->len == 0) return -1;
#endif
- return rb_sys_stat(RSTRING(file)->ptr, st);
+ return stat(RSTRING(file)->ptr, st);
}
static VALUE
@@ -323,7 +323,7 @@ rb_file_s_stat(obj, fname)
struct stat st;
Check_SafeStr(fname);
- if (rb_sys_stat(RSTRING(fname)->ptr, &st) == -1) {
+ if (stat(RSTRING(fname)->ptr, &st) == -1) {
rb_sys_fail(RSTRING(fname)->ptr);
}
return stat_new(&st);
@@ -419,7 +419,7 @@ eaccess(path, mode)
struct stat st;
static int euid = -1;
- if (rb_sys_stat(path, &st) < 0) return (-1);
+ if (stat(path, &st) < 0) return (-1);
if (euid == -1)
euid = geteuid ();
@@ -721,7 +721,7 @@ check3rdbyte(file, mode)
{
struct stat st;
- if (rb_sys_stat(file, &st) < 0) return Qfalse;
+ if (stat(file, &st) < 0) return Qfalse;
if (st.st_mode & mode) return Qtrue;
return Qfalse;
}
View
@@ -420,7 +420,7 @@ rb_mark_hash(tbl)
void
rb_gc_mark_maybe(obj)
- void *obj;
+ VALUE obj;
{
if (is_pointer_to_heap(obj)) {
rb_gc_mark(obj);
@@ -429,7 +429,7 @@ rb_gc_mark_maybe(obj)
void
rb_gc_mark(ptr)
- void *ptr;
+ VALUE ptr;
{
register RVALUE *obj = RANY(ptr);
@@ -460,7 +460,7 @@ rb_gc_mark(ptr)
case NODE_MASGN:
case NODE_RESCUE:
case NODE_RESBODY:
- rb_gc_mark(obj->as.node.u2.node);
+ rb_gc_mark((VALUE)obj->as.node.u2.node);
/* fall through */
case NODE_BLOCK: /* 1,3 */
case NODE_ARRAY:
@@ -474,7 +474,7 @@ rb_gc_mark(ptr)
case NODE_CALL:
case NODE_DEFS:
case NODE_OP_ASGN1:
- rb_gc_mark(obj->as.node.u1.node);
+ rb_gc_mark((VALUE)obj->as.node.u1.node);
/* fall through */
case NODE_SUPER: /* 3 */
case NODE_FCALL:
@@ -497,7 +497,7 @@ rb_gc_mark(ptr)
case NODE_MATCH3:
case NODE_OP_ASGN_OR:
case NODE_OP_ASGN_AND:
- rb_gc_mark(obj->as.node.u1.node);
+ rb_gc_mark((VALUE)obj->as.node.u1.node);
/* fall through */
case NODE_METHOD: /* 2 */
case NODE_NOT:
@@ -531,7 +531,7 @@ rb_gc_mark(ptr)
case NODE_SCOPE: /* 2,3 */
case NODE_CLASS:
case NODE_BLOCK_PASS:
- rb_gc_mark(obj->as.node.u3.node);
+ rb_gc_mark((VALUE)obj->as.node.u3.node);
obj = RANY(obj->as.node.u2.node);
goto Top;
@@ -572,10 +572,10 @@ rb_gc_mark(ptr)
default:
if (is_pointer_to_heap(obj->as.node.u1.node)) {
- rb_gc_mark(obj->as.node.u1.node);
+ rb_gc_mark((VALUE)obj->as.node.u1.node);
}
if (is_pointer_to_heap(obj->as.node.u2.node)) {
- rb_gc_mark(obj->as.node.u2.node);
+ rb_gc_mark((VALUE)obj->as.node.u2.node);
}
if (is_pointer_to_heap(obj->as.node.u3.node)) {
obj = RANY(obj->as.node.u3.node);
@@ -689,7 +689,7 @@ gc_sweep()
p = heaps[i]; pend = p + HEAP_SLOTS;
while (p < pend) {
if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE)
- rb_gc_mark(p);
+ rb_gc_mark((VALUE)p);
p++;
}
}
@@ -981,9 +981,9 @@ rb_gc()
}
}
}
- rb_gc_mark(ruby_class);
- rb_gc_mark(ruby_scope);
- rb_gc_mark(ruby_dyna_vars);
+ rb_gc_mark((VALUE)ruby_class);
+ rb_gc_mark((VALUE)ruby_scope);
+ rb_gc_mark((VALUE)ruby_dyna_vars);
if (finalizer_table) {
rb_mark_tbl(finalizer_table);
}
Oops, something went wrong.

0 comments on commit 5ab2b8a

Please sign in to comment.