diff options
Diffstat (limited to 'ltable.c')
-rw-r--r-- | ltable.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 1.110 2002/06/13 13:39:55 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 1.111 2002/06/24 20:18:38 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 | */ |
@@ -46,8 +46,11 @@ | |||
46 | #define toobig(x) ((((x)-1) >> MAXBITS) != 0) | 46 | #define toobig(x) ((((x)-1) >> MAXBITS) != 0) |
47 | 47 | ||
48 | 48 | ||
49 | /* function to convert a lua_Number to int (with any rounding method) */ | ||
50 | #ifndef lua_number2int | ||
51 | #define lua_number2int(i,n) ((i)=(int)(n)) | ||
52 | #endif | ||
49 | 53 | ||
50 | #define TagDefault LUA_TTABLE | ||
51 | 54 | ||
52 | 55 | ||
53 | #define hashnum(t,n) \ | 56 | #define hashnum(t,n) \ |
@@ -68,8 +71,11 @@ | |||
68 | */ | 71 | */ |
69 | Node *luaH_mainposition (const Table *t, const TObject *key) { | 72 | Node *luaH_mainposition (const Table *t, const TObject *key) { |
70 | switch (ttype(key)) { | 73 | switch (ttype(key)) { |
71 | case LUA_TNUMBER: | 74 | case LUA_TNUMBER: { |
72 | return hashnum(t, nvalue(key)); | 75 | int ikey; |
76 | lua_number2int(ikey, nvalue(key)); | ||
77 | return hashnum(t, ikey); | ||
78 | } | ||
73 | case LUA_TSTRING: | 79 | case LUA_TSTRING: |
74 | return hashstr(t, tsvalue(key)); | 80 | return hashstr(t, tsvalue(key)); |
75 | case LUA_TBOOLEAN: | 81 | case LUA_TBOOLEAN: |