diff options
author | Mike Pall <mike> | 2012-08-25 23:02:29 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-08-25 23:02:29 +0200 |
commit | 4c882fe71406a923f07c8e9a0b9189036e0ba386 (patch) | |
tree | 22aa3995b5bdc2fce05ba17488799e67abc635ba /src/lib_base.c | |
parent | 653facd0d5c1a4f7eae43eefbf8148f57e28e606 (diff) | |
download | luajit-4c882fe71406a923f07c8e9a0b9189036e0ba386.tar.gz luajit-4c882fe71406a923f07c8e9a0b9189036e0ba386.tar.bz2 luajit-4c882fe71406a923f07c8e9a0b9189036e0ba386.zip |
Replace strtod() with builtin string to number conversion.
Diffstat (limited to 'src/lib_base.c')
-rw-r--r-- | src/lib_base.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lib_base.c b/src/lib_base.c index 383955d4..9702c5b4 100644 --- a/src/lib_base.c +++ b/src/lib_base.c | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "lj_ff.h" | 31 | #include "lj_ff.h" |
32 | #include "lj_dispatch.h" | 32 | #include "lj_dispatch.h" |
33 | #include "lj_char.h" | 33 | #include "lj_char.h" |
34 | #include "lj_strscan.h" | ||
34 | #include "lj_lib.h" | 35 | #include "lj_lib.h" |
35 | 36 | ||
36 | /* -- Base library: checks ------------------------------------------------ */ | 37 | /* -- Base library: checks ------------------------------------------------ */ |
@@ -191,7 +192,7 @@ LJLIB_ASM(tonumber) LJLIB_REC(.) | |||
191 | int32_t base = lj_lib_optint(L, 2, 10); | 192 | int32_t base = lj_lib_optint(L, 2, 10); |
192 | if (base == 10) { | 193 | if (base == 10) { |
193 | TValue *o = lj_lib_checkany(L, 1); | 194 | TValue *o = lj_lib_checkany(L, 1); |
194 | if (tvisnumber(o) || (tvisstr(o) && lj_str_tonumber(strV(o), o))) { | 195 | if (lj_strscan_numberobj(o)) { |
195 | copyTV(L, L->base-1, o); | 196 | copyTV(L, L->base-1, o); |
196 | return FFH_RES(1); | 197 | return FFH_RES(1); |
197 | } | 198 | } |