summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/configure2
-rw-r--r--src/nopsyncd.c23
2 files changed, 24 insertions, 1 deletions
diff --git a/src/configure b/src/configure
index 75ed3e6..dd60d70 100755
--- a/src/configure
+++ b/src/configure
@@ -162,7 +162,7 @@ if [ -z "$LUA_DIR" ]; then
break
fi
else
- for dir in `ls -d $prefix/include/lua* 2> /dev/null`; do
+ for dir in `ls -r -d $prefix/include/lua* 2> /dev/null`; do
if [ -e $dir/lua.h ]; then
test_lua_version $dir/lua.h
if [ $? -eq 1 ]; then
diff --git a/src/nopsyncd.c b/src/nopsyncd.c
index 8a059d0..d4f3c08 100644
--- a/src/nopsyncd.c
+++ b/src/nopsyncd.c
@@ -36,6 +36,20 @@
#define QLISTENER LIBDIR"/qlistener.lua"
#define TCPSERVER LIBDIR"/tcpserver.lua"
+#if LUA_VERSION_NUM > 501
+static const luaL_Reg nopsyncd_lualibs[] = {
+ {"_G", luaopen_base},
+ {LUA_LOADLIBNAME, luaopen_package},
+ {LUA_TABLIBNAME, luaopen_table},
+ {LUA_STRLIBNAME, luaopen_string},
+ {LUA_MATHLIBNAME, luaopen_math},
+ {LUA_IOLIBNAME, luaopen_io},
+ {LUA_OSLIBNAME, luaopen_os},
+ {LUA_BITLIBNAME, luaopen_bit32},
+ {LUA_PIPELIBNAME, luaopen_pipe},
+ {NULL, NULL}
+};
+#else
static const luaL_Reg nopsyncd_lualibs[] = {
{"", luaopen_base},
{LUA_LOADLIBNAME, luaopen_package},
@@ -47,15 +61,24 @@ static const luaL_Reg nopsyncd_lualibs[] = {
{LUA_PIPELIBNAME, luaopen_pipe},
{NULL, NULL}
};
+#endif
int init_main_loop(lua_State *L, const char* filename)
{
const luaL_Reg *lib = nopsyncd_lualibs;
+
+#if LUA_VERSION_NUM > 501
+ for (; lib->func; lib++) {
+ luaL_requiref(L, lib->name, lib->func, 1);
+ lua_pop(L, 1);
+ }
+#else
for (; lib->func; lib++) {
lua_pushcfunction(L, lib->func);
lua_pushstring(L, lib->name);
lua_call(L, 1, 0);
}
+#endif
int ret = luaL_loadfile(L, filename);
if(ret) {