aboutsummaryrefslogtreecommitdiff
path: root/src/ldo.js
diff options
context:
space:
mode:
authorBenoit Giannangeli <giann008@gmail.com>2017-03-29 14:39:57 +0200
committerBenoit Giannangeli <giann008@gmail.com>2017-03-30 09:57:53 +0200
commit456ab7b69f88859683c60cc2261e70d6dbadd8e8 (patch)
tree12baf4ae489e7afd4819ec94bc413c1c2a1db05d /src/ldo.js
parent2e5b595a2e04fe72555a565af4aae43560946473 (diff)
downloadfengari-456ab7b69f88859683c60cc2261e70d6dbadd8e8.tar.gz
fengari-456ab7b69f88859683c60cc2261e70d6dbadd8e8.tar.bz2
fengari-456ab7b69f88859683c60cc2261e70d6dbadd8e8.zip
8-bit string internally tests
Lexing/Parsing is done on byte rather than js strings
Diffstat (limited to 'src/ldo.js')
-rw-r--r--src/ldo.js10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/ldo.js b/src/ldo.js
index 54d1ac0..6a74cad 100644
--- a/src/ldo.js
+++ b/src/ldo.js
@@ -519,8 +519,8 @@ class SParser {
}
const checkmode = function(L, mode, x) {
- if (mode && mode.indexOf(x.charCodeAt(0)) === -1) {
- lapi.lua_pushstring(L, lua.to_luastring(`attempt to load a ${lobject.jsstring(x)} chunk (mode is '${mode}')`));
+ if (mode && mode.indexOf(x[0]) === -1) {
+ lapi.lua_pushstring(L, lua.to_luastring(`attempt to load a ${lobject.jsstring(x)} chunk (mode is '${lobject.jsstring(mode)}')`));
luaD_throw(L, TS.LUA_ERRSYNTAX);
}
};
@@ -528,11 +528,11 @@ const checkmode = function(L, mode, x) {
const f_parser = function(L, p) {
let cl;
let c = p.z.getc(); /* read first character */
- if (String.fromCharCode(c) === lua.LUA_SIGNATURE.charAt(0)) {
- checkmode(L, p.mode, "binary");
+ if (c === lua.LUA_SIGNATURE.charCodeAt(0)) {
+ checkmode(L, p.mode, lua.to_luastring("binary"));
cl = new BytecodeParser(L, p.z.buffer).luaU_undump();
} else {
- checkmode(L, p.mode, "text");
+ checkmode(L, p.mode, lua.to_luastring("text"));
cl = lparser.luaY_parser(L, p.z, p.buff, p.dyd, p.name, c);
}