summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-10-08 10:29:38 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-10-08 10:29:38 -0300
commit6a84c329005ab7fc3f17283feda3f41010728288 (patch)
tree5da3ae7e8ed5c1f48522aac4d169c5f2ff180288
parent6a10f03ff81606e567c6891a90d70066a03c686e (diff)
downloadlua-github-6a84c329005ab7fc3f17283feda3f41010728288.tar.gz
No coercion string->number in arithmetic with LUA_NOCVTS2N
-rw-r--r--lstrlib.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lstrlib.c b/lstrlib.c
index 7f4a0184..48acb8bf 100644
--- a/lstrlib.c
+++ b/lstrlib.c
@@ -233,6 +233,17 @@ static int str_dump (lua_State *L) {
** =======================================================
*/
+#if defined(LUA_NOCVTS2N) /* { */
+
+/* no coercion from strings to numbers */
+
+static const luaL_Reg stringmetamethods[] = {
+ {"__index", NULL}, /* placeholder */
+ {NULL, NULL}
+};
+
+#else /* }{ */
+
static int tonum (lua_State *L, int arg) {
if (lua_type(L, arg) == LUA_TNUMBER) { /* already a number? */
lua_pushvalue(L, arg);
@@ -311,6 +322,8 @@ static const luaL_Reg stringmetamethods[] = {
{NULL, NULL}
};
+#endif /* } */
+
/* }====================================================== */
/*