summaryrefslogtreecommitdiff
path: root/src/lobject.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-21 20:49:22 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-21 20:51:02 +1000
commitf7550508fef2ae2f6c64b1f5f359af5f65bb62fd (patch)
tree64be33e524df651fa70a3f9f8630a0dd91a3e1cf /src/lobject.js
parent93c8906ca2f77270054edb9f7669ca9b06f80b6f (diff)
downloadfengari-f7550508fef2ae2f6c64b1f5f359af5f65bb62fd.tar.gz
fengari-f7550508fef2ae2f6c64b1f5f359af5f65bb62fd.tar.bz2
fengari-f7550508fef2ae2f6c64b1f5f359af5f65bb62fd.zip
src/lobject.js: Check that there is no trailing junk from lua_strx2number
Also stop adding trailing null byte in llex.js
Diffstat (limited to 'src/lobject.js')
-rw-r--r--src/lobject.js5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lobject.js b/src/lobject.js
index 0898a15..153d776 100644
--- a/src/lobject.js
+++ b/src/lobject.js
@@ -346,7 +346,8 @@ const lua_strx2number = function(s) {
e += exp1;
}
if (neg) r = -r;
- return defs.to_jsstring(s).trim().search(/s/) < 0 ? luaconf.ldexp(r, e) : null; /* Only valid if nothing left is s*/
+ while (ljstype.lisspace(s[0])) s = s.slice(1); /* skip trailing spaces */
+ return s.length === 0 ? luaconf.ldexp(r, e) : null; /* Only valid if nothing left is s*/
};
const l_str2dloc = function(s, mode) {
@@ -401,7 +402,7 @@ const l_str2int = function(s) {
while (ljstype.lisspace(s[0])) s = s.slice(1); /* skip trailing spaces */
- if (empty || (s.length > 0 && s[0] !== 0)) return null; /* something wrong in the numeral */
+ if (empty || (s.length !== 0)) return null; /* something wrong in the numeral */
else {
return (neg ? -a : a)|0;
}