summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/llex.js10
-rw-r--r--src/lzio.js5
2 files changed, 10 insertions, 5 deletions
diff --git a/src/llex.js b/src/llex.js
index c110a7a..0be6ea8 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -351,7 +351,7 @@ const gethexa = function(ls) {
const readhexaesc = function(ls) {
let r = gethexa(ls);
r = (r << 4) + gethexa(ls);
- ls.buff.n -= 2; /* remove saved chars from buffer */
+ lzio.luaZ_buffremove(ls.buff, 2); /* remove saved chars from buffer */
return r;
};
@@ -370,7 +370,7 @@ const readutf8desc = function(ls) {
}
esccheck(ls, ls.current === char['}'], defs.to_luastring("missing '}'", true));
next(ls); /* skip '}' */
- ls.buff.n -= i; /* remove saved chars from buffer */
+ lzio.luaZ_buffremove(ls.buff, i); /* remove saved chars from buffer */
return r;
};
@@ -389,7 +389,7 @@ const readdecesc = function(ls) {
save_and_next(ls);
}
esccheck(ls, r <= 255, defs.to_luastring("decimal escape too large", true));
- ls.buff.n -= i; /* remove read digits from buffer */
+ lzio.luaZ_buffremove(ls.buff, i); /* remove read digits from buffer */
return r;
};
@@ -425,7 +425,7 @@ const read_string = function(ls, del, seminfo) {
c = ls.current; will = 'read_save'; break;
case lzio.EOZ: will = 'no_save'; break; /* will raise an error next loop */
case char['z']: { /* zap following span of spaces */
- ls.buff.n -= 1; /* remove '\\' */
+ lzio.luaZ_buffremove(ls.buff, 1); /* remove '\\' */
next(ls); /* skip the 'z' */
while (ljstype.lisspace(ls.current)) {
if (currIsNewline(ls)) inclinenumber(ls);
@@ -444,7 +444,7 @@ const read_string = function(ls, del, seminfo) {
next(ls);
if (will === 'read_save' || will === 'only_save') {
- ls.buff.n -= 1; /* remove '\\' */
+ lzio.luaZ_buffremove(ls.buff, 1); /* remove '\\' */
save(ls, c);
}
diff --git a/src/lzio.js b/src/lzio.js
index 72969d4..9aa25bd 100644
--- a/src/lzio.js
+++ b/src/lzio.js
@@ -10,6 +10,10 @@ class MBuffer {
}
}
+const luaZ_buffremove = function(buff, i) {
+ buff.n -= i;
+};
+
const luaZ_resetbuffer = function(buff) {
buff.n = 0;
buff.buffer = [];
@@ -80,6 +84,7 @@ const luaZ_read = function(z, b, b_offset, n) {
};
module.exports.EOZ = EOZ;
+module.exports.luaZ_buffremove = luaZ_buffremove;
module.exports.luaZ_fill = luaZ_fill;
module.exports.luaZ_read = luaZ_read;
module.exports.luaZ_resetbuffer = luaZ_resetbuffer;