corrected definition of lua_number2int for Windows

This commit is contained in:
Roberto Ierusalimschy 2005-05-03 16:30:17 -03:00
parent b0abc2ca03
commit d5fd44d747
3 changed files with 12 additions and 10 deletions

View File

@ -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) ** Lua tables (hash)
** See Copyright Notice in lua.h ** 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_TSTRING: return luaH_getstr(t, rawtsvalue(key));
case LUA_TNUMBER: { case LUA_TNUMBER: {
int k; 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? */ if (luai_numeq(cast(lua_Number, k), nvalue(key))) /* index is integer? */
return luaH_getnum(t, k); /* use specialized version */ return luaH_getnum(t, k); /* use specialized version */
/* else go through */ /* else go through */

View File

@ -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 ** Configuration file for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -421,10 +421,10 @@
/* On Windows/Pentium, resort to assembler */ /* On Windows/Pentium, resort to assembler */
#elif !defined(__STRICT_ANSI__) && defined(_MSC_VER) && defined(_M_IX86) #elif !defined(__STRICT_ANSI__) && defined(_MSC_VER) && defined(_M_IX86)
#define lua_number2int(i,d) __asm { \ #define lua_number2int(i,d) \
fld d \ __asm fld d; \
fistp i \ __asm fistp i;
}
/* on Pentium machines compliant with C99, you can try lrint */ /* on Pentium machines compliant with C99, you can try lrint */
#elif defined (__i386) && defined(__STDC_VERSION__) && \ #elif defined (__i386) && defined(__STDC_VERSION__) && \
@ -445,7 +445,7 @@
/* On a GNU or Windows/Pentium, resort to assembler */ /* On a GNU or Windows/Pentium, resort to assembler */
#if (defined(__GNUC__) && defined(__i386)) || \ #if (defined(__GNUC__) && defined(__i386)) || \
(defined(_MSC_VER) && defined(_M_IX86)) (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 */ /* this option always work, but may be slow */
#else #else

5
lvm.c
View File

@ -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 ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -50,7 +50,8 @@ int luaV_tostring (lua_State *L, StkId obj) {
return 0; return 0;
else { else {
char s[LUAI_MAXNUMBER2STR]; 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)); setsvalue2s(L, obj, luaS_new(L, s));
return 1; return 1;
} }