summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/io.c b/io.c
index 642dd05f5dc..9f03c09a96e 100644
--- a/io.c
+++ b/io.c
@@ -89,7 +89,7 @@ struct timeval rb_time_interval _((VALUE));
static VALUE filename, current_file;
static int gets_lineno;
-static int init_p = 0, next_p = 0;
+static int init_p = 0, next_p = 0, first_p = 1;
static VALUE lineno;
#ifdef _STDIO_USES_IOSTREAM /* GNU libc */
@@ -2362,6 +2362,7 @@ next_argv()
current_file = rb_stdin;
}
init_p = 1;
+ first_p = 0;
gets_lineno = 0;
}
@@ -3168,8 +3169,12 @@ argf_readchar()
static VALUE
argf_eof()
{
- if (init_p == 0 && !next_argv())
+ int first = first_p;
+
+ if (!next_argv()) return Qtrue;
+ if (!first && next_p == -1) {
return Qtrue;
+ }
if (TYPE(current_file) != T_FILE) {
return argf_forward();
}