diff options
| author | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-12-19 09:59:36 +0900 |
|---|---|---|
| committer | Yukihiro "Matz" Matsumoto <[email protected]> | 2019-12-19 10:00:33 +0900 |
| commit | 87809742f57fc78be9c17a0d5943dd12440a90db (patch) | |
| tree | b19188890082652bfd9cd445628be164854b6111 | |
| parent | fcde80a4d0123e17f7ad163033b2a43132571754 (diff) | |
| download | mruby-87809742f57fc78be9c17a0d5943dd12440a90db.tar.gz mruby-87809742f57fc78be9c17a0d5943dd12440a90db.zip | |
Fix mixed declarations in 429f6de
| -rw-r--r-- | mrbgems/mruby-test/vformat.c | 67 |
1 files changed, 48 insertions, 19 deletions
diff --git a/mrbgems/mruby-test/vformat.c b/mrbgems/mruby-test/vformat.c index d495779f3..7775e1fd2 100644 --- a/mrbgems/mruby-test/vformat.c +++ b/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); } |
