aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-stringy
diff options
context:
space:
mode:
authorKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-07-11 17:17:22 +0300
committerKaarle Ritvanen <kaarle.ritvanen@datakunkku.fi>2014-07-11 17:23:02 +0300
commit2f4fe7a3dec8be69a248e4086b4c99f9135541e7 (patch)
tree7510224b4f187bc2d9eb4b2e5ca2d538acc0a9bf /main/lua-stringy
parent56b3caa54422c3e2a4e924dd51c07b346f62068b (diff)
downloadaports-2f4fe7a3dec8be69a248e4086b4c99f9135541e7.tar.bz2
aports-2f4fe7a3dec8be69a248e4086b4c99f9135541e7.tar.xz
main/lua-stringy: upgrade to 0.4 and support Lua 5.2
Diffstat (limited to 'main/lua-stringy')
-rw-r--r--main/lua-stringy/0001-use-memcmp-for-startswith-endswith.patch78
-rw-r--r--main/lua-stringy/APKBUILD63
-rw-r--r--main/lua-stringy/link-to-correct-lua-version.patch19
-rw-r--r--main/lua-stringy/stringy-memcmp.patch64
4 files changed, 67 insertions, 157 deletions
diff --git a/main/lua-stringy/0001-use-memcmp-for-startswith-endswith.patch b/main/lua-stringy/0001-use-memcmp-for-startswith-endswith.patch
deleted file mode 100644
index 4680a05615..0000000000
--- a/main/lua-stringy/0001-use-memcmp-for-startswith-endswith.patch
+++ /dev/null
@@ -1,78 +0,0 @@
-From 86e4e9d16befd02230a699f045afdd68a47f6122 Mon Sep 17 00:00:00 2001
-From: Natanael Copa <ncopa@alpinelinux.org>
-Date: Wed, 12 Oct 2011 20:57:55 +0200
-Subject: [PATCH] use memcmp for startswith/endswith
-
-This fixes an uninitialized variable bug and should be faster since
-most libc has optimized memcmp()
-
-Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
----
- stringy/stringy.c | 43 +++++++++++++------------------------------
- 1 files changed, 13 insertions(+), 30 deletions(-)
-
-diff --git a/stringy/stringy.c b/stringy/stringy.c
-index 3341b87..aa9a2a2 100644
---- a/stringy/stringy.c
-+++ b/stringy/stringy.c
-@@ -65,44 +65,27 @@ static int endswith(lua_State *L) {
-
- size_t token_len;
- const char *token = luaL_checklstring(L, 2, &token_len);
-+ int end = 0;
-
-- int ti = token_len, si = string_len, end = 1;
-- if(token_len <= string_len){
-- while(ti > 0) {
-- if(string[--si] != token[--ti]){
-- end = 0;
-- break;
--
-- }
-- }
-- }
-- else {
-- end = 0;
-+ if(token_len <= string_len) {
-+ string += string_len - token_len;
-+ end = memcmp(string, token, token_len) == 0;
- }
- lua_pushboolean(L, end);
- return 1;
- }
-
- static int startswith(lua_State *L) {
-- const char *string = luaL_checkstring(L, 1);
-- int string_len = lua_objlen(L, 1);
-+ size_t string_len;
-+ const char *string = luaL_checklstring(L, 1, &string_len);
-+
-+ size_t token_len;
-+ const char *token = luaL_checklstring(L, 2, &token_len);
-+ int start = 0;
-+
-+ if (token_len <= string_len)
-+ start = memcmp(string, token, token_len) == 0;
-
-- const char *token = luaL_checkstring(L, 2);
-- int token_len = lua_objlen(L, 2);
-- int i, start = 1;
-- // please make this less ugly...
-- if(token_len <= string_len){
-- while(i < token_len) {
-- if(string[i] != token[i]){
-- start = 0;
-- break;
-- }
-- i++;
-- }
-- }
-- else {
-- start = 0;
-- }
- lua_pushboolean(L, start);
- return 1;
- }
---
-1.7.7
-
diff --git a/main/lua-stringy/APKBUILD b/main/lua-stringy/APKBUILD
index a38718f8c7..68798781ff 100644
--- a/main/lua-stringy/APKBUILD
+++ b/main/lua-stringy/APKBUILD
@@ -1,42 +1,75 @@
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+
+_luaversions="5.1 5.2"
pkgname=lua-stringy
-pkgver=0.2
-pkgrel=0
+pkgver=0.4
+pkgrel=2
pkgdesc="Lua string utility library"
-url="http://hackmap.blogspot.com"
+url="https://github.com/brentp/lua-projects/"
arch="all"
license="MIT"
depends=""
-makedepends="lua lua-dev"
+makedepends=""
install=""
subpackages=""
-source="http://bpbio.googlecode.com/files/stringy-$pkgver.tar.gz
- stringy-memcmp.patch"
+source="lua-projects-$pkgver.tar.gz::https://github.com/brentp/lua-projects/archive/$pkgver.tar.gz
+ link-to-correct-lua-version.patch"
+
+for _v in $_luaversions; do
+ depends="$depends lua$_v-stringy"
+ makedepends="$makedepends lua$_v-dev"
+ subpackages="$subpackages lua$_v-stringy:split_${_v/./_}"
+done
+
-_builddir="$srcdir"/stringy-$pkgver
+_builddir="$srcdir"/lua-projects-$pkgver/stringy
prepare() {
local i
cd "$_builddir"
for i in $source; do
case $i in
- *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+ *.patch) msg $i; patch -p2 -i "$srcdir"/$i || return 1;;
esac
done
}
build() {
cd "$_builddir"
- ${CC:-gcc} ${CFLAGS} -fPIC -shared ${LDFLAGS} -llua -o stringy.so stringy.c || return 1
- lua stringy_test.lua
+ for _v in $_luaversions; do
+ make CC="${CC:-gcc}" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
+ LUA_PC="lua$_v" LUA="lua$_v" || return 1
+ mv stringy.so stringy.so.$_v
+ make clean
+ done
}
package() {
- local _lualibdir=/usr/lib/lua/5.1
+ local d
cd "$_builddir"
- mkdir -p "$pkgdir"/$_lualibdir
- cp stringy.so "$pkgdir"/$_lualibdir/
+ for _v in $_luaversions; do
+ d=$pkgdir/usr/lib/lua/$_v
+ mkdir -p "$d" || return 1
+ cp stringy.so.$_v "$d/stringy.so"
+ done
}
-md5sums="c53f05a37410a234d4afa0aa3210d800 stringy-0.2.tar.gz
-b3fbeca41227425894d6e0d74a684969 stringy-memcmp.patch"
+_split() {
+ local d=usr/lib/lua
+ replaces="$pkgname"
+ depends=
+ mkdir -p "$subpkgdir/$d" || return 1
+ mv "$pkgdir/$d/$1" "$subpkgdir/$d"
+}
+
+for _v in $_luaversions; do
+ eval "split_${_v/./_}() { _split $_v; }"
+done
+
+
+md5sums="cac1787756fe42151d7b60df9f19c9e3 lua-projects-0.4.tar.gz
+9c882939f48bf6dd129b93e46d6f4eb3 link-to-correct-lua-version.patch"
+sha256sums="72a800d2e3e1cc13fbf458ad5cbc06b8ea705afedfe72221dbe9e7cec935721e lua-projects-0.4.tar.gz
+5df2a0cc52ccdecd2a6b1a8f07d2c53aba805da5ba5cf1b129c94d68c1331026 link-to-correct-lua-version.patch"
+sha512sums="7bcd5449a99e5e1633e9cd1175208f1cde65a8dddbd9a06726c16518805387a5d3809fc7644fae090c4f3e948ed1364911e12d923fc26dbf5378c8adb1a07b3a lua-projects-0.4.tar.gz
+dd498d9cda5af9f751d3566bfa01ae575eb2513b7fb5d4cd197f95cc1dcd08a17b5a806b06ae1c65545e69ca961cddde73d1e75682269937e1f568b9f4603083 link-to-correct-lua-version.patch"
diff --git a/main/lua-stringy/link-to-correct-lua-version.patch b/main/lua-stringy/link-to-correct-lua-version.patch
new file mode 100644
index 0000000000..e7ecc5d363
--- /dev/null
+++ b/main/lua-stringy/link-to-correct-lua-version.patch
@@ -0,0 +1,19 @@
+--- lua-projects-0.4/stringy/Makefile
++++ lua-projects-0.4.libs/stringy/Makefile
+@@ -1,6 +1,7 @@
+ LUA ?= lua5.1
+ LUA_PC ?= lua5.1
+ LUA_CFLAGS = $(shell pkg-config $(LUA_PC) --cflags)
++LUA_LDFLAGS = $(shell pkg-config $(LUA_PC) --libs)
+
+ CFLAGS ?= -O3 -Wall -Werror
+
+@@ -12,7 +13,7 @@
+ stringy.o: fastsearch.h
+
+ stringy.so: stringy.o stringy_test.lua
+- $(CC) -shared stringy.o -o $@
++ $(CC) -shared $(LUA_LDFLAGS) stringy.o -o $@
+ $(LUA) stringy_test.lua
+
+ clean:
diff --git a/main/lua-stringy/stringy-memcmp.patch b/main/lua-stringy/stringy-memcmp.patch
deleted file mode 100644
index d9019b79cc..0000000000
--- a/main/lua-stringy/stringy-memcmp.patch
+++ /dev/null
@@ -1,64 +0,0 @@
---- ./stringy.c.orig
-+++ ./stringy.c
-@@ -8,49 +8,27 @@
-
-
- static int endswith(lua_State *L) {
-- const char *string = luaL_checkstring(L, 1);
-- int string_len = lua_objlen(L, 1);
-+ size_t string_len, token_len;
-+ const char *string = luaL_checklstring(L, 1, &string_len);
-+ const char *token = luaL_checklstring(L, 2, &token_len);
-+ int end = 0;
-
-- const char *token = luaL_checkstring(L, 2);
-- int token_len = lua_objlen(L, 2);
--
-- int ti = token_len, si = string_len, end = 1;
- if(token_len <= string_len){
-- while(ti > 0) {
-- if(string[--si] != token[--ti]){
-- end = 0;
-- break;
--
-- }
-- }
-+ string += string_len - token_len;
-+ end = memcmp(string, token, token_len) == 0;
- }
-- else {
-- end = 0;
-- }
- lua_pushboolean(L, end);
- return 1;
- }
-
- static int startswith(lua_State *L) {
-- const char *string = luaL_checkstring(L, 1);
-- int string_len = lua_objlen(L, 1);
-+ size_t string_len, token_len;
-+ const char *string = luaL_checklstring(L, 1, &string_len);
-+ const char *token = luaL_checklstring(L, 2, &token_len);
-+ int start = 0;
-
-- const char *token = luaL_checkstring(L, 2);
-- int token_len = lua_objlen(L, 2);
-- int i, start = 1;
-- // please make this less ugly...
-- if(token_len <= string_len){
-- while(i < token_len) {
-- if(string[i] != token[i]){
-- start = 0;
-- break;
-- }
-- i++;
-- }
-- }
-- else {
-- start = 0;
-- }
-+ if(token_len <= string_len)
-+ start = memcmp(string, token, token_len) == 0;
- lua_pushboolean(L, start);
- return 1;
- }