diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-20 08:25:03 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-20 08:25:03 +0000 |
commit | 40e477f05c78f64d22377ee2bac52d146596851d (patch) | |
tree | 4a71a2838d258197aee63a23371721f11423700b /io.c | |
parent | a1140a3ebff3fcd9940e2777a22e8a060d3500df (diff) | |
download | ruby-40e477f05c78f64d22377ee2bac52d146596851d.tar.gz |
io.c: update argf lineno
* io.c (argf_rewind): rewind line number in non-global ARGF
instance.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57125 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 10 |
1 files changed, 9 insertions, 1 deletions
@@ -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; } /* |