From 456ab7b69f88859683c60cc2261e70d6dbadd8e8 Mon Sep 17 00:00:00 2001 From: Benoit Giannangeli Date: Wed, 29 Mar 2017 14:39:57 +0200 Subject: 8-bit string internally tests Lexing/Parsing is done on byte rather than js strings --- src/lobject.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/lobject.js') diff --git a/src/lobject.js b/src/lobject.js index 812ac6a..e958975 100644 --- a/src/lobject.js +++ b/src/lobject.js @@ -132,6 +132,8 @@ const luaO_nilobject = new TValue(CT.LUA_TNIL, null); module.exports.luaO_nilobject = luaO_nilobject; const jsstring = function(value, from, to) { + assert(Array.isArray(value), "jsstring expect a array of bytes"); + let u0, u1, u2, u3, u4, u5; let idx = 0; value = value.slice(from ? from : 0, to); @@ -194,6 +196,8 @@ class Table extends TValue { } } else if (typeof key === "string") { // To avoid key = lua.to_luastring(key).map(e => `${e}|`).join(''); + } else if (Array.isArray(key)) { + key = key.map(e => `${e}|`).join(''); } return key; @@ -293,7 +297,7 @@ const luaO_chunkid = function(source, bufflen) { else { /* truncate it */ out = out.concat(source.slice(1, bufflen)); } - } else if (source.charAt(0) === '@') { /* file name */ + } else if (source[0] === '@'.charCodeAt(0)) { /* file name */ if (l <= bufflen) /* small enough? */ out = source.slice(1); else { /* add '...' before rest of name */ -- cgit v1.2.3-54-g00ecf