summaryrefslogtreecommitdiff
path: root/src/lib/elua
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@osg.samsung.com>2016-08-08 14:38:08 +0100
committerDaniel Kolesa <d.kolesa@osg.samsung.com>2016-08-08 14:38:39 +0100
commitd27c27528c2bb640f2e0c01249aeeb8a4a143679 (patch)
tree7dcee99a6bd1ce51b9899645300a21df2c745869 /src/lib/elua
parenta5fd63067d608bc9c92c1ffa29f17070d6139095 (diff)
downloadefl-d27c27528c2bb640f2e0c01249aeeb8a4a143679.tar.gz
elua: load modules from local dirs first
This fixes cases when running scripts locally - local modules are preferred over systemwide, avoiding possibly outdated system scripts from being run.
Diffstat (limited to 'src/lib/elua')
-rw-r--r--src/lib/elua/elua.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/elua/elua.c b/src/lib/elua/elua.c
index f537663d53..185f592890 100644
--- a/src/lib/elua/elua.c
+++ b/src/lib/elua/elua.c
@@ -499,28 +499,33 @@ _elua_module_system_init(lua_State *L)
const char *modpath = es->moddir;
const char *appspath = es->appsdir;
Eina_Stringshare *data = NULL;
- int n = 4;
if (!corepath || !modpath || !appspath)
return 0;
lua_pushvalue(L, 1);
es->requireref = luaL_ref(L, LUA_REGISTRYINDEX);
lua_pushvalue(L, 2);
es->apploadref = luaL_ref(L, LUA_REGISTRYINDEX);
- lua_pushfstring(L, "%s/?.lua;", corepath);
+
+ /* module path, local directories take priority */
+ int n = 0;
+ lua_pushvalue(L, 3); ++n;
+ lua_pushfstring(L, ";%s/?.lua", corepath); ++n;
EINA_LIST_FREE(es->lincs, data)
{
- lua_pushfstring(L, "%s/?.lua;", data);
+ lua_pushfstring(L, ";%s/?.lua", data);
eina_stringshare_del(data);
++n;
}
- lua_pushfstring(L, "%s/?.eo.lua;", modpath);
- lua_pushfstring(L, "%s/?.lua;", modpath);
- lua_pushfstring(L, "%s/?.lua;", appspath);
- lua_pushvalue(L, 3);
- lua_concat(L, n + 1);
- lua_pushfstring(L, "%s/?.lua;", appspath);
+ lua_pushfstring(L, ";%s/?.eo.lua", modpath); ++n;
+ lua_pushfstring(L, ";%s/?.lua", modpath); ++n;
+ lua_pushfstring(L, ";%s/?.lua", appspath); ++n;
+ lua_concat(L, n);
+
+ /* apps path, local directory takes priority as well */
lua_pushvalue(L, 4);
+ lua_pushfstring(L, ";%s/?.lua", appspath);
lua_concat(L, 2);
+
return 2;
}