Unverified Commit a3434399 authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto Committed by GitHub

Merge pull request #4985 from dearblue/print-gems

Makes `mrb_any_to_s()` accept an object whose class is `NULL`
parents e2ac2a82 49b2e8c3
...@@ -1728,7 +1728,10 @@ mrb_class_real(struct RClass* cl) ...@@ -1728,7 +1728,10 @@ mrb_class_real(struct RClass* cl)
MRB_API const char* MRB_API const char*
mrb_class_name(mrb_state *mrb, struct RClass* c) mrb_class_name(mrb_state *mrb, struct RClass* c)
{ {
mrb_value name = class_name_str(mrb, c); mrb_value name;
if (c == NULL) return NULL;
name = class_name_str(mrb, c);
return RSTRING_PTR(name); return RSTRING_PTR(name);
} }
......
...@@ -2759,7 +2759,7 @@ mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len) ...@@ -2759,7 +2759,7 @@ mrb_str_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
MRB_API mrb_value MRB_API mrb_value
mrb_str_cat_cstr(mrb_state *mrb, mrb_value str, const char *ptr) mrb_str_cat_cstr(mrb_state *mrb, mrb_value str, const char *ptr)
{ {
return mrb_str_cat(mrb, str, ptr, strlen(ptr)); return mrb_str_cat(mrb, str, ptr, ptr ? strlen(ptr) : 0);
} }
MRB_API mrb_value MRB_API mrb_value
......
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