2 * filter-visitor-ir-normalize-glob-patterns.c
4 * LTTng filter IR normalize string
6 * Copyright 2017 Philippe Proulx <pproulx@efficios.com>
8 * SPDX-License-Identifier: LGPL-2.1-only
12 #include "filter-ast.hpp"
13 #include "filter-ir.hpp"
14 #include "filter-parser.hpp"
16 #include <common/compat/errno.hpp>
17 #include <common/macros.hpp>
18 #include <common/string-utils/string-utils.hpp>
26 static int normalize_glob_patterns(struct ir_op
*node
)
31 fprintf(stderr
, "[error] %s: unknown op type\n", __func__
);
35 return normalize_glob_patterns(node
->u
.root
.child
);
38 if (node
->data_type
== IR_DATA_STRING
) {
39 enum ir_load_string_type type
= node
->u
.load
.u
.string
.type
;
40 if (type
== IR_LOAD_STRING_TYPE_GLOB_STAR_END
||
41 type
== IR_LOAD_STRING_TYPE_GLOB_STAR
) {
42 LTTNG_ASSERT(node
->u
.load
.u
.string
.value
);
43 strutils_normalize_star_glob_pattern(node
->u
.load
.u
.string
.value
);
50 return normalize_glob_patterns(node
->u
.unary
.child
);
53 int ret
= normalize_glob_patterns(node
->u
.binary
.left
);
57 return normalize_glob_patterns(node
->u
.binary
.right
);
63 ret
= normalize_glob_patterns(node
->u
.logical
.left
);
66 return normalize_glob_patterns(node
->u
.logical
.right
);
72 * This function normalizes all the globbing literal strings with
73 * utils_normalize_glob_pattern(). See the documentation of
74 * utils_normalize_glob_pattern() for more details.
76 int filter_visitor_ir_normalize_glob_patterns(struct filter_parser_ctx
*ctx
)
78 return normalize_glob_patterns(ctx
->ir_root
);