Kaynağa Gözat

corrected definition of lua_number2int for Windows

Roberto Ierusalimschy 20 yıl önce
ebeveyn
işleme
d5fd44d747
3 değiştirilmiş dosya ile 12 ekleme ve 10 silme
  1. 3 2
      ltable.c
  2. 6 6
      luaconf.h
  3. 3 2
      lvm.c

+ 3 - 2
ltable.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltable.c,v 2.19 2005/03/16 16:58:41 roberto Exp roberto $
+** $Id: ltable.c,v 2.20 2005/04/01 13:51:37 roberto Exp roberto $
 ** Lua tables (hash)
 ** See Copyright Notice in lua.h
 */
@@ -469,7 +469,8 @@ const TValue *luaH_get (Table *t, const TValue *key) {
     case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
     case LUA_TNUMBER: {
       int k;
-      lua_number2int(k, (nvalue(key)));
+      lua_Number n = nvalue(key);
+      lua_number2int(k, n);
       if (luai_numeq(cast(lua_Number, k), nvalue(key)))  /* index is integer? */
         return luaH_getnum(t, k);  /* use specialized version */
       /* else go through */

+ 6 - 6
luaconf.h

@@ -1,5 +1,5 @@
 /*
-** $Id: luaconf.h,v 1.45 2005/04/27 18:37:51 roberto Exp roberto $
+** $Id: luaconf.h,v 1.46 2005/04/29 13:53:59 roberto Exp $
 ** Configuration file for Lua
 ** See Copyright Notice in lua.h
 */
@@ -421,10 +421,10 @@
 
 /* On  Windows/Pentium, resort to assembler */
 #elif !defined(__STRICT_ANSI__) && defined(_MSC_VER) && defined(_M_IX86)
-#define lua_number2int(i,d)	__asm { \
-	fld d \
-	fistp i \
-	}
+#define lua_number2int(i,d)	\
+	__asm fld d; \
+	__asm fistp i;
+
 
 /* on Pentium machines compliant with C99, you can try lrint */
 #elif defined (__i386) && defined(__STDC_VERSION__) && \
@@ -445,7 +445,7 @@
 /* On a GNU or Windows/Pentium, resort to assembler */
 #if (defined(__GNUC__) && defined(__i386)) || \
     (defined(_MSC_VER) && defined(_M_IX86))
-#define lua_number2integer(i,n)		lua_number2int((i), (n))
+#define lua_number2integer(i,n)		lua_number2int(i, n)
 
 /* this option always work, but may be slow */
 #else

+ 3 - 2
lvm.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lvm.c,v 2.39 2005/05/02 17:49:43 roberto Exp roberto $
+** $Id: lvm.c,v 2.40 2005/05/03 19:01:17 roberto Exp roberto $
 ** Lua virtual machine
 ** See Copyright Notice in lua.h
 */
@@ -50,7 +50,8 @@ int luaV_tostring (lua_State *L, StkId obj) {
     return 0;
   else {
     char s[LUAI_MAXNUMBER2STR];
-    lua_number2str(s, nvalue(obj));
+    lua_Number n = nvalue(obj);
+    lua_number2str(s, n);
     setsvalue2s(L, obj, luaS_new(L, s));
     return 1;
   }