ruby-changes:12575
From: nobu <ko1@a...>
Date: Sun, 26 Jul 2009 19:20:41 +0900 (JST)
Subject: [ruby-changes:12575] Ruby:r24284 (trunk, ruby_1_8): * io.c (argf_eof): go to the next file if called after ARGF.close
nobu 2009-07-26 19:17:39 +0900 (Sun, 26 Jul 2009) New Revision: 24284 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24284 Log: * io.c (argf_eof): go to the next file if called after ARGF.close or ARGF.skip. [ruby-core:24561] Modified files: branches/ruby_1_8/ChangeLog branches/ruby_1_8/io.c branches/ruby_1_8/test/ruby/test_argf.rb trunk/ChangeLog trunk/io.c trunk/test/ruby/test_argf.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 24283) +++ ChangeLog (revision 24284) @@ -1,3 +1,8 @@ +Sun Jul 26 19:17:33 2009 Nobuyoshi Nakada <nobu@r...> + + * io.c (argf_eof): go to the next file if called after ARGF.close + or ARGF.skip. [ruby-core:24561] + Sun Jul 26 18:30:02 2009 Nobuyoshi Nakada <nobu@r...> * vm_insnhelper.c (vm_call_method): __send__ can call protected Index: io.c =================================================================== --- io.c (revision 24283) +++ io.c (revision 24284) @@ -8502,6 +8502,7 @@ { if (RTEST(ARGF.current_file)) { if (ARGF.init_p == 0) return Qtrue; + next_argv(); ARGF_FORWARD(0, 0); if (rb_io_eof(ARGF.current_file)) { return Qtrue; Index: test/ruby/test_argf.rb =================================================================== --- test/ruby/test_argf.rb (revision 24283) +++ test/ruby/test_argf.rb (revision 24284) @@ -437,6 +437,18 @@ assert_equal(x, a.shift) end end + + t1 = Tempfile.new("foo") + t1.binmode + t1.puts "foo" + t1.close + t2 = Tempfile.new("bar") + t2.binmode + t2.puts "bar" + t2.close + ruby('-e', 'STDERR.reopen(STDOUT); ARGF.gets; ARGF.skip; p ARGF.eof?', t1.path, t2.path) do |f| + assert_equal(%w(false), f.read.split(/\n/)) + end end def test_read Index: ruby_1_8/ChangeLog =================================================================== --- ruby_1_8/ChangeLog (revision 24283) +++ ruby_1_8/ChangeLog (revision 24284) @@ -1,3 +1,8 @@ +Sun Jul 26 19:17:33 2009 Nobuyoshi Nakada <nobu@r...> + + * io.c (argf_eof): go to the next file if called after ARGF.close + or ARGF.skip. [ruby-core:24561] + Sun Jul 26 18:42:23 2009 Nobuyoshi Nakada <nobu@r...> * io.c (Init_IO): $FILENAME should correspond to the first elemen Index: ruby_1_8/io.c =================================================================== --- ruby_1_8/io.c (revision 24283) +++ ruby_1_8/io.c (revision 24284) @@ -5586,6 +5586,7 @@ { if (current_file) { if (init_p == 0) return Qtrue; + next_argv(); ARGF_FORWARD(0, 0); if (rb_io_eof(current_file)) { return Qtrue; Index: ruby_1_8/test/ruby/test_argf.rb =================================================================== --- ruby_1_8/test/ruby/test_argf.rb (revision 24283) +++ ruby_1_8/test/ruby/test_argf.rb (revision 24284) @@ -260,6 +260,18 @@ assert_equal(x, a.shift) end end + + t1 = Tempfile.new("foo") + t1.binmode + t1.puts "foo" + t1.close + t2 = Tempfile.new("bar") + t2.binmode + t2.puts "bar" + t2.close + ruby('-e', 'STDERR.reopen(STDOUT); ARGF.gets; ARGF.skip; p ARGF.eof?', t1.path, t2.path) do |f| + assert_equal(%w(false), f.read.split(/\n/)) + end end def test_read -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/