diff options
Diffstat (limited to 'apps/plugins/lua/loadlib.c')
-rw-r--r-- | apps/plugins/lua/loadlib.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/apps/plugins/lua/loadlib.c b/apps/plugins/lua/loadlib.c index 035116dc71..1cc7ebd7db 100644 --- a/apps/plugins/lua/loadlib.c +++ b/apps/plugins/lua/loadlib.c | |||
@@ -20,6 +20,7 @@ | |||
20 | 20 | ||
21 | #include "lauxlib.h" | 21 | #include "lauxlib.h" |
22 | #include "lualib.h" | 22 | #include "lualib.h" |
23 | #include "rocklib.h" | ||
23 | 24 | ||
24 | 25 | ||
25 | #define setprogdir(L) ((void)0) | 26 | #define setprogdir(L) ((void)0) |
@@ -53,7 +54,7 @@ static const char *pushnexttemplate (lua_State *L, const char *path) { | |||
53 | 54 | ||
54 | static const char *findfile (lua_State *L, const char *name, | 55 | static const char *findfile (lua_State *L, const char *name, |
55 | const char *pname) { | 56 | const char *pname) { |
56 | const char *path; | 57 | const char *path, *current_path = get_current_path(L, 2); |
57 | name = luaL_gsub(L, name, ".", LUA_DIRSEP); | 58 | name = luaL_gsub(L, name, ".", LUA_DIRSEP); |
58 | lua_getfield(L, LUA_ENVIRONINDEX, pname); | 59 | lua_getfield(L, LUA_ENVIRONINDEX, pname); |
59 | path = lua_tostring(L, -1); | 60 | path = lua_tostring(L, -1); |
@@ -63,6 +64,7 @@ static const char *findfile (lua_State *L, const char *name, | |||
63 | while ((path = pushnexttemplate(L, path)) != NULL) { | 64 | while ((path = pushnexttemplate(L, path)) != NULL) { |
64 | const char *filename; | 65 | const char *filename; |
65 | filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); | 66 | filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); |
67 | if(current_path != NULL) filename = luaL_gsub(L, filename, "$", current_path); | ||
66 | lua_remove(L, -2); /* remove path template */ | 68 | lua_remove(L, -2); /* remove path template */ |
67 | if (readable(filename)) /* does file exist and is readable? */ | 69 | if (readable(filename)) /* does file exist and is readable? */ |
68 | return filename; /* return that file name */ | 70 | return filename; /* return that file name */ |