diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-10-08 10:29:38 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-10-08 10:29:38 -0300 |
| commit | 6a84c329005ab7fc3f17283feda3f41010728288 (patch) | |
| tree | 5da3ae7e8ed5c1f48522aac4d169c5f2ff180288 | |
| parent | 6a10f03ff81606e567c6891a90d70066a03c686e (diff) | |
| download | lua-6a84c329005ab7fc3f17283feda3f41010728288.tar.gz lua-6a84c329005ab7fc3f17283feda3f41010728288.tar.bz2 lua-6a84c329005ab7fc3f17283feda3f41010728288.zip | |
No coercion string->number in arithmetic with LUA_NOCVTS2N
| -rw-r--r-- | lstrlib.c | 13 |
1 files changed, 13 insertions, 0 deletions
| @@ -233,6 +233,17 @@ static int str_dump (lua_State *L) { | |||
| 233 | ** ======================================================= | 233 | ** ======================================================= |
| 234 | */ | 234 | */ |
| 235 | 235 | ||
| 236 | #if defined(LUA_NOCVTS2N) /* { */ | ||
| 237 | |||
| 238 | /* no coercion from strings to numbers */ | ||
| 239 | |||
| 240 | static const luaL_Reg stringmetamethods[] = { | ||
| 241 | {"__index", NULL}, /* placeholder */ | ||
| 242 | {NULL, NULL} | ||
| 243 | }; | ||
| 244 | |||
| 245 | #else /* }{ */ | ||
| 246 | |||
| 236 | static int tonum (lua_State *L, int arg) { | 247 | static int tonum (lua_State *L, int arg) { |
| 237 | if (lua_type(L, arg) == LUA_TNUMBER) { /* already a number? */ | 248 | if (lua_type(L, arg) == LUA_TNUMBER) { /* already a number? */ |
| 238 | lua_pushvalue(L, arg); | 249 | lua_pushvalue(L, arg); |
| @@ -311,6 +322,8 @@ static const luaL_Reg stringmetamethods[] = { | |||
| 311 | {NULL, NULL} | 322 | {NULL, NULL} |
| 312 | }; | 323 | }; |
| 313 | 324 | ||
| 325 | #endif /* } */ | ||
| 326 | |||
| 314 | /* }====================================================== */ | 327 | /* }====================================================== */ |
| 315 | 328 | ||
| 316 | /* | 329 | /* |
