lua

A copy of the Lua development repository
Log | Files | Refs | README

commit d5fd44d747e9efce5875a0d08f6484f4187838bd
parent b0abc2ca03556a4483750c2c2389bd413710e36f
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Tue,  3 May 2005 16:29:55 -0300

corrected definition of lua_number2int for Windows

Diffstat:
Mltable.c | 5+++--
Mluaconf.h | 12++++++------
Mlvm.c | 5+++--
3 files changed, 12 insertions(+), 10 deletions(-)

diff --git a/ltable.c b/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 */ diff --git a/luaconf.h b/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 diff --git a/lvm.c b/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; }