* 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: svn+ssh://ci.ruby-lang.org/ruby/trunk@1261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-03-19 03:20:24 +00:00
parent aa6fa0c75d
commit 1f904eed44
12 changed files with 106 additions and 63 deletions

View File

@ -3,17 +3,49 @@
*.rej *.rej
*.sav *.sav
*~ *~
.ccmalloc
.ppack
COPYING.LIB
ChangeLog.pre-alpha
ChangeLog.pre1_1
Makefile Makefile
README.fat-patch README.fat-patch
README.v6
a.rb
archive archive
automake
beos
config.cache config.cache
config.h config.h
config.h.in
config.log config.log
config.status config.status
configure configure
foo.rb
miniruby miniruby
miniruby.elhash
miniruby.elhash2
miniruby.orig2
miniruby.plhash
miniruby.plhash2
modex.rb
newdate.rb
newver.rb newver.rb
parse.c parse.c
parse.y.try
pitest.rb
ppack ppack
rbconfig.rb rbconfig.rb
rename2.h
repack
riscos
rubicon
ruby ruby
ruby-man.rd.gz
rubyunit
st.c.power
this that
tmp
web
y.output
y.tab.c

View File

@ -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> Sun Mar 18 08:58:18 2001 Wakou Aoyama <wakou@fsinet.or.jp>
* lib/net/cgi.rb: // === '' --> //.match('') * 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. * lib/net/cgi.rb: cgi#header(): bug fix.
thanks to IWATSUKI Hiroyuki <don@na.rim.or.jp>. 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> 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). * dir.c (dir_s_chdir): block form of Dir.chdir. (RCR#U016).

1
ToDo
View File

@ -25,6 +25,7 @@ Language Spec.
* unify == and eql? again * unify == and eql? again
* to_i returns nil if str contains no digit. * to_i returns nil if str contains no digit.
* raise exception by `` error * raise exception by `` error
* jar like combined library package.
Hacking Interpreter Hacking Interpreter

31
dir.c
View File

@ -45,7 +45,7 @@
# include <ndir.h> # include <ndir.h>
# endif # endif
# if defined(NT) && defined(_MSC_VER) # if defined(NT) && defined(_MSC_VER)
# include "missing/dir.h" # include "win32/dir.h"
# endif # endif
#endif #endif
@ -62,7 +62,7 @@ char *strchr _((char*,char));
#include <ctype.h> #include <ctype.h>
#ifndef HAVE_LSTAT #ifndef HAVE_LSTAT
#define lstat rb_sys_stat #define lstat stat
#endif #endif
#define FNM_NOESCAPE 0x01 #define FNM_NOESCAPE 0x01
@ -610,9 +610,10 @@ remove_backslashes(p)
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) # define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
#endif #endif
#define GLOB_RECURSIVE 0x10
void static void
rb_glob_helper(path, flag, func, arg) glob_helper(path, flag, func, arg)
char *path; char *path;
int flag; int flag;
void (*func)(); void (*func)();
@ -623,10 +624,10 @@ rb_glob_helper(path, flag, func, arg)
if (!has_magic(path, 0)) { if (!has_magic(path, 0)) {
remove_backslashes(path); remove_backslashes(path);
if (rb_sys_stat(path, &st) == 0) { if (stat(path, &st) == 0) {
(*func)(path, arg); (*func)(path, arg);
} }
else { else if (!(flag & GLOB_RECURSIVE)) {
/* In case stat error is other than ENOENT and /* In case stat error is other than ENOENT and
we may want to know what is wrong. */ we may want to know what is wrong. */
rb_sys_warning(path); rb_sys_warning(path);
@ -654,7 +655,7 @@ rb_glob_helper(path, flag, func, arg)
else dir = base; else dir = base;
magic = extract_elem(p); magic = extract_elem(p);
if (lstat(dir, &st) < 0) { if (stat(dir, &st) < 0) {
rb_sys_warning(dir); rb_sys_warning(dir);
free(base); free(base);
break; break;
@ -664,7 +665,7 @@ rb_glob_helper(path, flag, func, arg)
recursive = 1; recursive = 1;
buf = ALLOC_N(char, strlen(base)+strlen(m)+3); buf = ALLOC_N(char, strlen(base)+strlen(m)+3);
sprintf(buf, "%s%s", base, *base ? m : m+1); 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); free(buf);
} }
dirp = opendir(dir); dirp = opendir(dir);
@ -690,15 +691,15 @@ rb_glob_helper(path, flag, func, arg)
if (strcmp(".", dp->d_name) == 0 || strcmp("..", dp->d_name) == 0) if (strcmp(".", dp->d_name) == 0 || strcmp("..", dp->d_name) == 0)
continue; continue;
buf = ALLOC_N(char, strlen(base)+NAMLEN(dp)+strlen(m)+6); 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) { if (lstat(buf, &st) < 0) {
rb_sys_warning(buf); rb_sys_warning(buf);
continue; continue;
} }
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
strcat(buf, "**"); strcat(buf, "/**");
strcat(buf, m); strcat(buf, m);
rb_glob_helper(buf, flag, func, arg); glob_helper(buf, flag|GLOB_RECURSIVE, func, arg);
} }
free(buf); free(buf);
continue; continue;
@ -721,14 +722,14 @@ rb_glob_helper(path, flag, func, arg)
free(base); free(base);
free(magic); free(magic);
while (link) { while (link) {
if (lstat(link->path, &st) == 0) { if (stat(link->path, &st) == 0) {
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
int len = strlen(link->path); int len = strlen(link->path);
int mlen = strlen(m); int mlen = strlen(m);
char *t = ALLOC_N(char, len+mlen+1); char *t = ALLOC_N(char, len+mlen+1);
sprintf(t, "%s%s", link->path, m); sprintf(t, "%s%s", link->path, m);
rb_glob_helper(t, flag, func, arg); glob_helper(t, flag|GLOB_RECURSIVE, func, arg);
free(t); free(t);
} }
tmp = link; tmp = link;
@ -751,7 +752,7 @@ rb_glob(path, func, arg)
void (*func)(); void (*func)();
VALUE arg; VALUE arg;
{ {
rb_glob_helper(path, FNM_PERIOD|FNM_PATHNAME, func, arg); glob_helper(path, FNM_PERIOD|FNM_PATHNAME, func, arg);
} }
void void
@ -760,7 +761,7 @@ rb_iglob(path, func, arg)
void (*func)(); void (*func)();
VALUE arg; 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 static void

21
eval.c
View File

@ -5956,13 +5956,13 @@ blk_mark(data)
{ {
while (data) { while (data) {
rb_gc_mark_frame(&data->frame); rb_gc_mark_frame(&data->frame);
rb_gc_mark(data->scope); rb_gc_mark((VALUE)data->scope);
rb_gc_mark(data->var); rb_gc_mark((VALUE)data->var);
rb_gc_mark(data->body); rb_gc_mark((VALUE)data->body);
rb_gc_mark(data->self); rb_gc_mark((VALUE)data->self);
rb_gc_mark(data->dyna_vars); rb_gc_mark((VALUE)data->dyna_vars);
rb_gc_mark(data->klass); rb_gc_mark((VALUE)data->klass);
rb_gc_mark(data->tag); rb_gc_mark((VALUE)data->tag);
data = data->prev; data = data->prev;
} }
} }
@ -6456,7 +6456,7 @@ bm_mark(data)
rb_gc_mark(data->oklass); rb_gc_mark(data->oklass);
rb_gc_mark(data->klass); rb_gc_mark(data->klass);
rb_gc_mark(data->recv); rb_gc_mark(data->recv);
rb_gc_mark(data->body); rb_gc_mark((VALUE)data->body);
} }
static VALUE static VALUE
@ -6916,8 +6916,8 @@ thread_mark(th)
rb_gc_mark(th->klass); rb_gc_mark(th->klass);
rb_gc_mark(th->wrapper); rb_gc_mark(th->wrapper);
rb_gc_mark(th->scope); rb_gc_mark((VALUE)th->scope);
rb_gc_mark(th->dyna_vars); rb_gc_mark((VALUE)th->dyna_vars);
rb_gc_mark(th->errinfo); rb_gc_mark(th->errinfo);
rb_gc_mark(th->last_line); rb_gc_mark(th->last_line);
rb_gc_mark(th->last_match); rb_gc_mark(th->last_match);
@ -7910,6 +7910,7 @@ rb_thread_abort_exc_set(thread, val)
\ \
th->status = THREAD_RUNNABLE;\ th->status = THREAD_RUNNABLE;\
th->result = 0;\ th->result = 0;\
th->flags = 0;\
\ \
th->stk_ptr = 0;\ th->stk_ptr = 0;\
th->stk_len = 0;\ th->stk_len = 0;\

10
file.c
View File

@ -67,7 +67,7 @@ char *strrchr _((const char*,const char));
#include <sys/stat.h> #include <sys/stat.h>
#ifndef HAVE_LSTAT #ifndef HAVE_LSTAT
#define lstat rb_sys_stat #define lstat stat
#endif #endif
VALUE rb_cFile; VALUE rb_cFile;
@ -313,7 +313,7 @@ rb_stat(file, st)
#if defined DJGPP #if defined DJGPP
if (RSTRING(file)->len == 0) return -1; if (RSTRING(file)->len == 0) return -1;
#endif #endif
return rb_sys_stat(RSTRING(file)->ptr, st); return stat(RSTRING(file)->ptr, st);
} }
static VALUE static VALUE
@ -323,7 +323,7 @@ rb_file_s_stat(obj, fname)
struct stat st; struct stat st;
Check_SafeStr(fname); 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); rb_sys_fail(RSTRING(fname)->ptr);
} }
return stat_new(&st); return stat_new(&st);
@ -419,7 +419,7 @@ eaccess(path, mode)
struct stat st; struct stat st;
static int euid = -1; static int euid = -1;
if (rb_sys_stat(path, &st) < 0) return (-1); if (stat(path, &st) < 0) return (-1);
if (euid == -1) if (euid == -1)
euid = geteuid (); euid = geteuid ();
@ -721,7 +721,7 @@ check3rdbyte(file, mode)
{ {
struct stat st; 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; if (st.st_mode & mode) return Qtrue;
return Qfalse; return Qfalse;
} }

24
gc.c
View File

@ -420,7 +420,7 @@ rb_mark_hash(tbl)
void void
rb_gc_mark_maybe(obj) rb_gc_mark_maybe(obj)
void *obj; VALUE obj;
{ {
if (is_pointer_to_heap(obj)) { if (is_pointer_to_heap(obj)) {
rb_gc_mark(obj); rb_gc_mark(obj);
@ -429,7 +429,7 @@ rb_gc_mark_maybe(obj)
void void
rb_gc_mark(ptr) rb_gc_mark(ptr)
void *ptr; VALUE ptr;
{ {
register RVALUE *obj = RANY(ptr); register RVALUE *obj = RANY(ptr);
@ -460,7 +460,7 @@ rb_gc_mark(ptr)
case NODE_MASGN: case NODE_MASGN:
case NODE_RESCUE: case NODE_RESCUE:
case NODE_RESBODY: case NODE_RESBODY:
rb_gc_mark(obj->as.node.u2.node); rb_gc_mark((VALUE)obj->as.node.u2.node);
/* fall through */ /* fall through */
case NODE_BLOCK: /* 1,3 */ case NODE_BLOCK: /* 1,3 */
case NODE_ARRAY: case NODE_ARRAY:
@ -474,7 +474,7 @@ rb_gc_mark(ptr)
case NODE_CALL: case NODE_CALL:
case NODE_DEFS: case NODE_DEFS:
case NODE_OP_ASGN1: case NODE_OP_ASGN1:
rb_gc_mark(obj->as.node.u1.node); rb_gc_mark((VALUE)obj->as.node.u1.node);
/* fall through */ /* fall through */
case NODE_SUPER: /* 3 */ case NODE_SUPER: /* 3 */
case NODE_FCALL: case NODE_FCALL:
@ -497,7 +497,7 @@ rb_gc_mark(ptr)
case NODE_MATCH3: case NODE_MATCH3:
case NODE_OP_ASGN_OR: case NODE_OP_ASGN_OR:
case NODE_OP_ASGN_AND: case NODE_OP_ASGN_AND:
rb_gc_mark(obj->as.node.u1.node); rb_gc_mark((VALUE)obj->as.node.u1.node);
/* fall through */ /* fall through */
case NODE_METHOD: /* 2 */ case NODE_METHOD: /* 2 */
case NODE_NOT: case NODE_NOT:
@ -531,7 +531,7 @@ rb_gc_mark(ptr)
case NODE_SCOPE: /* 2,3 */ case NODE_SCOPE: /* 2,3 */
case NODE_CLASS: case NODE_CLASS:
case NODE_BLOCK_PASS: 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); obj = RANY(obj->as.node.u2.node);
goto Top; goto Top;
@ -572,10 +572,10 @@ rb_gc_mark(ptr)
default: default:
if (is_pointer_to_heap(obj->as.node.u1.node)) { 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)) { 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)) { if (is_pointer_to_heap(obj->as.node.u3.node)) {
obj = RANY(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; p = heaps[i]; pend = p + HEAP_SLOTS;
while (p < pend) { while (p < pend) {
if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE) if (!(p->as.basic.flags&FL_MARK) && BUILTIN_TYPE(p) == T_NODE)
rb_gc_mark(p); rb_gc_mark((VALUE)p);
p++; p++;
} }
} }
@ -981,9 +981,9 @@ rb_gc()
} }
} }
} }
rb_gc_mark(ruby_class); rb_gc_mark((VALUE)ruby_class);
rb_gc_mark(ruby_scope); rb_gc_mark((VALUE)ruby_scope);
rb_gc_mark(ruby_dyna_vars); rb_gc_mark((VALUE)ruby_dyna_vars);
if (finalizer_table) { if (finalizer_table) {
rb_mark_tbl(finalizer_table); rb_mark_tbl(finalizer_table);
} }

View File

@ -182,8 +182,8 @@ char *rb_find_file _((char*));
void rb_gc_mark_locations _((VALUE*, VALUE*)); void rb_gc_mark_locations _((VALUE*, VALUE*));
void rb_mark_tbl _((struct st_table*)); void rb_mark_tbl _((struct st_table*));
void rb_mark_hash _((struct st_table*)); void rb_mark_hash _((struct st_table*));
void rb_gc_mark_maybe _((void*)); void rb_gc_mark_maybe _((VALUE));
void rb_gc_mark _((void*)); void rb_gc_mark _((VALUE));
void rb_gc_force_recycle _((VALUE)); void rb_gc_force_recycle _((VALUE));
void rb_gc _((void)); void rb_gc _((void));
void rb_gc_call_finalizer_at_exit _((void)); void rb_gc_call_finalizer_at_exit _((void));

4
ruby.h
View File

@ -592,10 +592,6 @@ rb_special_const_p(VALUE obj)
static char *dln_libs_to_be_linked[] = { EXTLIB, 0 }; static char *dln_libs_to_be_linked[] = { EXTLIB, 0 };
#endif #endif
#ifndef rb_sys_stat
#define rb_sys_stat stat
#endif
#if defined(__cplusplus) #if defined(__cplusplus)
} /* extern "C" { */ } /* extern "C" { */
#endif #endif

View File

@ -266,7 +266,7 @@ rb_class2name(klass)
struct trace_var { struct trace_var {
int removed; int removed;
void (*func)(); void (*func)();
void *data; VALUE data;
struct trace_var *next; struct trace_var *next;
}; };
@ -362,7 +362,7 @@ val_setter(val, id, data, entry)
static void static void
val_marker(data) val_marker(data)
void *data; VALUE data;
{ {
if (data) rb_gc_mark_maybe(data); if (data) rb_gc_mark_maybe(data);
} }
@ -387,7 +387,7 @@ var_setter(val, id, var)
static void static void
var_marker(var) var_marker(var)
VALUE **var; VALUE *var;
{ {
if (var) rb_gc_mark_maybe(*var); if (var) rb_gc_mark_maybe(*var);
} }
@ -514,7 +514,7 @@ rb_f_trace_var(argc, argv)
trace = ALLOC(struct trace_var); trace = ALLOC(struct trace_var);
trace->next = entry->trace; trace->next = entry->trace;
trace->func = rb_trace_eval; trace->func = rb_trace_eval;
trace->data = (void*)cmd; trace->data = cmd;
trace->removed = 0; trace->removed = 0;
entry->trace = trace; entry->trace = trace;
@ -576,7 +576,7 @@ rb_f_untrace_var(argc, argv)
} }
else { else {
while (trace) { while (trace) {
if (trace->data == (void*)cmd) { if (trace->data == cmd) {
trace->removed = 1; trace->removed = 1;
if (!entry->block_trace) remove_trace(entry); if (!entry->block_trace) remove_trace(entry);
return rb_ary_new3(1, cmd); return rb_ary_new3(1, cmd);

View File

@ -1,4 +1,4 @@
#define RUBY_VERSION "1.7.0" #define RUBY_VERSION "1.7.0"
#define RUBY_RELEASE_DATE "2001-03-16" #define RUBY_RELEASE_DATE "2001-03-19"
#define RUBY_VERSION_CODE 170 #define RUBY_VERSION_CODE 170
#define RUBY_RELEASE_CODE 20010316 #define RUBY_RELEASE_CODE 20010319

View File

@ -179,8 +179,8 @@ extern "C++" {
#define pclose _pclose #define pclose _pclose
#define strcasecmp _stricmp #define strcasecmp _stricmp
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
#undef rb_sys_stat #undef stat
#define rb_sys_stat win32_stat #define stat win32_stat
/* these are defined in nt.c */ /* these are defined in nt.c */
#ifdef __MINGW32__ #ifdef __MINGW32__