ruby-changes:31773
From: tmm1 <ko1@a...>
Date: Tue, 26 Nov 2013 14:27:28 +0900 (JST)
Subject: [ruby-changes:31773] tmm1:r43852 (trunk): * ext/objspace/objspace_dump.c (dump_append_string_value): Escape
tmm1 2013-11-26 14:27:22 +0900 (Tue, 26 Nov 2013) New Revision: 43852 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=43852 Log: * ext/objspace/objspace_dump.c (dump_append_string_value): Escape control characters for strict json parsers. * ext/objspace/objspace_dump.c (objspace_dump): Document File/IO output option. Modified files: trunk/ChangeLog trunk/ext/objspace/objspace_dump.c Index: ChangeLog =================================================================== --- ChangeLog (revision 43851) +++ ChangeLog (revision 43852) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Nov 26 14:23:17 2013 Aman Gupta <ruby@t...> + + * ext/objspace/objspace_dump.c (dump_append_string_value): Escape + control characters for strict json parsers. + * ext/objspace/objspace_dump.c (objspace_dump): Document File/IO + output option. + Tue Nov 26 11:43:19 2013 Masaki Matsushita <glass.saga@g...> * ruby_atomic.h: use __atomic builtin functions supported by GCC. Index: ext/objspace/objspace_dump.c =================================================================== --- ext/objspace/objspace_dump.c (revision 43851) +++ ext/objspace/objspace_dump.c (revision 43852) @@ -82,7 +82,10 @@ dump_append_string_value(struct dump_con https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace_dump.c#L82 dump_append(dc, "\\r"); break; default: - dump_append(dc, "%c", c); + if (c <= 0x1f) + dump_append(dc, "\\u%04d", c); + else + dump_append(dc, "%c", c); } } dump_append(dc, "\""); @@ -362,6 +365,8 @@ objspace_dump(int argc, VALUE *argv, VAL https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace_dump.c#L365 * ObjectSpace.dump_all([output: :file]) # => #<File:/tmp/rubyheap20131125-88469-laoj3v.json> * ObjectSpace.dump_all(output: :stdout) # => nil * ObjectSpace.dump_all(output: :string) # => "{...}\n{...}\n..." + * ObjectSpace.dump_all(output: + * File.open('heap.json','w')) # => #<File:heap.json> * * Dump the contents of the ruby heap as JSON. * -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/