new function 'luaV_flttointeger' to convert floats to integers (without

string coercions) + string operands to bitwise operations handled
by string metamethods
This commit is contained in:
Roberto Ierusalimschy
2017-11-08 12:50:23 -02:00
parent c3e5946fb2
commit 26679ea35b
8 changed files with 126 additions and 48 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lobject.c,v 2.117 2017/07/07 16:34:32 roberto Exp roberto $
** $Id: lobject.c,v 2.118 2017/10/10 20:05:40 roberto Exp roberto $
** Some generic functions over Lua objects
** See Copyright Notice in lua.h
*/
@@ -127,7 +127,7 @@ int luaO_rawarith (lua_State *L, int op, const TValue *p1, const TValue *p2,
case LUA_OPSHL: case LUA_OPSHR:
case LUA_OPBNOT: { /* operate only on integers */
lua_Integer i1; lua_Integer i2;
if (tointeger(p1, &i1) && tointeger(p2, &i2)) {
if (tointegerns(p1, &i1) && tointegerns(p2, &i2)) {
setivalue(res, intarith(L, op, i1, i2));
return 1;
}