mirror of
https://github.com/ccxvii/mujs.git
synced 2026-09-24 17:43:36 +08:00
Fix bug in number parsing.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user