do not use "to_f" to retrieve floats in mrb_get_args(); close #1965

This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-03-28 11:04:15 +09:00
parent b8e434a5e6
commit 514cafe6c3
3 changed files with 3 additions and 20 deletions
+1
View File
@@ -23,6 +23,7 @@ mrb_value mrb_fixnum_plus(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_fixnum_minus(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_fixnum_mul(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_value mrb_num_div(mrb_state *mrb, mrb_value x, mrb_value y);
mrb_float mrb_to_flo(mrb_state *mrb, mrb_value x);
#if defined(__cplusplus)
} /* extern "C" { */
+1 -19
View File
@@ -568,25 +568,7 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p = va_arg(ap, mrb_float*);
if (i < argc) {
switch (mrb_type(*sp)) {
case MRB_TT_FLOAT:
*p = mrb_float(*sp);
break;
case MRB_TT_FIXNUM:
*p = (mrb_float)mrb_fixnum(*sp);
break;
case MRB_TT_STRING:
mrb_raise(mrb, E_TYPE_ERROR, "no implicit conversion of String into Float");
break;
default:
{
mrb_value tmp;
tmp = mrb_convert_type(mrb, *sp, MRB_TT_FLOAT, "Float", "to_f");
*p = mrb_float(tmp);
}
break;
}
*p = mrb_to_flo(mrb, *sp);
sp++;
i++;
}
+1 -1
View File
@@ -27,7 +27,7 @@
#define FLO_EPSILON DBL_EPSILON
#endif
static mrb_float
mrb_float
mrb_to_flo(mrb_state *mrb, mrb_value val)
{
switch (mrb_type(val)) {