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-672bb67ee6b3f1c705fca4537824e6190c4a8d57.tar.gz
lua-672bb67ee6b3f1c705fca4537824e6190c4a8d57.tar.bz2
lua-672bb67ee6b3f1c705fca4537824e6190c4a8d57.zip
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 @@
1/* 1/*
2** $Id: loadlib.c,v 1.50 2005/12/19 20:56:39 roberto Exp roberto $ 2** $Id: loadlib.c,v 1.51 2005/12/29 15:32:11 roberto Exp roberto $
3** Dynamic library loader for Lua 3** Dynamic library loader for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5** 5**
@@ -22,10 +22,6 @@
22#include "lualib.h" 22#include "lualib.h"
23 23
24 24
25/* environment variables that hold the search path for packages */
26#define LUA_PATH "LUA_PATH"
27#define LUA_CPATH "LUA_CPATH"
28
29/* prefix for open functions in C libraries */ 25/* prefix for open functions in C libraries */
30#define LUA_POF "luaopen_" 26#define LUA_POF "luaopen_"
31 27
diff --git a/lua.c b/lua.c
index 964ecdb0..a6405f6a 100644
--- a/lua.c
+++ b/lua.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lua.c,v 1.156 2005/12/29 12:30:16 roberto Exp roberto $ 2** $Id: lua.c,v 1.157 2005/12/29 16:23:32 roberto Exp roberto $
3** Lua stand-alone interpreter 3** Lua stand-alone interpreter
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -306,12 +306,12 @@ static int runargs (lua_State *L, char **argv, int n) {
306 306
307 307
308static int handle_luainit (lua_State *L) { 308static int handle_luainit (lua_State *L) {
309 const char *init = getenv("LUA_INIT"); 309 const char *init = getenv(LUA_INIT);
310 if (init == NULL) return 0; /* status OK */ 310 if (init == NULL) return 0; /* status OK */
311 else if (init[0] == '@') 311 else if (init[0] == '@')
312 return dofile(L, init+1); 312 return dofile(L, init+1);
313 else 313 else
314 return dostring(L, init, "=LUA_INIT"); 314 return dostring(L, init, "=" LUA_INIT);
315} 315}
316 316
317 317
diff --git a/luaconf.h b/luaconf.h
index cdbc4abb..0d42a985 100644
--- a/luaconf.h
+++ b/luaconf.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: luaconf.h,v 1.80 2006/01/27 13:54:39 roberto Exp roberto $ 2** $Id: luaconf.h,v 1.81 2006/02/10 17:44:06 roberto Exp roberto $
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*/
@@ -60,6 +60,18 @@
60 60
61 61
62/* 62/*
63@@ LUA_PATH and LUA_CPATH are the names of the environment variables that
64@* Lua check to set its paths.
65@@ LUA_INIT is the name of the environment variable that Lua
66@* checks for initialization code.
67** CHANGE them if you want different names.
68*/
69#define LUA_PATH "LUA_PATH"
70#define LUA_CPATH "LUA_CPATH"
71#define LUA_INIT "LUA_INIT"
72
73
74/*
63@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for 75@@ LUA_PATH_DEFAULT is the default path that Lua uses to look for
64@* Lua libraries. 76@* Lua libraries.
65@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for 77@@ LUA_CPATH_DEFAULT is the default path that Lua uses to look for
@@ -543,11 +555,25 @@
543/* On a Pentium, resort to a trick */ 555/* On a Pentium, resort to a trick */
544#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \ 556#if defined(LUA_NUMBER_DOUBLE) && !defined(LUA_ANSI) && !defined(__SSE2__) && \
545 (defined(__i386) || defined (_M_IX86) || defined(__i386__)) 557 (defined(__i386) || defined (_M_IX86) || defined(__i386__))
558
559/* On a Microsoft compiler, use assembler */
560#if defined(_MSC_VER)
561
562#define lua_number2int(i,d) __asm fld d __asm fistp i
563#define lua_number2integer(i,n) lua_number2int(i, n)
564
565/* the next trick should work on any Pentium, but sometimes clashes
566 with a DirectX idiosyncrasy */
567#else
568
546union luai_Cast { double l_d; long l_l; }; 569union luai_Cast { double l_d; long l_l; };
547#define lua_number2int(i,d) \ 570#define lua_number2int(i,d) \
548 { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; } 571 { volatile union luai_Cast u; u.l_d = (d) + 6755399441055744.0; (i) = u.l_l; }
549#define lua_number2integer(i,n) lua_number2int(i, n) 572#define lua_number2integer(i,n) lua_number2int(i, n)
550 573
574#endif
575
576
551/* this option always works, but may be slow */ 577/* this option always works, but may be slow */
552#else 578#else
553#define lua_number2int(i,d) ((i)=(int)(d)) 579#define lua_number2int(i,d) ((i)=(int)(d))