Fix mixed declarations in
MODIFY
mrbgems/mruby-test/vformat.c
mrbgems/mruby-test/vformat.c
@@ -9,8 +9,10 @@ static mrb_value
vf_s_format_0(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str;
+ const char *fmt;
+
mrb_get_args(mrb, "S", &fmt_str);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
+ fmt = RSTRING_CSTR(mrb, fmt_str);
return mrb_format(mrb, fmt);
}
@@ -20,9 +22,12 @@ static mrb_value
vf_s_format_c(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str, arg_str;
+ const char *fmt;
+ char c;
+
mrb_get_args(mrb, "SS", &fmt_str, &arg_str);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
- const char c = RSTRING_CSTR(mrb, arg_str)[0];
+ fmt = RSTRING_CSTR(mrb, fmt_str);
+ c = RSTRING_CSTR(mrb, arg_str)[0];
return mrb_format(mrb, fmt, c);
}
@@ -32,9 +37,12 @@ static mrb_value
vf_s_format_d(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str, arg_int;
+ const char *fmt;
+ int d;
+
mrb_get_args(mrb, "Si", &fmt_str, &arg_int);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
- const int d = mrb_fixnum(arg_int);
+ fmt = RSTRING_CSTR(mrb, fmt_str);
+ d = mrb_fixnum(arg_int);
return mrb_format(mrb, fmt, d);
}
@@ -45,9 +53,12 @@ static mrb_value
vf_s_format_f(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str, arg_flt;
+ const char *fmt;
+ mrb_float f;
+
mrb_get_args(mrb, "Sf", &fmt_str, &arg_flt);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
- const mrb_float f = mrb_float(arg_flt);
+ fmt = RSTRING_CSTR(mrb, fmt_str);
+ f = mrb_float(arg_flt);
return mrb_format(mrb, fmt, f);
}
@@ -58,9 +69,12 @@ static mrb_value
vf_s_format_i(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str, arg_int;
+ const char *fmt;
+ mrb_int i;
+
mrb_get_args(mrb, "Si", &fmt_str, &arg_int);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
- const mrb_int i = mrb_fixnum(arg_int);
+ fmt = RSTRING_CSTR(mrb, fmt_str);
+ i = mrb_fixnum(arg_int);
return mrb_format(mrb, fmt, i);
}
@@ -70,10 +84,14 @@ static mrb_value
vf_s_format_l(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str, arg_str, arg_int;
+ const char *fmt;
+ const char *s;
+ size_t len;
+
mrb_get_args(mrb, "SSi", &fmt_str, &arg_str, &arg_int);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
- const char *s = RSTRING_PTR(arg_str);
- size_t len = (size_t)mrb_fixnum(arg_int);
+ fmt = RSTRING_CSTR(mrb, fmt_str);
+ s = RSTRING_PTR(arg_str);
+ len = (size_t)mrb_fixnum(arg_int);
if (len > (size_t)RSTRING_LEN(arg_str)) len = (size_t)RSTRING_LEN(arg_str);
return mrb_format(mrb, fmt, s, len);
@@ -84,9 +102,12 @@ static mrb_value
vf_s_format_n(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str, arg_sym;
+ const char *fmt;
+ mrb_sym n;
+
mrb_get_args(mrb, "Sn", &fmt_str, &arg_sym);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
- const mrb_sym n = mrb_symbol(arg_sym);
+ fmt = RSTRING_CSTR(mrb, fmt_str);
+ n = mrb_symbol(arg_sym);
return mrb_format(mrb, fmt, n);
}
@@ -96,9 +117,12 @@ static mrb_value
vf_s_format_s(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str, arg_str;
+ const char *fmt;
+ const char *s;
+
mrb_get_args(mrb, "SS", &fmt_str, &arg_str);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
- const char *s = RSTRING_CSTR(mrb, arg_str);
+ fmt = RSTRING_CSTR(mrb, fmt_str);
+ s = RSTRING_CSTR(mrb, arg_str);
return mrb_format(mrb, fmt, s);
}
@@ -108,9 +132,12 @@ static mrb_value
vf_s_format_C(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str, arg_cls;
+ const char *fmt;
+ struct RClass *c;
+
mrb_get_args(mrb, "SC", &fmt_str, &arg_cls);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
- const struct RClass *c = mrb_class_ptr(arg_cls);
+ fmt = RSTRING_CSTR(mrb, fmt_str);
+ c = mrb_class_ptr(arg_cls);
return mrb_format(mrb, fmt, c);
}
@@ -120,8 +147,10 @@ static mrb_value
vf_s_format_v(mrb_state *mrb, mrb_value klass)
{
mrb_value fmt_str, arg_v;
+ const char *fmt;
+
mrb_get_args(mrb, "So", &fmt_str, &arg_v);
- const char *fmt = RSTRING_CSTR(mrb, fmt_str);
+ fmt = RSTRING_CSTR(mrb, fmt_str);
return mrb_format(mrb, fmt, arg_v);
}

Fix mixed declarations in 429f6de