packages/net/haproxy/patches/050-MINOR-lua-Add-hlua_prepend_path-function.patch
Christian Lachner fdaa55a918 haproxy: Update HAProxy to v2.1.2
- Major version jump from v2.0 to v2.1
- Update haproxy download URL and hash
- Add new patches (see https://www.haproxy.org/bugs/bugs-2.1.2.html)
- Stop building LUA 5.3 in the haproxy build-process and use liblua5.3 as a dependency instead

Signed-off-by: Christian Lachner <gladiac@gmail.com>
2020-02-03 07:54:31 +01:00

38 lines
1.4 KiB
Diff

commit ed5d6a9f3c2a1cf9e0408c438c76c0643df9d6a5
Author: Tim Duesterhus <tim@bastelstu.be>
Date: Sun Jan 12 13:55:39 2020 +0100
MINOR: lua: Add hlua_prepend_path function
This function is added in preparation for following patches.
(cherry picked from commit c9fc9f2836f1e56eef3eaf690421eeff34dd8a2b)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/hlua.c b/src/hlua.c
index 37f786687..10d615211 100644
--- a/src/hlua.c
+++ b/src/hlua.c
@@ -7458,6 +7458,22 @@ static int hlua_load(char **args, int section_type, struct proxy *curpx,
return 0;
}
+/* Prepend the given <path> followed by a semicolon to the `package.<type>` variable
+ * in the given <ctx>.
+ */
+static int hlua_prepend_path(struct hlua ctx, char *type, char *path)
+{
+ lua_getglobal(ctx.T, "package"); /* push package variable */
+ lua_pushstring(ctx.T, path); /* push given path */
+ lua_pushstring(ctx.T, ";"); /* push semicolon */
+ lua_getfield(ctx.T, -3, type); /* push old path */
+ lua_concat(ctx.T, 3); /* concatenate to new path */
+ lua_setfield(ctx.T, -2, type); /* store new path */
+ lua_pop(ctx.T, 1); /* pop package variable */
+
+ return 0;
+}
+
/* configuration keywords declaration */
static struct cfg_kw_list cfg_kws = {{ },{
{ CFG_GLOBAL, "lua-load", hlua_load },