summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c10
1 files changed, 10 insertions, 0 deletions
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;
}