From: William Lallemand Date: Sat, 13 Jun 2026 18:49:43 +0000 (+0200) Subject: MINOR: lua: export hlua_pusherror() and check_args() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=974560128df130fd49dd03761f27cbf8b5359802;p=thirdparty%2Fhaproxy.git MINOR: lua: export hlua_pusherror() and check_args() hlua_pusherror() and check_args() are being exported. check_args() is now a macro to hlua_check_args() so it's not confusing when called outside hlua.c. --- diff --git a/include/haproxy/hlua.h b/include/haproxy/hlua.h index 31a7af083..ed9416b05 100644 --- a/include/haproxy/hlua.h +++ b/include/haproxy/hlua.h @@ -81,6 +81,15 @@ void hlua_pushref(lua_State *L, int ref); void hlua_unref(lua_State *L, int ref); struct hlua *hlua_gethlua(lua_State *L); void hlua_yieldk(lua_State *L, int nresults, lua_KContext ctx, lua_KFunction k, int timeout, unsigned int flags); +int hlua_pusherror(lua_State *L, const char *fmt, ...); + +__LJMP static inline void hlua_check_args(lua_State *L, int nb, char *fcn) +{ + if (lua_gettop(L) == nb) + return; + WILL_LJMP(luaL_error(L, "'%s' needs %d arguments", fcn, nb)); +} +#define check_args hlua_check_args #else /* USE_LUA */ diff --git a/src/hlua.c b/src/hlua.c index 124c8c1c0..3ea6ec458 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -999,13 +999,6 @@ const char *hlua_traceback(lua_State *L, const char* sep) * stack. If the number of arguments available is not the same * then an error is thrown. */ -__LJMP static inline void check_args(lua_State *L, int nb, char *fcn) -{ - if (lua_gettop(L) == nb) - return; - WILL_LJMP(luaL_error(L, "'%s' needs %d arguments", fcn, nb)); -} - /* This function pushes an error string prefixed by the file name * and the line number where the error is encountered. * @@ -1022,7 +1015,7 @@ __LJMP static int _hlua_pusherror(lua_State *L) return 1; } -static int hlua_pusherror(lua_State *L, const char *fmt, ...) +int hlua_pusherror(lua_State *L, const char *fmt, ...) { va_list argp; int ret = 1;