mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2025-07-22 10:45:15 +03:00
93 lines
2.4 KiB
Diff
93 lines
2.4 KiB
Diff
From a6eace5116d1a711218a7c9086a4e3c4db88ee57 Mon Sep 17 00:00:00 2001
|
|
From: Natanael Copa <ncopa@alpinelinux.org>
|
|
Date: Wed, 19 Jun 2013 14:52:00 +0200
|
|
Subject: [PATCH] support for Lua 5.2
|
|
|
|
---
|
|
Makefile | 2 +-
|
|
laugeas.c | 21 +++++++++++++++++----
|
|
2 files changed, 18 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/Makefile b/Makefile
|
|
index e79a48c..22dca18 100644
|
|
--- a/Makefile
|
|
+++ b/Makefile
|
|
@@ -10,7 +10,7 @@ else
|
|
FULL_VERSION := $(VERSION)
|
|
endif
|
|
|
|
-LUAPC := $(shell for pc in lua lua5.1; do \
|
|
+LUAPC := $(shell for pc in lua lua5.2 lua5.1; do \
|
|
$(PKGCONFIG) --exists $$pc && echo $$pc && break; \
|
|
done)
|
|
|
|
diff --git a/laugeas.c b/laugeas.c
|
|
index 05b99c3..11a8736 100644
|
|
--- a/laugeas.c
|
|
+++ b/laugeas.c
|
|
@@ -4,6 +4,7 @@
|
|
-- In general, the functions map straight to the C library. See the
|
|
-- descriptions below for details.
|
|
*/
|
|
+#include <assert.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <lua.h>
|
|
@@ -21,6 +22,18 @@
|
|
|
|
#define LUA_FILEHANDLE "FILE*"
|
|
|
|
+#if LUA_VERSION_NUM < 502
|
|
+# define luaL_newlib(L,l) (lua_newtable(L), luaL_register(L,NULL,l))
|
|
+# define luaL_setfuncs(L,l,n) (assert(n==0), luaL_register(L,NULL,l))
|
|
+#else
|
|
+static int luaL_typerror (lua_State *L, int narg, const char *tname)
|
|
+{
|
|
+ const char *msg = lua_pushfstring(L, "%s expected, got %s",
|
|
+ tname, luaL_typename(L, narg));
|
|
+ return luaL_argerror(L, narg, msg);
|
|
+}
|
|
+#endif
|
|
+
|
|
struct aug_flagmap {
|
|
const char *name;
|
|
int value;
|
|
@@ -286,7 +299,7 @@ static int Paug_error_details(lua_State *L)
|
|
return 1;
|
|
}
|
|
|
|
-static const luaL_reg Paug_methods[] = {
|
|
+static const luaL_Reg Paug_methods[] = {
|
|
/*
|
|
--- Initializes the library.
|
|
--
|
|
@@ -363,7 +376,7 @@ function print(augobj, path, file_handle)
|
|
{NULL, NULL}
|
|
};
|
|
|
|
-static const luaL_reg Luag_meta_methods[] = {
|
|
+static const luaL_Reg Laug_meta_methods[] = {
|
|
{"__gc", Paug_close},
|
|
{NULL, NULL}
|
|
};
|
|
@@ -372,7 +385,7 @@ static const luaL_reg Luag_meta_methods[] = {
|
|
LUALIB_API int luaopen_augeas(lua_State *L)
|
|
{
|
|
struct aug_flagmap *f = Taug_flagmap;
|
|
- luaL_register(L, LIBNAME, Paug_methods);
|
|
+ luaL_newlib(L, Paug_methods);
|
|
lua_pushliteral(L, "version");
|
|
lua_pushliteral(L, VERSION);
|
|
lua_settable(L, -3);
|
|
@@ -385,7 +398,7 @@ LUALIB_API int luaopen_augeas(lua_State *L)
|
|
}
|
|
|
|
luaL_newmetatable(L, PAUG_META);
|
|
- luaL_register(L, NULL, Luag_meta_methods);
|
|
+ luaL_setfuncs(L, Laug_meta_methods, 0);
|
|
lua_pushliteral(L, "__index");
|
|
lua_pushvalue(L, -3);
|
|
lua_rawset(L, -3);
|
|
--
|
|
1.8.3.1
|
|
|