From bfab4a4be407a0f68bef3f2d6ba6d8ea64241858 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 18 Jan 2014 15:15:30 +0100 Subject: [PATCH] Fix bug in number parsing. --- jslex.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/jslex.c b/jslex.c index 34a9601..1b76c74 100644 --- a/jslex.c +++ b/jslex.c @@ -245,7 +245,7 @@ static inline double lexexponent(js_State *J, const char **sp) static inline int lexnumber(js_State *J, const char **sp) { - double n = 0; + double n; if (ACCEPT('0')) { if (ACCEPT('x') || ACCEPT('X')) { @@ -254,9 +254,11 @@ static inline int lexnumber(js_State *J, const char **sp) } if (isdec(PEEK)) return jsP_error(J, "number with leading zero"); - } - - if (ACCEPT('.')) { + n = 0; + if (ACCEPT('.')) + n += lexfraction(J, sp); + n *= pow(10, lexexponent(J, sp)); + } else if (ACCEPT('.')) { if (!isdec(PEEK)) return '.'; n = lexfraction(J, sp);