From 537f4a9dacc066893dad17a8a96c450de48abbdb Mon Sep 17 00:00:00 2001 From: Kinsey Moore Date: Wed, 8 Jan 2014 16:34:24 +0000 Subject: pbx_lua: Add support for Lua 5.2 This adds support for Lua 5.2 in pbx_lua which is available on newer operating systems. (closes issue ASTERISK-23011) Review: https://reviewboard.asterisk.org/r/3075/ Reported by: George Joseph Patch by: George Joseph ........ Merged revisions 405090 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 405091 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 405124 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@405130 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- pbx/pbx_lua.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'pbx') diff --git a/pbx/pbx_lua.c b/pbx/pbx_lua.c index f429a4a25..c4492c7e5 100644 --- a/pbx/pbx_lua.c +++ b/pbx/pbx_lua.c @@ -872,8 +872,11 @@ static int lua_sort_extensions(lua_State *L) * table in the extensions_order table */ for (lua_pushnil(L); lua_next(L, context); lua_pop(L, 1)) { int exten = lua_gettop(L) - 1; - +#if LUA_VERSION_NUM < 502 lua_pushinteger(L, lua_objlen(L, context_order) + 1); +#else + lua_pushinteger(L, lua_rawlen(L, context_order) + 1); +#endif lua_pushvalue(L, exten); lua_settable(L, context_order); } @@ -1505,9 +1508,13 @@ static int lua_find_extension(lua_State *L, const char *context, const char *ext lua_remove(L, -2); /* remove the extensions order table */ context_order_table = lua_gettop(L); - + /* step through the extensions looking for a match */ +#if LUA_VERSION_NUM < 502 for (i = 1; i < lua_objlen(L, context_order_table) + 1; i++) { +#else + for (i = 1; i < lua_rawlen(L, context_order_table) + 1; i++) { +#endif int e_index_copy, match = 0; const char *e; -- cgit v1.2.3