[LTP] [PATCH 7/9] metadata: metaparse: Ignore ', ' in array inside parenthesis
Cyril Hrubis
chrubis@suse.cz
Wed Dec 18 20:00:27 CET 2024
This fixes the TST_CAP() macros:
"caps": [
- "TST_CAP("TST_CAP_DROP",
- "CAP_NET_RAW")"
+ "TST_CAP(TST_CAP_DROP,CAP_NET_RAW)"
],
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
metadata/metaparse.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/metadata/metaparse.c b/metadata/metaparse.c
index f133a65d6..29c03e5c3 100644
--- a/metadata/metaparse.c
+++ b/metadata/metaparse.c
@@ -372,6 +372,7 @@ static int parse_array(FILE *f, struct data_node *node)
{
char *token;
char *entry = NULL;
+ int parent_cnt = 0;
for (;;) {
if (!(token = next_token(f, NULL)))
@@ -402,7 +403,7 @@ static int parse_array(FILE *f, struct data_node *node)
return 0;
}
- if (!strcmp(token, ",")) {
+ if (!strcmp(token, ",") && parent_cnt <= 0) {
finalize_array_entry(&entry, node);
continue;
}
@@ -412,6 +413,12 @@ static int parse_array(FILE *f, struct data_node *node)
continue;
}
+ if (!strcmp(token, "("))
+ parent_cnt++;
+
+ if (!strcmp(token, ")"))
+ parent_cnt--;
+
try_apply_macro(&token);
str_append(&entry, token);
}
--
2.45.2
More information about the ltp
mailing list