summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2018-04-20 22:19:16 +1000
committerdaurnimator <quae@daurnimator.com>2018-04-20 22:19:16 +1000
commit1cd5b00d25478b35deba1329d95a342062c51d4c (patch)
treed0a3c3233b2dbfc76a24638b673048eab9c0e2e1 /src
parent6934a870564f8fd2d5cd7df3446e293d070c9a9e (diff)
downloadfengari-1cd5b00d25478b35deba1329d95a342062c51d4c.tar.gz
fengari-1cd5b00d25478b35deba1329d95a342062c51d4c.tar.bz2
fengari-1cd5b00d25478b35deba1329d95a342062c51d4c.zip
src/l*lib.js: Remove some uses of caching to_luastring
Diffstat (limited to 'src')
-rw-r--r--src/lbaselib.js4
-rw-r--r--src/loslib.js2
-rw-r--r--src/lstrlib.js26
-rw-r--r--src/ltablib.js2
-rw-r--r--src/lutf8lib.js2
5 files changed, 18 insertions, 18 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js
index b589d6f..63754ef 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -411,14 +411,14 @@ const RESERVEDSLOT = 5;
** reserved slot inside the stack.
*/
const generic_reader = function(L, ud) {
- luaL_checkstack(L, 2, to_luastring("too many nested functions", true));
+ luaL_checkstack(L, 2, "too many nested functions");
lua_pushvalue(L, 1); /* get function */
lua_call(L, 0, 1); /* call it */
if (lua_isnil(L, -1)) {
lua_pop(L, 1); /* pop result */
return null;
} else if (!lua_isstring(L, -1))
- luaL_error(L, to_luastring("reader function must return a string", true));
+ luaL_error(L, to_luastring("reader function must return a string"));
lua_replace(L, RESERVEDSLOT); /* save string in reserved slot */
return lua_tostring(L, RESERVEDSLOT);
};
diff --git a/src/loslib.js b/src/loslib.js
index 814d1b2..66bcb18 100644
--- a/src/loslib.js
+++ b/src/loslib.js
@@ -141,7 +141,7 @@ const os_date = function(L) {
}
if (stm === null) /* invalid date? */
- luaL_error(L, to_luastring("time result cannot be represented in this installation", true));
+ luaL_error(L, to_luastring("time result cannot be represented in this installation"));
if (s[i] === "*".charCodeAt(0) && s[i+1] === "t".charCodeAt(0)) {
lua_createtable(L, 0, 9); /* 9 = number of fields */
setallfields(L, stm, utc);
diff --git a/src/lstrlib.js b/src/lstrlib.js
index 67c4537..50dbcf2 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -292,7 +292,7 @@ const addliteral = function(L, b, arg) {
break;
}
default: {
- luaL_argerror(L, arg, to_luastring("value has no literal form", true));
+ luaL_argerror(L, arg, to_luastring("value has no literal form"));
}
}
};
@@ -301,7 +301,7 @@ const scanformat = function(L, strfrmt, i, form) {
let p = i;
while (strfrmt[p] !== 0 && luastring_indexOf(FLAGS, strfrmt[p]) >= 0) p++; /* skip flags */
if (p - i >= FLAGS.length)
- luaL_error(L, to_luastring("invalid format (repeated flags)", true));
+ luaL_error(L, to_luastring("invalid format (repeated flags)"));
if (isdigit(strfrmt[p])) p++; /* skip width */
if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */
if (strfrmt[p] === 46 /* '.'.charCodeAt(0) */) {
@@ -310,7 +310,7 @@ const scanformat = function(L, strfrmt, i, form) {
if (isdigit(strfrmt[p])) p++; /* (2 digits at most) */
}
if (isdigit(strfrmt[p]))
- luaL_error(L, to_luastring("invalid format (width or precision too long)", true));
+ luaL_error(L, to_luastring("invalid format (width or precision too long)"));
form[0] = 37 /* "%".charCodeAt(0) */;
for (let j = 0; j < p - i + 1; j++)
form[j+1] = strfrmt[i+j];
@@ -345,7 +345,7 @@ const str_format = function(L) {
} else { /* format item */
let form = []; /* to store the format ('%...') */
if (++arg > top)
- luaL_argerror(L, arg, to_luastring("no value", true));
+ luaL_argerror(L, arg, to_luastring("no value"));
i = scanformat(L, strfrmt, i, form);
switch (String.fromCharCode(strfrmt[i++])) {
case 'c': {
@@ -535,13 +535,13 @@ const getdetails = function(h, totalsize, fmt) {
let align = r.size; /* usually, alignment follows size */
if (r.opt === Kpaddalign) { /* 'X' gets alignment from following option */
if (fmt.off >= fmt.s.length || fmt.s[fmt.off] === 0)
- luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'", true));
+ luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'"));
else {
let o = getoption(h, fmt);
align = o.size;
o = o.opt;
if (o === Kchar || align === 0)
- luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'", true));
+ luaL_argerror(h.L, 1, to_luastring("invalid next option for option 'X'"));
}
}
if (align <= 1 || r.opt === Kchar) /* need no alignment? */
@@ -550,7 +550,7 @@ const getdetails = function(h, totalsize, fmt) {
if (align > h.maxalign) /* enforce maximum alignment */
align = h.maxalign;
if ((align & (align -1)) !== 0) /* is 'align' not a power of 2? */
- luaL_argerror(h.L, 1, to_luastring("format asks for alignment not power of 2", true));
+ luaL_argerror(h.L, 1, to_luastring("format asks for alignment not power of 2"));
r.ntoalign = (align - (totalsize & (align - 1))) & (align - 1);
}
return r;
@@ -831,10 +831,10 @@ const str_unpack = function(L) {
let size = details.size;
let ntoalign = details.ntoalign;
if (/*ntoalign + size > ~pos ||*/ pos + ntoalign + size > ld)
- luaL_argerror(L, 2, to_luastring("data string too short", true));
+ luaL_argerror(L, 2, to_luastring("data string too short"));
pos += ntoalign; /* skip alignment */
/* stack space for item + next position */
- luaL_checkstack(L, 2, to_luastring("too many results", true));
+ luaL_checkstack(L, 2, "too many results");
n++;
switch (opt) {
case Kint:
@@ -1039,7 +1039,7 @@ const min_expand = function(ms, s, p, ep) {
const start_capture = function(ms, s, p, what) {
let level = ms.level;
- if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, to_luastring("too many captures", true));
+ if (level >= LUA_MAXCAPTURES) luaL_error(ms.L, to_luastring("too many captures"));
ms.capture[level] = ms.capture[level] ? ms.capture[level] : {};
ms.capture[level].init = s;
ms.capture[level].len = what;
@@ -1091,7 +1091,7 @@ const match = function(ms, s, p) {
let gotoinit = true;
if (ms.matchdepth-- === 0)
- luaL_error(ms.L, to_luastring("pattern too complex", true));
+ luaL_error(ms.L, to_luastring("pattern too complex"));
while (gotoinit || gotodefault) {
gotoinit = false;
@@ -1203,7 +1203,7 @@ const push_onecapture = function(ms, i, s, e) {
luaL_error(ms.L, to_luastring("invalid capture index %%%d"), i + 1);
} else {
let l = ms.capture[i].len;
- if (l === CAP_UNFINISHED) luaL_error(ms.L, to_luastring("unfinished capture", true));
+ if (l === CAP_UNFINISHED) luaL_error(ms.L, to_luastring("unfinished capture"));
if (l === CAP_POSITION)
lua_pushinteger(ms.L, ms.capture[i].init - ms.src_init + 1);
else
@@ -1213,7 +1213,7 @@ const push_onecapture = function(ms, i, s, e) {
const push_captures = function(ms, s, e) {
let nlevels = ms.level === 0 && ms.src.subarray(s) ? 1 : ms.level;
- luaL_checkstack(ms.L, nlevels, to_luastring("too many catpures", true));
+ luaL_checkstack(ms.L, nlevels, "too many captures");
for (let i = 0; i < nlevels; i++)
push_onecapture(ms, i, s, e);
return nlevels; /* number of strings pushed */
diff --git a/src/ltablib.js b/src/ltablib.js
index a521720..93db0aa 100644
--- a/src/ltablib.js
+++ b/src/ltablib.js
@@ -211,7 +211,7 @@ const unpack = function(L) {
if (i > e) return 0; /* empty range */
let n = e - i; /* number of elements minus 1 (avoid overflows) */
if (n >= Number.MAX_SAFE_INTEGER || !lua_checkstack(L, ++n))
- return luaL_error(L, to_luastring("too many results to unpack", true));
+ return luaL_error(L, to_luastring("too many results to unpack"));
for (; i < e; i++) /* push arg[i..e - 1] (to avoid overflows) */
lua_geti(L, 1, i);
lua_geti(L, 1, e); /* push last element */
diff --git a/src/lutf8lib.js b/src/lutf8lib.js
index 34d1365..d3dc3a2 100644
--- a/src/lutf8lib.js
+++ b/src/lutf8lib.js
@@ -219,7 +219,7 @@ const iter_aux = function(L) {
else {
let dec = utf8_decode(s, n);
if (dec === null || iscont(s[dec.pos]))
- return luaL_error(L, to_luastring("invalid UTF-8 code", true));
+ return luaL_error(L, to_luastring("invalid UTF-8 code"));
lua_pushinteger(L, n + 1);
lua_pushinteger(L, dec.code);
return 2;