diff options
author | Ferenc Wágner <wferi@niif.hu> | 2013-12-17 11:34:29 +0100 |
---|---|---|
committer | Ferenc Wágner <wferi@niif.hu> | 2014-03-02 09:16:32 +0100 |
commit | ea804356f1dea456524807d809673c7f27ec9b00 (patch) | |
tree | c4c4e1e65171ef605093b844ec1336f2c9cef049 | |
parent | 98d07d0daf618f5e5accd6410e7c5d06f3157f48 (diff) | |
download | syslinux-ea804356f1dea456524807d809673c7f27ec9b00.tar.gz |
lua: base the package load paths on the Syslinux path
-rw-r--r-- | com32/lua/src/loadlib.c | 32 | ||||
-rw-r--r-- | com32/lua/src/luaconf.h | 5 |
2 files changed, 35 insertions, 2 deletions
diff --git a/com32/lua/src/loadlib.c b/com32/lua/src/loadlib.c index 2029f677..1d93569a 100644 --- a/com32/lua/src/loadlib.c +++ b/com32/lua/src/loadlib.c @@ -16,6 +16,10 @@ #include <windows.h> #endif +/* Base the Lua paths on the Syslinux path */ +#ifdef SYSLINUX +#include <fs.h> +#endif #include <stdlib.h> #include <string.h> @@ -667,6 +671,33 @@ static int ll_seeall (lua_State *L) { #define AUXMARK "\1" +#ifdef SYSLINUX +static void setpath (lua_State *L, const char *fieldname, const char *envname1, + const char *envname2, const char *def) { + struct path_entry *entry; + luaL_Buffer b; + luaL_buffinit (L, &b); + (void)envname1; + (void)envname2; + list_for_each_entry(entry, &PATH, list) { + const char *e = entry->str; + int need_slash = e[strlen(e)-1] != '/'; + void add (const char *stem) { + luaL_addstring (&b, e); + if (need_slash) luaL_addchar (&b, '/'); + luaL_addstring (&b, stem); + luaL_addstring (&b, def); + luaL_addchar (&b, ';'); + } + add ("?"); + add ("?/init"); + } + luaL_addstring (&b, "./?"); + luaL_addstring (&b, def); + luaL_pushresult (&b); + lua_setfield(L, -2, fieldname); +} +#else /* ** return registry.LUA_NOENV as a boolean */ @@ -696,6 +727,7 @@ static void setpath (lua_State *L, const char *fieldname, const char *envname1, setprogdir(L); lua_setfield(L, -2, fieldname); } +#endif static const luaL_Reg pk_funcs[] = { diff --git a/com32/lua/src/luaconf.h b/com32/lua/src/luaconf.h index ed4a4d4b..011b9688 100644 --- a/com32/lua/src/luaconf.h +++ b/com32/lua/src/luaconf.h @@ -98,8 +98,9 @@ LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll;" ".\\?.dll" #elif defined(SYSLINUX) -#define LUA_PATH_DEFAULT "./?.lua" -#define LUA_CPATH_DEFAULT "./?.c32" +/* Extensions for converting the Syslinux path into package load paths */ +#define LUA_PATH_DEFAULT ".lua" +#define LUA_CPATH_DEFAULT ".c32" #else /* }{ */ #define LUA_VDIR LUA_VERSION_MAJOR "." LUA_VERSION_MINOR "/" |