aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--com32/lua/src/loadlib.c32
-rw-r--r--com32/lua/src/luaconf.h5
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 "/"