aboutsummaryrefslogtreecommitdiff
path: root/json.c
diff options
context:
space:
mode:
Diffstat (limited to 'json.c')
-rw-r--r--json.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/json.c b/json.c
index 546d99b..23079a7 100644
--- a/json.c
+++ b/json.c
@@ -18,9 +18,8 @@ static int _json_match(const char *text, match_t *m, int comma, bool verbose)
{
if (!verbose) {
if (m->pat->type != BP_REF && m->pat->type != BP_ERROR) {
- for (match_t *child = m->child; child; child = child->nextsibling) {
- comma |= _json_match(text, child, comma, verbose);
- }
+ for (int i = 0; m->children && m->children[i]; i++)
+ comma |= _json_match(text, m->children[i], comma, verbose);
return comma;
}
}
@@ -39,9 +38,8 @@ static int _json_match(const char *text, match_t *m, int comma, bool verbose)
}
printf("\",\"start\":%ld,\"end\":%ld,\"children\":[",
m->start - text, m->end - text);
- for (match_t *child = m->child; child; child = child->nextsibling) {
- comma |= _json_match(text, child, comma, verbose);
- }
+ for (int i = 0; m->children && m->children[i]; i++)
+ comma |= _json_match(text, m->children[i], comma, verbose);
printf("]}");
return 1;
}