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_sub_bang): fill wchar terminator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9d17096309
commit
117438ee7b
2 changed files with 5 additions and 1 deletions
2
string.c
2
string.c
|
@ -4158,7 +4158,7 @@ rb_str_sub_bang(int argc, VALUE *argv, VALUE str)
|
||||||
memcpy(p + beg0, rp, rlen);
|
memcpy(p + beg0, rp, rlen);
|
||||||
len += rlen - plen;
|
len += rlen - plen;
|
||||||
STR_SET_LEN(str, len);
|
STR_SET_LEN(str, len);
|
||||||
RSTRING_PTR(str)[len] = '\0';
|
TERM_FILL(&RSTRING_PTR(str)[len], TERM_LEN(str));
|
||||||
ENC_CODERANGE_SET(str, cr);
|
ENC_CODERANGE_SET(str, cr);
|
||||||
if (tainted) OBJ_TAINT(str);
|
if (tainted) OBJ_TAINT(str);
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,10 @@ class Test_StringCStr < Test::Unit::TestCase
|
||||||
assert_wchars_term_char("a"*30) {|s| s[29,1] = ""}
|
assert_wchars_term_char("a"*30) {|s| s[29,1] = ""}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_wchar_sub!
|
||||||
|
assert_wchars_term_char("foobar") {|s| s.sub!(/#{"foo".encode(s.encoding)}/, "")}
|
||||||
|
end
|
||||||
|
|
||||||
def assert_wchars_term_char(str)
|
def assert_wchars_term_char(str)
|
||||||
result = {}
|
result = {}
|
||||||
WCHARS.map do |enc|
|
WCHARS.map do |enc|
|
||||||
|
|
Loading…
Add table
Reference in a new issue