1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/stringio/stringio.c (strio_gets): only "gets" should set $_.

* ext/stringio/stringio.c (strio_getline): should not set $_ here.

* io.c (argf_to_s): argf.to_s returns "ARGF".

* io.c (set_defout_var, set_deferr_var): make $defout and $deferr
  obsolete.

* io.c (set_input_var, set_output_var): allow $stdin, $stdout,
  $stderr not to be instance of IO.

* io.c (rb_f_readline): forward method to current_file. gets,
  readline, readlines, getc, readchar, tell, seek, pos=, rewind,
  fileno, to_io, eof, each_line, each_byte, binmode, and closed?
  as well.

* io.c (argf_forward): utility function to forward method to
  current_file.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@4190 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2003-07-28 07:31:52 +00:00
parent 4158a73ee4
commit dea1baa169
7 changed files with 193 additions and 88 deletions

View file

@ -161,7 +161,7 @@ static VALUE strio_each_byte _((VALUE));
static VALUE strio_getc _((VALUE));
static VALUE strio_ungetc _((VALUE, VALUE));
static VALUE strio_readchar _((VALUE));
static VALUE strio_gets_internal _((int, VALUE *, struct StringIO *));
static VALUE strio_getline _((int, VALUE *, struct StringIO *));
static VALUE strio_gets _((int, VALUE *, VALUE));
static VALUE strio_readline _((int, VALUE *, VALUE));
static VALUE strio_each _((int, VALUE *, VALUE));
@ -633,7 +633,7 @@ bm_search(little, llen, big, blen, skip)
}
static VALUE
strio_gets_internal(argc, argv, ptr)
strio_getline(argc, argv, ptr)
int argc;
VALUE *argv;
struct StringIO *ptr;
@ -701,7 +701,6 @@ strio_gets_internal(argc, argv, ptr)
}
ptr->pos = e - RSTRING(ptr->string)->ptr;
ptr->lineno++;
rb_lastline_set(str);
return str;
}
@ -711,7 +710,10 @@ strio_gets(argc, argv, self)
VALUE *argv;
VALUE self;
{
return strio_gets_internal(argc, argv, readable(StringIO(self)));
VALUE str = strio_getline(argc, argv, readable(StringIO(self)));
rb_lastline_set(str);
return str;
}
static VALUE
@ -720,7 +722,7 @@ strio_readline(argc, argv, self)
VALUE *argv;
VALUE self;
{
VALUE line = strio_gets_internal(argc, argv, readable(StringIO(self)));
VALUE line = strio_getline(argc, argv, readable(StringIO(self)));
if (NIL_P(line)) rb_eof_error();
return line;
}
@ -734,7 +736,7 @@ strio_each(argc, argv, self)
struct StringIO *ptr = StringIO(self);
VALUE line;
while (!NIL_P(line = strio_gets_internal(argc, argv, readable(ptr)))) {
while (!NIL_P(line = strio_getline(argc, argv, readable(ptr)))) {
rb_yield(line);
}
return self;
@ -748,7 +750,7 @@ strio_readlines(argc, argv, self)
{
struct StringIO *ptr = StringIO(self);
VALUE ary = rb_ary_new(), line;
while (!NIL_P(line = strio_gets_internal(argc, argv, readable(ptr)))) {
while (!NIL_P(line = strio_getline(argc, argv, readable(ptr)))) {
rb_ary_push(ary, line);
}
return ary;