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_delete_bang): fill wchar terminator.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48764 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-12-10 12:26:11 +00:00
parent 117438ee7b
commit 7a77cf7133
2 changed files with 5 additions and 1 deletions

View file

@ -5971,7 +5971,7 @@ rb_str_delete_bang(int argc, VALUE *argv, VALUE str)
s += clen; s += clen;
} }
} }
*t = '\0'; TERM_FILL(t, TERM_LEN(str));
STR_SET_LEN(str, t - RSTRING_PTR(str)); STR_SET_LEN(str, t - RSTRING_PTR(str));
ENC_CODERANGE_SET(str, cr); ENC_CODERANGE_SET(str, cr);

View file

@ -64,6 +64,10 @@ class Test_StringCStr < Test::Unit::TestCase
assert_wchars_term_char("foobar") {|s| s.sub!(/#{"foo".encode(s.encoding)}/, "")} assert_wchars_term_char("foobar") {|s| s.sub!(/#{"foo".encode(s.encoding)}/, "")}
end end
def test_wchar_delete!
assert_wchars_term_char("foobar") {|s| s.delete!("ao".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|