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

ruby-changes:18238

From: yugui <ko1@a...>
Date: Mon, 20 Dec 2010 22:30:24 +0900 (JST)
Subject: [ruby-changes:18238] Ruby:r30262 (ruby_1_9_2): merges r29868 and r29872 from trunk into ruby_1_9_2.

yugui	2010-12-20 22:22:53 +0900 (Mon, 20 Dec 2010)

  New Revision: 30262

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

  Log:
    merges r29868 and r29872 from trunk into ruby_1_9_2.
    --
    * string.c (rb_str_inspect): append for each chars instead of bulk
      copy if encoding conversion is needed.  [ruby-core:33283]
    --
    * string.c (rb_str_inspect): fix for ascii-compatible external
      encoding and different encoding string.  [ruby-core:33283]

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

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 30261)
+++ ruby_1_9_2/ChangeLog	(revision 30262)
@@ -1,3 +1,13 @@
+Mon Nov 22 21:30:57 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (rb_str_inspect): fix for ascii-compatible external
+	  encoding and different encoding string.  [ruby-core:33283]
+
+Mon Nov 22 18:33:30 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (rb_str_inspect): append for each chars instead of bulk
+	  copy if encoding conversion is needed.  [ruby-core:33283]
+
 Mon Nov 22 11:58:11 2010  NARUSE, Yui  <naruse@r...>
 
 	* string.c (rb_str_concat): set ENC_CODERANGE_VALID when the
Index: ruby_1_9_2/string.c
===================================================================
--- ruby_1_9_2/string.c	(revision 30261)
+++ ruby_1_9_2/string.c	(revision 30262)
@@ -4195,8 +4195,10 @@
               (cc == '$' || cc == '@' || cc == '{')))) {
 	    if (p - n > prev) str_buf_cat(result, prev, p - n - prev);
 	    str_buf_cat2(result, "\\");
-	    prev = p - n;
-	    continue;
+	    if (asciicompat || enc == resenc) {
+		prev = p - n;
+		continue;
+	    }
 	}
 	switch (c) {
 	  case '\n': cc = 'n'; break;
Index: ruby_1_9_2/version.h
===================================================================
--- ruby_1_9_2/version.h	(revision 30261)
+++ ruby_1_9_2/version.h	(revision 30262)
@@ -1,5 +1,5 @@
 #define RUBY_VERSION "1.9.2"
-#define RUBY_PATCHLEVEL 102
+#define RUBY_PATCHLEVEL 103
 #define RUBY_VERSION_MAJOR 1
 #define RUBY_VERSION_MINOR 9
 #define RUBY_VERSION_TEENY 1
Index: ruby_1_9_2/test/ruby/test_string.rb
===================================================================
--- ruby_1_9_2/test/ruby/test_string.rb	(revision 30261)
+++ ruby_1_9_2/test/ruby/test_string.rb	(revision 30262)
@@ -1886,10 +1886,20 @@
   end
 
   def test_ascii_incomat_inspect
+    bug4081 = '[ruby-core:33283]'
     [Encoding::UTF_16LE, Encoding::UTF_16BE,
      Encoding::UTF_32LE, Encoding::UTF_32BE].each do |e|
       assert_equal('"abc"', "abc".encode(e).inspect)
       assert_equal('"\\u3042\\u3044\\u3046"', "\u3042\u3044\u3046".encode(e).inspect)
+      assert_equal('"ab\\"c"', "ab\"c".encode(e).inspect, bug4081)
     end
+    begin
+      ext = Encoding.default_external
+      Encoding.default_external = "us-ascii"
+      i = "abc\"\\".force_encoding("utf-8").inspect
+    ensure
+      Encoding.default_external = ext
+    end
+    assert_equal('"abc\\"\\\\"', i, bug4081)
   end
 end

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

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