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

ruby-changes:13690

From: yugui <ko1@a...>
Date: Sun, 25 Oct 2009 23:46:37 +0900 (JST)
Subject: [ruby-changes:13690] Ruby:r25477 (ruby_1_9_1): merges r24509 from trunk into ruby_1_9_1.

yugui	2009-10-25 23:46:11 +0900 (Sun, 25 Oct 2009)

  New Revision: 25477

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

  Log:
    merges r24509 from trunk into ruby_1_9_1.
    --
    * string.c (rb_str_new_frozen): must not change encoding of frozen
      shared string.  [ruby-dev:39068]

  Modified files:
    branches/ruby_1_9_1/ChangeLog
    branches/ruby_1_9_1/string.c
    branches/ruby_1_9_1/test/ruby/test_string.rb
    branches/ruby_1_9_1/version.h

Index: ruby_1_9_1/ChangeLog
===================================================================
--- ruby_1_9_1/ChangeLog	(revision 25476)
+++ ruby_1_9_1/ChangeLog	(revision 25477)
@@ -1,3 +1,8 @@
+Wed Aug 12 12:59:51 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (rb_str_new_frozen): must not change encoding of frozen
+	  shared string.  [ruby-dev:39068]
+
 Fri Oct 23 10:51:04 2009  Yuki Sonoda (Yugui)  <yugui@y...>
 
 	* test/ruby/test_m17n.rb (TestM17N#test_sprintf_s):
Index: ruby_1_9_1/string.c
===================================================================
--- ruby_1_9_1/string.c	(revision 25476)
+++ ruby_1_9_1/string.c	(revision 25477)
@@ -666,13 +666,14 @@
 	long ofs;
 	ofs = RSTRING_LEN(str) - RSTRING_LEN(orig);
 	if ((ofs > 0) || (klass != RBASIC(str)->klass) ||
-	    (!OBJ_TAINTED(str) && OBJ_TAINTED(orig))) {
+	    (!OBJ_TAINTED(str) && OBJ_TAINTED(orig)) ||
+	    ENCODING_GET(str) != ENCODING_GET(orig)) {
 	    str = str_new3(klass, str);
 	    RSTRING(str)->as.heap.ptr += ofs;
 	    RSTRING(str)->as.heap.len -= ofs;
+	    rb_enc_cr_str_exact_copy(str, orig);
+	    OBJ_INFECT(str, orig);
 	}
-	rb_enc_cr_str_exact_copy(str, orig);
-	OBJ_INFECT(str, orig);
     }
     else if (STR_EMBED_P(orig)) {
 	str = str_new(klass, RSTRING_PTR(orig), RSTRING_LEN(orig));
Index: ruby_1_9_1/version.h
===================================================================
--- ruby_1_9_1/version.h	(revision 25476)
+++ ruby_1_9_1/version.h	(revision 25477)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.1"
-#define RUBY_PATCHLEVEL 285
+#define RUBY_PATCHLEVEL 286
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 9
 #define RUBY_VERSION_TEENY 1
Index: ruby_1_9_1/test/ruby/test_string.rb
===================================================================
--- ruby_1_9_1/test/ruby/test_string.rb	(revision 25476)
+++ ruby_1_9_1/test/ruby/test_string.rb	(revision 25477)
@@ -1786,4 +1786,17 @@
       ("aaaaaaaa".."zzzzzzzz").each {|s| s.to_sym }
     INPUT
   end
+
+  def test_shared_force_encoding
+    s = "\u{3066}\u{3059}\u{3068}".gsub(//, '')
+    h = {}
+    h[s] = nil
+    k = h.keys[0]
+    assert_equal(s, k, '[ruby-dev:39068]')
+    assert_equal(Encoding::UTF_8, k.encoding, '[ruby-dev:39068]')
+    s.dup.force_encoding(Encoding::ASCII_8BIT).gsub(//, '')
+    k = h.keys[0]
+    assert_equal(s, k, '[ruby-dev:39068]')
+    assert_equal(Encoding::UTF_8, k.encoding, '[ruby-dev:39068]')
+  end
 end

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

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