From 7d309480dd783112aad8c4761921c4d45ec70327 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 30 Aug 2004 15:35:14 -0300 Subject: new way to handle _PATH (old LUA_PATH) --- lauxlib.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) (limited to 'lauxlib.c') diff --git a/lauxlib.c b/lauxlib.c index 83bae2e4..8cfe594b 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.121 2004/07/13 20:11:32 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.122 2004/08/13 19:52:53 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -341,17 +341,6 @@ LUALIB_API int luaL_getn (lua_State *L, int t) { /* }====================================================== */ -static const char *getpath (lua_State *L) { - const char *path; - lua_getglobal(L, LUA_PATH); /* try global variable */ - path = lua_tostring(L, -1); - if (path) return path; - path = getenv(LUA_PATH); /* else try environment variable */ - if (path) return path; - return LUA_PATH_DEFAULT; /* else use default */ -} - - static const char *pushnexttemplate (lua_State *L, const char *path) { const char *l; if (*path == '\0') return NULL; /* no more templates */ @@ -383,10 +372,7 @@ static const char *luaL_gsub (lua_State *L, const char *s, LUALIB_API const char *luaL_searchpath (lua_State *L, const char *name, const char *path) { FILE *f; - const char *p; - if (path == NULL) path = getpath(L); - else lua_pushnil(L); /* to balance item pushed by `getpath' */ - p = path; + const char *p = path; for (;;) { const char *fname; if ((p = pushnexttemplate(L, p)) == NULL) { @@ -398,7 +384,6 @@ LUALIB_API const char *luaL_searchpath (lua_State *L, const char *name, f = fopen(fname, "r"); /* try to read it */ if (f) { fclose(f); - lua_remove(L, -2); /* remove path */ return fname; } lua_pop(L, 1); /* remove file name */ -- cgit v1.2.3-55-g6feb