From f3277faf934a449ca680ba4ce4c3b98906b22af0 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 8 Mar 2019 18:22:57 +0000 Subject: [PATCH] [Minor] Trace glob includes --- contrib/libucl/ucl_util.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/contrib/libucl/ucl_util.c b/contrib/libucl/ucl_util.c index fdd0862cc..11799ab1e 100644 --- a/contrib/libucl/ucl_util.c +++ b/contrib/libucl/ucl_util.c @@ -1394,7 +1394,9 @@ ucl_include_file_single (const unsigned char *data, size_t len, */ static bool ucl_include_file (const unsigned char *data, size_t len, - struct ucl_parser *parser, struct ucl_include_params *params) + struct ucl_parser *parser, + struct ucl_include_params *params, + const ucl_object_t *args) { const unsigned char *p = data, *end = data + len; bool need_glob = false; @@ -1424,6 +1426,20 @@ ucl_include_file (const unsigned char *data, size_t len, return (!params->must_exist || false); } for (i = 0; i < globbuf.gl_pathc; i ++) { + + if (parser->include_trace_func) { + const ucl_object_t *parent = NULL; + + if (parser->stack) { + parent = parser->stack->obj; + } + + parser->include_trace_func (parser, parent, NULL, + globbuf.gl_pathv[i], + strlen (globbuf.gl_pathv[i]), + parser->include_trace_ud); + } + if (!ucl_include_file_single ((unsigned char *)globbuf.gl_pathv[i], strlen (globbuf.gl_pathv[i]), parser, params)) { if (params->soft_fail) { @@ -1565,7 +1581,7 @@ ucl_include_common (const unsigned char *data, size_t len, } else if (data != NULL) { /* Try to load a file */ - return ucl_include_file (data, len, parser, ¶ms); + return ucl_include_file (data, len, parser, ¶ms, args); } } else { @@ -1580,7 +1596,7 @@ ucl_include_common (const unsigned char *data, size_t len, snprintf (ipath, sizeof (ipath), "%s/%.*s", ucl_object_tostring(param), (int)len, data); if ((search = ucl_include_file (ipath, strlen (ipath), - parser, ¶ms))) { + parser, ¶ms, args))) { if (!params.allow_glob) { break; } -- 2.39.5