diff --git a/ChangeLog b/ChangeLog index f9c0fec49e..d6c6e4b819 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,9 @@ Mon Aug 20 23:28:39 2007 Yukihiro Matsumoto * dir.c (dir_foreach): return Enumerator if no block given. [ruby-dev:31525] + * io.c (rb_io_s_foreach): argument count check before making + Enumerator. [ruby-dev:31525] + Mon Aug 20 23:17:14 2007 Nobuyoshi Nakada * vm_core.h (struct rb_thread_struct): removed first_func_arg and diff --git a/array.c b/array.c index d3b3b909d6..0d351ccbb4 100644 --- a/array.c +++ b/array.c @@ -922,7 +922,7 @@ rb_ary_rindex(int argc, VALUE *argv, VALUE ary) long i = RARRAY_LEN(ary); if (rb_scan_args(argc, argv, "01", &val) == 0) { - RETURN_ENUMERATOR(ary, 0, 0); + RETURN_ENUMERATOR(ary, 0, 0); while (i--) { if (RTEST(rb_yield(RARRAY_PTR(ary)[i]))) return LONG2NUM(i); diff --git a/io.c b/io.c index e78fd6c5f6..069ba21df0 100644 --- a/io.c +++ b/io.c @@ -5185,8 +5185,8 @@ rb_io_s_foreach(int argc, VALUE *argv, VALUE self) VALUE fname; struct foreach_arg arg; - RETURN_ENUMERATOR(self, argc, argv); rb_scan_args(argc, argv, "12", &fname, NULL, NULL); + RETURN_ENUMERATOR(self, argc, argv); FilePathValue(fname); arg.io = rb_io_open(RSTRING_PTR(fname), "r"); if (NIL_P(arg.io)) return Qnil;