summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-23 12:24:56 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-23 12:24:56 +0000
commita5fadaadd368d0a96d7e3bc3edfdc92ae22f44ce (patch)
tree5166fcd26432715a2f711efca4b0e3873e24c371
parentbac8fa5f9db55f8f7a9100fcb0e9cc43846442f0 (diff)
* 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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--string.c5
-rw-r--r--test/ruby/test_module.rb4
-rw-r--r--test/ruby/test_string.rb6
4 files changed, 12 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a756a8ec7..b8f30c1dc7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Apr 23 21:14:38 2013 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@fsij.org>
* missing/isnan.c (isnan): Don't define if isnan() macro is defined.
diff --git a/string.c b/string.c
index 22e98f2569..42798385fa 100644
--- a/string.c
+++ b/string.c
@@ -4572,11 +4572,6 @@ rb_str_inspect(VALUE str)
}
}
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;
diff --git a/test/ruby/test_module.rb b/test/ruby/test_module.rb
index 75fd81247a..0bb27be968 100644
--- a/test/ruby/test_module.rb
+++ b/test/ruby/test_module.rb
@@ -609,7 +609,7 @@ class TestModule < Test::Unit::TestCase
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
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
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb
index f1ed82a4dd..651ab7c90c 100644
--- a/test/ruby/test_string.rb
+++ b/test/ruby/test_string.rb
@@ -1986,9 +1986,11 @@ class TestString < Test::Unit::TestCase
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