ruby-changes:22700
From: nobu <ko1@a...>
Date: Wed, 22 Feb 2012 22:04:50 +0900 (JST)
Subject: [ruby-changes:22700] nobu:r34749 (ruby_1_9_3): merge revision(s) 34735,34736:
nobu 2012-02-22 22:04:38 +0900 (Wed, 22 Feb 2012) New Revision: 34749 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34749 Log: merge revision(s) 34735,34736: * io.c (rb_io_s_foreach): return enumerator including kerword arguments. [ruby-dev:45267][Bug #6054] * io.c (rb_io_s_foreach): argument check before making Enumerator. [ruby-dev:31525] Modified files: branches/ruby_1_9_3/ChangeLog branches/ruby_1_9_3/io.c branches/ruby_1_9_3/test/ruby/test_io.rb branches/ruby_1_9_3/version.h Index: ruby_1_9_3/ChangeLog =================================================================== --- ruby_1_9_3/ChangeLog (revision 34748) +++ ruby_1_9_3/ChangeLog (revision 34749) @@ -1,3 +1,13 @@ +Wed Feb 22 22:04:15 2012 Nobuyoshi Nakada <nobu@r...> + + * io.c (rb_io_s_foreach): argument check before making Enumerator. + [ruby-dev:31525] + +Wed Feb 22 22:04:15 2012 Nobuyoshi Nakada <nobu@r...> + + * io.c (rb_io_s_foreach): return enumerator including kerword + arguments. [ruby-dev:45267][Bug #6054] + Wed Feb 22 21:42:16 2012 NARUSE, Yui <naruse@r...> * configure.in: remove workaround replacement from gcc to gcc-4.2. Index: ruby_1_9_3/io.c =================================================================== --- ruby_1_9_3/io.c (revision 34748) +++ ruby_1_9_3/io.c (revision 34749) @@ -8484,10 +8484,11 @@ rb_io_s_foreach(int argc, VALUE *argv, VALUE self) { VALUE opt; + int orig_argc = argc; struct foreach_arg arg; argc = rb_scan_args(argc, argv, "13:", NULL, NULL, NULL, NULL, &opt); - RETURN_ENUMERATOR(self, argc, argv); + RETURN_ENUMERATOR(self, orig_argc, argv); open_key_args(argc, argv, opt, &arg); if (NIL_P(arg.io)) return Qnil; return rb_ensure(io_s_foreach, (VALUE)&arg, rb_io_close, arg.io); Index: ruby_1_9_3/version.h =================================================================== --- ruby_1_9_3/version.h (revision 34748) +++ ruby_1_9_3/version.h (revision 34749) @@ -1,5 +1,5 @@ #define RUBY_VERSION "1.9.3" -#define RUBY_PATCHLEVEL 137 +#define RUBY_PATCHLEVEL 138 #define RUBY_RELEASE_DATE "2012-02-22" #define RUBY_RELEASE_YEAR 2012 Index: ruby_1_9_3/test/ruby/test_io.rb =================================================================== --- ruby_1_9_3/test/ruby/test_io.rb (revision 34748) +++ ruby_1_9_3/test/ruby/test_io.rb (revision 34749) @@ -1555,6 +1555,16 @@ IO.foreach(t.path, "b", 3) {|x| a << x } assert_equal(["foo", "\nb", "ar\n", "b", "az\n"], a) + bug = '[ruby-dev:31525]' + assert_raise(ArgumentError, bug) {IO.foreach} + + a = nil + assert_nothing_raised(ArgumentError, bug) {a = IO.foreach(t.path).to_a} + assert_equal(["foo\n", "bar\n", "baz\n"], a, bug) + + bug6054 = '[ruby-dev:45267]' + e = assert_raise(IOError, bug6054) {IO.foreach(t.path, mode:"w").next} + assert_match(/not opened for reading/, e.message, bug6054) end def test_s_readlines -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/