diff options
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $ | 2 | ** $Id: ltable.c,v 1.101 2002/02/14 21:41:08 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -85,7 +85,8 @@ Node *luaH_mainposition (const Table *t, const TObject *key) { | |||
85 | */ | 85 | */ |
86 | static int arrayindex (const TObject *key) { | 86 | static int arrayindex (const TObject *key) { |
87 | if (ttype(key) == LUA_TNUMBER) { | 87 | if (ttype(key) == LUA_TNUMBER) { |
88 | int k = cast(int, nvalue(key)); | 88 | int k; |
89 | lua_number2int(k, (nvalue(key))); | ||
89 | if (cast(lua_Number, k) == nvalue(key) && k >= 1 && !toobig(k)) | 90 | if (cast(lua_Number, k) == nvalue(key) && k >= 1 && !toobig(k)) |
90 | return k; | 91 | return k; |
91 | } | 92 | } |
@@ -421,7 +422,8 @@ const TObject *luaH_get (Table *t, const TObject *key) { | |||
421 | switch (ttype(key)) { | 422 | switch (ttype(key)) { |
422 | case LUA_TSTRING: return luaH_getstr(t, tsvalue(key)); | 423 | case LUA_TSTRING: return luaH_getstr(t, tsvalue(key)); |
423 | case LUA_TNUMBER: { | 424 | case LUA_TNUMBER: { |
424 | int k = cast(int, nvalue(key)); | 425 | int k; |
426 | lua_number2int(k, (nvalue(key))); | ||
425 | if (cast(lua_Number, k) == nvalue(key)) /* is an integer index? */ | 427 | if (cast(lua_Number, k) == nvalue(key)) /* is an integer index? */ |
426 | return luaH_getnum(t, k); /* use specialized version */ | 428 | return luaH_getnum(t, k); /* use specialized version */ |
427 | /* else go through */ | 429 | /* else go through */ |