ref: bfab4a4be407a0f68bef3f2d6ba6d8ea64241858
parent: 63d88a9c1b48234e50ef3e349c546f5e9fee1bea
author: Tor Andersson <[email protected]>
date: Sat Jan 18 10:15:30 EST 2014
Fix bug in number parsing.
--- a/jslex.c
+++ b/jslex.c
@@ -245,7 +245,7 @@
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 @@
}
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);