ruby-changes:36680
From: nobu <ko1@a...>
Date: Wed, 10 Dec 2014 16:49:16 +0900 (JST)
Subject: [ruby-changes:36680] nobu:r48761 (trunk): string.c: term fill
nobu 2014-12-10 16:48:56 +0900 (Wed, 10 Dec 2014) New Revision: 48761 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48761 Log: string.c: term fill * string.c (rb_str_chop_bang): fill wchar terminator. Modified files: trunk/string.c trunk/test/-ext-/string/test_cstr.rb Index: string.c =================================================================== --- string.c (revision 48760) +++ string.c (revision 48761) @@ -7024,7 +7024,7 @@ rb_str_chop_bang(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L7024 long len; len = chopped_length(str); STR_SET_LEN(str, len); - RSTRING_PTR(str)[len] = '\0'; + TERM_FILL(&RSTRING_PTR(str)[len], TERM_LEN(str)); if (ENC_CODERANGE(str) != ENC_CODERANGE_7BIT) { ENC_CODERANGE_CLEAR(str); } Index: test/-ext-/string/test_cstr.rb =================================================================== --- test/-ext-/string/test_cstr.rb (revision 48760) +++ test/-ext-/string/test_cstr.rb (revision 48761) @@ -52,6 +52,10 @@ class Test_StringCStr < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/-ext-/string/test_cstr.rb#L52 assert_wchars_term_char("a\n") {|s| s.chop!} end + def test_wchar_chomp! + assert_wchars_term_char("a\n") {|s| s.chomp!} + end + def assert_wchars_term_char(str) result = {} WCHARS.map do |enc| -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/