summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés <andmarti@gmail.com>2021-03-23 10:55:20 -0300
committerAndrés <andmarti@gmail.com>2021-03-23 10:55:20 -0300
commite8e167c19a3540655af0a6ff9535298cc15703a4 (patch)
tree232a2ab6a991703231b71b40786eb42514c2ea02
parentafbc248751590d94fcf47beb16cc5a982a4f03ff (diff)
parent047bf3fe65847dd94022227236cf2f1a3480272d (diff)
Merge branch 'freeze' of https://github.com/andmarti1424/sc-im into freeze
-rwxr-xr-xsrc/Makefile18
-rw-r--r--src/lua.c15
2 files changed, 25 insertions, 8 deletions
diff --git a/src/Makefile b/src/Makefile
index fadf0b5..5bea05b 100755
--- a/src/Makefile
+++ b/src/Makefile
@@ -135,15 +135,19 @@ ifneq (, $(shell which pkg-config))
endif
# NOTE: lua support
- ifneq ($(shell pkg-config --exists lua51 || echo 'no'),no)
- CFLAGS += -DXLUA $(shell pkg-config --cflags lua51)
- LDLIBS += $(shell pkg-config --libs lua51) -Wl,--export-dynamic
- else ifneq ($(shell pkg-config --exists lua-5.1 || echo 'no'),no) # FreeBSD
- CFLAGS += -DXLUA $(shell pkg-config --cflags lua-5.1)
+ ifneq ($(shell pkg-config --exists lua || echo 'no'),no) # Check for user's default lua
+ CFLAGS += -DXLUA $(shell pkg-config --cflags lua)
ifneq ($(shell uname -s),Darwin)
- LDLIBS += $(shell pkg-config --libs lua-5.1) -Wl,--export-dynamic
+ LDLIBS += $(shell pkg-config --libs lua) -Wl,--export-dynamic
else
- LDLIBS += $(shell pkg-config --libs lua-5.1) -rdynamic
+ LDLIBS += $(shell pkg-config --libs lua) -rdynamic
+ endif
+ else ifneq ($(shell pkg-config --exists luajit || echo 'no'),no) # If not found, check for luajit
+ CFLAGS += -DXLUA $(shell pkg-config --cflags luajit)
+ ifneq ($(shell uname -s),Darwin)
+ LDLIBS += $(shell pkg-config --libs luajit) -Wl,--export-dynamic
+ else
+ LDLIBS += $(shell pkg-config --libs luajit) -rdynamic
endif
endif
else ifeq ($(shell uname -s),Darwin)
diff --git a/src/lua.c b/src/lua.c
index fd54bb5..d7f6259 100644
--- a/src/lua.c
+++ b/src/lua.c
@@ -295,7 +295,7 @@ LC_NUMBER2(curcol,curcol)
LC_NUMBER2(maxcols,maxcols)
LC_NUMBER2(maxrows,maxrows)
-static const luaL_reg sclib[] = {
+static const luaL_Reg sclib[] = {
{ "lgetnum", l_getnum },
{ "lsetnum", l_setnum },
{ "lsetform", l_setform },
@@ -312,6 +312,13 @@ static const luaL_reg sclib[] = {
{NULL,NULL}
};
+static int registerLuaFuncs(lua_State *L) {
+#if LUA_VERSION_NUM >= 502
+ luaL_newlib(L, sclib); /* Load SC specific LUA commands after init.lua exec*/
+#endif
+ return 1;
+}
+
/**
* \brief TODO Document doLuainit()
*
@@ -334,7 +341,13 @@ void doLuainit() {
if (lua_pcall(L, 0, 0, 0)) /* PRIMING RUN. FORGET THIS AND YOU'RE TOAST */
fprintf(stderr, "\nFATAL ERROR:\n Couldn't initialized Lua: %s\n\n", lua_tostring(L,-1));
}
+
+
+#if LUA_VERSION_NUM >= 502
+ luaL_requiref(L, "sc", registerLuaFuncs, 1); /* sc = require("sc") */
+#else
luaL_register(L, "sc", sclib); /* Load SC specific LUA commands after init.lua exec*/
+#endif
return;
}