From 075e78b39b62d67acee9fb6008898673cf0b1ac1 Mon Sep 17 00:00:00 2001 From: matz Date: Thu, 11 Nov 2004 00:42:16 +0000 Subject: * dir.c (rb_push_glob): Dir.glob should have call its block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7246 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ dir.c | 14 +++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8fef803e9d..6e96dab06b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Nov 11 09:41:01 2004 Yukihiro Matsumoto + + * dir.c (rb_push_glob): Dir.glob should have call its block. + Thu Nov 11 01:52:52 2004 Nobuyoshi Nakada * error.c (syserr_initialize): use stringified object. diff --git a/dir.c b/dir.c index 5c7f1cc5db..f0b1f00f23 100644 --- a/dir.c +++ b/dir.c @@ -939,18 +939,18 @@ glob_helper(pv, sub, flags, func, arg) p = sub ? sub : path; if (!has_magic(p, 0, flags)) { #if defined DOSISH - remove_backslashes(RSTRING(path)->ptr); + remove_backslashes(path); #else if (!(flags & FNM_NOESCAPE)) remove_backslashes(p); #endif - if (lstat(RSTRING(path)->ptr, &st) == 0) { - status = glob_call_func(func, path, arg); + if (lstat(path, &st) == 0) { + status = glob_call_func(func, pv, arg); if (status) return status; } else if (errno != ENOENT) { /* In case stat error is other than ENOENT and we may want to know what is wrong. */ - rb_sys_warning(RSTRING(path)->ptr); + rb_sys_warning(path); } return 0; } @@ -1119,7 +1119,7 @@ rb_glob(path, func, arg) args.func = func; args.arg = arg; - status = rb_glob2(rb_str_new2(path), 0, func, &args); + status = rb_glob2(rb_str_new2(path), 0, rb_glob_caller, &args); if (status) rb_jump_tag(status); } @@ -1254,6 +1254,10 @@ rb_push_glob(str, flags) /* else unmatched braces */ } if (status) rb_jump_tag(status); + if (rb_block_given_p()) { + rb_ary_each(ary); + return Qnil; + } return ary; } -- cgit v1.2.3