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
commit27a9a7d1dbf5410ee6ba3e2d7cd7c329adff6463 (patch)
tree91b1af76818262c2f4bc4b89d1d86e3d4bca7505
parentb259db28fd7a1238a2939cee3ba6a3e60d8cf2cd (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/branches/ruby_1_8@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 d0d08d16b5..37978cfaab 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:42:23 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* io.c (Init_IO): $FILENAME should correspond to the first elemen
diff --git a/io.c b/io.c
index 289354db07..ce02ca0ee6 100644
--- a/io.c
+++ b/io.c
@@ -5586,6 +5586,7 @@ argf_eof()
{
if (current_file) {
if (init_p == 0) return Qtrue;
+ next_argv();
ARGF_FORWARD(0, 0);
if (rb_io_eof(current_file)) {
return Qtrue;
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index 4ac4281a4e..e61ed8dd64 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -260,6 +260,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