mrb_p() should print mrb_obj_as_string() if #inspect does not return a string value

This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-12-12 21:32:02 +09:00
parent 9723d6e4ba
commit 4078670bca
+7 -2
View File
@@ -27,8 +27,13 @@ MRB_API void
mrb_p(mrb_state *mrb, mrb_value obj)
{
#ifdef ENABLE_STDIO
obj = mrb_funcall(mrb, obj, "inspect", 0);
printstr(mrb, obj);
mrb_value val;
val = mrb_funcall(mrb, obj, "inspect", 0);
if (!mrb_string_p(val)) {
val = mrb_obj_as_string(mrb, obj);
}
printstr(mrb, val);
putc('\n', stdout);
#endif
}