1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

string.c: term fill

* string.c (rb_str_splice_0): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-12-10 07:49:10 +00:00
parent ed94c24944
commit 9d17096309
2 changed files with 6 additions and 2 deletions

View file

@ -3709,7 +3709,7 @@ rb_str_splice_0(VALUE str, long beg, long len, VALUE val)
RSTRING_GETMEM(str, sptr, slen);
if (len < vlen) {
/* expand string */
RESIZE_CAPA(str, slen + vlen - len + TERM_LEN(str));
RESIZE_CAPA(str, slen + vlen - len);
sptr = RSTRING_PTR(str);
}
@ -3726,7 +3726,7 @@ rb_str_splice_0(VALUE str, long beg, long len, VALUE val)
}
slen += vlen - len;
STR_SET_LEN(str, slen);
sptr[slen] = '\0';
TERM_FILL(&sptr[slen], TERM_LEN(str));
OBJ_INFECT(str, val);
}

View file

@ -56,6 +56,10 @@ class Test_StringCStr < Test::Unit::TestCase
assert_wchars_term_char("a\n") {|s| s.chomp!}
end
def test_wchar_aset
assert_wchars_term_char("a"*30) {|s| s[29,1] = ""}
end
def assert_wchars_term_char(str)
result = {}
WCHARS.map do |enc|