Using an enumeration for float->integer coercion modes
This commit is contained in:
4
ltable.c
4
ltable.c
@@ -626,7 +626,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
|
||||
else if (ttisfloat(key)) {
|
||||
lua_Number f = fltvalue(key);
|
||||
lua_Integer k;
|
||||
if (luaV_flttointeger(f, &k, 0)) { /* does key fit in an integer? */
|
||||
if (luaV_flttointeger(f, &k, F2Ieq)) { /* does key fit in an integer? */
|
||||
setivalue(&aux, k);
|
||||
key = &aux; /* insert it as an integer */
|
||||
}
|
||||
@@ -745,7 +745,7 @@ const TValue *luaH_get (Table *t, const TValue *key) {
|
||||
case LUA_TNIL: return &absentkey;
|
||||
case LUA_TNUMFLT: {
|
||||
lua_Integer k;
|
||||
if (luaV_flttointeger(fltvalue(key), &k, 0)) /* index is an integral? */
|
||||
if (luaV_flttointeger(fltvalue(key), &k, F2Ieq)) /* integral index? */
|
||||
return luaH_getint(t, k); /* use specialized version */
|
||||
/* else... */
|
||||
} /* FALLTHROUGH */
|
||||
|
||||
Reference in New Issue
Block a user