From 227667062d5433c018e46de196f0d5d7a53f27e3 Mon Sep 17 00:00:00 2001 From: obache Date: Wed, 30 Oct 2013 10:36:12 +0000 Subject: [PATCH] Let to be buildable with lua-5.1 too. --- databases/lua-tokyocabinet/distinfo | 4 +- .../patches/patch-tokyocabinet.c | 110 ++-------------- databases/tokyotyrant/distinfo | 4 +- databases/tokyotyrant/patches/patch-scrext.c | 121 +++--------------- 4 files changed, 33 insertions(+), 206 deletions(-) diff --git a/databases/lua-tokyocabinet/distinfo b/databases/lua-tokyocabinet/distinfo index f8a629e7bc0c..58b9c978cc84 100644 --- a/databases/lua-tokyocabinet/distinfo +++ b/databases/lua-tokyocabinet/distinfo @@ -1,8 +1,8 @@ -$NetBSD: distinfo,v 1.7 2013/10/27 13:01:33 obache Exp $ +$NetBSD: distinfo,v 1.8 2013/10/30 10:36:12 obache Exp $ SHA1 (tokyocabinet-lua-1.10.tar.gz) = 4f182f990b53eae3fe78f1dfba0e64cc52316bef RMD160 (tokyocabinet-lua-1.10.tar.gz) = b0cf1183d3e9b9dc07c2cd5c32be06adbe9a1187 Size (tokyocabinet-lua-1.10.tar.gz) = 111135 bytes SHA1 (patch-aa) = a02449c57d232192058c5673fbd3910220db856f SHA1 (patch-ab) = 80aadd7a2ea3caef9a6965c995f526b00b6ff64f -SHA1 (patch-tokyocabinet.c) = d03ef080a0b4e8bfeb4f4331553fd1042bf02887 +SHA1 (patch-tokyocabinet.c) = 329efb1d5529136c1bafec2164ad94a26d818b58 diff --git a/databases/lua-tokyocabinet/patches/patch-tokyocabinet.c b/databases/lua-tokyocabinet/patches/patch-tokyocabinet.c index ebcbf7990942..b40c83b2f828 100644 --- a/databases/lua-tokyocabinet/patches/patch-tokyocabinet.c +++ b/databases/lua-tokyocabinet/patches/patch-tokyocabinet.c @@ -1,102 +1,20 @@ -$NetBSD: patch-tokyocabinet.c,v 1.1 2013/10/27 13:01:33 obache Exp $ +$NetBSD: patch-tokyocabinet.c,v 1.2 2013/10/30 10:36:12 obache Exp $ * Lua 5.2 API change --- tokyocabinet.c.orig 2010-09-19 23:14:07.000000000 +0000 +++ tokyocabinet.c -@@ -369,7 +369,7 @@ int luaopen_tokyocabinet(lua_State *lua) +@@ -34,6 +34,13 @@ + #include + #include - /* convert a table of Lua into a list object of TC */ - static TCLIST *tabletotclist(lua_State *lua, int index){ -- int len = lua_objlen(lua, index); -+ int len = lua_rawlen(lua, index); - TCLIST *list = tclistnew2(len); - for(int i = 1; i <= len; i++){ - lua_rawgeti(lua, index, i); -@@ -536,7 +536,7 @@ static int util_pack(lua_State *lua){ - lua_rawseti(lua, aidx, eidx++); - break; - case LUA_TTABLE: -- len = lua_objlen(lua, i); -+ len = lua_rawlen(lua, i); - for(int j = 1; j <= len; j++){ - lua_rawgeti(lua, i, j); - lua_rawseti(lua, aidx, eidx++); -@@ -1200,7 +1200,7 @@ static int util_ucs(lua_State *lua){ - lua_error(lua); - } - if(lua_type(lua, 1) == LUA_TTABLE){ -- int anum = lua_objlen(lua, 1); -+ int anum = lua_rawlen(lua, 1); - uint16_t *ary = tcmalloc(sizeof(*ary) * anum + 1); - for(int i = 1; i <= anum; i++){ - lua_rawgeti(lua, 1, i); -@@ -1260,7 +1260,7 @@ static int util_dist(lua_State *lua){ - static int util_isect(lua_State *lua){ - int argc = lua_gettop(lua); - if(argc == 1 && lua_type(lua, 1) == LUA_TTABLE){ -- int len = lua_objlen(lua, 1); -+ int len = lua_rawlen(lua, 1); - for(int i = 1; i <= len; i++){ - lua_rawgeti(lua, 1, i); - if(lua_type(lua, -1) == LUA_TTABLE){ -@@ -1279,7 +1279,7 @@ static int util_isect(lua_State *lua){ - int rnum = 0; - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- int len = lua_objlen(lua, i); -+ int len = lua_rawlen(lua, i); - if(len < 1){ - lua_settop(lua, 0); - lua_newtable(lua); -@@ -1293,7 +1293,7 @@ static int util_isect(lua_State *lua){ - TCMAP *latter = NULL; - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- int len = lua_objlen(lua, i); -+ int len = lua_rawlen(lua, i); - if(former){ - latter = tcmapnew2(tclmin(len, tcmaprnum(former))); - for(int j = 1; j <= len; j++){ -@@ -1338,7 +1338,7 @@ static int util_isect(lua_State *lua){ - TCMAP *freq = tcmapnew2(rnum); - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- int len = lua_objlen(lua, i); -+ int len = lua_rawlen(lua, i); - TCMAP *uniq = tcmapnew2(len); - for(int j = 1; j <= len; j++){ - lua_rawgeti(lua, i, j); -@@ -1379,7 +1379,7 @@ static int util_isect(lua_State *lua){ - static int util_union(lua_State *lua){ - int argc = lua_gettop(lua); - if(argc == 1 && lua_type(lua, 1) == LUA_TTABLE){ -- int len = lua_objlen(lua, 1); -+ int len = lua_rawlen(lua, 1); - for(int i = 1; i <= len; i++){ - lua_rawgeti(lua, 1, i); - if(lua_type(lua, -1) == LUA_TTABLE){ -@@ -1397,12 +1397,12 @@ static int util_union(lua_State *lua){ - int rnum = 0; - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- rnum += lua_objlen(lua, i); -+ rnum += lua_rawlen(lua, i); - } - TCMAP *result = tcmapnew2(rnum); - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- int len = lua_objlen(lua, i); -+ int len = lua_rawlen(lua, i); - for(int j = 1; j <= len; j++){ - lua_rawgeti(lua, i, j); - size_t size; -@@ -6400,7 +6400,7 @@ static int tdbqry_metasearch(lua_State * - lua_error(lua); - } - TDBQRY *qry = data->qry; -- int num = lua_objlen(lua, 2); -+ int num = lua_rawlen(lua, 2); - TDBQRY **qrys = tcmalloc(sizeof(*qrys) * (num + 1)); - int qnum = 0; - qrys[qnum++] = qry; ++#ifdef LUA_VERSION_NUM ++# if (LUA_VERSION_NUM >= 502) ++#undef lua_objlen ++#define lua_objlen lua_rawlen ++# endif ++#endif ++ + #define SWAB16(TC_num) \ + ( \ + ((TC_num & 0x00ffU) << 8) | \ diff --git a/databases/tokyotyrant/distinfo b/databases/tokyotyrant/distinfo index 26a0f528ad79..b160baa8be21 100644 --- a/databases/tokyotyrant/distinfo +++ b/databases/tokyotyrant/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.26 2013/07/07 05:19:39 obache Exp $ +$NetBSD: distinfo,v 1.27 2013/10/30 10:43:24 obache Exp $ SHA1 (tokyotyrant-1.1.41.tar.gz) = 060ac946a9ac902c1d244ffafd444f0e5840c0ce RMD160 (tokyotyrant-1.1.41.tar.gz) = 679122c30104213991c640e4c9d4d0203308190a @@ -6,4 +6,4 @@ Size (tokyotyrant-1.1.41.tar.gz) = 196196 bytes SHA1 (patch-aa) = d1c6aa7e3197b33a1988320ca5ad865ae3fa23c4 SHA1 (patch-ab) = c263651729d1b8ce4fccb877869cc577577b260e SHA1 (patch-ac) = fc87f88b82b8c49f340eb6707f4c2f8382eb2a7b -SHA1 (patch-scrext.c) = 4db91ba450574889ed3e06092074b9a4cda834fe +SHA1 (patch-scrext.c) = 62b71b62d612014316bca22fe97fc16b85f7ca05 diff --git a/databases/tokyotyrant/patches/patch-scrext.c b/databases/tokyotyrant/patches/patch-scrext.c index 83838b047e3c..8d1dec62d369 100644 --- a/databases/tokyotyrant/patches/patch-scrext.c +++ b/databases/tokyotyrant/patches/patch-scrext.c @@ -1,111 +1,20 @@ -$NetBSD: patch-scrext.c,v 1.1 2013/07/07 05:19:39 obache Exp $ +$NetBSD: patch-scrext.c,v 1.2 2013/10/30 10:43:24 obache Exp $ * Lua-5.2 API change (lua_objlen was renamed lua_rawlen). --- scrext.c.orig 2010-08-05 06:24:33.000000000 +0000 +++ scrext.c -@@ -389,7 +389,7 @@ char *scrextcallmethod(void *scr, const - } - break; - case LUA_TTABLE: -- if(lua_objlen(lua, 1) > 0){ -+ if(lua_rawlen(lua, 1) > 0){ - lua_rawgeti(lua, 1, 1); - switch(lua_type(lua, -1)){ - case LUA_TNUMBER: -@@ -879,7 +879,7 @@ static int serv_misc(lua_State *lua){ - tclistpush(args, aptr, asiz); - break; - case LUA_TTABLE: -- len = lua_objlen(lua, i); -+ len = lua_rawlen(lua, i); - for(int j = 1; j <= len; j++){ - lua_rawgeti(lua, i, j); - switch(lua_type(lua, -1)){ -@@ -970,7 +970,7 @@ static int serv_mapreduce(lua_State *lua - tclistpush(keys, kbuf, ksiz); - break; - case LUA_TTABLE: -- len = lua_objlen(lua, 3); -+ len = lua_rawlen(lua, 3); - keys = tclistnew2(len); - for(int i = 1; i <= len; i++){ - lua_rawgeti(lua, 3, i); -@@ -1311,7 +1311,7 @@ static int serv_pack(lua_State *lua){ - lua_rawseti(lua, aidx, eidx++); - break; - case LUA_TTABLE: -- len = lua_objlen(lua, i); -+ len = lua_rawlen(lua, i); - for(int j = 1; j <= len; j++){ - lua_rawgeti(lua, i, j); - lua_rawseti(lua, aidx, eidx++); -@@ -1983,7 +1983,7 @@ static int serv_ucs(lua_State *lua){ - lua_error(lua); - } - if(lua_type(lua, 1) == LUA_TTABLE){ -- int anum = lua_objlen(lua, 1); -+ int anum = lua_rawlen(lua, 1); - uint16_t *ary = tcmalloc(sizeof(*ary) * anum + 1); - for(int i = 1; i <= anum; i++){ - lua_rawgeti(lua, 1, i); -@@ -2043,7 +2043,7 @@ static int serv_dist(lua_State *lua){ - static int serv_isect(lua_State *lua){ - int argc = lua_gettop(lua); - if(argc == 1 && lua_type(lua, 1) == LUA_TTABLE){ -- int len = lua_objlen(lua, 1); -+ int len = lua_rawlen(lua, 1); - for(int i = 1; i <= len; i++){ - lua_rawgeti(lua, 1, i); - if(lua_type(lua, -1) == LUA_TTABLE){ -@@ -2062,7 +2062,7 @@ static int serv_isect(lua_State *lua){ - int rnum = 0; - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- int len = lua_objlen(lua, i); -+ int len = lua_rawlen(lua, i); - if(len < 1){ - lua_settop(lua, 0); - lua_newtable(lua); -@@ -2076,7 +2076,7 @@ static int serv_isect(lua_State *lua){ - TCMAP *latter = NULL; - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- int len = lua_objlen(lua, i); -+ int len = lua_rawlen(lua, i); - if(former){ - latter = tcmapnew2(tclmin(len, tcmaprnum(former))); - for(int j = 1; j <= len; j++){ -@@ -2121,7 +2121,7 @@ static int serv_isect(lua_State *lua){ - TCMAP *freq = tcmapnew2(rnum); - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- int len = lua_objlen(lua, i); -+ int len = lua_rawlen(lua, i); - TCMAP *uniq = tcmapnew2(len); - for(int j = 1; j <= len; j++){ - lua_rawgeti(lua, i, j); -@@ -2162,7 +2162,7 @@ static int serv_isect(lua_State *lua){ - static int serv_union(lua_State *lua){ - int argc = lua_gettop(lua); - if(argc == 1 && lua_type(lua, 1) == LUA_TTABLE){ -- int len = lua_objlen(lua, 1); -+ int len = lua_rawlen(lua, 1); - for(int i = 1; i <= len; i++){ - lua_rawgeti(lua, 1, i); - if(lua_type(lua, -1) == LUA_TTABLE){ -@@ -2180,12 +2180,12 @@ static int serv_union(lua_State *lua){ - int rnum = 0; - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- rnum += lua_objlen(lua, i); -+ rnum += lua_rawlen(lua, i); - } - TCMAP *result = tcmapnew2(rnum); - for(int i = 1; i <= argc; i++){ - if(lua_type(lua, i) != LUA_TTABLE) continue; -- int len = lua_objlen(lua, i); -+ int len = lua_rawlen(lua, i); - for(int j = 1; j <= len; j++){ - lua_rawgeti(lua, i, j); - size_t size; +@@ -153,6 +153,13 @@ bool scrextkill(void *scr){ + #include "lualib.h" + #include "lauxlib.h" + ++#ifdef LUA_VERSION_NUM ++# if (LUA_VERSION_NUM >= 502) ++#undef lua_objlen ++#define lua_objlen lua_rawlen ++# endif ++#endif ++ + #define SERVVAR "_serv_" // global variable name for server resources + #define ITERVAR "_iter_" // global variable name for iterator + #define MRMAPVAR "_mrmap_" // global variable name for mapreduce mapper