From 6a84c329005ab7fc3f17283feda3f41010728288 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Tue, 8 Oct 2019 10:29:38 -0300 Subject: No coercion string->number in arithmetic with LUA_NOCVTS2N --- lstrlib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'lstrlib.c') 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 /* } */ + /* }====================================================== */ /* -- cgit v1.2.3-55-g6feb