Skip to content

Commit

Permalink
Fix mixed declarations in 429f6de
Browse files Browse the repository at this point in the history
  • Loading branch information
matz committed Dec 19, 2019
1 parent fcde80a commit 8780974
Showing 1 changed file with 48 additions and 19 deletions.
67 changes: 48 additions & 19 deletions mrbgems/mruby-test/vformat.c
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 8780974

Please sign in to comment.