aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-05-03 16:30:17 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2005-05-03 16:30:17 -0300
commitd5fd44d747e9efce5875a0d08f6484f4187838bd (patch)
tree17b9251d4ece07ef07e4c34a867de135a9394aef
parentb0abc2ca03556a4483750c2c2389bd413710e36f (diff)
downloadlua-d5fd44d747e9efce5875a0d08f6484f4187838bd.tar.gz
lua-d5fd44d747e9efce5875a0d08f6484f4187838bd.tar.bz2
lua-d5fd44d747e9efce5875a0d08f6484f4187838bd.zip
corrected definition of lua_number2int for Windows
-rw-r--r--ltable.c5
-rw-r--r--luaconf.h12
-rw-r--r--lvm.c5
3 files changed, 12 insertions, 10 deletions
diff --git a/ltable.c b/ltable.c
index ab69c343..7b51da46 100644
--- a/ltable.c
+++ b/ltable.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ltable.c,v 2.19 2005/03/16 16:58:41 roberto Exp roberto $ 2** $Id: ltable.c,v 2.20 2005/04/01 13:51:37 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*/
@@ -469,7 +469,8 @@ const TValue *luaH_get (Table *t, const TValue *key) {
469 case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key)); 469 case LUA_TSTRING: return luaH_getstr(t, rawtsvalue(key));
470 case LUA_TNUMBER: { 470 case LUA_TNUMBER: {
471 int k; 471 int k;
472 lua_number2int(k, (nvalue(key))); 472 lua_Number n = nvalue(key);
473 lua_number2int(k, n);
473 if (luai_numeq(cast(lua_Number, k), nvalue(key))) /* index is integer? */ 474 if (luai_numeq(cast(lua_Number, k), nvalue(key))) /* index is integer? */
474 return luaH_getnum(t, k); /* use specialized version */ 475 return luaH_getnum(t, k); /* use specialized version */
475 /* else go through */ 476 /* else go through */
diff --git a/luaconf.h b/luaconf.h
index c9077ab0..d59b8f22 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.45 2005/04/27 18:37:51 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.46 2005/04/29 13:53:59 roberto Exp $
3** Configuration file for Lua 3** Configuration file for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -421,10 +421,10 @@
421 421
422/* On Windows/Pentium, resort to assembler */ 422/* On Windows/Pentium, resort to assembler */
423#elif !defined(__STRICT_ANSI__) && defined(_MSC_VER) && defined(_M_IX86) 423#elif !defined(__STRICT_ANSI__) && defined(_MSC_VER) && defined(_M_IX86)
424#define lua_number2int(i,d) __asm { \ 424#define lua_number2int(i,d) \
425 fld d \ 425 __asm fld d; \
426 fistp i \ 426 __asm fistp i;
427 } 427
428 428
429/* on Pentium machines compliant with C99, you can try lrint */ 429/* on Pentium machines compliant with C99, you can try lrint */
430#elif defined (__i386) && defined(__STDC_VERSION__) && \ 430#elif defined (__i386) && defined(__STDC_VERSION__) && \
@@ -445,7 +445,7 @@
445/* On a GNU or Windows/Pentium, resort to assembler */ 445/* On a GNU or Windows/Pentium, resort to assembler */
446#if (defined(__GNUC__) && defined(__i386)) || \ 446#if (defined(__GNUC__) && defined(__i386)) || \
447 (defined(_MSC_VER) && defined(_M_IX86)) 447 (defined(_MSC_VER) && defined(_M_IX86))
448#define lua_number2integer(i,n) lua_number2int((i), (n)) 448#define lua_number2integer(i,n) lua_number2int(i, n)
449 449
450/* this option always work, but may be slow */ 450/* this option always work, but may be slow */
451#else 451#else
diff --git a/lvm.c b/lvm.c
index 69cb38f4..6170e7ad 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.39 2005/05/02 17:49:43 roberto Exp roberto $ 2** $Id: lvm.c,v 2.40 2005/05/03 19:01:17 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -50,7 +50,8 @@ int luaV_tostring (lua_State *L, StkId obj) {
50 return 0; 50 return 0;
51 else { 51 else {
52 char s[LUAI_MAXNUMBER2STR]; 52 char s[LUAI_MAXNUMBER2STR];
53 lua_number2str(s, nvalue(obj)); 53 lua_Number n = nvalue(obj);
54 lua_number2str(s, n);
54 setsvalue2s(L, obj, luaS_new(L, s)); 55 setsvalue2s(L, obj, luaS_new(L, s));
55 return 1; 56 return 1;
56 } 57 }