* 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
Родитель aa6fa0c75d
Коммит 1f904eed44
12 изменённых файлов: 106 добавлений и 63 удалений

Просмотреть файл

@ -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

Просмотреть файл

@ -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).

1
ToDo
Просмотреть файл

@ -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

43
dir.c
Просмотреть файл

@ -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

21
eval.c
Просмотреть файл

@ -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;\

10
file.c
Просмотреть файл

@ -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;
}

24
gc.c
Просмотреть файл

@ -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);
}

Просмотреть файл

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

4
ruby.h
Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -1,4 +1,4 @@
#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_RELEASE_CODE 20010316
#define RUBY_RELEASE_CODE 20010319

Просмотреть файл

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