summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
Diffstat (limited to 'io.c')
-rw-r--r--io.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/io.c b/io.c
index 3da57a0b40..65254ff102 100644
--- a/io.c
+++ b/io.c
@@ -11098,11 +11098,19 @@ argf_set_pos(VALUE argf, VALUE offset)
static VALUE
argf_rewind(VALUE argf)
{
+ VALUE ret;
+ int old_lineno;
+
if (!next_argv()) {
rb_raise(rb_eArgError, "no stream to rewind");
}
ARGF_FORWARD(0, 0);
- return rb_io_rewind(ARGF.current_file);
+ old_lineno = RFILE(ARGF.current_file)->fptr->lineno;
+ ret = rb_io_rewind(ARGF.current_file);
+ if (!global_argf_p(argf)) {
+ ARGF.last_lineno = ARGF.lineno -= old_lineno;
+ }
+ return ret;
}
/*