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

ruby-changes:28371

From: naruse <ko1@a...>
Date: Tue, 23 Apr 2013 21:25:06 +0900 (JST)
Subject: [ruby-changes:28371] naruse:r40423 (trunk): * string.c (rb_str_inspect): refix r40413, on Ruby 1.9 usual character

naruse	2013-04-23 21:24:56 +0900 (Tue, 23 Apr 2013)

  New Revision: 40423

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

  Log:
    * string.c (rb_str_inspect): refix r40413, on Ruby 1.9 usual character
      escape uses hex/Unicode escapes, so fix to use Unicode escape on
      Unicode strings and hex on others. [ruby-core:54458] [Bug #8290]

  Modified files:
    trunk/ChangeLog
    trunk/string.c
    trunk/test/ruby/test_module.rb
    trunk/test/ruby/test_string.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40422)
+++ ChangeLog	(revision 40423)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Apr 23 21:14:38 2013  NARUSE, Yui  <naruse@r...>
+
+	* string.c (rb_str_inspect): refix r40413, on Ruby 1.9 usual character
+	  escape uses hex/Unicode escapes, so fix to use Unicode escape on
+	  Unicode strings and hex on others. [ruby-core:54458] [Bug #8290]
+
 Tue Apr 23 20:10:02 2013  Tanaka Akira  <akr@f...>
 
 	* missing/isnan.c (isnan): Don't define if isnan() macro is defined.
Index: string.c
===================================================================
--- string.c	(revision 40422)
+++ string.c	(revision 40423)
@@ -4572,11 +4572,6 @@ rb_str_inspect(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L4572
 	    }
 	}
 	switch (c) {
-	  case '\0':
-	    if (p - n > prev) str_buf_cat(result, prev, p - n - prev);
-	    str_buf_cat(result, "\\000", 4);
-	    prev = p;
-	    continue;
 	  case '\n': cc = 'n'; break;
 	  case '\r': cc = 'r'; break;
 	  case '\t': cc = 't'; break;
Index: test/ruby/test_module.rb
===================================================================
--- test/ruby/test_module.rb	(revision 40422)
+++ test/ruby/test_module.rb	(revision 40423)
@@ -609,7 +609,7 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L609
     assert_raise(TypeError, bug5084) { c1.const_get(1) }
     bug7574 = '[ruby-dev:46749]'
     e = assert_raise(NameError) { Object.const_get("String\0") }
-    assert_equal("wrong constant name \"String\\000\"", e.message, bug7574)
+    assert_equal("wrong constant name \"String\\u0000\"", e.message, bug7574)
   end
 
   def test_const_defined_invalid_name
@@ -619,7 +619,7 @@ class TestModule < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_module.rb#L619
     assert_raise(TypeError, bug5084) { c1.const_defined?(1) }
     bug7574 = '[ruby-dev:46749]'
     e = assert_raise(NameError) { Object.const_defined?("String\0") }
-    assert_equal("wrong constant name \"String\\000\"", e.message, bug7574)
+    assert_equal("wrong constant name \"String\\u0000\"", e.message, bug7574)
   end
 
   def test_const_get_no_inherited
Index: test/ruby/test_string.rb
===================================================================
--- test/ruby/test_string.rb	(revision 40422)
+++ test/ruby/test_string.rb	(revision 40423)
@@ -1986,9 +1986,11 @@ class TestString < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_string.rb#L1986
   end
 
   def test_inspect_nul
+    bug8290 = '[ruby-core:54458]'
     s = "\0" + "12"
-    assert_not_equal '"\\012"', eval(s.inspect)
-    assert_equal s, eval(s.inspect)
+    assert_equal '"\u000012"', s.inspect, bug8290
+    s = "\0".b + "12"
+    assert_equal '"\x0012"', s.inspect, bug8290
   end
 
   def test_partition

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

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