aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-21 20:50:05 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-21 20:51:06 +1000
commitb0d9825d459eca0211947330d93dd7454b4ff5b0 (patch)
tree9f61ef204c4bec661f8a3aaaccfa7064f4ab341f /src
parentf7550508fef2ae2f6c64b1f5f359af5f65bb62fd (diff)
downloadfengari-b0d9825d459eca0211947330d93dd7454b4ff5b0.tar.gz
fengari-b0d9825d459eca0211947330d93dd7454b4ff5b0.tar.bz2
fengari-b0d9825d459eca0211947330d93dd7454b4ff5b0.zip
src/lobject.js: our lua_strx2number returns null on failure
Diffstat (limited to 'src')
-rw-r--r--src/lobject.js6
1 files 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);