Backport #4112 ยป stringio_gets.diff
w/ext/stringio/stringio.c | ||
---|---|---|
e = s + RSTRING_LEN(ptr->string);
|
||
s += ptr->pos;
|
||
if (limit > 0 && s + limit < e) {
|
||
e = s + limit;
|
||
e = rb_enc_right_char_head(s, s + limit, e, rb_enc_get(ptr->string));
|
||
}
|
||
if (NIL_P(str)) {
|
||
str = strio_substr(ptr, ptr->pos, e - s);
|
w/test/stringio/test_stringio.rb | ||
---|---|---|
assert_equal("a" * 10000 + "zz", f.gets("zz"))
|
||
f = StringIO.new("a" * 10000 + "zz!")
|
||
assert_equal("a" * 10000 + "zz!", f.gets("zzz"))
|
||
["a".encode("utf-16be"), "\u3042"].each do |s|
|
||
assert_equal(s, StringIO.new(s).gets(1))
|
||
assert_equal(s, StringIO.new(s).gets(nil, 1))
|
||
end
|
||
end
|
||
def test_each
|