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

ruby-changes:34162

From: nobu <ko1@a...>
Date: Fri, 30 May 2014 11:33:47 +0900 (JST)
Subject: [ruby-changes:34162] nobu:r46243 (trunk): string.c: reset code range

nobu	2014-05-30 11:33:38 +0900 (Fri, 30 May 2014)

  New Revision: 46243

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

  Log:
    string.c: reset code range
    
    * string.c (rb_str_substr): need to reset code range for shared
      string too, not only copied string.
      [ruby-core:62842] [Bug #9882]

  Modified files:
    trunk/ChangeLog
    trunk/string.c
    trunk/test/ruby/test_string.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46242)
+++ ChangeLog	(revision 46243)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri May 30 11:33:35 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (rb_str_substr): need to reset code range for shared
+	  string too, not only copied string.
+	  [ruby-core:62842] [Bug #9882]
+
 Fri May 30 10:22:21 2014  Mark Lorenz  <mlorenz@c...>
 
 	* lib/erb.rb (result): [DOC] no longer accepts a Proc, as
Index: string.c
===================================================================
--- string.c	(revision 46242)
+++ string.c	(revision 46243)
@@ -1894,10 +1894,10 @@ rb_str_substr(VALUE str, long beg, long https://github.com/ruby/ruby/blob/trunk/string.c#L1894
     }
     else {
 	str2 = rb_str_new_with_class(str, p, len);
-	rb_enc_cr_str_copy_for_substr(str2, str);
 	OBJ_INFECT(str2, str);
 	RB_GC_GUARD(str);
     }
+    rb_enc_cr_str_copy_for_substr(str2, str);
 
     return str2;
 }
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 46242)
+++ test/ruby/test_string.rb	(revision 46243)
@@ -894,6 +894,8 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L894
     assert_not_equal(S("a").hash, S("a\0").hash, bug4104)
     bug9172 = '[ruby-core:58658] [Bug #9172]'
     assert_not_equal(S("sub-setter").hash, S("discover").hash, bug9172)
+    bug9882 = '[ruby-core:62842] [Bug #9882]'
+    assert_equal(S(bug9882).hash, S("\u{30c6 30b9 30c8 2019}#{bug9882}")[4..-1].hash, bug9882)
   end
 
   def test_hash_random

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

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