aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-05-15 14:50:53 +1000
committerdaurnimator <quae@daurnimator.com>2017-05-15 14:50:53 +1000
commit3947c2cb2fa6193645ac30898064e3d335a63545 (patch)
treee392a1b1d82f0defea0ca5d7caa171988c9e5fbe
parent874cec3fc683671f6d5e540b7f854461a9c5544e (diff)
downloadfengari-3947c2cb2fa6193645ac30898064e3d335a63545.tar.gz
fengari-3947c2cb2fa6193645ac30898064e3d335a63545.tar.bz2
fengari-3947c2cb2fa6193645ac30898064e3d335a63545.zip
src/lauxlib.js: Move binary signature check before line correction
-rw-r--r--src/lauxlib.js8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/lauxlib.js b/src/lauxlib.js
index 23cd041..3019bf3 100644
--- a/src/lauxlib.js
+++ b/src/lauxlib.js
@@ -791,12 +791,12 @@ if (!WEB) {
}
try {
- let com;
- if ((com = skipcomment(lf)).skipped) /* read initial portion */
- lf.buff[lf.n++] = '\n'.charCodeAt(0); /* add line to correct line numbers */
-
+ let com = skipcomment(lf);
+ /* check for signature first, as we don't want to add line number corrections in binary case */
if (com.c === lua.LUA_SIGNATURE.charCodeAt(0) && filename) { /* binary file? */
lf.binary = true;
+ } else if (com.skipped) { /* read initial portion */
+ lf.buff[lf.n++] = '\n'.charCodeAt(0); /* add line to correct line numbers */
}
if (com.c !== null)
lf.buff[lf.n++] = com.c; /* 'c' is the first character of the stream */