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)
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)
499 const char *modpath = es->moddir; 499 const char *modpath = es->moddir;
500 const char *appspath = es->appsdir; 500 const char *appspath = es->appsdir;
501 Eina_Stringshare *data = NULL; 501 Eina_Stringshare *data = NULL;
502 int n = 4;
503 if (!corepath || !modpath || !appspath) 502 if (!corepath || !modpath || !appspath)
504 return 0; 503 return 0;
505 lua_pushvalue(L, 1); 504 lua_pushvalue(L, 1);
506 es->requireref = luaL_ref(L, LUA_REGISTRYINDEX); 505 es->requireref = luaL_ref(L, LUA_REGISTRYINDEX);
507 lua_pushvalue(L, 2); 506 lua_pushvalue(L, 2);
508 es->apploadref = luaL_ref(L, LUA_REGISTRYINDEX); 507 es->apploadref = luaL_ref(L, LUA_REGISTRYINDEX);
509 lua_pushfstring(L, "%s/?.lua;", corepath); 508
509 /* module path, local directories take priority */
510 int n = 0;
511 lua_pushvalue(L, 3); ++n;
512 lua_pushfstring(L, ";%s/?.lua", corepath); ++n;
510 EINA_LIST_FREE(es->lincs, data) 513 EINA_LIST_FREE(es->lincs, data)
511 { 514 {
512 lua_pushfstring(L, "%s/?.lua;", data); 515 lua_pushfstring(L, ";%s/?.lua", data);
513 eina_stringshare_del(data); 516 eina_stringshare_del(data);
514 ++n; 517 ++n;
515 } 518 }
516 lua_pushfstring(L, "%s/?.eo.lua;", modpath); 519 lua_pushfstring(L, ";%s/?.eo.lua", modpath); ++n;
517 lua_pushfstring(L, "%s/?.lua;", modpath); 520 lua_pushfstring(L, ";%s/?.lua", modpath); ++n;
518 lua_pushfstring(L, "%s/?.lua;", appspath); 521 lua_pushfstring(L, ";%s/?.lua", appspath); ++n;
519 lua_pushvalue(L, 3); 522 lua_concat(L, n);
520 lua_concat(L, n + 1); 523
521 lua_pushfstring(L, "%s/?.lua;", appspath); 524 /* apps path, local directory takes priority as well */
522 lua_pushvalue(L, 4); 525 lua_pushvalue(L, 4);
526 lua_pushfstring(L, ";%s/?.lua", appspath);
523 lua_concat(L, 2); 527 lua_concat(L, 2);
528
524 return 2; 529 return 2;
525} 530}
526 531