use new mrb_format API from mrb_raisef; its only format specifier is "%S" (stringify) and takes mrb_value; close #1062

This commit is contained in:
Yukihiro Matz Matsumoto
2013-03-27 23:41:23 +09:00
parent 8ce842a5d9
commit 18b2683b97
12 changed files with 70 additions and 68 deletions
+4 -8
View File
@@ -281,16 +281,12 @@ void
mrb_raisef(mrb_state *mrb, struct RClass *c, const char *fmt, ...)
{
va_list args;
char buf[256];
int n;
mrb_value mesg;
va_start(args, fmt);
n = vsnprintf(buf, sizeof(buf), fmt, args);
mesg = mrb_vformat(mrb, fmt, args);
va_end(args);
if (n < 0) {
n = 0;
}
mrb_exc_raise(mrb, mrb_exc_new(mrb, c, buf, n));
mrb_exc_raise(mrb, mrb_exc_new3(mrb, c, mesg));
}
void
@@ -393,7 +389,7 @@ exception_call:
break;
default:
mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%d for 0..3)", argc);
mrb_raisef(mrb, E_ARGUMENT_ERROR, "wrong number of arguments (%S for 0..3)", mrb_fixnum_value(argc));
break;
}
if (argc > 0) {