mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
stop using strtol (via readint) except in load.c; use custom readint_float
This commit is contained in:
@@ -19,7 +19,6 @@ typedef double mrb_float;
|
||||
|
||||
typedef int mrb_int;
|
||||
typedef intptr_t mrb_sym;
|
||||
#define readint(p,base) strtol((p),NULL,(base))
|
||||
|
||||
#undef PARSER_DUMP /* do not print out parser state */
|
||||
//#define PARSER_DUMP /* print out parser state */
|
||||
|
||||
+11
-8
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -413,7 +413,7 @@ read_rite_irep_record(mrb_state *mrb, unsigned char *src, mrb_irep *irep, uint32
|
||||
|
||||
switch (tt) { //pool data
|
||||
case MRB_TT_FIXNUM:
|
||||
fix_num = readint(buf, 10);
|
||||
fix_num = strtol(buf, NULL, 10);
|
||||
irep->pool[i] = mrb_fixnum_value(fix_num);
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user