ruby-changes:62598
From: Nobuyoshi <ko1@a...>
Date: Mon, 17 Aug 2020 22:30:54 +0900 (JST)
Subject: [ruby-changes:62598] 7b4b5e0840 (master): Fixed the radix for control chars
https://git.ruby-lang.org/ruby.git/commit/?id=7b4b5e0840 From 7b4b5e08409f1df2a99c00d40f4859b584cd1dd6 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Mon, 17 Aug 2020 22:29:51 +0900 Subject: Fixed the radix for control chars diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index 2659404..81e490f 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -87,7 +87,7 @@ dump_append_string_value(struct dump_config *dc, VALUE obj) https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace_dump.c#L87 break; default: if (c <= 0x1f) - dump_append(dc, "\\u%04d", c); + dump_append(dc, "\\u%04x", c); else dump_append(dc, "%c", c); } diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index a224263..9d05a4c 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -275,6 +275,10 @@ class TestObjSpace < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/objspace/test_objspace.rb#L275 JSON.parse(info) if defined?(JSON) end + def test_dump_control_char + assert_include(ObjectSpace.dump("\x0f"), '"value":"\u000f"') + end + def test_dump_special_consts # [ruby-core:69692] [Bug #11291] assert_equal('null', ObjectSpace.dump(nil)) -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/