diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/codegen.c | 2 | ||||
| -rw-r--r-- | src/error.c | 15 | ||||
| -rw-r--r-- | src/re.h | 12 | ||||
| -rw-r--r-- | src/string.c | 2 |
4 files changed, 12 insertions, 19 deletions
diff --git a/src/codegen.c b/src/codegen.c index c869285d9..a36d609c6 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -16,7 +16,7 @@ #include "mruby/debug.h" #include "node.h" #include "opcode.h" -#include "re.h" +#include "mruby/re.h" #include "mrb_throw.h" typedef mrb_ast_node node; diff --git a/src/error.c b/src/error.c index feec9dbc5..feaa61122 100644 --- a/src/error.c +++ b/src/error.c @@ -127,7 +127,12 @@ exc_inspect(mrb_state *mrb, mrb_value exc) mesg = mrb_attr_get(mrb, exc, mrb_intern_lit(mrb, "mesg")); file = mrb_attr_get(mrb, exc, mrb_intern_lit(mrb, "file")); line = mrb_attr_get(mrb, exc, mrb_intern_lit(mrb, "line")); - append_mesg = !mrb_nil_p(mesg) && RSTRING_LEN(mesg) > 0; + + append_mesg = !mrb_nil_p(mesg); + if (append_mesg) { + mesg = mrb_obj_as_string(mrb, mesg); + append_mesg = RSTRING_LEN(mesg) > 0; + } if (!mrb_nil_p(file) && !mrb_nil_p(line)) { str = mrb_str_dup(mrb, file); @@ -144,14 +149,14 @@ exc_inspect(mrb_state *mrb, mrb_value exc) } } else { - str = mrb_str_new_cstr(mrb, mrb_obj_classname(mrb, exc)); + const char *cname = mrb_obj_classname(mrb, exc); + str = mrb_str_new_cstr(mrb, cname); + mrb_str_cat_lit(mrb, str, ": "); if (append_mesg) { - mrb_str_cat_lit(mrb, str, ": "); mrb_str_append(mrb, str, mesg); } else { - mrb_str_cat_lit(mrb, str, ": "); - mrb_str_cat_cstr(mrb, str, mrb_obj_classname(mrb, exc)); + mrb_str_cat_cstr(mrb, str, cname); } } return str; diff --git a/src/re.h b/src/re.h deleted file mode 100644 index ee2638b22..000000000 --- a/src/re.h +++ /dev/null @@ -1,12 +0,0 @@ -/* -** re.h - Regexp class -** -** See Copyright Notice in mruby.h -*/ - -#ifndef RE_H -#define RE_H - -#define REGEXP_CLASS "Regexp" - -#endif /* RE_H */ diff --git a/src/string.c b/src/string.c index ebc579ec5..9c206157e 100644 --- a/src/string.c +++ b/src/string.c @@ -14,7 +14,7 @@ #include "mruby/class.h" #include "mruby/range.h" #include "mruby/string.h" -#include "re.h" +#include "mruby/re.h" #define STR_EMBED_P(s) ((s)->flags & MRB_STR_EMBED) #define STR_SET_EMBED_FLAG(s) ((s)->flags |= MRB_STR_EMBED) |
