aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-pc/lpc-lua5.2-compat.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/lua-pc/lpc-lua5.2-compat.patch')
-rw-r--r--main/lua-pc/lpc-lua5.2-compat.patch115
1 files changed, 61 insertions, 54 deletions
diff --git a/main/lua-pc/lpc-lua5.2-compat.patch b/main/lua-pc/lpc-lua5.2-compat.patch
index e12131e865..98ec7b1a58 100644
--- a/main/lua-pc/lpc-lua5.2-compat.patch
+++ b/main/lua-pc/lpc-lua5.2-compat.patch
@@ -1,7 +1,6 @@
-diff -ru lpc-1.0.0.orig/Makefile lpc-1.0.0/Makefile
---- lpc-1.0.0.orig/Makefile 2012-08-21 17:39:10.000000000 -0300
-+++ lpc-1.0.0/Makefile 2014-05-10 14:54:26.573670586 -0300
-@@ -1,16 +1,20 @@
+--- lpc-1.0.0.orig/Makefile
++++ lpc-1.0.0/Makefile
+@@ -1,17 +1,24 @@
-LUA_PREFIX = /usr/local/
-PREFIX = /usr/local/
+LUA_PKGCONF ?= lua
@@ -13,23 +12,35 @@ diff -ru lpc-1.0.0.orig/Makefile lpc-1.0.0/Makefile
+ifneq ($(shell pkg-config $(LUA_PKGCONF) || echo not-installed),)
+$(error $(LUA_PKGCONF).pc not found)
+endif
-+
-+INSTALL_PREFIX = $(DESTDIR)$(shell pkg-config $(LUA_PKGCONF) --variable=INSTALL_CMOD)
++INSTALL_PREFIX = $(DESTDIR)$(shell pkg-config $(LUA_PKGCONF) --variable=INSTALL_CMOD)
++
CC = gcc
TARGET = lpc.so
OBJS = lpc.o
LIBS =
-CFLAGS = -I $(LUA_PREFIX)/include -fPIC
--LDFLAGS = -shared -fPIC
-+CFLAGS = $(shell pkg-config $(LUA_PKGCONF) --cflags) -fPIC
-+LDFLAGS = $(shell pkg-config $(LUA_PKGCONF) --libs) -shared -fPIC
++CFLAGS = -fPIC
+ LDFLAGS = -shared -fPIC
++LUA_CFLAGS = $(shell pkg-config $(LUA_PKGCONF) --cflags)
++LUA_LDFLAGS = $(shell pkg-config $(LUA_PKGCONF) --libs)
++
default: $(TARGET)
-diff -ru lpc-1.0.0.orig/lpc.c lpc-1.0.0/lpc.c
---- lpc-1.0.0.orig/lpc.c 2012-08-21 17:39:10.000000000 -0300
-+++ lpc-1.0.0/lpc.c 2014-05-10 16:35:47.714059553 -0300
+
+@@ -29,7 +36,7 @@
+ rm -rf $(MODULE)-$(VERSION)
+
+ $(TARGET): $(OBJS)
+- $(CC) $(LDFLAGS) -o $(TARGET) $(OBJS)
++ $(CC) $(LUA_LDFLAGS) $(LDFLAGS) -o $(TARGET) $(OBJS)
+
+ .c.o:
+- $(CC) $(CFLAGS) -c $< -o $@
++ $(CC) $(LUA_CFLAGS) $(CFLAGS) -c $< -o $@
+--- lpc-1.0.0.orig/lpc.c
++++ lpc-1.0.0/lpc.c
@@ -1,7 +1,7 @@
/*
** LuaProcessCall
@@ -45,7 +56,12 @@ diff -ru lpc-1.0.0.orig/lpc.c lpc-1.0.0/lpc.c
-#define topfile(L) ((FILE **)luaL_checkudata(L, 1, LUA_FILEHANDLE))
+#if LUA_VERSION_NUM < 502
-+
+
+-static FILE *tofile (lua_State *L) {
+- FILE **f = topfile(L);
+- if (*f == NULL)
+- luaL_error(L, "attempt to use a closed file");
+- return *f;
+static int lua_absindex(lua_State *L, int idx) {
+ return (idx > 0 || idx <= LUA_REGISTRYINDEX)? idx : lua_gettop(L) + idx + 1;
+} /* lua_absindex() */
@@ -96,27 +112,8 @@ diff -ru lpc-1.0.0.orig/lpc.c lpc-1.0.0/lpc.c
+ lua_pushinteger(L, en);
+ return 3;
+ }
-+}
-+
-+#define isclosed(p) ((p)->f == NULL)
-+#define markclosed(p) ((p)->f = NULL)
-+
-+#else
-+
-+#define isclosed(p) ((p)->closef == NULL)
-+#define markclosed(p) ((p)->closef = NULL)
-+
-+#endif
-+
-+#define tolstream(L) ((luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
+ }
- static FILE *tofile (lua_State *L) {
-- FILE **f = topfile(L);
-- if (*f == NULL)
-- luaL_error(L, "attempt to use a closed file");
-- return *f;
--}
--
-static int pushresult (lua_State *L, int i, const char *filename) {
- int en = errno; /* calls to Lua API may change this value */
- if (i) {
@@ -132,32 +129,43 @@ diff -ru lpc-1.0.0.orig/lpc.c lpc-1.0.0/lpc.c
- lua_pushinteger(L, en);
- return 3;
- }
--}
--
--static int io_fclose (lua_State *L) {
-- FILE **p = topfile(L);
-- int ok = (fclose(*p) == 0);
-- *p = NULL;
-- return pushresult(L, ok, NULL);
++#define isclosed(p) ((p)->f == NULL)
++#define markclosed(p) ((p)->f = NULL)
++
++#else
++
++#define isclosed(p) ((p)->closef == NULL)
++#define markclosed(p) ((p)->closef = NULL)
++
++#endif
++
++#define tolstream(L) ((luaL_Stream *)luaL_checkudata(L, 1, LUA_FILEHANDLE))
++
++static FILE *tofile (lua_State *L) {
+ luaL_Stream *p = tolstream(L);
+ if (isclosed(p))
+ luaL_error(L, "attempt to use a closed file");
+ return p->f;
}
--static FILE **newfile_fd(lua_State *L, int fd, const char *mode)
+-static int io_fclose (lua_State *L) {
+- FILE **p = topfile(L);
+- int ok = (fclose(*p) == 0);
+- *p = NULL;
+- return pushresult(L, ok, NULL);
+static int io_fclose (lua_State *L)
- {
-- FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *));
-- *pf = NULL; /* file handle is currently `closed' */
++{
+ luaL_Stream *p = tolstream(L);
+ int res = fclose(p->f);
+ markclosed(p);
+ return luaL_fileresult(L, (res == 0), NULL);
-+}
-+
+ }
+
+-static FILE **newfile_fd(lua_State *L, int fd, const char *mode)
+static luaL_Stream *newfile_fd(lua_State *L, int fd, const char *mode)
-+{
+ {
+- FILE **pf = (FILE **)lua_newuserdata(L, sizeof(FILE *));
+- *pf = NULL; /* file handle is currently `closed' */
+ luaL_Stream *p = (luaL_Stream *) lua_newuserdata(L, sizeof(luaL_Stream));
+ markclosed(p);
luaL_getmetatable(L, LUA_FILEHANDLE);
@@ -202,12 +210,6 @@ diff -ru lpc-1.0.0.orig/lpc.c lpc-1.0.0/lpc.c
- /* Cleanup */
- close(p_out[0]);
- close(p_in[1]);
--
-- lua_pushnumber(L, pid);
-- out = newfile_fd(L, p_out[1], "w");
-- in = newfile_fd(L, p_in[0], "r");
-- return 3;
-- }
+ /* Cleanup */
+ close(p_out[0]);
+ close(p_in[1]);
@@ -215,7 +217,12 @@ diff -ru lpc-1.0.0.orig/lpc.c lpc-1.0.0/lpc.c
+ newfile_fd(L, p_out[1], "w");
+ newfile_fd(L, p_in[0], "r");
+ return 3;
-+
+
+- lua_pushnumber(L, pid);
+- out = newfile_fd(L, p_out[1], "w");
+- in = newfile_fd(L, p_in[0], "r");
+- return 3;
+- }
+err_closeinout:
+ close(p_in[0]);
+ close(p_in[1]);