* ext/stringio/stringio.c (strio_getline): round upto next char
boundary. [ruby-dev:42674] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30063 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
15dad95dfc
commit
bfcd4e5453
@ -1,3 +1,8 @@
|
|||||||
|
Fri Dec 3 07:08:42 2010 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* ext/stringio/stringio.c (strio_getline): round upto next char
|
||||||
|
boundary. [ruby-dev:42674]
|
||||||
|
|
||||||
Fri Dec 3 06:52:46 2010 Tanaka Akira <akr@fsij.org>
|
Fri Dec 3 06:52:46 2010 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* compile.c: parenthesize macro arguments.
|
* compile.c: parenthesize macro arguments.
|
||||||
|
@ -954,7 +954,7 @@ strio_getline(int argc, VALUE *argv, struct StringIO *ptr)
|
|||||||
e = s + RSTRING_LEN(ptr->string);
|
e = s + RSTRING_LEN(ptr->string);
|
||||||
s += ptr->pos;
|
s += ptr->pos;
|
||||||
if (limit > 0 && s + limit < e) {
|
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)) {
|
if (NIL_P(str)) {
|
||||||
str = strio_substr(ptr, ptr->pos, e - s);
|
str = strio_substr(ptr, ptr->pos, e - s);
|
||||||
|
@ -378,6 +378,12 @@ class TestStringIO < Test::Unit::TestCase
|
|||||||
assert_equal("a" * 10000 + "zz", f.gets("zz"))
|
assert_equal("a" * 10000 + "zz", f.gets("zz"))
|
||||||
f = StringIO.new("a" * 10000 + "zz!")
|
f = StringIO.new("a" * 10000 + "zz!")
|
||||||
assert_equal("a" * 10000 + "zz!", f.gets("zzz"))
|
assert_equal("a" * 10000 + "zz!", f.gets("zzz"))
|
||||||
|
|
||||||
|
bug4112 = '[ruby-dev:42674]'
|
||||||
|
["a".encode("utf-16be"), "\u3042"].each do |s|
|
||||||
|
assert_equal(s, StringIO.new(s).gets(1), bug4112)
|
||||||
|
assert_equal(s, StringIO.new(s).gets(nil, 1), bug4112)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_each
|
def test_each
|
||||||
|
Loading…
x
Reference in New Issue
Block a user