From 8be410f0653bfb22970381447acf685af4795c00 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 13 Feb 2001 05:09:11 +0000 Subject: * io.c (rb_io_ctl): do not call ioctl/fcntl for f2, if f and f2 have same fileno. * eval.c (rb_load): raise LocaJumpError if unexpected local jumps appear during load. * ext/socket/socket.c (bsock_close_read): don't call rb_thread_fd_close(); it's supposed to be called by io_io_close(). * ext/socket/socket.c (bsock_close_read): do not modify f and f2. * ext/socket/socket.c (bsock_close_write): ditto. * ext/socket/socket.c (sock_new): avoid dup(2) on sockets. * parse.y (primary): preserve and clear in_single and in_def using stack to prevent nested method errors in singleton class bodies. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1177 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- dir.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'dir.c') diff --git a/dir.c b/dir.c index eee5fd3d6a..56475c113a 100644 --- a/dir.c +++ b/dir.c @@ -601,11 +601,22 @@ rb_glob_helper(path, flag, func, arg) rb_glob_helper(buf, flag, func, arg); free(buf); } - dirp = opendir(dir); - if (dirp == NULL) { - free(base); - break; + if (lstat(dir, &st) < 0) { + free(base); + break; } + if (S_ISDIR(st.st_mode)) { + dirp = opendir(dir); + if (dirp == NULL) { + free(base); + break; + } + } + else { + free(base); + break; + } + #define BASE (*base && !(*base == '/' && !base[1])) for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) { @@ -636,7 +647,7 @@ rb_glob_helper(path, flag, func, arg) free(base); free(magic); while (link) { - stat(link->path, &st); /* should success */ + lstat(link->path, &st); /* should success */ if (S_ISDIR(st.st_mode)) { int len = strlen(link->path); int mlen = strlen(m); -- cgit v1.2.3