mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-bin-mirb: combine variable declaration with initialization
This commit is contained in:
@@ -114,10 +114,7 @@ get_history_path(mrb_state *mrb)
|
||||
static void
|
||||
p(mrb_state *mrb, mrb_value obj)
|
||||
{
|
||||
mrb_value val;
|
||||
char* msg;
|
||||
|
||||
val = mrb_funcall_argv(mrb, obj, MRB_SYM(inspect), 0, NULL);
|
||||
mrb_value val = mrb_funcall_argv(mrb, obj, MRB_SYM(inspect), 0, NULL);
|
||||
if (!mrb->exc) {
|
||||
fputs(" => ", stdout);
|
||||
}
|
||||
@@ -127,7 +124,7 @@ p(mrb_state *mrb, mrb_value obj)
|
||||
if (!mrb_string_p(val)) {
|
||||
val = mrb_obj_as_string(mrb, obj);
|
||||
}
|
||||
msg = mrb_locale_from_utf8(RSTRING_PTR(val), (int)RSTRING_LEN(val));
|
||||
char* msg = mrb_locale_from_utf8(RSTRING_PTR(val), (int)RSTRING_LEN(val));
|
||||
fwrite(msg, strlen(msg), 1, stdout);
|
||||
mrb_locale_free(msg);
|
||||
putc('\n', stdout);
|
||||
@@ -136,14 +133,11 @@ p(mrb_state *mrb, mrb_value obj)
|
||||
static void
|
||||
p_error(mrb_state *mrb, struct RObject* exc)
|
||||
{
|
||||
mrb_value val;
|
||||
char* msg;
|
||||
|
||||
val = mrb_exc_get_output(mrb, exc);
|
||||
mrb_value val = mrb_exc_get_output(mrb, exc);
|
||||
if (!mrb_string_p(val)) {
|
||||
val = mrb_obj_as_string(mrb, val);
|
||||
}
|
||||
msg = mrb_locale_from_utf8(RSTRING_PTR(val), (int)RSTRING_LEN(val));
|
||||
char* msg = mrb_locale_from_utf8(RSTRING_PTR(val), (int)RSTRING_LEN(val));
|
||||
fwrite(msg, strlen(msg), 1, stdout);
|
||||
mrb_locale_free(msg);
|
||||
putc('\n', stdout);
|
||||
|
||||
Reference in New Issue
Block a user