diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-09 20:12:02 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2012-02-09 20:12:02 +0000 |
commit | 36b3d5577ca9c9e32fa690149d73d557af996422 (patch) | |
tree | 8aa46568cdf61990c1fec5aaba1ec86dd11de8bc /io.c | |
parent | 0234bcfd19aa0a7b4152809c13554144b7322f41 (diff) |
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
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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; } |