summaryrefslogtreecommitdiff
path: root/ext/objspace
diff options
context:
space:
mode:
authortmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-26 05:27:22 +0000
committertmm1 <tmm1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-11-26 05:27:22 +0000
commitadcd0174b97e09f3f1f1651f9d2399167ac313ee (patch)
treedec21f5fb66fe7a6e67b9d15eddcaf1242e34d0e /ext/objspace
parent0791c940ad9c4749e72accb91c7e22e684fde668 (diff)
* 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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/objspace')
-rw-r--r--ext/objspace/objspace_dump.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c
index 7b0992c..a9906b8 100644
--- a/ext/objspace/objspace_dump.c
+++ b/ext/objspace/objspace_dump.c
@@ -82,7 +82,10 @@ dump_append_string_value(struct dump_config *dc, VALUE obj)
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, VALUE os)
* 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.
*