ruby-changes:36687
From: nobu <ko1@a...>
Date: Thu, 11 Dec 2014 09:38:13 +0900 (JST)
Subject: [ruby-changes:36687] nobu:r48768 (trunk): string.c: term fill
nobu 2014-12-11 09:37:58 +0900 (Thu, 11 Dec 2014) New Revision: 48768 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48768 Log: string.c: term fill * string.c (rb_str_squeeze_bang): fill wchar terminator. Modified files: trunk/string.c trunk/test/-ext-/string/test_cstr.rb Index: string.c =================================================================== --- string.c (revision 48767) +++ string.c (revision 48768) @@ -6076,7 +6076,7 @@ rb_str_squeeze_bang(int argc, VALUE *arg https://github.com/ruby/ruby/blob/trunk/string.c#L6076 } } - *t = '\0'; + TERM_FILL(t, TERM_LEN(str)); if (t - RSTRING_PTR(str) != RSTRING_LEN(str)) { STR_SET_LEN(str, t - RSTRING_PTR(str)); modify = 1; Index: test/-ext-/string/test_cstr.rb =================================================================== --- test/-ext-/string/test_cstr.rb (revision 48767) +++ test/-ext-/string/test_cstr.rb (revision 48768) @@ -68,6 +68,10 @@ class Test_StringCStr < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/-ext-/string/test_cstr.rb#L68 assert_wchars_term_char("foobar") {|s| s.delete!("ao".encode(s.encoding))} end + def test_wchar_squeeze! + assert_wchars_term_char("foo!") {|s| s.squeeze!} + end + def assert_wchars_term_char(str) result = {} WCHARS.map do |enc| -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/