[前][次][番号順一覧][スレッド一覧]

ruby-changes:36679

From: nobu <ko1@a...>
Date: Wed, 10 Dec 2014 16:49:11 +0900 (JST)
Subject: [ruby-changes:36679] nobu:r48760 (trunk): string.c: term fill

nobu	2014-12-10 16:48:48 +0900 (Wed, 10 Dec 2014)

  New Revision: 48760

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48760

  Log:
    string.c: term fill
    
    * string.c (rb_str_chomp_bang): fill wchar terminator.

  Modified files:
    trunk/string.c
    trunk/test/-ext-/string/test_cstr.rb
Index: string.c
===================================================================
--- string.c	(revision 48759)
+++ string.c	(revision 48760)
@@ -7188,7 +7188,7 @@ rb_str_chomp_bang(int argc, VALUE *argv, https://github.com/ruby/ruby/blob/trunk/string.c#L7188
 	len = chompped_length(str, rs);
 	if (len < olen) {
 	    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 48759)
+++ test/-ext-/string/test_cstr.rb	(revision 48760)
@@ -48,6 +48,10 @@ class Test_StringCStr < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/-ext-/string/test_cstr.rb#L48
     assert_wchars_term_char("a ") {|s| s.rstrip!}
   end
 
+  def test_wchar_chop!
+    assert_wchars_term_char("a\n") {|s| s.chop!}
+  end
+
   def assert_wchars_term_char(str)
     result = {}
     WCHARS.map do |enc|

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]