summaryrefslogtreecommitdiff
path: root/src/lua.c
diff options
context:
space:
mode:
authorLua Team <team@lua.org>2011-12-16 12:00:00 +0000
committerrepogen <>2011-12-16 12:00:00 +0000
commit6ee889a587f9b600b564d5c0ba0350faab0387cd (patch)
tree94d059b3fd94eb21259dcfdbed8589e151f8ae5d /src/lua.c
parent227b79b8219eb0879e115d1796d6e62f26eb1a04 (diff)
downloadlua-github-5.2.0.tar.gz
Diffstat (limited to 'src/lua.c')
-rw-r--r--src/lua.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/src/lua.c b/src/lua.c
index e1410000..e20ab86d 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -1,5 +1,5 @@
/*
-** $Id: lua.c,v 1.202 2011/08/17 20:19:52 roberto Exp $
+** $Id: lua.c,v 1.203 2011/12/12 16:34:03 roberto Exp $
** Lua stand-alone interpreter
** See Copyright Notice in lua.h
*/
@@ -439,18 +439,6 @@ static int handle_luainit (lua_State *L) {
}
-static void resetpaths (lua_State *L) {
- lua_getglobal(L, "package");
- if (!lua_istable(L, -1)) /* no module 'package'? */
- return; /* nothing to be done */
- lua_pushliteral(L, LUA_PATH_DEFAULT);
- lua_setfield(L, -2, "path"); /* package.path = default */
- lua_pushliteral(L, LUA_CPATH_DEFAULT);
- lua_setfield(L, -2, "cpath"); /* package.cpath = default */
- lua_pop(L, 1); /* remove 'package' */
-}
-
-
static int pmain (lua_State *L) {
int argc = (int)lua_tointeger(L, 1);
char **argv = (char **)lua_touserdata(L, 2);
@@ -464,14 +452,17 @@ static int pmain (lua_State *L) {
return 0;
}
if (args[has_v]) print_version();
+ if (args[has_E]) { /* option '-E'? */
+ lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */
+ lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
+ }
/* open standard libraries */
luaL_checkversion(L);
lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */
luaL_openlibs(L); /* open libraries */
lua_gc(L, LUA_GCRESTART, 0);
- if (args[has_E]) /* avoid LUA_INIT? */
- resetpaths(L);
- else if (handle_luainit(L) != LUA_OK) return 0;
+ if (!args[has_E] && handle_luainit(L) != LUA_OK)
+ return 0; /* error running LUA_INIT */
/* execute arguments -e and -l */
if (!runargs(L, argv, (script > 0) ? script : argc)) return 0;
/* execute main script (if there is one) */