From 0b00e7f1a20b5c4c3f21aaf163818335d0d61928 Mon Sep 17 00:00:00 2001
From: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 18 Mar 2002 15:18:35 -0300
Subject: new macro to convert double->int

---
 ltable.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

(limited to 'ltable.c')

diff --git a/ltable.c b/ltable.c
index 098109ff..d0feafef 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
 /*
-** $Id: ltable.c,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $
+** $Id: ltable.c,v 1.101 2002/02/14 21:41:08 roberto Exp roberto $
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 */
@@ -85,7 +85,8 @@ Node *luaH_mainposition (const Table *t, const TObject *key) {
 */
 static int arrayindex (const TObject *key) {
   if (ttype(key) == LUA_TNUMBER) {
-    int k = cast(int, nvalue(key));
+    int k;
+    lua_number2int(k, (nvalue(key)));
     if (cast(lua_Number, k) == nvalue(key) && k >= 1 && !toobig(k))
       return k;
   }
@@ -421,7 +422,8 @@ const TObject *luaH_get (Table *t, const TObject *key) {
   switch (ttype(key)) {
     case LUA_TSTRING: return luaH_getstr(t, tsvalue(key));
     case LUA_TNUMBER: {
-      int k = cast(int, nvalue(key));
+      int k;
+      lua_number2int(k, (nvalue(key)));
       if (cast(lua_Number, k) == nvalue(key))  /* is an integer index? */
         return luaH_getnum(t, k);  /* use specialized version */
       /* else go through */
-- 
cgit v1.2.3-55-g6feb