Gentoo Archives: gentoo-commits

From: Conrad Kostecki <conikost@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lua/luaexpat/files/, dev-lua/luaexpat/
Date: Thu, 08 Oct 2020 19:14:08
Message-Id: 1602184421.f8051ee00cc653d5e43febbf00b05dc24959ee8c.conikost@gentoo
1 commit: f8051ee00cc653d5e43febbf00b05dc24959ee8c
2 Author: Azamat H. Hackimov <azamat.hackimov <AT> gmail <DOT> com>
3 AuthorDate: Mon Oct 5 22:05:59 2020 +0000
4 Commit: Conrad Kostecki <conikost <AT> gentoo <DOT> org>
5 CommitDate: Thu Oct 8 19:13:41 2020 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f8051ee0
7
8 dev-lua/luaexpat: restore more functionality
9
10 Restore more features that sill missed in forked 1.3.3
11
12 See: https://github.com/tomasguisasola/luaexpat/pull/5
13 Closes: https://github.com/gentoo/gentoo/pull/17813
14 Package-Manager: Portage-3.0.4, Repoman-3.0.1
15 Signed-off-by: Azamat H. Hackimov <azamat.hackimov <AT> gmail.com>
16 Signed-off-by: Conrad Kostecki <conikost <AT> gentoo.org>
17
18 .../luaexpat/files/luaexpat-1.3.3_makefile.patch | 10 +-
19 .../luaexpat-1.3.3_restore_functionality.patch | 109 +++++++++++++++++++++
20 dev-lua/luaexpat/luaexpat-1.3.3-r2.ebuild | 49 +++++++++
21 3 files changed, 167 insertions(+), 1 deletion(-)
22
23 diff --git a/dev-lua/luaexpat/files/luaexpat-1.3.3_makefile.patch b/dev-lua/luaexpat/files/luaexpat-1.3.3_makefile.patch
24 index 95de7be6069..a780dddea83 100644
25 --- a/dev-lua/luaexpat/files/luaexpat-1.3.3_makefile.patch
26 +++ b/dev-lua/luaexpat/files/luaexpat-1.3.3_makefile.patch
27 @@ -1,5 +1,5 @@
28 diff --git a/makefile b/makefile
29 -index 1a5a145..df09239 100644
30 +index 1a5a145..50912f0 100644
31 --- a/makefile
32 +++ b/makefile
33 @@ -45,7 +45,7 @@ OBJS= src/lxplib.o
34 @@ -11,3 +11,11 @@ index 1a5a145..df09239 100644
35
36 install:
37 mkdir -p $(LUA_LIBDIR)
38 +@@ -53,6 +53,7 @@ install:
39 + cd $(LUA_LIBDIR); ln -f -s $(LIBNAME) $T.so
40 + mkdir -p $(LUA_DIR)/$T
41 + cp src/$T/lom.lua $(LUA_DIR)/$T
42 ++ cp src/$T/totable.lua $(LUA_DIR)/$T
43 +
44 + clean:
45 + rm -f src/$(LIBNAME) $(OBJS)
46
47 diff --git a/dev-lua/luaexpat/files/luaexpat-1.3.3_restore_functionality.patch b/dev-lua/luaexpat/files/luaexpat-1.3.3_restore_functionality.patch
48 new file mode 100644
49 index 00000000000..c0bc8c1a7b4
50 --- /dev/null
51 +++ b/dev-lua/luaexpat/files/luaexpat-1.3.3_restore_functionality.patch
52 @@ -0,0 +1,109 @@
53 +From 4ef48128bd9a725daca1d5a4aabe0c1665d78742 Mon Sep 17 00:00:00 2001
54 +From: Matthew Wild <mwild1@×××××.com>
55 +Date: Wed, 2 Apr 2014 21:02:29 +0100
56 +Subject: [PATCH] Make merging of CharacterData events optional, controlled by
57 + the 3rd parameter of lxp.new()
58 +
59 +---
60 + src/lxplib.c | 12 ++++++++++--
61 + 1 file changed, 10 insertions(+), 2 deletions(-)
62 +
63 +diff --git a/src/lxplib.c b/src/lxplib.c
64 +index a7d6c42..794f6e3 100644
65 +--- a/src/lxplib.c
66 ++++ b/src/lxplib.c
67 +@@ -57,6 +57,7 @@ struct lxp_userdata {
68 + int tableref; /* table with callbacks for this parser */
69 + enum XPState state;
70 + luaL_Buffer *b; /* to concatenate sequences of cdata pieces */
71 ++ int bufferCharData; /* whether to buffer cdata pieces */
72 + };
73 +
74 + typedef struct lxp_userdata lxp_userdata;
75 +@@ -171,8 +172,13 @@ static void f_CharData (void *ud, const char *s, int len) {
76 + lxp_userdata *xpu = (lxp_userdata *)ud;
77 + if (xpu->state == XPSok) {
78 + if (getHandle(xpu, CharDataKey) == 0) return; /* no handle */
79 +- xpu->state = XPSstring;
80 +- luaL_buffinit(xpu->L, xpu->b);
81 ++ if(xpu->bufferCharData != 0) {
82 ++ xpu->state = XPSstring;
83 ++ luaL_buffinit(xpu->L, xpu->b);
84 ++ } else {
85 ++ lua_pushlstring(xpu->L, s, len);
86 ++ docall(xpu, 1, 0);
87 ++ }
88 + }
89 + if (xpu->state == XPSstring)
90 + luaL_addlstring(xpu->b, s, len);
91 +@@ -393,8 +399,10 @@ static void checkcallbacks (lua_State *L) {
92 +
93 + static int lxp_make_parser (lua_State *L) {
94 + XML_Parser p;
95 ++ int bufferCharData = (lua_type(L, 3) != LUA_TBOOLEAN) || (lua_toboolean(L, 3) != 0);
96 + char sep = *luaL_optstring(L, 2, "");
97 + lxp_userdata *xpu = createlxp(L);
98 ++ xpu->bufferCharData = bufferCharData;
99 + p = xpu->parser = (sep == '\0') ? XML_ParserCreate(NULL) :
100 + XML_ParserCreateNS(NULL, sep);
101 + if (!p)
102 +From cbaf85740f6032cfc025c7bde3f9861d15825928 Mon Sep 17 00:00:00 2001
103 +From: Matthew Wild <mwild1@×××××.com>
104 +Date: Wed, 2 Apr 2014 20:56:58 +0100
105 +Subject: [PATCH] Add support for XmlDecl handlers
106 +
107 +---
108 + src/lxplib.c | 14 +++++++++++++-
109 + src/lxplib.h | 1 +
110 + 2 files changed, 14 insertions(+), 1 deletion(-)
111 +
112 +diff --git a/src/lxplib.c b/src/lxplib.c
113 +index 35bec3c..a7d6c42 100644
114 +--- a/src/lxplib.c
115 ++++ b/src/lxplib.c
116 +@@ -345,6 +345,16 @@ static void f_StartDoctypeDecl (void *ud, const XML_Char *doctypeName,
117 + docall(xpu, 4, 0);
118 + }
119 +
120 ++static void f_XmlDecl (void *ud, const XML_Char *version,
121 ++ const XML_Char *encoding,
122 ++ int standalone) {
123 ++ lxp_userdata *xpu = (lxp_userdata *)ud;
124 ++ if (getHandle(xpu, XmlDeclKey) == 0) return; /* no handle */
125 ++ lua_pushstring(xpu->L, version);
126 ++ lua_pushstring(xpu->L, encoding);
127 ++ lua_pushboolean(xpu->L, standalone);
128 ++ docall(xpu, 3, 0);
129 ++}
130 + /* }====================================================== */
131 +
132 +
133 +@@ -365,7 +375,7 @@ static void checkcallbacks (lua_State *L) {
134 + "Default", "DefaultExpand", "StartElement", "EndElement",
135 + "ExternalEntityRef", "StartNamespaceDecl", "EndNamespaceDecl",
136 + "NotationDecl", "NotStandalone", "ProcessingInstruction",
137 +- "UnparsedEntityDecl", "StartDoctypeDecl", NULL};
138 ++ "UnparsedEntityDecl", "StartDoctypeDecl", "XmlDecl", NULL};
139 + if (hasfield(L, "_nonstrict")) return;
140 + lua_pushnil(L);
141 + while (lua_next(L, 1)) {
142 +@@ -420,6 +430,8 @@ static int lxp_make_parser (lua_State *L) {
143 + XML_SetUnparsedEntityDeclHandler(p, f_UnparsedEntityDecl);
144 + if (hasfield(L, StartDoctypeDeclKey))
145 + XML_SetStartDoctypeDeclHandler(p, f_StartDoctypeDecl);
146 ++ if (hasfield(L, XmlDeclKey))
147 ++ XML_SetXmlDeclHandler(p, f_XmlDecl);
148 + return 1;
149 + }
150 +
151 +diff --git a/src/lxplib.h b/src/lxplib.h
152 +index 9c0be4f..4c7084c 100644
153 +--- a/src/lxplib.h
154 ++++ b/src/lxplib.h
155 +@@ -20,5 +20,6 @@
156 + #define ProcessingInstructionKey "ProcessingInstruction"
157 + #define UnparsedEntityDeclKey "UnparsedEntityDecl"
158 + #define StartDoctypeDeclKey "StartDoctypeDecl"
159 ++#define XmlDeclKey "XmlDecl"
160 +
161 + int luaopen_lxp (lua_State *L);
162
163 diff --git a/dev-lua/luaexpat/luaexpat-1.3.3-r2.ebuild b/dev-lua/luaexpat/luaexpat-1.3.3-r2.ebuild
164 new file mode 100644
165 index 00000000000..5b99b5d96ba
166 --- /dev/null
167 +++ b/dev-lua/luaexpat/luaexpat-1.3.3-r2.ebuild
168 @@ -0,0 +1,49 @@
169 +# Copyright 1999-2020 Gentoo Authors
170 +# Distributed under the terms of the GNU General Public License v2
171 +
172 +EAPI=7
173 +
174 +inherit multilib-minimal toolchain-funcs
175 +
176 +DESCRIPTION="LuaExpat is a SAX XML parser based on the Expat library"
177 +HOMEPAGE="https://matthewwild.co.uk/projects/luaexpat/ https://github.com/tomasguisasola/luaexpat"
178 +SRC_URI="https://github.com/tomasguisasola/luaexpat/archive/v${PV}.tar.gz -> ${P}.tar.gz"
179 +
180 +LICENSE="MIT"
181 +SLOT="0"
182 +KEYWORDS="~amd64 ~arm ~arm64 ~hppa ~mips ~ppc ~ppc64 ~sparc ~x86"
183 +
184 +RDEPEND=">=dev-lang/lua-5.1.5-r2:0[${MULTILIB_USEDEP}]
185 + >=dev-libs/expat-2.1.0-r3[${MULTILIB_USEDEP}]"
186 +DEPEND="${RDEPEND}"
187 +BDEPEND="virtual/pkgconfig"
188 +
189 +PATCHES=(
190 + "${FILESDIR}/${P}_makefile.patch"
191 + "${FILESDIR}/${P}_getcurrentbytecount.patch"
192 + "${FILESDIR}/${P}_restore_functionality.patch"
193 +)
194 +
195 +src_prepare() {
196 + default
197 + multilib_copy_sources
198 +}
199 +
200 +multilib_src_compile() {
201 + emake \
202 + CFLAGS="${CFLAGS}" \
203 + LDFLAGS="${LDFLAGS}" \
204 + CC="$(tc-getCC)" \
205 + LUA_INC="$($(tc-getPKG_CONFIG) --variable INSTALL_INC lua)"
206 +}
207 +
208 +multilib_src_install() {
209 + emake \
210 + LUA_DIR="${D}/$($(tc-getPKG_CONFIG) --variable INSTALL_LMOD lua)" \
211 + LUA_LIBDIR="${D}/$($(tc-getPKG_CONFIG) --variable INSTALL_CMOD lua)" \
212 + install
213 +}
214 +
215 +multilib_src_install_all() {
216 + dodoc -r README.md doc/*
217 +}