From 6919ca61edb2da9ea81217fdc355eef1208a6398 Mon Sep 17 00:00:00 2001 From: Yukihiro Matsumoto Date: Wed, 13 Jun 2012 23:16:53 +0900 Subject: stop using strtol (via readint) except in load.c; use custom readint_float --- src/codegen.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/codegen.c') diff --git a/src/codegen.c b/src/codegen.c index 5f8d17314..63531eac1 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -1575,16 +1575,18 @@ codegen(codegen_scope *s, node *tree, int val) if (val) { char *p = (char*)tree->car; int base = (intptr_t)tree->cdr->car; - long i = readint(p, base); + mrb_float f; + mrb_int i; mrb_code co; - if ((i == LONG_MAX && errno == ERANGE) || !FIXABLE(i)) { - mrb_float f = readint_float(s, p, base); + f = readint_float(s, p, base); + if (!FIXABLE(f)) { int off = new_lit(s, mrb_float_value(f)); genop(s, MKOP_ABx(OP_LOADL, cursp(), off)); } else { + i = (mrb_int)f; if (i < MAXARG_sBx && i > -MAXARG_sBx) { co = MKOP_AsBx(OP_LOADI, cursp(), i); } @@ -1629,17 +1631,18 @@ codegen(codegen_scope *s, node *tree, int val) { char *p = (char*)tree->car; int base = (intptr_t)tree->cdr->car; - long i = readint(p, base); + mrb_float f; + mrb_int i; mrb_code co; - if ((i == LONG_MAX && errno == ERANGE) || !FIXABLE(i)) { - mrb_float f = readint_float(s, p, base); + f = readint_float(s, p, base); + if (!FIXABLE(f)) { int off = new_lit(s, mrb_float_value(-f)); - + genop(s, MKOP_ABx(OP_LOADL, cursp(), off)); } else { - i = -i; + i = (mrb_int)-f; if (i < MAXARG_sBx && i > -MAXARG_sBx) { co = MKOP_AsBx(OP_LOADI, cursp(), i); } -- cgit v1.2.3