aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-12-05 14:14:29 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-12-05 14:14:29 -0300
commitd30569c06407529cc6e99f4a35ae5f9bfe6fa940 (patch)
tree51e560713cb01203d94d792a1e80f38ba7f84c52 /ltable.c
parent2d92102dee88a81711dca8e8ea3ef0ea9d732283 (diff)
downloadlua-d30569c06407529cc6e99f4a35ae5f9bfe6fa940.tar.gz
lua-d30569c06407529cc6e99f4a35ae5f9bfe6fa940.tar.bz2
lua-d30569c06407529cc6e99f4a35ae5f9bfe6fa940.zip
Using an enumeration for float->integer coercion modes
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ltable.c b/ltable.c
index 4c7ae994..cc3c3dd4 100644
--- a/ltable.c
+++ b/ltable.c
@@ -626,7 +626,7 @@ TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key) {
626 else if (ttisfloat(key)) { 626 else if (ttisfloat(key)) {
627 lua_Number f = fltvalue(key); 627 lua_Number f = fltvalue(key);
628 lua_Integer k; 628 lua_Integer k;
629 if (luaV_flttointeger(f, &k, 0)) { /* does key fit in an integer? */ 629 if (luaV_flttointeger(f, &k, F2Ieq)) { /* does key fit in an integer? */
630 setivalue(&aux, k); 630 setivalue(&aux, k);
631 key = &aux; /* insert it as an integer */ 631 key = &aux; /* insert it as an integer */
632 } 632 }
@@ -745,7 +745,7 @@ const TValue *luaH_get (Table *t, const TValue *key) {
745 case LUA_TNIL: return &absentkey; 745 case LUA_TNIL: return &absentkey;
746 case LUA_TNUMFLT: { 746 case LUA_TNUMFLT: {
747 lua_Integer k; 747 lua_Integer k;
748 if (luaV_flttointeger(fltvalue(key), &k, 0)) /* index is an integral? */ 748 if (luaV_flttointeger(fltvalue(key), &k, F2Ieq)) /* integral index? */
749 return luaH_getint(t, k); /* use specialized version */ 749 return luaH_getint(t, k); /* use specialized version */
750 /* else... */ 750 /* else... */
751 } /* FALLTHROUGH */ 751 } /* FALLTHROUGH */