summaryrefslogtreecommitdiff
path: root/src/loslib.js
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-15 14:57:13 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-15 14:57:13 +1100
commite0e5d05626fcd6cb4622abcaae9fc951d9ae91b1 (patch)
tree49531b2a69c166ad193adddf50edbadb5e1a91a1 /src/loslib.js
parent6099ba186c38c854332ec483edd6cbca3cf94871 (diff)
parent8249248f80467f1660509a30623f40bb9ff1eba7 (diff)
downloadfengari-e0e5d05626fcd6cb4622abcaae9fc951d9ae91b1.tar.gz
fengari-e0e5d05626fcd6cb4622abcaae9fc951d9ae91b1.tar.bz2
fengari-e0e5d05626fcd6cb4622abcaae9fc951d9ae91b1.zip
Merge branch 'Uint8Array'
Diffstat (limited to 'src/loslib.js')
-rw-r--r--src/loslib.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/loslib.js b/src/loslib.js
index 19dfd02..f27a7ed 100644
--- a/src/loslib.js
+++ b/src/loslib.js
@@ -73,7 +73,7 @@ const checkoption = function(L, conv, i, buff) {
if (option[o] === '|'.charCodeAt(0)) /* next block? */
oplen++; /* will check options with next length (+1) */
else if (array_cmp(conv, i, option, o, oplen)) { /* match? */
- buff.push(...conv.slice(i, i+oplen)); /* copy valid option to buffer */
+ buff.set(conv.slice(i, i+oplen)); /* copy valid option to buffer */
return i + oplen; /* return next item */
}
}
@@ -102,6 +102,8 @@ const os_date = function(L) {
lua.lua_createtable(L, 0, 9); /* 9 = number of fields */
setallfields(L, stm, utc);
} else {
+ let cc = new Uint8Array(4);
+ cc[0] = "%".charCodeAt(0);
let b = new lauxlib.luaL_Buffer();
lauxlib.luaL_buffinit(L, b);
while (i < s.length) {
@@ -109,8 +111,10 @@ const os_date = function(L) {
lauxlib.luaL_addchar(b, s[i++]);
} else {
i++; /* skip '%' */
- let cc = ["%".charCodeAt(0)];
- i = checkoption(L, s, i, cc); /* copy specifier to 'cc' */
+ i = checkoption(L, s, i, cc.subarray(1)); /* copy specifier to 'cc' */
+ let len = cc.indexOf(0);
+ if (len !== -1)
+ cc = cc.subarray(0, len);
let buff = strftime(lua.to_jsstring(cc), stm);
lauxlib.luaL_addstring(b, lua.to_luastring(buff));
}