From eca6d64df06195cfab8e9f102e4ef4971563150d Mon Sep 17 00:00:00 2001 From: Stefan Fritsch Date: Sat, 16 Jun 2012 22:39:54 +0000 Subject: [PATCH] allow tail call optimization in log methods, remove foo method git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1351013 13f79535-47bb-0310-9956-ffa450edef68 --- modules/lua/lua_config.c | 58 +++++++++++---------------------------- modules/lua/lua_request.c | 27 ++++++------------ 2 files changed, 25 insertions(+), 60 deletions(-) diff --git a/modules/lua/lua_config.c b/modules/lua/lua_config.c index 0e675652e3..07dd932b85 100644 --- a/modules/lua/lua_config.c +++ b/modules/lua/lua_config.c @@ -154,14 +154,6 @@ static const struct luaL_Reg cfg_methods[] = { {NULL, NULL} }; - -static int cmd_foo(lua_State *L) -{ - cmd_parms *cmd = check_cmd_parms(L, 1); - ap_log_error(APLOG_MARK, APLOG_ERR, 0, cmd->server, APLOGNO(01479) "FOO!"); - return 0; -} - /* helper function for the logging functions below */ static int cmd_log_at(lua_State *L, int level) { @@ -181,88 +173,70 @@ static int cmd_log_at(lua_State *L, int level) /* r:debug(String) and friends which use apache logging */ static int cmd_emerg(lua_State *L) { - cmd_log_at(L, APLOG_EMERG); - return 0; + return cmd_log_at(L, APLOG_EMERG); } static int cmd_alert(lua_State *L) { - cmd_log_at(L, APLOG_ALERT); - return 0; + return cmd_log_at(L, APLOG_ALERT); } static int cmd_crit(lua_State *L) { - cmd_log_at(L, APLOG_CRIT); - return 0; + return cmd_log_at(L, APLOG_CRIT); } static int cmd_err(lua_State *L) { - cmd_log_at(L, APLOG_ERR); - return 0; + return cmd_log_at(L, APLOG_ERR); } static int cmd_warn(lua_State *L) { - cmd_log_at(L, APLOG_WARNING); - return 0; + return cmd_log_at(L, APLOG_WARNING); } static int cmd_notice(lua_State *L) { - cmd_log_at(L, APLOG_NOTICE); - return 0; + return cmd_log_at(L, APLOG_NOTICE); } static int cmd_info(lua_State *L) { - cmd_log_at(L, APLOG_INFO); - return 0; + return cmd_log_at(L, APLOG_INFO); } static int cmd_debug(lua_State *L) { - cmd_log_at(L, APLOG_DEBUG); - return 0; + return cmd_log_at(L, APLOG_DEBUG); } static int cmd_trace1(lua_State *L) { - cmd_log_at(L, APLOG_TRACE1); - return 0; + return cmd_log_at(L, APLOG_TRACE1); } static int cmd_trace2(lua_State *L) { - cmd_log_at(L, APLOG_TRACE2); - return 0; + return cmd_log_at(L, APLOG_TRACE2); } static int cmd_trace3(lua_State *L) { - cmd_log_at(L, APLOG_TRACE3); - return 0; + return cmd_log_at(L, APLOG_TRACE3); } static int cmd_trace4(lua_State *L) { - cmd_log_at(L, APLOG_TRACE4); - return 0; + return cmd_log_at(L, APLOG_TRACE4); } static int cmd_trace5(lua_State *L) { - cmd_log_at(L, APLOG_TRACE5); - return 0; + return cmd_log_at(L, APLOG_TRACE5); } static int cmd_trace6(lua_State *L) { - cmd_log_at(L, APLOG_TRACE6); - return 0; + return cmd_log_at(L, APLOG_TRACE6); } static int cmd_trace7(lua_State *L) { - cmd_log_at(L, APLOG_TRACE7); - return 0; + return cmd_log_at(L, APLOG_TRACE7); } static int cmd_trace8(lua_State *L) { - cmd_log_at(L, APLOG_TRACE8); - return 0; + return cmd_log_at(L, APLOG_TRACE8); } static const struct luaL_Reg cmd_methods[] = { - {"foo", cmd_foo}, - {"trace8", cmd_trace8}, {"trace7", cmd_trace7}, {"trace6", cmd_trace6}, diff --git a/modules/lua/lua_request.c b/modules/lua/lua_request.c index 91bd3b75e6..c62baccf3e 100644 --- a/modules/lua/lua_request.c +++ b/modules/lua/lua_request.c @@ -452,49 +452,40 @@ static int req_log_at(lua_State *L, int level) /* r:debug(String) and friends which use apache logging */ static int req_emerg(lua_State *L) { - req_log_at(L, APLOG_EMERG); - return 0; + return req_log_at(L, APLOG_EMERG); } static int req_alert(lua_State *L) { - req_log_at(L, APLOG_ALERT); - return 0; + return req_log_at(L, APLOG_ALERT); } static int req_crit(lua_State *L) { - req_log_at(L, APLOG_CRIT); - return 0; + return req_log_at(L, APLOG_CRIT); } static int req_err(lua_State *L) { - req_log_at(L, APLOG_ERR); - return 0; + return req_log_at(L, APLOG_ERR); } static int req_warn(lua_State *L) { - req_log_at(L, APLOG_WARNING); - return 0; + return req_log_at(L, APLOG_WARNING); } static int req_notice(lua_State *L) { - req_log_at(L, APLOG_NOTICE); - return 0; + return req_log_at(L, APLOG_NOTICE); } static int req_info(lua_State *L) { - req_log_at(L, APLOG_INFO); - return 0; + return req_log_at(L, APLOG_INFO); } static int req_debug(lua_State *L) { - req_log_at(L, APLOG_DEBUG); - return 0; + return req_log_at(L, APLOG_DEBUG); } #define APLUA_REQ_TRACE(lev) static int req_trace##lev(lua_State *L) \ { \ - req_log_at(L, APLOG_TRACE##lev); \ - return 0; \ + return req_log_at(L, APLOG_TRACE##lev); \ } APLUA_REQ_TRACE(1) -- 2.40.0