Created
December 5, 2019 12:36
-
-
Save amuramatsu/041701a67a754af767739190c48dd1c4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/Makefile b/src/Makefile | |
index fb08e9a..3ae1543 100755 | |
--- a/src/Makefile | |
+++ b/src/Makefile | |
@@ -122,7 +122,14 @@ ifneq (, $(shell which pkg-config)) | |
endif | |
# NOTE: lua support | |
- ifneq ($(shell pkg-config --exists lua51 || echo 'no'),no) | |
+ ifneq ($(shell pkg-config --exists lua || echo 'no'),no) | |
+ CFLAGS += -DXLUA $(shell pkg-config --cflags lua) | |
+ ifneq ($(shell uname -s),Darwin) | |
+ LDLIBS += $(shell pkg-config --libs lua) -Wl,--export-dynamic | |
+ else | |
+ LDLIBS += $(shell pkg-config --libs lua) -rdynamic | |
+ endif | |
+ else 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 | |
diff --git a/src/lua.c b/src/lua.c | |
index fd54bb5..67054a5 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 }, | |
@@ -334,7 +334,11 @@ 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_newlib(L, sclib); /* Load SC specific LUA commands after init.lua exec*/ | |
+#else | |
luaL_register(L, "sc", sclib); /* Load SC specific LUA commands after init.lua exec*/ | |
+#endif | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment