summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-14 03:05:29 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-11-14 03:05:29 +0000
commitf2dd4eb3cc32b5edd4f6cbff34b922f662300ea5 (patch)
tree7c2fb6a634767ca478f936bc7406129e65fae1d2 /io.c
parent261903223a967079521c68dda54fe722de98cbf5 (diff)
* io.c (argf_readlines): forward to current_file for arguments
check. http://twitter.com/nagachika/status/3634254856589312 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/io.c b/io.c
index b668688821..174a4ef189 100644
--- a/io.c
+++ b/io.c
@@ -7172,13 +7172,23 @@ rb_f_readlines(int argc, VALUE *argv, VALUE recv)
static VALUE
argf_readlines(int argc, VALUE *argv, VALUE argf)
{
- VALUE line, ary;
+ int lineno = ARGF.lineno;
+ VALUE lines, ary;
ary = rb_ary_new();
- while (!NIL_P(line = argf_getline(argc, argv, argf))) {
- rb_ary_push(ary, line);
+ while (next_argv()) {
+ if (ARGF_GENERIC_INPUT_P()) {
+ lines = rb_funcall3(ARGF.current_file, rb_intern("readlines"), argc, argv);
+ }
+ else {
+ lines = rb_io_readlines(argc, argv, ARGF.current_file);
+ argf_close(ARGF.current_file);
+ }
+ ARGF.next_p = 1;
+ rb_ary_concat(ary, lines);
+ ARGF.lineno = lineno + RARRAY_LEN(ary);
+ ARGF.last_lineno = ARGF.lineno;
}
-
return ary;
}