aboutsummaryrefslogtreecommitdiff
path: root/ltable.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.c')
-rw-r--r--ltable.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ltable.c b/ltable.c
index a3a169b7..361facc8 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.13 2005/01/04 15:55:12 roberto Exp roberto $ 2** $Id: ltable.c,v 2.14 2005/01/05 18:20:51 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*/
@@ -119,7 +119,7 @@ static int arrayindex (const TValue *key) {
119 lua_Number n = nvalue(key); 119 lua_Number n = nvalue(key);
120 int k; 120 int k;
121 lua_number2int(k, n); 121 lua_number2int(k, n);
122 if (cast(lua_Number, k) == nvalue(key)) 122 if (num_eq(cast(lua_Number, k), nvalue(key)))
123 return k; 123 return k;
124 } 124 }
125 return -1; /* `key' did not match some condition */ 125 return -1; /* `key' did not match some condition */
@@ -436,7 +436,7 @@ const TValue *luaH_getnum (Table *t, int key) {
436 lua_Number nk = cast(lua_Number, key); 436 lua_Number nk = cast(lua_Number, key);
437 Node *n = hashnum(t, nk); 437 Node *n = hashnum(t, nk);
438 do { /* check whether `key' is somewhere in the chain */ 438 do { /* check whether `key' is somewhere in the chain */
439 if (ttisnumber(gkey(n)) && nvalue(gkey(n)) == nk) 439 if (ttisnumber(gkey(n)) && num_eq(nvalue(gkey(n)), nk))
440 return gval(n); /* that's it */ 440 return gval(n); /* that's it */
441 else n = gnext(n); 441 else n = gnext(n);
442 } while (n); 442 } while (n);
@@ -469,7 +469,7 @@ const TValue *luaH_get (Table *t, const TValue *key) {
469 case LUA_TNUMBER: { 469 case LUA_TNUMBER: {
470 int k; 470 int k;
471 lua_number2int(k, (nvalue(key))); 471 lua_number2int(k, (nvalue(key)));
472 if (cast(lua_Number, k) == nvalue(key)) /* is an integer index? */ 472 if (num_eq(cast(lua_Number, k), nvalue(key))) /* is an integer index? */
473 return luaH_getnum(t, k); /* use specialized version */ 473 return luaH_getnum(t, k); /* use specialized version */
474 /* else go through */ 474 /* else go through */
475 } 475 }
@@ -493,7 +493,7 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
493 return cast(TValue *, p); 493 return cast(TValue *, p);
494 else { 494 else {
495 if (ttisnil(key)) luaG_runerror(L, "table index is nil"); 495 if (ttisnil(key)) luaG_runerror(L, "table index is nil");
496 else if (ttisnumber(key) && nvalue(key) != nvalue(key)) 496 else if (ttisnumber(key) && !num_eq(nvalue(key), nvalue(key)))
497 luaG_runerror(L, "table index is NaN"); 497 luaG_runerror(L, "table index is NaN");
498 return newkey(L, t, key); 498 return newkey(L, t, key);
499 } 499 }