summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaurnimator <quae@daurnimator.com>2017-12-29 02:31:22 +1100
committerdaurnimator <quae@daurnimator.com>2017-12-29 02:44:44 +1100
commit1371afafae9144b30475262f06940c4057485d02 (patch)
tree1df4d0ffcd1f3dadb8942646533b779df8e8a4a4
parentc93673f0af0ebdc5165cf0acc340f65b6c6fa786 (diff)
downloadfengari-1371afafae9144b30475262f06940c4057485d02.tar.gz
fengari-1371afafae9144b30475262f06940c4057485d02.tar.bz2
fengari-1371afafae9144b30475262f06940c4057485d02.zip
src/: Pass js strings to auxlib functions such as luaL_argcheck
-rw-r--r--src/lbaselib.js10
-rw-r--r--src/lcorolib.js2
-rw-r--r--src/ldblib.js14
-rw-r--r--src/lmathlib.js12
-rw-r--r--src/loslib.js2
-rw-r--r--src/lstrlib.js26
-rw-r--r--src/ltablib.js12
-rw-r--r--src/lutf8lib.js20
-rw-r--r--tests/test-suite/ltests.js8
9 files changed, 53 insertions, 53 deletions
diff --git a/src/lbaselib.js b/src/lbaselib.js
index d000ae4..2e8de76 100644
--- a/src/lbaselib.js
+++ b/src/lbaselib.js
@@ -63,7 +63,7 @@ const luaB_getmetatable = function(L) {
const luaB_setmetatable = function(L) {
let t = lua.lua_type(L, 2);
lauxlib.luaL_checktype(L, 1, lua.LUA_TTABLE);
- lauxlib.luaL_argcheck(L, t === lua.LUA_TNIL || t === lua.LUA_TTABLE, 2, lua.to_luastring("nil or table expected", true));
+ lauxlib.luaL_argcheck(L, t === lua.LUA_TNIL || t === lua.LUA_TTABLE, 2, "nil or table expected");
if (lauxlib.luaL_getmetafield(L, 1, lua.to_luastring("__metatable", true)) !== lua.LUA_TNIL)
return lauxlib.luaL_error(L, lua.to_luastring("cannot change a protected metatable", true));
lua.lua_settop(L, 2);
@@ -80,7 +80,7 @@ const luaB_rawequal = function(L) {
const luaB_rawlen = function(L) {
let t = lua.lua_type(L, 1);
- lauxlib.luaL_argcheck(L, t === lua.LUA_TTABLE || t === lua.LUA_TSTRING, 1, lua.to_luastring("table or string expected", true));
+ lauxlib.luaL_argcheck(L, t === lua.LUA_TTABLE || t === lua.LUA_TSTRING, 1, "table or string expected");
lua.lua_pushinteger(L, lua.lua_rawlen(L, 1));
return 1;
};
@@ -115,7 +115,7 @@ const luaB_collectgarbage = function(L) {
const luaB_type = function(L) {
let t = lua.lua_type(L, 1);
- lauxlib.luaL_argcheck(L, t !== lua.LUA_TNONE, 1, lua.to_luastring("value expected", true));
+ lauxlib.luaL_argcheck(L, t !== lua.LUA_TNONE, 1, "value expected");
lua.lua_pushstring(L, lua.lua_typename(L, t));
return 1;
};
@@ -209,7 +209,7 @@ const luaB_tonumber = function(L) {
let base = lauxlib.luaL_checkinteger(L, 2);
lauxlib.luaL_checktype(L, 1, lua.LUA_TSTRING); /* no numbers as strings */
let s = lua.lua_tostring(L, 1);
- lauxlib.luaL_argcheck(L, 2 <= base && base <= 36, 2, lua.to_luastring("base out of range", true));
+ lauxlib.luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
let n = b_str2int(s, base);
if (n !== null) {
lua.lua_pushinteger(L, n);
@@ -253,7 +253,7 @@ const luaB_select = function(L) {
let i = lauxlib.luaL_checkinteger(L, 1);
if (i < 0) i = n + i;
else if (i > n) i = n;
- lauxlib.luaL_argcheck(L, 1 <= i, 1, lua.to_luastring("index out of range", true));
+ lauxlib.luaL_argcheck(L, 1 <= i, 1, "index out of range");
return n - i;
}
};
diff --git a/src/lcorolib.js b/src/lcorolib.js
index a72d22b..321331b 100644
--- a/src/lcorolib.js
+++ b/src/lcorolib.js
@@ -5,7 +5,7 @@ const lauxlib = require('./lauxlib.js');
const getco = function(L) {
let co = lua.lua_tothread(L, 1);
- lauxlib.luaL_argcheck(L, co, 1, lua.to_luastring("thread expected", true));
+ lauxlib.luaL_argcheck(L, co, 1, "thread expected");
return co;
};
diff --git a/src/ldblib.js b/src/ldblib.js
index eb64b03..5d8f5c4 100644
--- a/src/ldblib.js
+++ b/src/ldblib.js
@@ -30,7 +30,7 @@ const db_getmetatable = function(L) {
const db_setmetatable = function(L) {
const t = lua.lua_type(L, 2);
- lauxlib.luaL_argcheck(L, t == lua.LUA_TNIL || t == lua.LUA_TTABLE, 2, lua.to_luastring("nil or table expected", true));
+ lauxlib.luaL_argcheck(L, t == lua.LUA_TNIL || t == lua.LUA_TTABLE, 2, "nil or table expected");
lua.lua_settop(L, 2);
lua.lua_setmetatable(L, 1);
return 1; /* return 1st argument */
@@ -134,7 +134,7 @@ const db_getinfo = function(L) {
}
if (!lua.lua_getinfo(L1, options, ar))
- lauxlib.luaL_argerror(L, arg + 2, lua.to_luastring("invalid option", true));
+ lauxlib.luaL_argerror(L, arg + 2, "invalid option");
lua.lua_newtable(L); /* table to collect results */
if (options.indexOf('S'.charCodeAt(0)) > -1) {
settabss(L, lua.to_luastring("source", true), ar.source);
@@ -176,7 +176,7 @@ const db_getlocal = function(L) {
} else { /* stack-level argument */
let level = lauxlib.luaL_checkinteger(L, arg + 1);
if (!lua.lua_getstack(L1, level, ar)) /* out of range? */
- return lauxlib.luaL_argerror(L, arg+1, lua.to_luastring("level out of range", true));
+ return lauxlib.luaL_argerror(L, arg+1, "level out of range");
checkstack(L, L1, 1);
let name = lua.lua_getlocal(L1, ar, nvar);
if (name) {
@@ -200,7 +200,7 @@ const db_setlocal = function(L) {
let level = lauxlib.luaL_checkinteger(L, arg + 1);
let nvar = lauxlib.luaL_checkinteger(L, arg + 2);
if (!lua.lua_getstack(L1, level, ar)) /* out of range? */
- return lauxlib.luaL_argerror(L, arg + 1, lua.to_luastring("level out of range", true));
+ return lauxlib.luaL_argerror(L, arg + 1, "level out of range");
lauxlib.luaL_checkany(L, arg + 3);
lua.lua_settop(L, arg + 3);
checkstack(L, L1, 1);
@@ -242,7 +242,7 @@ const db_setupvalue = function(L) {
const checkupval = function(L, argf, argnup) {
let nup = lauxlib.luaL_checkinteger(L, argnup); /* upvalue index */
lauxlib.luaL_checktype(L, argf, lua.LUA_TFUNCTION); /* closure */
- lauxlib.luaL_argcheck(L, (lua.lua_getupvalue(L, argf, nup) !== null), argnup, lua.to_luastring("invalid upvalue index", true));
+ lauxlib.luaL_argcheck(L, (lua.lua_getupvalue(L, argf, nup) !== null), argnup, "invalid upvalue index");
return nup;
};
@@ -255,8 +255,8 @@ const db_upvalueid = function(L) {
const db_upvaluejoin = function(L) {
let n1 = checkupval(L, 1, 2);
let n2 = checkupval(L, 3, 4);
- lauxlib.luaL_argcheck(L, !lua.lua_iscfunction(L, 1), 1, lua.to_luastring("Lua function expected", true));
- lauxlib.luaL_argcheck(L, !lua.lua_iscfunction(L, 3), 3, lua.to_luastring("Lua function expected", true));
+ lauxlib.luaL_argcheck(L, !lua.lua_iscfunction(L, 1), 1, "Lua function expected");
+ lauxlib.luaL_argcheck(L, !lua.lua_iscfunction(L, 3), 3, "Lua function expected");
lua.lua_upvaluejoin(L, 1, n1, 3, n2);
return 0;
};
diff --git a/src/lmathlib.js b/src/lmathlib.js
index e056fd8..ac41d8a 100644
--- a/src/lmathlib.js
+++ b/src/lmathlib.js
@@ -21,13 +21,13 @@ const math_random = function(L) {
up = lauxlib.luaL_checkinteger(L, 2);
break;
}
- default: return lauxlib.luaL_error(L, lua.to_luastring("wrong number of arguments", true));
+ default: return lauxlib.luaL_error(L, "wrong number of arguments");
}
/* random integer in the interval [low, up] */
- lauxlib.luaL_argcheck(L, low <= up, 1, lua.to_luastring("interval is empty", true));
+ lauxlib.luaL_argcheck(L, low <= up, 1, "interval is empty");
lauxlib.luaL_argcheck(L, low >= 0 || up <= luaconf.LUA_MAXINTEGER + low, 1,
- lua.to_luastring("interval too large", true));
+ "interval too large");
r *= (up - low) + 1;
lua.lua_pushinteger(L, Math.floor(r) + low);
@@ -162,7 +162,7 @@ const math_rad = function(L) {
const math_min = function(L) {
let n = lua.lua_gettop(L); /* number of arguments */
let imin = 1; /* index of current minimum value */
- lauxlib.luaL_argcheck(L, n >= 1, 1, lua.to_luastring("value expected", true));
+ lauxlib.luaL_argcheck(L, n >= 1, 1, "value expected");
for (let i = 2; i <= n; i++){
if (lua.lua_compare(L, i, imin, lua.LUA_OPLT))
imin = i;
@@ -174,7 +174,7 @@ const math_min = function(L) {
const math_max = function(L) {
let n = lua.lua_gettop(L); /* number of arguments */
let imax = 1; /* index of current minimum value */
- lauxlib.luaL_argcheck(L, n >= 1, 1, lua.to_luastring("value expected", true));
+ lauxlib.luaL_argcheck(L, n >= 1, 1, "value expected");
for (let i = 2; i <= n; i++){
if (lua.lua_compare(L, imax, i, lua.LUA_OPLT))
imax = i;
@@ -201,7 +201,7 @@ const math_fmod = function(L) {
let d = lua.lua_tointeger(L, 2);
/* no special case needed for -1 in javascript */
if (d === 0) {
- lauxlib.luaL_argerror(L, 2, lua.to_luastring("zero", true));
+ lauxlib.luaL_argerror(L, 2, "zero");
} else
lua.lua_pushinteger(L, (lua.lua_tointeger(L, 1) % d)|0);
} else {
diff --git a/src/loslib.js b/src/loslib.js
index 99e5787..09ee168 100644
--- a/src/loslib.js
+++ b/src/loslib.js
@@ -144,7 +144,7 @@ const os_time = function(L) {
const l_checktime = function(L, arg) {
let t = lauxlib.luaL_checkinteger(L, arg);
- // lauxlib.luaL_argcheck(L, t, arg, lua.to_luastring("time out-of-bounds"));
+ // lauxlib.luaL_argcheck(L, t, arg, "time out-of-bounds");
return t;
};
diff --git a/src/lstrlib.js b/src/lstrlib.js
index a8a017f..ddb2161 100644
--- a/src/lstrlib.js
+++ b/src/lstrlib.js
@@ -306,7 +306,7 @@ const str_format = function(L) {
if (form.length <= 2 || form[2] === 0) { /* no modifiers? */
lauxlib.luaL_addvalue(b); /* keep entire string */
} else {
- lauxlib.luaL_argcheck(L, s.length === strlen(s), arg, lua.to_luastring("string contains zeros", true));
+ lauxlib.luaL_argcheck(L, s.length === strlen(s), arg, "string contains zeros");
if (form.indexOf('.'.charCodeAt(0)) < 0 && s.length >= 100) {
/* no precision and string is too long to be formatted */
lauxlib.luaL_addvalue(b); /* keep entire string */
@@ -534,7 +534,7 @@ const str_pack = function(L) {
let n = lauxlib.luaL_checkinteger(L, arg);
if (size < SZINT) { /* need overflow check? */
let lim = 1 << (size * 8) - 1;
- lauxlib.luaL_argcheck(L, -lim <= n && n < lim, arg, lua.to_luastring("integer overflow", true));
+ lauxlib.luaL_argcheck(L, -lim <= n && n < lim, arg, "integer overflow");
}
packint(b, n, h.islittle, size, n < 0);
break;
@@ -542,7 +542,7 @@ const str_pack = function(L) {
case KOption.Kuint: { /* unsigned integers */
let n = lauxlib.luaL_checkinteger(L, arg);
if (size < SZINT)
- lauxlib.luaL_argcheck(L, (n>>>0) < (1 << (size * NB)), arg, lua.to_luastring("unsigned overflow", true));
+ lauxlib.luaL_argcheck(L, (n>>>0) < (1 << (size * NB)), arg, "unsigned overflow");
packint(b, n>>>0, h.islittle, size, false);
break;
}
@@ -558,7 +558,7 @@ const str_pack = function(L) {
case KOption.Kchar: { /* fixed-size string */
let s = lauxlib.luaL_checkstring(L, arg);
let len = s.length;
- lauxlib.luaL_argcheck(L, len <= size, arg, lua.to_luastring("string longer than given size", true));
+ lauxlib.luaL_argcheck(L, len <= size, arg, "string longer than given size");
lauxlib.luaL_addlstring(b, s, len); /* add string */
while (len++ < size) /* pad extra space */
lauxlib.luaL_addchar(b, LUAL_PACKPADBYTE);
@@ -569,7 +569,7 @@ const str_pack = function(L) {
let len = s.length;
lauxlib.luaL_argcheck(L,
size >= 4 /* sizeof(size_t) */ || len < (1 << (size * NB)),
- arg, lua.to_luastring("string length does not fit in given size", true));
+ arg, "string length does not fit in given size");
packint(b, len, h.islittle, size, 0); /* pack length */
lauxlib.luaL_addlstring(b, s, len);
totalsize += len;
@@ -578,7 +578,7 @@ const str_pack = function(L) {
case KOption.Kzstr: { /* zero-terminated string */
let s = lauxlib.luaL_checkstring(L, arg);
let len = s.length;
- lauxlib.luaL_argcheck(L, s.indexOf(0) < 0, arg, lua.to_luastring("strings contains zeros", true));
+ lauxlib.luaL_argcheck(L, s.indexOf(0) < 0, arg, "strings contains zeros");
lauxlib.luaL_addlstring(b, s, len);
lauxlib.luaL_addchar(b, 0); /* add zero at the end */
totalsize += len + 1;
@@ -651,10 +651,10 @@ const str_byte = function(L) {
if (pose > l) pose = l;
if (posi > pose) return 0; /* empty interval; return no values */
if (pose - posi >= Number.MAX_SAFE_INTEGER) /* arithmetic overflow? */
- return lauxlib.luaL_error(L, lua.to_luastring("string slice too long", true));
+ return lauxlib.luaL_error(L, "string slice too long");
let n = (pose - posi) + 1;
- lauxlib.luaL_checkstack(L, n, lua.to_luastring("string slice too long", true));
+ lauxlib.luaL_checkstack(L, n, "string slice too long");
for (let i = 0; i < n; i++)
lua.lua_pushinteger(L, s[posi + i - 1]);
return n;
@@ -673,12 +673,12 @@ const str_packsize = function(L) {
let size = details.size;
let ntoalign = details.ntoalign;
size += ntoalign; /* total space used by option */
- lauxlib.luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, lua.to_luastring("format result too large", true));
+ lauxlib.luaL_argcheck(L, totalsize <= MAXSIZE - size, 1, "format result too large");
totalsize += size;
switch (opt) {
case KOption.Kstring: /* strings with length count */
case KOption.Kzstr: /* zero-terminated string */
- lauxlib.luaL_argerror(L, 1, lua.to_luastring("variable-length format", true));
+ lauxlib.luaL_argerror(L, 1, "variable-length format");
/* call never return, but to avoid warnings: *//* fall through */
default: break;
}
@@ -738,7 +738,7 @@ const str_unpack = function(L) {
let ld = data.length;
let pos = posrelat(lauxlib.luaL_optinteger(L, 3, 1), ld) - 1;
let n = 0; /* number of results */
- lauxlib.luaL_argcheck(L, pos <= ld && pos >= 0, 3, lua.to_luastring("initial position out of string", true));
+ lauxlib.luaL_argcheck(L, pos <= ld && pos >= 0, 3, "initial position out of string");
while (fmt.off < fmt.s.length) {
let details = getdetails(h, pos, fmt);
let opt = details.opt;
@@ -768,7 +768,7 @@ const str_unpack = function(L) {
}
case KOption.Kstring: {
let len = unpackint(L, data.slice(pos), h.islittle, size, 0);
- lauxlib.luaL_argcheck(L, pos + len + size <= ld, 2, lua.to_luastring("data string too short", true));
+ lauxlib.luaL_argcheck(L, pos + len + size <= ld, 2, "data string too short");
lua.lua_pushstring(L, data.slice(pos + size, pos + size + len));
pos += len; /* skip string */
break;
@@ -1323,7 +1323,7 @@ const str_gsub = function(L) {
let ms = new MatchState(L);
let b = new lauxlib.luaL_Buffer();
lauxlib.luaL_argcheck(L, tr === lua.LUA_TNUMBER || tr === lua.LUA_TSTRING || tr === lua.LUA_TFUNCTION || tr === lua.LUA_TTABLE, 3,
- lua.to_luastring("string/function/table expected", true));
+ "string/function/table expected");
lauxlib.luaL_buffinit(L, b);
if (anchor) {
p = p.slice(1); lp--; /* skip anchor character */
diff --git a/src/ltablib.js b/src/ltablib.js
index 56671c4..215610f 100644
--- a/src/ltablib.js
+++ b/src/ltablib.js
@@ -62,7 +62,7 @@ const tinsert = function(L) {
break;
case 3: {
pos = lauxlib.luaL_checkinteger(L, 2); /* 2nd argument is the position */
- lauxlib.luaL_argcheck(L, 1 <= pos && pos <= e, 2, lua.to_luastring("position out of bounds", true));
+ lauxlib.luaL_argcheck(L, 1 <= pos && pos <= e, 2, "position out of bounds");
for (let i = e; i > pos; i--) { /* move up elements */
lua.lua_geti(L, 1, i - 1);
lua.lua_seti(L, 1, i); /* t[i] = t[i - 1] */
@@ -70,7 +70,7 @@ const tinsert = function(L) {
break;
}
default: {
- return lauxlib.luaL_error(L, lua.to_luastring("wrong number of arguments to 'insert'", true));
+ return lauxlib.luaL_error(L, "wrong number of arguments to 'insert'");
}
}
@@ -82,7 +82,7 @@ const tremove = function(L) {
let size = aux_getn(L, 1, TAB_RW);
let pos = lauxlib.luaL_optinteger(L, 2, size);
if (pos !== size) /* validate 'pos' if given */
- lauxlib.luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, lua.to_luastring("position out of bounds", true));
+ lauxlib.luaL_argcheck(L, 1 <= pos && pos <= size + 1, 1, "position out of bounds");
lua.lua_geti(L, 1, pos); /* result = t[pos] */
for (; pos < size; pos++) {
lua.lua_geti(L, 1, pos + 1);
@@ -107,9 +107,9 @@ const tmove = function(L) {
checktab(L, 1, TAB_R);
checktab(L, tt, TAB_W);
if (e >= f) { /* otherwise, nothing to move */
- lauxlib.luaL_argcheck(L, f > 0 || e < luaconf.LUA_MAXINTEGER + f, 3, lua.to_luastring("too many elements to move", true));
+ lauxlib.luaL_argcheck(L, f > 0 || e < luaconf.LUA_MAXINTEGER + f, 3, "too many elements to move");
let n = e - f + 1; /* number of elements to move */
- lauxlib.luaL_argcheck(L, t <= luaconf.LUA_MAXINTEGER - n + 1, 4, lua.to_luastring("destination wrap around", true));
+ lauxlib.luaL_argcheck(L, t <= luaconf.LUA_MAXINTEGER - n + 1, 4, "destination wrap around");
if (t > e || t <= f || (tt !== 1 && lua.lua_compare(L, 1, tt, lua.LUA_OPEQ) !== 1)) {
for (let i = 0; i < n; i++) {
@@ -291,7 +291,7 @@ const auxsort = function(L, lo, up, rnd) {
const sort = function(L) {
let n = aux_getn(L, 1, TAB_RW);
if (n > 1) { /* non-trivial interval? */
- lauxlib.luaL_argcheck(L, n < luaconf.LUA_MAXINTEGER, 1, lua.to_luastring("array too big", true));
+ lauxlib.luaL_argcheck(L, n < luaconf.LUA_MAXINTEGER, 1, "array too big");
if (!lua.lua_isnoneornil(L, 2)) /* is there a 2nd argument? */
lauxlib.luaL_checktype(L, 2, lua.LUA_TFUNCTION); /* must be a function */
lua.lua_settop(L, 2); /* make sure there are two arguments */
diff --git a/src/lutf8lib.js b/src/lutf8lib.js
index f581a9e..4298a33 100644
--- a/src/lutf8lib.js
+++ b/src/lutf8lib.js
@@ -59,8 +59,8 @@ const utflen = function(L) {
let posi = u_posrelat(lauxlib.luaL_optinteger(L, 2, 1), len);
let posj = u_posrelat(lauxlib.luaL_optinteger(L, 3, -1), len);
- lauxlib.luaL_argcheck(L, 1 <= posi && --posi <= len, 2, lua.to_luastring("initial position out of string"));
- lauxlib.luaL_argcheck(L, --posj < len, 3, lua.to_luastring("final position out of string"));
+ lauxlib.luaL_argcheck(L, 1 <= posi && --posi <= len, 2, "initial position out of string");
+ lauxlib.luaL_argcheck(L, --posj < len, 3, "final position out of string");
while (posi <= posj) {
let dec = utf8_decode(s, posi);
@@ -78,7 +78,7 @@ const utflen = function(L) {
const pushutfchar = function(L, arg) {
let code = lauxlib.luaL_checkinteger(L, arg);
- lauxlib.luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, lua.to_luastring("value out of range", true));
+ lauxlib.luaL_argcheck(L, 0 <= code && code <= MAXUNICODE, arg, "value out of range");
lua.lua_pushstring(L, lua.to_luastring(String.fromCodePoint(code)));
};
@@ -111,14 +111,14 @@ const byteoffset = function(L) {
let posi = n >= 0 ? 1 : s.length + 1;
posi = u_posrelat(lauxlib.luaL_optinteger(L, 3, posi), s.length);
- lauxlib.luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, lua.to_luastring("position out of range", true));
+ lauxlib.luaL_argcheck(L, 1 <= posi && --posi <= s.length, 3, "position out of range");
if (n === 0) {
/* find beginning of current byte sequence */
while (posi > 0 && iscont(s[posi])) posi--;
} else {
if (iscont(s[posi]))
- lauxlib.luaL_error(L, lua.to_luastring("initial position is a continuation byte", true));
+ lauxlib.luaL_error(L, "initial position is a continuation byte");
if (n < 0) {
while (n < 0 && posi > 0) { /* move back */
@@ -155,19 +155,19 @@ const codepoint = function(L) {
let posi = u_posrelat(lauxlib.luaL_optinteger(L, 2, 1), s.length);
let pose = u_posrelat(lauxlib.luaL_optinteger(L, 3, posi), s.length);
- lauxlib.luaL_argcheck(L, posi >= 1, 2, lua.to_luastring("out of range", true));
- lauxlib.luaL_argcheck(L, pose <= s.length, 3, lua.to_luastring("out of range", true));
+ lauxlib.luaL_argcheck(L, posi >= 1, 2, "out of range");
+ lauxlib.luaL_argcheck(L, pose <= s.length, 3, "out of range");
if (posi > pose) return 0; /* empty interval; return no values */
if (pose - posi >= Number.MAX_SAFE_INTEGER)
- return lauxlib.luaL_error(L, lua.to_luastring("string slice too long", true));
+ return lauxlib.luaL_error(L, "string slice too long");
let n = (pose - posi) + 1;
- lauxlib.luaL_checkstack(L, n, lua.to_luastring("string slice too long", true));
+ lauxlib.luaL_checkstack(L, n, "string slice too long");
n = 0;
for (posi -= 1; posi < pose;) {
let dec = utf8_decode(s, posi);
if (dec === null)
- return lauxlib.luaL_error(L, lua.to_luastring("invalid UTF-8 code", true));
+ return lauxlib.luaL_error(L, "invalid UTF-8 code");
lua.lua_pushinteger(L, dec.code);
posi = dec.pos;
n++;
diff --git a/tests/test-suite/ltests.js b/tests/test-suite/ltests.js
index 08bb603..fa6d697 100644
--- a/tests/test-suite/ltests.js
+++ b/tests/test-suite/ltests.js
@@ -552,7 +552,7 @@ const newstate = function(L) {
const getstate = function(L) {
let L1 = lua.lua_touserdata(L, 1);
- lauxlib.luaL_argcheck(L, L1 !== null, 1, lua.to_luastring("state expected", true));
+ lauxlib.luaL_argcheck(L, L1 !== null, 1, "state expected");
return L1;
};
@@ -751,7 +751,7 @@ const makeCfunc = function(L) {
const coresume = function(L) {
let status;
let co = lua.lua_tothread(L, 1);
- lauxlib.luaL_argcheck(L, co, 1, lua.to_luastring("coroutine expected", true));
+ lauxlib.luaL_argcheck(L, co, 1, "coroutine expected");
status = lua.lua_resume(co, L, 0);
if (status != lua.LUA_OK && status !== lua.LUA_YIELD) {
lua.lua_pushboolean(L, 0);
@@ -805,7 +805,7 @@ const buildop = function(p, pc) {
const listcode = function(L) {
lauxlib.luaL_argcheck(L, lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1),
- 1, lua.to_luastring("Lua function expected", true));
+ 1, "Lua function expected");
let p = obj_at(L, 1);
lua.lua_newtable(L);
setnameval(L, lua.to_luastring("maxstack", true), p.maxstacksize);
@@ -821,7 +821,7 @@ const listcode = function(L) {
const listk = function(L) {
lauxlib.luaL_argcheck(L,
lua.lua_isfunction(L, 1) && !lua.lua_iscfunction(L, 1),
- 1, lua.to_luastring("Lua function expected"), true);
+ 1, "Lua function expected");
let p = obj_at(L, 1);
lua.lua_createtable(L, p.k.length, 0);
for (let i = 0; i < p.k.length; i++) {