ruby-changes:22368
From: naruse <ko1@a...>
Date: Thu, 2 Feb 2012 17:53:07 +0900 (JST)
Subject: [ruby-changes:22368] naruse:r34417 (trunk): * io.c (argf_next_argv): reset ARGF.next_p on ARGV.replace.
naruse 2012-02-02 17:52:55 +0900 (Thu, 02 Feb 2012) New Revision: 34417 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=34417 Log: * io.c (argf_next_argv): reset ARGF.next_p on ARGV.replace. r34409 breaks replacing ARGV. [ruby-dev:45160] [Bug #5952] Modified files: trunk/ChangeLog trunk/io.c trunk/test/ruby/test_argf.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 34416) +++ ChangeLog (revision 34417) @@ -1,3 +1,9 @@ +Thu Feb 2 17:51:02 2012 NARUSE, Yui <naruse@r...> + + * io.c (argf_next_argv): reset ARGF.next_p on ARGV.replace. + r34409 breaks replacing ARGV. + [ruby-dev:45160] [Bug #5952] + Thu Feb 2 16:21:01 2012 NAKAMURA Usaku <usa@r...> * test/net/http/test_http.rb (TestNetHTTPKeepAlive#*): remove debug Index: io.c =================================================================== --- io.c (revision 34416) +++ io.c (revision 34417) @@ -7306,6 +7306,14 @@ } ARGF.init_p = 1; } + else { + if (NIL_P(ARGF.argv)) { + ARGF.next_p = -1; + } + else if (ARGF.next_p == -1 && RARRAY_LEN(ARGF.argv) > 0) { + ARGF.next_p = 1; + } + } if (ARGF.next_p == 1) { retry: Index: test/ruby/test_argf.rb =================================================================== --- test/ruby/test_argf.rb (revision 34416) +++ test/ruby/test_argf.rb (revision 34417) @@ -678,6 +678,16 @@ end end + def test_close_replace + ruby('-e', <<-SRC) do |f| + ARGF.close + ARGV.replace ['#{@t1.path}', '#{@t2.path}', '#{@t3.path}'] + puts ARGF.read + SRC + assert_equal("1\n2\n3\n4\n5\n6\n", f.read) + end + end + def test_closed ruby('-e', <<-SRC, @t1.path, @t2.path, @t3.path) do |f| 3.times do -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/