Commit cd2ca8f5 authored by Rainer Jung's avatar Rainer Jung
Browse files

mod_lua: Improve compatibility with Lua 5.1, 5.2 and 5.3.

PR58188, PR60831, PR61245.

RTC

The following lua 5.2 and 5.3 compat change
should be checked for runtime correctness
by someone more knowledgeable about lua.

Index: modules/lua/lua_apr.c
--- modules/lua/lua_apr.c (original)
+++ modules/lua/lua_apr.c Tue Jul  4 20:48:43 2017
@@ -82,7 +82,11 @@ static const luaL_Reg lua_table_methods[
 int ap_lua_init(lua_State *L, apr_pool_t *p)
 {
     luaL_newmetatable(L, "Apr.Table");
+#if LUA_VERSION_NUM < 502
     luaL_register(L, "apr_table", lua_table_methods);
+#else
+    luaL_newlib(L, lua_table_methods);
+#endif
     lua_pushstring(L, "__index");
     lua_pushstring(L, "get");
     lua_gettable(L, 2);


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1800835 13f79535-47bb-0310-9956-ffa450edef68
parent 39258e5c
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2,6 +2,9 @@

Changes with Apache 2.4.27

  *) mod_lua: Improve compatibility with Lua 5.1, 5.2 and 5.3.
     PR58188, PR60831, PR61245. [Rainer Jung]
  
  *) mod_http2: disable and give warning when mpm_prefork is encountered. The server will
     continue to work, but HTTP/2 will no longer be negotiated. [Stefan Eissing]
  
+3 −0
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@
** TODO: document or remove block sections
** TODO: test per-dir behavior of block sections
** TODO: Suppress internal details (fs path to scripts, etc) in error responses
** TODO: Check whether we can tighten the mode flag in lua_load(),
         luaL_loadfile() an dluaL_loadbuffer() from NULL (="bt")
         to e.g. "t".
    
* License
  Apache License, Version 2.0,
+5 −33
Original line number Diff line number Diff line
@@ -12,47 +12,19 @@ AC_DEFUN([CHECK_LUA_PATH], [dnl
    AC_MSG_CHECKING([for lua.h in $1/$2])
    if test -f $1/$2/lua.h; then
        AC_MSG_RESULT([yes])

        save_CFLAGS=$CFLAGS
        save_LDFLAGS=$LDFLAGS
        save_LIBS=$LIBS

        CFLAGS="$CFLAGS"
        LDFLAGS="-L$1/$3 $LDFLAGS $lib_m"

        AC_CHECK_LIB($4, luaL_newstate, [
            dnl mod_lua relies on some compatibility APIs to function.
            AC_MSG_CHECKING([for luaL_register in -l$4])
            CFLAGS="$CFLAGS -I$1/$2"
            LIBS="-l$4"
            AC_LINK_IFELSE([
                AC_LANG_PROGRAM([[
                    #define LUA_COMPAT_ALL
                    #define LUA_COMPAT_5_2
                    #define LUA_COMPAT_5_1
                    #define LUA_COMPAT_MODULE

                    #include <lua.h>
                    #include <lauxlib.h>
                ]], [[
                    /* This isn't a valid call, but we're testing linkability */
                    luaL_register(NULL, NULL, NULL);
                ]])
            ], [
                AC_MSG_RESULT([yes])
            LUA_LIBS="-L$1/$3 -l$4 $lib_m"
            if test "x$ap_platform_runtime_link_flag" != "x"; then
               APR_ADDTO(LUA_LIBS, [$ap_platform_runtime_link_flag$1/$3])
            fi
            LUA_CFLAGS="-I$1/$2"
            ], [
                AC_MSG_RESULT([no])
            ])
        ])

        CFLAGS=$save_CFLAGS
        LDFLAGS=$save_LDFLAGS
        LIBS=$save_LIBS

        if test -n "${LUA_LIBS}"; then
            break
+4 −0
Original line number Diff line number Diff line
@@ -82,7 +82,11 @@ static const luaL_Reg lua_table_methods[] = {
int ap_lua_init(lua_State *L, apr_pool_t *p)
{
    luaL_newmetatable(L, "Apr.Table");
#if LUA_VERSION_NUM < 502
    luaL_register(L, "apr_table", lua_table_methods);
#else
    luaL_newlib(L, lua_table_methods);
#endif
    lua_pushstring(L, "__index");
    lua_pushstring(L, "get");
    lua_gettable(L, 2);
+2 −2
Original line number Diff line number Diff line
@@ -265,13 +265,13 @@ void ap_lua_load_config_lmodule(lua_State *L)
    lua_pushvalue(L, -1);

    lua_setfield(L, -2, "__index");
    luaL_register(L, NULL, cfg_methods);        /* [metatable] */
    luaL_setfuncs_compat(L, cfg_methods);       /* [metatable] */


    luaL_newmetatable(L, "Apache2.CommandParameters");
    lua_pushvalue(L, -1);

    lua_setfield(L, -2, "__index");
    luaL_register(L, NULL, cmd_methods);        /* [metatable] */
    luaL_setfuncs_compat(L, cmd_methods);       /* [metatable] */

}
Loading