File httpd-2.4.12-lua-5.2.patch of Package apache2

Index: httpd-2.4.26/modules/lua/mod_lua.c
===================================================================
--- httpd-2.4.26.orig/modules/lua/mod_lua.c	2017-03-01 17:54:35.000000000 +0100
+++ httpd-2.4.26/modules/lua/mod_lua.c	2017-06-19 10:04:42.413328131 +0200
@@ -1086,7 +1086,11 @@ static const char *register_named_block_
             lua_dump(lvm, ldump_writer, &b);
 #endif
             luaL_pushresult(&b);
+#if LUA_VERSION_NUM < 502
             spec->bytecode_len = lua_strlen(lvm, -1);
+#else
+            spec->bytecode_len = lua_rawlen(lvm, -1);
+#endif
             spec->bytecode = apr_pstrmemdup(cmd->pool, lua_tostring(lvm, -1),
                                             spec->bytecode_len);
             lua_close(lvm);
Index: httpd-2.4.26/modules/lua/lua_apr.c
===================================================================
--- httpd-2.4.26.orig/modules/lua/lua_apr.c	2014-09-05 16:20:27.000000000 +0200
+++ httpd-2.4.26/modules/lua/lua_apr.c	2017-06-19 10:04:42.413328131 +0200
@@ -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);
Index: httpd-2.4.26/modules/lua/lua_config.c
===================================================================
--- httpd-2.4.26.orig/modules/lua/lua_config.c	2017-03-01 17:54:35.000000000 +0100
+++ httpd-2.4.26/modules/lua/lua_config.c	2017-06-19 10:04:42.413328131 +0200
@@ -265,13 +265,20 @@ void ap_lua_load_config_lmodule(lua_Stat
     lua_pushvalue(L, -1);
 
     lua_setfield(L, -2, "__index");
+#if LUA_VERSION_NUM < 502
     luaL_register(L, NULL, cfg_methods);        /* [metatable] */
-
+#else
+    luaL_setfuncs(L, cfg_methods, 0);
+#endif
 
     luaL_newmetatable(L, "Apache2.CommandParameters");
     lua_pushvalue(L, -1);
 
     lua_setfield(L, -2, "__index");
+#if LUA_VERSION_NUM < 502
     luaL_register(L, NULL, cmd_methods);        /* [metatable] */
+#else
+    luaL_setfuncs(L, cmd_methods, 0);
+#endif
 
 }
Index: httpd-2.4.26/modules/lua/lua_request.c
===================================================================
--- httpd-2.4.26.orig/modules/lua/lua_request.c	2017-03-01 17:54:35.000000000 +0100
+++ httpd-2.4.26/modules/lua/lua_request.c	2017-06-19 10:09:16.137841283 +0200
@@ -150,7 +150,11 @@ static int req_aprtable2luatable_cb(void
         }
     case LUA_TTABLE:{
             /* [array, table<s,t>, table<s,s>] */
+#if LUA_VERSION_NUM < 502
+            int size = lua_objlen(L, -1);
+#else
             int size = lua_rawlen(L, -1);
+#endif
             lua_pushnumber(L, size + 1);        /* [#, array, table<s,t>, table<s,s>] */
             lua_pushstring(L, value);   /* [string, #, array, table<s,t>, table<s,s>] */
             lua_settable(L, -3);        /* [array, table<s,t>, table<s,s>] */
@@ -200,7 +204,11 @@ static int req_aprtable2luatable_cb_len(
     
     case LUA_TTABLE:{
             /* [array, table<s,t>, table<s,s>] */
+#if LUA_VERSION_NUM < 502
+            int size = lua_objlen(L, -1);
+#else
             int size = lua_rawlen(L, -1);
+#endif
             lua_pushnumber(L, size + 1);        /* [#, array, table<s,t>, table<s,s>] */
             lua_pushlstring(L, value, len);   /* [string, #, array, table<s,t>, table<s,s>] */
             lua_settable(L, -3);        /* [array, table<s,t>, table<s,s>] */
@@ -345,7 +353,7 @@ static int req_parsebody(lua_State *L)
     char *multipart;
     const char *contentType;
     request_rec *r = ap_lua_check_request_rec(L, 1);
-    max_post_size = (apr_size_t) luaL_optint(L, 2, MAX_STRING_LEN);
+    max_post_size = (apr_size_t) luaL_optinteger(L, 2, MAX_STRING_LEN);
     multipart = apr_pcalloc(r->pool, 256);
     contentType = apr_table_get(r->headers_in, "Content-Type");
     lua_newtable(L);
@@ -418,7 +426,7 @@ static int lua_ap_requestbody(lua_State
     
     r = ap_lua_check_request_rec(L, 1);
     filename = luaL_optstring(L, 2, 0);
-    maxSize = luaL_optint(L, 3, 0);
+    maxSize = luaL_optinteger(L, 3, 0);
 
     if (r) {
         apr_off_t size;
@@ -1708,7 +1716,7 @@ static int lua_ap_make_etag(lua_State *L
     luaL_checktype(L, 1, LUA_TUSERDATA);
     r = ap_lua_check_request_rec(L, 1);
     luaL_checktype(L, 2, LUA_TBOOLEAN);
-    force_weak = luaL_optint(L, 2, 0);
+    force_weak = luaL_optinteger(L, 2, 0);
     returnValue = ap_make_etag(r, force_weak);
     lua_pushstring(L, returnValue);
     return 1;
@@ -2040,7 +2048,7 @@ static int lua_set_cookie(lua_State *L)
         /* expiry */
         lua_pushstring(L, "expires");
         lua_gettable(L, -2);
-        expires = luaL_optint(L, -1, 0);
+        expires = luaL_optinteger(L, -1, 0);
         lua_pop(L, 1);
         
         /* secure */
@@ -2959,7 +2967,11 @@ void ap_lua_load_request_lmodule(lua_Sta
     lua_pushvalue(L, -1);
 
     lua_setfield(L, -2, "__index");
+#if LUA_VERSION_NUM < 502
     luaL_register(L, NULL, request_methods);    /* [metatable] */
+#else
+    luaL_setfuncs(L, request_methods, 0);
+#endif
 
     lua_pop(L, 2);
 
@@ -2967,7 +2979,11 @@ void ap_lua_load_request_lmodule(lua_Sta
     lua_pushvalue(L, -1);
 
     lua_setfield(L, -2, "__index");
+#if LUA_VERSION_NUM < 502
     luaL_register(L, NULL, connection_methods); /* [metatable] */
+#else
+    luaL_setfuncs(L, connection_methods, 0);
+#endif
 
     lua_pop(L, 2);
 
@@ -2975,7 +2991,11 @@ void ap_lua_load_request_lmodule(lua_Sta
     lua_pushvalue(L, -1);
 
     lua_setfield(L, -2, "__index");
+#if LUA_VERSION_NUM < 502
     luaL_register(L, NULL, server_methods);     /* [metatable] */
+#else
+    luaL_setfuncs(L, server_methods, 0);
+#endif
 
     lua_pop(L, 2);