summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-26 10:17:39 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-07-26 10:17:39 +0000
commitb7f26835dae3005f1eefbb1700aa711b811fb2fc (patch)
tree441748b8075458313fb3a1dd4b25b57ca924dfd2
parentf9f1581f6d777be9ee2fe8612d77832cd214d1a2 (diff)
* io.c (argf_eof): go to the next file if called after ARGF.close
or ARGF.skip. [ruby-core:24561] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--io.c1
-rw-r--r--test/ruby/test_argf.rb12
3 files changed, 18 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 8d876b1eaf..53e41d209e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Jul 26 19:17:33 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* vm_insnhelper.c (vm_call_method): __send__ can call protected
diff --git a/io.c b/io.c
index bef54643f4..3345caf484 100644
--- a/io.c
+++ b/io.c
@@ -8502,6 +8502,7 @@ argf_eof(VALUE argf)
{
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;
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index c00db99bf9..ed92a516ad 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -437,6 +437,18 @@ class TestArgf < Test::Unit::TestCase
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