Fix broken support of `MRB_WITHOUT_FLOAT`; fix #4015

parent 50a9c5d7
......@@ -20,9 +20,11 @@ enum_update_hash(mrb_state *mrb, mrb_value self)
if (mrb_fixnum_p(item_hash)) {
hv = mrb_fixnum(item_hash);
}
#ifndef MRB_WITHOUT_FLOAT
else if (mrb_float_p(item_hash)) {
hv = (mrb_int)mrb_float(item_hash);
}
#endif
else {
mrb_raise(mrb, E_TYPE_ERROR, "can't calculate hash");
}
......
......@@ -128,8 +128,13 @@ read_irep_record_1(mrb_state *mrb, const uint8_t *bin, size_t *len, uint8_t flag
switch (tt) { /* pool data */
case IREP_TT_FIXNUM: {
mrb_value num = mrb_str_to_inum(mrb, s, 10, FALSE);
#ifdef MRB_WITHOUT_FLOAT
irep->pool[i] = num;
#else
irep->pool[i] = mrb_float_p(num)? mrb_float_pool(mrb, mrb_float(num)) : num;
} break;
#endif
}
break;
#ifndef MRB_WITHOUT_FLOAT
case IREP_TT_FLOAT:
......
......@@ -2167,10 +2167,13 @@ mrb_str_len_to_inum(mrb_state *mrb, const char *str, mrb_int len, mrb_int base,
n *= base;
n += c;
if (n > (uint64_t)MRB_INT_MAX + (sign ? 0 : 1)) {
#ifndef MRB_WITHOUT_FLOAT
if (base == 10) {
return mrb_float_value(mrb, mrb_str_to_dbl(mrb, mrb_str_new(mrb, str, len), badcheck));
}
else {
else
#endif
{
mrb_raisef(mrb, E_ARGUMENT_ERROR, "string (%S) too big for integer",
mrb_str_new(mrb, str, pend-str));
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment