summaryrefslogtreecommitdiff
path: root/loadlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'loadlib.c')
-rw-r--r--loadlib.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/loadlib.c b/loadlib.c
index 02787ef7..f2d7fe3c 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loadlib.c,v 1.106 2011/11/28 17:27:51 roberto Exp roberto $ 2** $Id: loadlib.c,v 1.107 2011/11/30 12:58:57 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**
@@ -615,12 +615,25 @@ static int ll_seeall (lua_State *L) {
615/* auxiliary mark (for internal use) */ 615/* auxiliary mark (for internal use) */
616#define AUXMARK "\1" 616#define AUXMARK "\1"
617 617
618
619/*
620** return registry.LUA_NOENV as a boolean
621*/
622static int noenv (lua_State *L) {
623 int b;
624 lua_getfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
625 b = lua_toboolean(L, -1);
626 lua_pop(L, 1); /* remove value */
627 return b;
628}
629
630
618static void setpath (lua_State *L, const char *fieldname, const char *envname1, 631static void setpath (lua_State *L, const char *fieldname, const char *envname1,
619 const char *envname2, const char *def) { 632 const char *envname2, const char *def) {
620 const char *path = getenv(envname1); 633 const char *path = getenv(envname1);
621 if (path == NULL) /* no environment variable? */ 634 if (path == NULL) /* no environment variable? */
622 path = getenv(envname2); /* try alternative name */ 635 path = getenv(envname2); /* try alternative name */
623 if (path == NULL) /* no environment variable? */ 636 if (path == NULL || noenv(L)) /* no environment variable? */
624 lua_pushstring(L, def); /* use default */ 637 lua_pushstring(L, def); /* use default */
625 else { 638 else {
626 /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */ 639 /* replace ";;" by ";AUXMARK;" and then AUXMARK by default path */