From e7132f1707e1a1bee15ed52b3550c4919048fe7b Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 3 Aug 2018 15:54:58 +0200 Subject: Change the default GLOB pattern Change the default GLOB pattern because the lua should be found in var directory by default. Change-Id: I8be0e85c97459553e1d6a9f58efa394eb311a514 Signed-off-by: Romain Forlot --- ctl-lib/ctl-lua.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ctl-lib/ctl-lua.c b/ctl-lib/ctl-lua.c index 67ef21a..9e4f791 100644 --- a/ctl-lib/ctl-lua.c +++ b/ctl-lib/ctl-lua.c @@ -35,7 +35,9 @@ #define LUA_MSG_MAX_LENGTH 2048 #define JSON_ERROR (json_object*)-1 #define LUA_PATH_VALUE "package.path = package.path .. ';?.lua;" +#ifndef LUA_GLOB_PATTERN #define LUA_GLOB_PATTERN "/?.lua;" +#endif static lua_State* luaState; CtlPluginT *ctlPlugins = NULL; @@ -1338,8 +1340,7 @@ int LuaConfigLoad(AFB_ApiT apiHandle, const char *prefix) { sep++; } - // token + the lua glob pattern which is 7 char length - total_len = base_len + spath_len + token_nb * 7 + 1; + total_len = base_len + spath_len + token_nb * strlen(LUA_GLOB_PATTERN) + 1; lua_str = malloc(total_len + 1); strncpy(lua_str, LUA_PATH_VALUE, total_len); for (i = 0; i < token_nb; i++) { -- cgit 1.2.3-korg