aboutsummaryrefslogtreecommitdiffstats
path: root/main/lua-stringy/0001-use-memcmp-for-startswith-endswith.patch
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/0001-use-memcmp-for-startswith-endswith.patch
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/0001-use-memcmp-for-startswith-endswith.patch')
-rw-r--r--main/lua-stringy/0001-use-memcmp-for-startswith-endswith.patch78
1 files changed, 0 insertions, 78 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
-