mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
stringio.c: encoding at empty result
* ext/stringio/stringio.c (strio_gets): should return string with the external encoding, at empty result. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
c5f66a376f
commit
24d03b2204
2 changed files with 4 additions and 1 deletions
|
@ -1149,7 +1149,8 @@ strio_gets(int argc, VALUE *argv, VALUE self)
|
|||
VALUE str;
|
||||
|
||||
if (prepare_getline_args(&arg, argc, argv)->limit == 0) {
|
||||
return rb_str_new(0, 0);
|
||||
struct StringIO *ptr = readable(self);
|
||||
return rb_enc_str_new(0, 0, get_enc(ptr));
|
||||
}
|
||||
|
||||
str = strio_getline(&arg, readable(self));
|
||||
|
|
|
@ -79,6 +79,8 @@ class TestStringIO < Test::Unit::TestCase
|
|||
assert_equal("def\n", stringio.gets(""))
|
||||
assert_raise(TypeError){StringIO.new("").gets(1, 1)}
|
||||
assert_nothing_raised {StringIO.new("").gets(nil, nil)}
|
||||
|
||||
assert_string("", Encoding::UTF_8, StringIO.new("foo").gets(0))
|
||||
end
|
||||
|
||||
def test_gets_chomp
|
||||
|
|
Loading…
Add table
Reference in a new issue