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

ruby-changes:36683

From: nobu <ko1@a...>
Date: Wed, 10 Dec 2014 21:26:22 +0900 (JST)
Subject: [ruby-changes:36683] nobu:r48764 (trunk): string.c: term fill

nobu	2014-12-10 21:26:11 +0900 (Wed, 10 Dec 2014)

  New Revision: 48764

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

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

  Modified files:
    trunk/string.c
    trunk/test/-ext-/string/test_cstr.rb
Index: string.c
===================================================================
--- string.c	(revision 48763)
+++ string.c	(revision 48764)
@@ -5971,7 +5971,7 @@ rb_str_delete_bang(int argc, VALUE *argv https://github.com/ruby/ruby/blob/trunk/string.c#L5971
 	    s += clen;
 	}
     }
-    *t = '\0';
+    TERM_FILL(t, TERM_LEN(str));
     STR_SET_LEN(str, t - RSTRING_PTR(str));
     ENC_CODERANGE_SET(str, cr);
 
Index: test/-ext-/string/test_cstr.rb
===================================================================
--- test/-ext-/string/test_cstr.rb	(revision 48763)
+++ test/-ext-/string/test_cstr.rb	(revision 48764)
@@ -64,6 +64,10 @@ class Test_StringCStr < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/-ext-/string/test_cstr.rb#L64
     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|

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

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