From 7a77cf71335c426d973bbf94518177954a175945 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 10 Dec 2014 12:26:11 +0000 Subject: 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 --- string.c | 2 +- test/-ext-/string/test_cstr.rb | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/string.c b/string.c index 2fb67efe92..d82051d25f 100644 --- a/string.c +++ b/string.c @@ -5971,7 +5971,7 @@ rb_str_delete_bang(int argc, VALUE *argv, VALUE str) s += clen; } } - *t = '\0'; + TERM_FILL(t, TERM_LEN(str)); STR_SET_LEN(str, t - RSTRING_PTR(str)); ENC_CODERANGE_SET(str, cr); diff --git a/test/-ext-/string/test_cstr.rb b/test/-ext-/string/test_cstr.rb index 4535921836..86670dc6e2 100644 --- a/test/-ext-/string/test_cstr.rb +++ b/test/-ext-/string/test_cstr.rb @@ -64,6 +64,10 @@ class Test_StringCStr < Test::Unit::TestCase assert_wchars_term_char("foobar") {|s| s.sub!(/#{"foo".encode(s.encoding)}/, "")} end + def test_wchar_delete! + assert_wchars_term_char("foobar") {|s| s.delete!("ao".encode(s.encoding))} + end + def assert_wchars_term_char(str) result = {} WCHARS.map do |enc| -- cgit v1.2.3