Skip to content
Browse files

mrb_get_args(i) should convert using to_int

  • Loading branch information...
1 parent b780e63 commit a18ab06a23c53dc7615e183b1e9cfcb0652f8650 @matz matz committed May 5, 2012
Showing with 18 additions and 3 deletions.
  1. +18 −3 src/class.c
View
21 src/class.c
@@ -357,7 +357,22 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
mrb_int *p;
p = va_arg(ap, mrb_int*);
- *p = (argc > i) ? mrb_fixnum(*sp) : 0;
+ switch (sp->tt) {
+ case MRB_TT_FIXNUM:
+ *p = mrb_fixnum(*sp);
+ break;
+ case MRB_TT_FLOAT:
+ *p = (mrb_int)mrb_float(*sp);
+ break;
+ default:
+ {
+ mrb_value tmp;
+
+ tmp = mrb_convert_type(mrb, *sp, MRB_TT_FIXNUM, "Integer", "to_int");
+ *p = mrb_fixnum(tmp);
+ }
+ break;
+ }
i++; sp++;
}
break;
@@ -368,10 +383,10 @@ mrb_get_args(mrb_state *mrb, const char *format, ...)
p = va_arg(ap, mrb_float*);
switch (sp->tt) {
case MRB_TT_FLOAT:
- *p = (argc > i) ? mrb_float(*sp) : 0;
+ *p = mrb_float(*sp);
break;
case MRB_TT_FIXNUM:
- *p = (argc > i) ? (mrb_float)mrb_fixnum(*sp) : 0;
+ *p = (mrb_float)mrb_fixnum(*sp);
break;
default:
{

0 comments on commit a18ab06

Please sign in to comment.
Something went wrong with that request. Please try again.