Showing the changes to src/lua.c (1 of 5 files). Show all
Unified · Split
| @@ -1,5 +1,5 @@ | ||
| 1 | 1 | /* |
| 2 | −** $Id: lua.c,v 1.202 2011/08/17 20:19:52 roberto Exp $ | |
| 2 | +** $Id: lua.c,v 1.203 2011/12/12 16:34:03 roberto Exp $ | |
| 3 | 3 | ** Lua stand-alone interpreter |
| 4 | 4 | ** See Copyright Notice in lua.h |
| 5 | 5 | */ |
| @@ -439,18 +439,6 @@ static int handle_luainit (lua_State *L) { · 433 unmodified lines | ||
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
| 442 | −static void resetpaths (lua_State *L) { | |
| 443 | − lua_getglobal(L, "package"); | |
| 444 | − if (!lua_istable(L, -1)) /* no module 'package'? */ | |
| 445 | − return; /* nothing to be done */ | |
| 446 | − lua_pushliteral(L, LUA_PATH_DEFAULT); | |
| 447 | − lua_setfield(L, -2, "path"); /* package.path = default */ | |
| 448 | − lua_pushliteral(L, LUA_CPATH_DEFAULT); | |
| 449 | − lua_setfield(L, -2, "cpath"); /* package.cpath = default */ | |
| 450 | − lua_pop(L, 1); /* remove 'package' */ | |
| 451 | −} | |
| 452 | − | |
| 453 | − | |
| 454 | 442 | static int pmain (lua_State *L) { |
| 455 | 443 | int argc = (int)lua_tointeger(L, 1); |
| 456 | 444 | char **argv = (char **)lua_touserdata(L, 2); |
| @@ -464,14 +452,17 @@ static int pmain (lua_State *L) { · 7 unmodified lines | ||
| 464 | 452 | return 0; |
| 465 | 453 | } |
| 466 | 454 | if (args[has_v]) print_version(); |
| 455 | + if (args[has_E]) { /* option '-E'? */ | |
| 456 | + lua_pushboolean(L, 1); /* signal for libraries to ignore env. vars. */ | |
| 457 | + lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV"); | |
| 458 | + } | |
| 467 | 459 | /* open standard libraries */ |
| 468 | 460 | luaL_checkversion(L); |
| 469 | 461 | lua_gc(L, LUA_GCSTOP, 0); /* stop collector during initialization */ |
| 470 | 462 | luaL_openlibs(L); /* open libraries */ |
| 471 | 463 | lua_gc(L, LUA_GCRESTART, 0); |
| 472 | − if (args[has_E]) /* avoid LUA_INIT? */ | |
| 473 | − resetpaths(L); | |
| 474 | − else if (handle_luainit(L) != LUA_OK) return 0; | |
| 464 | + if (!args[has_E] && handle_luainit(L) != LUA_OK) | |
| 465 | + return 0; /* error running LUA_INIT */ | |
| 475 | 466 | /* execute arguments -e and -l */ |
| 476 | 467 | if (!runargs(L, argv, (script > 0) ? script : argc)) return 0; |
| 477 | 468 | /* execute main script (if there is one) */ |