From b0d9825d459eca0211947330d93dd7454b4ff5b0 Mon Sep 17 00:00:00 2001 From: daurnimator Date: Sun, 21 May 2017 20:50:05 +1000 Subject: src/lobject.js: our lua_strx2number returns null on failure --- src/lobject.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lobject.js b/src/lobject.js index 153d776..18876a9 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -311,7 +311,7 @@ const lua_strx2number = function(s) { neg = s[0] === char['-']; /* check signal */ s = neg || s[0] === char['+'] ? s.slice(1) : s; /* skip sign if one */ if (!(s[0] === char['0'] && (s[1] === char['x'] || s[1] === char['X']))) /* check '0x' */ - return 0.0; /* invalid format (no '0x') */ + return null; /* invalid format (no '0x') */ for (s = s.slice(2); ; s = s.slice(1)) { /* skip '0x' and read numeral */ if (s[0] === dot) { @@ -328,7 +328,7 @@ const lua_strx2number = function(s) { } if (nosigdig + sigdig === 0) /* no digits? */ - return 0.0; /* invalid format */ + return null; /* invalid format */ e *= 4; /* each digit multiplies/divides value by 2^4 */ if (s[0] === char['p'] || s[0] === char['P']) { /* exponent part? */ let exp1 = 0; /* exponent value */ @@ -337,7 +337,7 @@ const lua_strx2number = function(s) { neg1 = s[0] === char['-']; /* check signal */ s = neg1 || s[0] === char['+'] ? s.slice(1) : s; /* skip sign if one */ if (!ljstype.lisdigit(s[0])) - return 0.0; /* invalid; must have at least one digit */ + return null; /* invalid; must have at least one digit */ while (ljstype.lisdigit(s[0])) { /* read exponent */ exp1 = exp1 * 10 + s[0] - char['0']; s = s.slice(1); -- cgit v1.2.3-70-g09d2