From 118e19314dfcc459bf9a0d19baedae365e8423cc Mon Sep 17 00:00:00 2001 From: Rainer Jung Date: Tue, 22 Jul 2014 11:57:06 +0000 Subject: [PATCH] Switch from lua_objlen() to Lua 5.2 preferred lua_rawlen(). Define lua_rawlen() in terms of lua_objlen() when building against older Lua. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1612552 13f79535-47bb-0310-9956-ffa450edef68 --- modules/lua/lua_request.c | 4 ++-- modules/lua/mod_lua.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/lua/lua_request.c b/modules/lua/lua_request.c index ff3d43436d..4f9dca8ff1 100644 --- a/modules/lua/lua_request.c +++ b/modules/lua/lua_request.c @@ -149,7 +149,7 @@ static int req_aprtable2luatable_cb(void *l, const char *key, } case LUA_TTABLE:{ /* [array, table, table] */ - int size = lua_objlen(L, -1); + int size = lua_rawlen(L, -1); lua_pushnumber(L, size + 1); /* [#, array, table, table] */ lua_pushstring(L, value); /* [string, #, array, table, table] */ lua_settable(L, -3); /* [array, table, table] */ @@ -198,7 +198,7 @@ static int req_aprtable2luatable_cb_len(void *l, const char *key, } case LUA_TTABLE:{ /* [array, table, table] */ - int size = lua_objlen(L, -1); + int size = lua_rawlen(L, -1); lua_pushnumber(L, size + 1); /* [#, array, table, table] */ lua_pushlstring(L, value, len); /* [string, #, array, table, table] */ lua_settable(L, -3); /* [array, table, table] */ diff --git a/modules/lua/mod_lua.h b/modules/lua/mod_lua.h index 5b422ed54a..d3cf2e9c7c 100644 --- a/modules/lua/mod_lua.h +++ b/modules/lua/mod_lua.h @@ -52,6 +52,8 @@ /* Load mode for lua_load() */ #define lua_load(a,b,c,d) lua_load(a,b,c,d,NULL) #define lua_resume(a,b) lua_resume(a, NULL, b) +#else +#define lua_rawlen(L,i) lua_objlen(L, (i)) #endif /* Create a set of AP_LUA_DECLARE(type), AP_LUA_DECLARE_NONSTD(type) and -- 2.50.1