[syslinux:master] lua: base the package load paths on the Syslinux path

syslinux-bot for Ferenc Wágner wferi at niif.hu
Sun Mar 2 13:48:30 PST 2014


Commit-ID:  ea804356f1dea456524807d809673c7f27ec9b00
Gitweb:     http://www.syslinux.org/commit/ea804356f1dea456524807d809673c7f27ec9b00
Author:     Ferenc Wágner <wferi at niif.hu>
AuthorDate: Tue, 17 Dec 2013 11:34:29 +0100
Committer:  Ferenc Wágner <wferi at niif.hu>
CommitDate: Sun, 2 Mar 2014 09:16:32 +0100

lua: base the package load paths on the Syslinux path


---
 com32/lua/src/loadlib.c | 32 ++++++++++++++++++++++++++++++++
 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 2029f67..1d93569 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 ed4a4d4..011b968 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 "/"


More information about the Syslinux-commits mailing list