aboutsummaryrefslogtreecommitdiff
path: root/lbaselib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-07-01 11:26:28 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2004-07-01 11:26:28 -0300
commit80ec81926c19ff638a65088bb3d5a55d20b55945 (patch)
tree6630fe28b6b20f83fd69ad64bc71fa4bc546b491 /lbaselib.c
parent96917ff42a7867e72629d6cd39c818df4c250b91 (diff)
downloadlua-80ec81926c19ff638a65088bb3d5a55d20b55945.tar.gz
lua-80ec81926c19ff638a65088bb3d5a55d20b55945.tar.bz2
lua-80ec81926c19ff638a65088bb3d5a55d20b55945.zip
`lua.c' also needs the default path, so auxlib should provide it
Diffstat (limited to 'lbaselib.c')
-rw-r--r--lbaselib.c16
1 files changed, 2 insertions, 14 deletions
diff --git a/lbaselib.c b/lbaselib.c
index e8d33229..a7d694ae 100644
--- a/lbaselib.c
+++ b/lbaselib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lbaselib.c,v 1.149 2004/06/21 20:05:29 roberto Exp roberto $ 2** $Id: lbaselib.c,v 1.150 2004/06/29 16:58:17 roberto Exp roberto $
3** Basic library 3** Basic library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -459,20 +459,8 @@ static int luaB_newproxy (lua_State *L) {
459*/ 459*/
460 460
461 461
462static const char *getpath (lua_State *L) {
463 const char *path;
464 lua_getglobal(L, LUA_PATH); /* try global variable */
465 path = lua_tostring(L, -1);
466 if (path) return path;
467 path = getenv(LUA_PATH); /* else try environment variable */
468 if (path) return path;
469 return LUA_PATH_DEFAULT; /* else use default */
470}
471
472
473static int luaB_require (lua_State *L) { 462static int luaB_require (lua_State *L) {
474 const char *name = luaL_checkstring(L, 1); 463 const char *name = luaL_checkstring(L, 1);
475 const char *path = getpath(L);
476 const char *fname; 464 const char *fname;
477 int loaded; 465 int loaded;
478 lua_getglobal(L, REQTAB); 466 lua_getglobal(L, REQTAB);
@@ -485,7 +473,7 @@ static int luaB_require (lua_State *L) {
485 /* else must load it; first mark it as loaded */ 473 /* else must load it; first mark it as loaded */
486 lua_pushboolean(L, 1); 474 lua_pushboolean(L, 1);
487 lua_setfield(L, loaded, name); /* _LOADED[name] = true */ 475 lua_setfield(L, loaded, name); /* _LOADED[name] = true */
488 fname = luaL_searchpath(L, name, path); 476 fname = luaL_searchpath(L, name, NULL);
489 if (fname == NULL || luaL_loadfile(L, fname) != 0) 477 if (fname == NULL || luaL_loadfile(L, fname) != 0)
490 return luaL_error(L, "error loading package `%s' (%s)", name, 478 return luaL_error(L, "error loading package `%s' (%s)", name,
491 lua_tostring(L, -1)); 479 lua_tostring(L, -1));