diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-07-01 16:31:10 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-07-01 16:31:10 -0300 |
| commit | 68ee518e816c87dbb376dc38d11d1b47dfe2b53e (patch) | |
| tree | 0253714c4b62b29993990db1b68add6f4e36c204 | |
| parent | 76a73cb2eef71eac3c93e9263443131164ee9fb9 (diff) | |
| download | lua-68ee518e816c87dbb376dc38d11d1b47dfe2b53e.tar.gz lua-68ee518e816c87dbb376dc38d11d1b47dfe2b53e.tar.bz2 lua-68ee518e816c87dbb376dc38d11d1b47dfe2b53e.zip | |
only tables need `lua_number2int'
| -rw-r--r-- | ltable.c | 14 | ||||
| -rw-r--r-- | lua.h | 8 |
2 files changed, 11 insertions, 11 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: |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.h,v 1.143 2002/06/25 19:18:49 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.144 2002/06/26 19:28:44 roberto Exp roberto $ |
| 3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
| 4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil | 4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil |
| 5 | ** http://www.lua.org mailto:info@lua.org | 5 | ** http://www.lua.org mailto:info@lua.org |
| @@ -301,12 +301,6 @@ LUA_API int lua_pushupvalues (lua_State *L); | |||
| 301 | #define LUA_NUMBER_FMT "%.16g" | 301 | #define LUA_NUMBER_FMT "%.16g" |
| 302 | #endif | 302 | #endif |
| 303 | 303 | ||
| 304 | |||
| 305 | /* function to convert a lua_Number to int (with any rounding method) */ | ||
| 306 | #ifndef lua_number2int | ||
| 307 | #define lua_number2int(i,n) ((i)=(int)(n)) | ||
| 308 | #endif | ||
| 309 | |||
| 310 | /* }====================================================================== */ | 304 | /* }====================================================================== */ |
| 311 | 305 | ||
| 312 | 306 | ||
