Commit 5e8d2a4b authored by cremno's avatar cremno

refactor code to call mrb_inspect() instead

mrb_inspect() also calls mrb_obj_as_string() after #inspect to ensure
the mrb_value is a string.
parent d2433a77
......@@ -11,12 +11,8 @@
static void
p(mrb_state *mrb, mrb_value obj)
{
mrb_value val;
mrb_value val = mrb_inspect(mrb, obj);
val = mrb_funcall(mrb, obj, "inspect", 0);
if (!mrb_string_p(val)) {
val = mrb_obj_as_string(mrb, obj);
}
fwrite(RSTRING_PTR(val), RSTRING_LEN(val), 1, stdout);
putc('\n', stdout);
}
......
......@@ -27,12 +27,8 @@ MRB_API void
mrb_p(mrb_state *mrb, mrb_value obj)
{
#ifdef ENABLE_STDIO
mrb_value val;
mrb_value val = mrb_inspect(mrb, obj);
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment