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


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@405091 65c4cc65-6c06-0410-ace0-fbb531ad65f3
changes/61/61/1
Kinsey Moore 11 years ago
parent 05f0ad2c56
commit 10cf34d36a

116
configure vendored

@ -1,5 +1,5 @@
#! /bin/sh
# From configure.ac Revision: 400075 .
# From configure.ac Revision: 400768 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for asterisk trunk.
#
@ -26319,6 +26319,118 @@ $as_echo "#define HAVE_OPENH323 1" >>confdefs.h
fi
if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then
pbxlibdir=""
# if --with-LUA=DIR has been specified, use it.
if test "x${LUA_DIR}" != "x"; then
if test -d ${LUA_DIR}/lib; then
pbxlibdir="-L${LUA_DIR}/lib"
else
pbxlibdir="-L${LUA_DIR}"
fi
fi
pbxfuncname="luaL_newstate"
if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers
AST_LUA_FOUND=yes
else
ast_ext_lib_check_save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} "
as_ac_Lib=`$as_echo "ac_cv_lib_lua5.2_${pbxfuncname}" | $as_tr_sh`
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${pbxfuncname} in -llua5.2" >&5
$as_echo_n "checking for ${pbxfuncname} in -llua5.2... " >&6; }
if eval \${$as_ac_Lib+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-llua5.2 ${pbxlibdir} -lm $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char ${pbxfuncname} ();
int
main ()
{
return ${pbxfuncname} ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
eval "$as_ac_Lib=yes"
else
eval "$as_ac_Lib=no"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
eval ac_res=\$$as_ac_Lib
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
$as_echo "$ac_res" >&6; }
if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then :
AST_LUA_FOUND=yes
else
AST_LUA_FOUND=no
fi
CFLAGS="${ast_ext_lib_check_save_CFLAGS}"
fi
# now check for the header.
if test "${AST_LUA_FOUND}" = "yes"; then
LUA_LIB="${pbxlibdir} -llua5.2 -lm"
# if --with-LUA=DIR has been specified, use it.
if test "x${LUA_DIR}" != "x"; then
LUA_INCLUDE="-I${LUA_DIR}/include"
fi
LUA_INCLUDE="${LUA_INCLUDE} "
if test "xlua5.2/lua.h" = "x" ; then # no header, assume found
LUA_HEADER_FOUND="1"
else # check for the header
ast_ext_lib_check_saved_CPPFLAGS="${CPPFLAGS}"
CPPFLAGS="${CPPFLAGS} ${LUA_INCLUDE}"
ac_fn_c_check_header_mongrel "$LINENO" "lua5.2/lua.h" "ac_cv_header_lua5_2_lua_h" "$ac_includes_default"
if test "x$ac_cv_header_lua5_2_lua_h" = xyes; then :
LUA_HEADER_FOUND=1
else
LUA_HEADER_FOUND=0
fi
CPPFLAGS="${ast_ext_lib_check_saved_CPPFLAGS}"
fi
if test "x${LUA_HEADER_FOUND}" = "x0" ; then
LUA_LIB=""
LUA_INCLUDE=""
else
if test "x${pbxfuncname}" = "x" ; then # only checking headers -> no library
LUA_LIB=""
fi
PBX_LUA=1
cat >>confdefs.h <<_ACEOF
#define HAVE_LUA 1
_ACEOF
fi
fi
fi
if test "x${PBX_LUA}" = "x1" ; then
if test x"${LUA_DIR}" = x; then
LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/lua5.2"
else
LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/lua5.2"
fi
fi
if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then
pbxlibdir=""
# if --with-LUA=DIR has been specified, use it.
@ -26442,7 +26554,7 @@ if test "x${PBX_LUA}" != "x1" -a "${USE_LUA}" != "no"; then
pbxlibdir="-L${LUA_DIR}"
fi
fi
pbxfuncname="luaL_register"
pbxfuncname="luaL_openlib"
if test "x${pbxfuncname}" = "x" ; then # empty lib, assume only headers
AST_LUA_FOUND=yes
else

@ -2093,6 +2093,15 @@ if test "${PBX_PWLIB}" = "1" -a "${USE_OPENH323}" != "no" ; then
[${PWLIB_INCLUDE}], [${PWLIB_LIB}])
fi
AST_EXT_LIB_CHECK([LUA], [lua5.2], [luaL_newstate], [lua5.2/lua.h], [-lm])
if test "x${PBX_LUA}" = "x1" ; then
if test x"${LUA_DIR}" = x; then
LUA_INCLUDE="${LUA_INCLUDE} -I/usr/include/lua5.2"
else
LUA_INCLUDE="${LUA_INCLUDE} -I${LUA_DIR}/lua5.2"
fi
fi
AST_EXT_LIB_CHECK([LUA], [lua5.1], [luaL_newstate], [lua5.1/lua.h], [-lm])
if test "x${PBX_LUA}" = "x1" ; then
if test x"${LUA_DIR}" = x; then
@ -2103,7 +2112,7 @@ if test "x${PBX_LUA}" = "x1" ; then
fi
# Some distributions (like SuSE) remove the 5.1 suffix.
AST_EXT_LIB_CHECK([LUA], [lua], [luaL_register], [lua.h], [-lm])
AST_EXT_LIB_CHECK([LUA], [lua], [luaL_openlib], [lua.h], [-lm])
AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])

@ -873,8 +873,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);
}
@ -1506,9 +1509,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;

Loading…
Cancel
Save