diff --git a/ChangeLog b/ChangeLog index 539ce186ce..941e132a42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +Thu Sep 21 17:23:05 2000 Yukihiro Matsumoto + + * file.c (rb_file_s_symlink): use HAVE_SYMLINK. + + * file.c (rb_file_s_readlink): use HAVE_READLINK. + + * dir.c (dir_tell): use HAVE_TELLDIR. + + * dir.c (dir_seek): use HAVE_SEEKDIR. + + * configure.in (AC_CHECK_FUNCS): lstat, symlink, readlink, + telldir, seekdir checks added. + + * file.c (lstat): should use stat(2) if lstat(2) is not + available. + Thu Sep 21 15:59:23 2000 Minero Aoki * lib/net/protocol.rb, smtp.rb, pop.rb, http.rb: 1.1.28. @@ -6,6 +22,11 @@ Thu Sep 21 15:59:23 2000 Minero Aoki * lib/net/http.rb (connecting): response is got in receive() +Thu Sep 21 15:49:07 2000 Wayne Scott + + * lib/find.rb (find): should not follow symbolic links; + tuned performance too. + Wed Sep 20 23:21:38 2000 Yukihiro Matsumoto * ruby.c (load_file): two Ctrl-D was required to stop ruby at the diff --git a/configure.in b/configure.in index f0ed110889..0e3d27b0da 100644 --- a/configure.in +++ b/configure.in @@ -230,10 +230,10 @@ AC_REPLACE_FUNCS(dup2 memmove mkdir strcasecmp strncasecmp strerror strftime\ strchr strstr strtoul crypt flock vsnprintf\ isinf isnan finite) AC_CHECK_FUNCS(fmod killpg drand48 random wait4 waitpid syscall getcwd chroot\ - truncate chsize times utimes fcntl lockf setitimer pause\ - setruid seteuid setreuid setrgid setegid setregid\ - getpgrp setpgrp getpgid setpgid getgroups getpriority\ - dlopen sigprocmask sigaction _setjmp setsid getrlimit) + truncate chsize times utimes fcntl lockf lstat symlink readlink\ + setitimer setruid seteuid setreuid setrgid setegid setregid pause\ + getpgrp setpgrp getpgid setpgid getgroups getpriority getrlimit\ + dlopen sigprocmask sigaction _setjmp setsid telldir seekdir) AC_STRUCT_TIMEZONE AC_CACHE_CHECK(for external int daylight, rb_cv_have_daylight, [AC_TRY_LINK([#include diff --git a/dir.c b/dir.c index d5267a86e8..efb28e6848 100644 --- a/dir.c +++ b/dir.c @@ -334,7 +334,7 @@ static VALUE dir_tell(dir) VALUE dir; { -#if !defined(__CYGWIN32__) && !defined(__BEOS__) +#ifdef HAVE_TELLDIR DIR *dirp; long pos; @@ -352,7 +352,7 @@ dir_seek(dir, pos) { DIR *dirp; -#if !defined(__CYGWIN32__) && !defined(__BEOS__) +#ifdef HAVE_SEEKDIR GetDIR(dir, dirp); seekdir(dirp, NUM2INT(pos)); return dir; diff --git a/file.c b/file.c index 00f4f2c15b..adf1ec51ab 100644 --- a/file.c +++ b/file.c @@ -66,7 +66,7 @@ char *strrchr _((const char*,const char)); #include #include -#ifdef __EMX__ +#ifndef HAVE_LSTAT #define lstat stat #endif @@ -348,7 +348,7 @@ static VALUE rb_file_s_lstat(obj, fname) VALUE obj, fname; { -#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__) +#ifdef HAVE_LSTAT struct stat st; Check_SafeStr(fname); @@ -357,8 +357,7 @@ rb_file_s_lstat(obj, fname) } return stat_new(&st); #else - rb_notimplement(); - return Qnil; /* not reached */ + return rb_file_s_stat(obj, fname); #endif } @@ -366,7 +365,7 @@ static VALUE rb_file_lstat(obj) VALUE obj; { -#if !defined(MSDOS) && !defined(NT) +#ifdef HAVE_LSTAT OpenFile *fptr; struct stat st; @@ -378,8 +377,7 @@ rb_file_lstat(obj) } return stat_new(&st); #else - rb_notimplement(); - return Qnil; /* not reached */ + return rb_io_stat(obj); #endif } @@ -822,15 +820,10 @@ rb_file_s_ftype(obj, fname) { struct stat st; -#if defined(MSDOS) || defined(NT) - if (rb_stat(fname, &st) < 0) - rb_sys_fail(RSTRING(fname)->ptr); -#else Check_SafeStr(fname); if (lstat(RSTRING(fname)->ptr, &st) == -1) { rb_sys_fail(RSTRING(fname)->ptr); } -#endif return rb_file_ftype(&st); } @@ -1119,7 +1112,7 @@ static VALUE rb_file_s_symlink(obj, from, to) VALUE obj, from, to; { -#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__) && !defined(riscos) +#ifdef HAVE_SYMLINK Check_SafeStr(from); Check_SafeStr(to); @@ -1136,7 +1129,7 @@ static VALUE rb_file_s_readlink(obj, path) VALUE obj, path; { -#if !defined(MSDOS) && !defined(NT) && !defined(__EMX__) && !defined(riscos) +#ifdef READLINK char buf[MAXPATHLEN]; int cc; diff --git a/io.c b/io.c index e61314a1fb..59058d7294 100644 --- a/io.c +++ b/io.c @@ -2792,7 +2792,7 @@ rb_io_ctl(io, req, arg, io_p) #ifdef HAVE_FCNTL TRAP_BEG; # if defined(__CYGWIN__) - retval = io_p?ioctl(fd, cmd, (void*) narg):fcntl(fd, cmd, narg); + retval = io_p?ioctl(fd, cmd, (void*)narg):fcntl(fd, cmd, narg); # else retval = io_p?ioctl(fd, cmd, narg):fcntl(fd, cmd, narg); # endif diff --git a/lib/find.rb b/lib/find.rb index 9fb012902c..a8dcea4f71 100644 --- a/lib/find.rb +++ b/lib/find.rb @@ -12,17 +12,17 @@ module Find while file = path.shift catch(:prune) { yield file - if File.directory? file then + if File.lstat(file).directory? then d = Dir.open(file) begin for f in d - next if f =~ /\A\.\.?\z/ - if File::ALT_SEPARATOR and file =~ /^([\/\\]|[A-Za-z]:[\/\\]?)$/ then + next if f == "." or f == ".." + if File::ALT_SEPARATOR and file =~ /^(?:[\/\\]|[A-Za-z]:[\/\\]?)$/ then f = file + f elsif file == "/" then f = "/" + f else - f = file + "/" + f + f = File.join(file, f) end path.unshift f end