diff options
-rw-r--r-- | io.c | 1 | ||||
-rw-r--r-- | test/ruby/test_argf.rb | 8 |
2 files changed, 8 insertions, 1 deletions
@@ -8023,6 +8023,7 @@ argf_next_argv(VALUE argf) } if (ARGF.next_p == 1) { + if (ARGF.init_p == 1) argf_close(argf); retry: if (RARRAY_LEN(ARGF.argv) > 0) { VALUE filename = rb_ary_shift(ARGF.argv); diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb index fdd31c630a..d6aa8f7295 100644 --- a/test/ruby/test_argf.rb +++ b/test/ruby/test_argf.rb @@ -137,7 +137,7 @@ class TestArgf < Test::Unit::TestCase INPUT end - def test_new_lineno + def test_new_lineno_each f = ARGF.class.new(@t1.path, @t2.path, @t3.path) result = [] f.each {|line| result << [f.lineno, line]; break if result.size == 3} @@ -146,10 +146,16 @@ class TestArgf < Test::Unit::TestCase f.rewind assert_equal(2, f.lineno) + ensure + f.close + end + def test_new_lineno_each_char f = ARGF.class.new(@t1.path, @t2.path, @t3.path) f.each_char.to_a assert_equal(0, f.lineno) + ensure + f.close end def test_inplace |