summaryrefslogtreecommitdiff
path: root/src/llex.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-03-24 08:57:07 +0100
committerBenoit Giannangeli <giann008@gmail.com>2017-03-24 08:57:07 +0100
commitd6af357adf720347f2b3e03c41a36dc70b5a3d33 (patch)
tree8531397db956e7ce54415236e8a70debdc2045a0 /src/llex.js
parentd3530bdc202419c85ec79fdb01197112cab8a788 (diff)
downloadfengari-d6af357adf720347f2b3e03c41a36dc70b5a3d33.tar.gz
fengari-d6af357adf720347f2b3e03c41a36dc70b5a3d33.tar.bz2
fengari-d6af357adf720347f2b3e03c41a36dc70b5a3d33.zip
\x escape sequence must store byte as is, in resulting string
Diffstat (limited to 'src/llex.js')
-rw-r--r--src/llex.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/llex.js b/src/llex.js
index 4f5b97e..9983c1d 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -480,11 +480,13 @@ const read_string = function(ls, del, seminfo) {
}
}
save_and_next(ls); /* skip delimiter */
+
seminfo.ts = new TValue(
CT.LUA_TLNGSTR,
- lua.to_luastring(
- ls.buff.buffer.slice(1, ls.buff.buffer.length-1).join('')
- )
+ ls.buff.buffer
+ .slice(1, ls.buff.n-1)
+ .map(e => typeof e === "string" ? lua.to_luastring(e) : [e])
+ .reduce((acc, e) => acc = acc.concat(e), []) /* Hex value must not be converted */
);
};
@@ -641,4 +643,4 @@ module.exports.luaX_next = luaX_next;
module.exports.luaX_setinput = luaX_setinput;
module.exports.luaX_syntaxerror = luaX_syntaxerror;
module.exports.luaX_token2str = luaX_token2str;
-module.exports.luaX_tokens = luaX_tokens; \ No newline at end of file
+module.exports.luaX_tokens = luaX_tokens;