mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (prepare_getline_args): io.gets(10,nil) should cause TypeError.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
59491ed3b0
commit
0ff4061ef7
3 changed files with 27 additions and 20 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Aug 17 21:50:22 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* io.c (prepare_getline_args): io.gets(10,nil) should cause TypeError.
|
||||||
|
|
||||||
Sun Aug 17 15:58:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Aug 17 15:58:39 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* lib/mkmf.rb: not check config.h.
|
* lib/mkmf.rb: not check config.h.
|
||||||
|
|
34
io.c
34
io.c
|
@ -1889,29 +1889,23 @@ rb_io_getline_fast(rb_io_t *fptr, rb_encoding *enc)
|
||||||
static void
|
static void
|
||||||
prepare_getline_args(int argc, VALUE *argv, VALUE *rsp, long *limit, VALUE io)
|
prepare_getline_args(int argc, VALUE *argv, VALUE *rsp, long *limit, VALUE io)
|
||||||
{
|
{
|
||||||
VALUE lim, rs;
|
VALUE rs = rb_rs, lim = Qnil;
|
||||||
rb_io_t *fptr;
|
rb_io_t *fptr;
|
||||||
|
|
||||||
if (argc == 0) {
|
if (argc == 1) {
|
||||||
rs = rb_rs;
|
VALUE tmp = Qnil;
|
||||||
lim = Qnil;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
rb_scan_args(argc, argv, "11", &rs, &lim);
|
|
||||||
if (!NIL_P(lim)) {
|
|
||||||
StringValue(rs);
|
|
||||||
}
|
|
||||||
else if (!NIL_P(rs) && TYPE(rs) != T_STRING) {
|
|
||||||
VALUE tmp = rb_check_string_type(rs);
|
|
||||||
|
|
||||||
if (NIL_P(tmp)) {
|
if (NIL_P(argv[0]) || !NIL_P(tmp = rb_check_string_type(argv[0]))) {
|
||||||
lim = rs;
|
rs = tmp;
|
||||||
rs = rb_rs;
|
}
|
||||||
}
|
else {
|
||||||
else {
|
lim = argv[0];
|
||||||
rs = tmp;
|
}
|
||||||
}
|
}
|
||||||
}
|
else if (2 <= argc) {
|
||||||
|
rb_scan_args(argc, argv, "2", &rs, &lim);
|
||||||
|
if (!NIL_P(rs))
|
||||||
|
StringValue(rs);
|
||||||
}
|
}
|
||||||
if (!NIL_P(rs)) {
|
if (!NIL_P(rs)) {
|
||||||
rb_encoding *enc_rs, *enc_io;
|
rb_encoding *enc_rs, *enc_io;
|
||||||
|
|
|
@ -44,6 +44,15 @@ class TestIO < Test::Unit::TestCase
|
||||||
r.close
|
r.close
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_gets_limit_extra_arg
|
||||||
|
with_pipe {|r, w|
|
||||||
|
r, w = IO.pipe
|
||||||
|
w << "0123456789"
|
||||||
|
w.close
|
||||||
|
assert_raise(TypeError) { r.gets(3,nil) }
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
# This test cause SEGV.
|
# This test cause SEGV.
|
||||||
def test_ungetc
|
def test_ungetc
|
||||||
r, w = IO.pipe
|
r, w = IO.pipe
|
||||||
|
|
Loading…
Add table
Reference in a new issue