mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #1757 from cubicdaiya/issues/use_mrb_str_cat_lit
use mrb_str_cat_lit() intead of mrb_str_cat
This commit is contained in:
+6
-6
@@ -1296,7 +1296,7 @@ mrb_class_name(mrb_state *mrb, struct RClass* c)
|
||||
if (mrb_nil_p(path)) {
|
||||
path = mrb_str_new_lit(mrb, "#<Class:");
|
||||
mrb_str_concat(mrb, path, mrb_ptr_to_str(mrb, c));
|
||||
mrb_str_cat(mrb, path, ">", 1);
|
||||
mrb_str_cat_lit(mrb, path, ">");
|
||||
}
|
||||
return mrb_str_ptr(path)->ptr;
|
||||
}
|
||||
@@ -1431,7 +1431,7 @@ mrb_mod_to_s(mrb_state *mrb, mrb_value klass)
|
||||
mrb_str_append(mrb, str, mrb_any_to_s(mrb, v));
|
||||
break;
|
||||
}
|
||||
mrb_str_cat(mrb, str, ">", 1);
|
||||
mrb_str_cat_lit(mrb, str, ">");
|
||||
}
|
||||
else {
|
||||
struct RClass *c;
|
||||
@@ -1444,20 +1444,20 @@ mrb_mod_to_s(mrb_state *mrb, mrb_value klass)
|
||||
if (mrb_nil_p(path)) {
|
||||
switch (mrb_type(klass)) {
|
||||
case MRB_TT_CLASS:
|
||||
mrb_str_cat(mrb, str, "#<Class:", 8);
|
||||
mrb_str_cat_lit(mrb, str, "#<Class:");
|
||||
break;
|
||||
|
||||
case MRB_TT_MODULE:
|
||||
mrb_str_cat(mrb, str, "#<Module:", 9);
|
||||
mrb_str_cat_lit(mrb, str, "#<Module:");
|
||||
break;
|
||||
|
||||
default:
|
||||
/* Shouldn't be happened? */
|
||||
mrb_str_cat(mrb, str, "#<??????:", 9);
|
||||
mrb_str_cat_lit(mrb, str, "#<??????:");
|
||||
break;
|
||||
}
|
||||
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, c));
|
||||
mrb_str_cat(mrb, str, ">", 1);
|
||||
mrb_str_cat_lit(mrb, str, ">");
|
||||
}
|
||||
else {
|
||||
str = path;
|
||||
|
||||
+6
-6
@@ -128,26 +128,26 @@ exc_inspect(mrb_state *mrb, mrb_value exc)
|
||||
|
||||
if (!mrb_nil_p(file) && !mrb_nil_p(line)) {
|
||||
str = file;
|
||||
mrb_str_cat(mrb, str, ":", 1);
|
||||
mrb_str_cat_lit(mrb, str, ":");
|
||||
mrb_str_append(mrb, str, line);
|
||||
mrb_str_cat(mrb, str, ": ", 2);
|
||||
mrb_str_cat_lit(mrb, str, ": ");
|
||||
if (!mrb_nil_p(mesg) && RSTRING_LEN(mesg) > 0) {
|
||||
mrb_str_append(mrb, str, mesg);
|
||||
mrb_str_cat(mrb, str, " (", 2);
|
||||
mrb_str_cat_lit(mrb, str, " (");
|
||||
}
|
||||
mrb_str_cat_cstr(mrb, str, mrb_obj_classname(mrb, exc));
|
||||
if (!mrb_nil_p(mesg) && RSTRING_LEN(mesg) > 0) {
|
||||
mrb_str_cat(mrb, str, ")", 1);
|
||||
mrb_str_cat_lit(mrb, str, ")");
|
||||
}
|
||||
}
|
||||
else {
|
||||
str = mrb_str_new_cstr(mrb, mrb_obj_classname(mrb, exc));
|
||||
if (!mrb_nil_p(mesg) && RSTRING_LEN(mesg) > 0) {
|
||||
mrb_str_cat(mrb, str, ": ", 2);
|
||||
mrb_str_cat_lit(mrb, str, ": ");
|
||||
mrb_str_append(mrb, str, mesg);
|
||||
}
|
||||
else {
|
||||
mrb_str_cat(mrb, str, ": ", 2);
|
||||
mrb_str_cat_lit(mrb, str, ": ");
|
||||
mrb_str_cat_cstr(mrb, str, mrb_obj_classname(mrb, exc));
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -672,7 +672,7 @@ inspect_hash(mrb_state *mrb, mrb_value hash, int recur)
|
||||
|
||||
ai = mrb_gc_arena_save(mrb);
|
||||
|
||||
if (RSTRING_LEN(str) > 1) mrb_str_cat(mrb, str, ", ", 2);
|
||||
if (RSTRING_LEN(str) > 1) mrb_str_cat_lit(mrb, str, ", ");
|
||||
|
||||
str2 = mrb_inspect(mrb, kh_key(h,k));
|
||||
mrb_str_append(mrb, str, str2);
|
||||
|
||||
+1
-1
@@ -444,7 +444,7 @@ mrb_any_to_s(mrb_state *mrb, mrb_value obj)
|
||||
|
||||
mrb_str_buf_cat(mrb, str, "#<", 2);
|
||||
mrb_str_cat_cstr(mrb, str, cname);
|
||||
mrb_str_cat(mrb, str, ":", 1);
|
||||
mrb_str_cat_lit(mrb, str, ":");
|
||||
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, mrb_cptr(obj)));
|
||||
mrb_str_buf_cat(mrb, str, ">", 1);
|
||||
|
||||
|
||||
+5
-5
@@ -568,14 +568,14 @@ inspect_i(mrb_state *mrb, mrb_sym sym, mrb_value v, void *p)
|
||||
/* need not to show internal data */
|
||||
if (RSTRING_PTR(str)[0] == '-') { /* first element */
|
||||
RSTRING_PTR(str)[0] = '#';
|
||||
mrb_str_cat(mrb, str, " ", 1);
|
||||
mrb_str_cat_lit(mrb, str, " ");
|
||||
}
|
||||
else {
|
||||
mrb_str_cat(mrb, str, ", ", 2);
|
||||
mrb_str_cat_lit(mrb, str, ", ");
|
||||
}
|
||||
s = mrb_sym2name_len(mrb, sym, &len);
|
||||
mrb_str_cat(mrb, str, s, len);
|
||||
mrb_str_cat(mrb, str, "=", 1);
|
||||
mrb_str_cat_lit(mrb, str, "=");
|
||||
if (mrb_type(v) == MRB_TT_OBJECT) {
|
||||
ins = mrb_any_to_s(mrb, v);
|
||||
}
|
||||
@@ -598,11 +598,11 @@ mrb_obj_iv_inspect(mrb_state *mrb, struct RObject *obj)
|
||||
|
||||
mrb_str_buf_cat(mrb, str, "-<", 2);
|
||||
mrb_str_cat_cstr(mrb, str, cn);
|
||||
mrb_str_cat(mrb, str, ":", 1);
|
||||
mrb_str_cat_lit(mrb, str, ":");
|
||||
mrb_str_concat(mrb, str, mrb_ptr_to_str(mrb, obj));
|
||||
|
||||
iv_foreach(mrb, t, inspect_i, &str);
|
||||
mrb_str_cat(mrb, str, ">", 1);
|
||||
mrb_str_cat_lit(mrb, str, ">");
|
||||
return str;
|
||||
}
|
||||
return mrb_any_to_s(mrb, mrb_obj_value(obj));
|
||||
|
||||
Reference in New Issue
Block a user