summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-28 07:31:52 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2003-07-28 07:31:52 +0000
commitdea1baa169ca752a5bde28c88d96feb622a0787b (patch)
tree2adb11bc7363099753a8ba640e105af07b843bb9 /ext
parent4158a73ee47321de856b8bce5668b07a824d3374 (diff)
* 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
Diffstat (limited to 'ext')
-rw-r--r--ext/stringio/stringio.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 366b337..7dfd8e6 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -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;