浏览代码

new macro luai_numisnan

Roberto Ierusalimschy 19 年之前
父节点
当前提交
db724e14e0
共有 2 个文件被更改,包括 4 次插入4 次删除
  1. 2 2
      lcode.c
  2. 2 2
      ltable.c

+ 2 - 2
lcode.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lcode.c,v 2.21 2005/11/08 19:44:31 roberto Exp roberto $
+** $Id: lcode.c,v 2.22 2005/11/16 11:55:27 roberto Exp roberto $
 ** Code generator for Lua
 ** See Copyright Notice in lua.h
 */
@@ -647,7 +647,7 @@ static int constfolding (OpCode op, expdesc *e1, expdesc *e2) {
     case OP_LEN: return 0;  /* no constant folding for 'len' */
     default: lua_assert(0); r = 0; break;
   }
-  if (r != r) return 0;  /* do not attempt to produce NaN */
+  if (luai_numisnan(r)) return 0;  /* do not attempt to produce NaN */
   e1->u.nval = r;
   return 1;
 }

+ 2 - 2
ltable.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltable.c,v 2.26 2005/07/11 14:01:37 roberto Exp roberto $
+** $Id: ltable.c,v 2.27 2005/10/24 17:37:52 roberto Exp roberto $
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 */
@@ -495,7 +495,7 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) {
     return cast(TValue *, p);
   else {
     if (ttisnil(key)) luaG_runerror(L, "table index is nil");
-    else if (ttisnumber(key) && !luai_numeq(nvalue(key), nvalue(key)))
+    else if (ttisnumber(key) && luai_numisnan(nvalue(key)))
       luaG_runerror(L, "table index is NaN");
     return newkey(L, t, key);
   }