mirror of
https://github.com/lua/lua
synced 2026-09-27 00:28:25 +03:00
No coercion string->number in arithmetic with LUA_NOCVTS2N
This commit is contained in:
parent
6a10f03ff8
commit
6a84c32900
1 changed files with 13 additions and 0 deletions
13
lstrlib.c
13
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 /* } */
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue