summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-04-10 15:27:23 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2006-04-10 15:27:23 -0300
commit672bb67ee6b3f1c705fca4537824e6190c4a8d57 (patch)
treeb5177e0595a029176a8bcfd21f23dbeb4bcdbb0e
parent90df6b7a542f39281181d39674756aa759bfad07 (diff)
downloadlua-github-672bb67ee6b3f1c705fca4537824e6190c4a8d57.tar.gz
environment variable names should be configurable
-rw-r--r--loadlib.c6
-rw-r--r--lua.c6
-rw-r--r--luaconf.h28
3 files changed, 31 insertions, 9 deletions
diff --git a/loadlib.c b/loadlib.c
index 77068832..b9ac3761 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.50 2005/12/19 20:56:39 roberto Exp roberto $
+** $Id: loadlib.c,v 1.51 2005/12/29 15:32:11 roberto Exp roberto $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -22,10 +22,6 @@
#include "lualib.h"
-/* environment variables that hold the search path for packages */
-#define LUA_PATH "LUA_PATH"
-#define LUA_CPATH "LUA_CPATH"
-
/* prefix for open functions in C libraries */
#define LUA_POF "luaopen_"
diff --git a/lua.c b/lua.c
index 964ecdb0..a6405f6a 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.156 2005/12/29 12:30:16 roberto Exp roberto $
+** $Id: lua.c,v 1.157 2005/12/29 16:23:32 roberto Exp roberto $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -306,12 +306,12 @@ static int runargs (lua_State *L, char **argv, int n) {
static int handle_luainit (lua_State *L) {
- const char *init = getenv("LUA_INIT");
+ const char *init = getenv(LUA_INIT);
if (init == NULL) return 0; /* status OK */
else if (init[0] == '@')
return dofile(L, init+1);
else
- return dostring(L, init, "=LUA_INIT");
+ return dostring(L, init, "=" LUA_INIT);
}
diff --git a/luaconf.h b/luaconf.h
index cdbc4abb..0d42a985 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
/*
-** $Id: luaconf.h,v 1.80 2006/01/27 13:54:39 roberto Exp roberto $
+** $Id: luaconf.h,v 1.81 2006/02/10 17:44:06 roberto Exp roberto $
** Configuration file for Lua
** See Copyright Notice in lua.h
*/
@@ -60,6 +60,18 @@
/*
+@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
+@* Lua check to set its paths.
+@@ LUA_INIT is the name of the environment variable that Lua
+@* checks for initialization code.
+** CHANGE them if you want different names.
+*/
+#define LUA_PATH "LUA_PATH"
+#define LUA_CPATH "LUA_CPATH"
+#define LUA_INIT "LUA_INIT"
+
+
+/*
@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
@* Lua libraries.
@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
@@ -543,11 +555,25 @@
/* On a Pentium, resort to a trick */
#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
(defined(__i386) || defined (_M_IX86) || defined(__i386__))
+
+/* On a Microsoft compiler, use assembler */
+#if defined(_MSC_VER)
+
+#define lua_number2int(i,d) __asm fld d __asm fistp i
+#define lua_number2integer(i,n) lua_number2int(i, n)
+
+/* the next trick should work on any Pentium, but sometimes clashes
+ with a DirectX idiosyncrasy */
+#else
+
union luai_Cast { double l_d; long l_l; };
#define lua_number2int(i,d) \
{ volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
#define lua_number2integer(i,n) lua_number2int(i, n)
+#endif
+
+
/* this option always works, but may be slow */
#else
#define lua_number2int(i,d) ((i)=(int)(d))