From 009debfd02f5024b85b5c325f42533b40f4028e9 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 20 Aug 2007 14:46:03 +0000 Subject: [PATCH] * io.c (rb_io_s_foreach): argument count check before making Enumerator. [ruby-dev:31525] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 3 +++ array.c | 2 +- io.c | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) 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;