summaryrefslogtreecommitdiff
path: root/src/llex.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-06-09 15:25:05 +1000
committerdaurnimator <quae@daurnimator.com>2017-06-09 16:18:09 +1000
commitb01bf7ef940503e373d59c912c9952582a608a77 (patch)
tree6304d51d53f9b72940fe90d78e8100b86213e3bd /src/llex.js
parentd47c82caf02bd21d05700c48a52d8be69db9ad7d (diff)
downloadfengari-b01bf7ef940503e373d59c912c9952582a608a77.tar.gz
fengari-b01bf7ef940503e373d59c912c9952582a608a77.tar.bz2
fengari-b01bf7ef940503e373d59c912c9952582a608a77.zip
src/lzio.js: Introduce luaZ_resetbuffer
Diffstat (limited to 'src/llex.js')
-rw-r--r--src/llex.js15
1 files changed, 4 insertions, 11 deletions
diff --git a/src/llex.js b/src/llex.js
index 4c2be8c..c110a7a 100644
--- a/src/llex.js
+++ b/src/llex.js
@@ -320,10 +320,7 @@ const read_long_string = function(ls, seminfo, sep) {
case char['\n']: case char['\r']: {
save(ls, char['\n']);
inclinenumber(ls);
- if (!seminfo) {
- ls.buff.n = 0;
- ls.buff.buffer = [];
- }
+ if (!seminfo) lzio.luaZ_resetbuffer(ls.buff);
break;
}
default: {
@@ -468,9 +465,7 @@ const isreserved = function(w) {
};
const llex = function(ls, seminfo) {
- ls.buff.n = 0;
- ls.buff.buffer = [];
-
+ lzio.luaZ_resetbuffer(ls.buff);
for (;;) {
assert(typeof ls.current == "number");
switch (ls.current) {
@@ -489,12 +484,10 @@ const llex = function(ls, seminfo) {
next(ls);
if (ls.current === char['[']) { /* long comment? */
let sep = skip_sep(ls);
- ls.buff.n = 0; /* 'skip_sep' may dirty the buffer */
- ls.buff.buffer = [];
+ lzio.luaZ_resetbuffer(ls.buff); /* 'skip_sep' may dirty the buffer */
if (sep >= 0) {
read_long_string(ls, null, sep); /* skip long comment */
- ls.buff.n = 0; /* previous call may dirty the buff. */
- ls.buff.buffer = [];
+ lzio.luaZ_resetbuffer(ls.buff); /* previous call may dirty the buff. */
break;
}
}