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
18 #include <common/compat/errno.h>
19 #include <common/macros.h>
20 #include <common/string-utils/string-utils.h>
22 #include "filter-ast.h"
23 #include "filter-parser.hpp"
24 #include "filter-ir.h"
27 int normalize_glob_patterns(struct ir_op
*node
)
32 fprintf(stderr
, "[error] %s: unknown op type\n", __func__
);
36 return normalize_glob_patterns(node
->u
.root
.child
);
39 if (node
->data_type
== IR_DATA_STRING
) {
40 enum ir_load_string_type type
=
41 node
->u
.load
.u
.string
.type
;
42 if (type
== IR_LOAD_STRING_TYPE_GLOB_STAR_END
||
43 type
== IR_LOAD_STRING_TYPE_GLOB_STAR
) {
44 LTTNG_ASSERT(node
->u
.load
.u
.string
.value
);
45 strutils_normalize_star_glob_pattern(
46 node
->u
.load
.u
.string
.value
);
53 return normalize_glob_patterns(node
->u
.unary
.child
);
56 int ret
= normalize_glob_patterns(node
->u
.binary
.left
);
60 return normalize_glob_patterns(node
->u
.binary
.right
);
66 ret
= normalize_glob_patterns(node
->u
.logical
.left
);
69 return normalize_glob_patterns(node
->u
.logical
.right
);
75 * This function normalizes all the globbing literal strings with
76 * utils_normalize_glob_pattern(). See the documentation of
77 * utils_normalize_glob_pattern() for more details.
79 int filter_visitor_ir_normalize_glob_patterns(struct filter_parser_ctx
*ctx
)
81 return normalize_glob_patterns(ctx
->ir_root
);