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
19 #include <common/compat/errno.h>
20 #include <common/macros.h>
21 #include <common/string-utils/string-utils.h>
23 #include "filter-ast.h"
24 #include "filter-parser.h"
25 #include "filter-ir.h"
28 int normalize_glob_patterns(struct ir_op
*node
)
33 fprintf(stderr
, "[error] %s: unknown op type\n", __func__
);
37 return normalize_glob_patterns(node
->u
.root
.child
);
40 if (node
->data_type
== IR_DATA_STRING
) {
41 enum ir_load_string_type type
=
42 node
->u
.load
.u
.string
.type
;
43 if (type
== IR_LOAD_STRING_TYPE_GLOB_STAR_END
||
44 type
== IR_LOAD_STRING_TYPE_GLOB_STAR
) {
45 assert(node
->u
.load
.u
.string
.value
);
46 strutils_normalize_star_glob_pattern(
47 node
->u
.load
.u
.string
.value
);
54 return normalize_glob_patterns(node
->u
.unary
.child
);
57 int ret
= normalize_glob_patterns(node
->u
.binary
.left
);
61 return normalize_glob_patterns(node
->u
.binary
.right
);
67 ret
= normalize_glob_patterns(node
->u
.logical
.left
);
70 return normalize_glob_patterns(node
->u
.logical
.right
);
76 * This function normalizes all the globbing literal strings with
77 * utils_normalize_glob_pattern(). See the documentation of
78 * utils_normalize_glob_pattern() for more details.
81 int filter_visitor_ir_normalize_glob_patterns(struct filter_parser_ctx
*ctx
)
83 return normalize_glob_patterns(ctx
->ir_root
);