summaryrefslogtreecommitdiffstats
path: root/testing/lua5.2-stringy
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2013-06-25 10:54:09 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2013-06-25 10:55:24 +0000
commit9af31e5c7840e276a65f5a4b341c88831eb9ab97 (patch)
tree121776d2babf739094d66651a3723c71c6fb2d62 /testing/lua5.2-stringy
parent8c8c4ac14ccec5762e1bf1d9a19db8301f47e0bc (diff)
downloadaports-9af31e5c7840e276a65f5a4b341c88831eb9ab97.tar.bz2
aports-9af31e5c7840e276a65f5a4b341c88831eb9ab97.tar.xz
testing/lua5.2-stringy: new aport
Lua string utility library https://code.google.com/p/bpbio/downloads/list
Diffstat (limited to 'testing/lua5.2-stringy')
-rw-r--r--testing/lua5.2-stringy/0001-use-memcmp-for-startswith-endswith.patch78
-rw-r--r--testing/lua5.2-stringy/APKBUILD43
-rw-r--r--testing/lua5.2-stringy/stringy-memcmp.patch64
3 files changed, 185 insertions, 0 deletions
diff --git a/testing/lua5.2-stringy/0001-use-memcmp-for-startswith-endswith.patch b/testing/lua5.2-stringy/0001-use-memcmp-for-startswith-endswith.patch
new file mode 100644
index 000000000..4680a0561
--- /dev/null
+++ b/testing/lua5.2-stringy/0001-use-memcmp-for-startswith-endswith.patch
@@ -0,0 +1,78 @@
+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/testing/lua5.2-stringy/APKBUILD b/testing/lua5.2-stringy/APKBUILD
new file mode 100644
index 000000000..3a302a11d
--- /dev/null
+++ b/testing/lua5.2-stringy/APKBUILD
@@ -0,0 +1,43 @@
+# Contributor: Natanael Copa <ncopa@alpinelinux.org>
+# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
+_luaver=5.2
+pkgname=lua${_luaver}-stringy
+pkgver=0.4
+pkgrel=0
+pkgdesc="Lua string utility library"
+url="https://code.google.com/p/bpbio/downloads/list"
+arch="all"
+license="MIT"
+depends=""
+makedepends="lua${_luaver}-dev"
+install=""
+subpackages=""
+source="lua-stringy-$pkgver.tar.gz::https://github.com/ncopa/lua-stringy/archive/v$pkgver.tar.gz"
+
+_builddir="$srcdir"/lua-stringy-$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;;
+ esac
+ done
+}
+
+build() {
+ cd "$_builddir"
+ make CC="$CC" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
+ LUA_PC="lua$_luaver" LUA="lua$_luaver" || return 1
+}
+
+package() {
+ local _lualibdir=/usr/lib/lua/$_luaver
+ cd "$_builddir"
+ mkdir -p "$pkgdir"/$_lualibdir
+ cp stringy.so "$pkgdir"/$_lualibdir/
+}
+
+md5sums="1c10c3c3bc800f0fb2920257ea884d1e lua-stringy-0.4.tar.gz"
+sha256sums="f953b83c9f4310aae206cb8938d89b2d659020322d2ad0778649ba707052b58b lua-stringy-0.4.tar.gz"
+sha512sums="d2607cd71d9b03bb4a8c91637a36eecebd6279c49ff8c7fdd58c0244ee1c4ccd9e26140aee9886886c7176c58f953300ebef1a2fe1a9f96bedf7e1d1c11135dd lua-stringy-0.4.tar.gz"
diff --git a/testing/lua5.2-stringy/stringy-memcmp.patch b/testing/lua5.2-stringy/stringy-memcmp.patch
new file mode 100644
index 000000000..d9019b79c
--- /dev/null
+++ b/testing/lua5.2-stringy/stringy-memcmp.patch
@@ -0,0 +1,64 @@
+--- ./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;
+ }