Project

General

Profile

Backport #4112 ยป stringio_gets.diff

nobu (Nobuyoshi Nakada), 12/03/2010 06:58 AM

View differences:

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
    (1-1/1)