From 36b3d5577ca9c9e32fa690149d73d557af996422 Mon Sep 17 00:00:00 2001 From: naruse Date: Thu, 9 Feb 2012 20:12:02 +0000 Subject: merge revision(s) 34409,34412,34417: * io.c (argf_close): skip stdin, which should be readable again. [ruby-dev:45160] [Bug #5952] * io.c (argf_readlines): reinitialize after all read to be readable again. * io.c (argf_next_argv): reset ARGF.next_p on ARGV.replace. r34409 breaks replacing ARGV. [ruby-dev:45160] [Bug #5952] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- io.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'io.c') diff --git a/io.c b/io.c index cc9e50e685..1c4b54ab70 100644 --- a/io.c +++ b/io.c @@ -6852,6 +6852,7 @@ argf_forward(int argc, VALUE *argv, VALUE argf) static void argf_close(VALUE file) { + if (file == rb_stdin) return; if (RB_TYPE_P(file, T_FILE)) { rb_io_set_write_io(file, Qnil); } @@ -6881,6 +6882,14 @@ argf_next_argv(VALUE argf) } 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: @@ -7262,6 +7271,7 @@ argf_readlines(int argc, VALUE *argv, VALUE argf) ARGF.lineno = lineno + RARRAY_LEN(ary); ARGF.last_lineno = ARGF.lineno; } + ARGF.init_p = 0; return ary; } -- cgit v1.2.3