Mercurial > hg > th-libs
changeset 612:cc9ec51b4875
Add some comments and debug messages.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 16 Jan 2020 12:50:28 +0200 |
parents | d895b0fd6ad6 |
children | 2e3b81ae8c8a |
files | th_regex.c |
diffstat | 1 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/th_regex.c Thu Jan 16 12:50:09 2020 +0200 +++ b/th_regex.c Thu Jan 16 12:50:28 2020 +0200 @@ -563,7 +563,7 @@ const th_regex_node *node = &expr->nodes[n]; size_t soffs; - DBG_RE_PRINT_MATCH("expr %p [%" PRIu_SIZE_T "/%" PRIu_SIZE_T "]: %s ", + DBG_RE_PRINT_MATCH(" expr %p [%" PRIu_SIZE_T "/%" PRIu_SIZE_T "]: %s ", (void *) expr, n, expr->nnodes, re_match_modes[node->mode]); switch (node->mode) @@ -654,10 +654,15 @@ BOOL matched; size_t coffs = soffs; + DBG_RE_PRINT_MATCH("\nDO_MATCH @ startoffs=%" PRIu_SIZE_T ": '%s'\n", + soffs, haystack + soffs); + if ((matched = th_regex_do_match_expr(expr, haystack, &coffs, flags))) { + // A match was found, increase count nmatches++; + // Deliver to caller if required if (pnmatches != NULL) *pnmatches = nmatches; @@ -673,9 +678,12 @@ th_llist_append_node((th_llist_t **) pmatches, (th_llist_t *) match); } + // Check match count limit, if set if (maxmatches > 0 && nmatches >= maxmatches) break; + // If offset was not advanced, increase by one + // otherwise use end of match offset as new start if (soffs == coffs) soffs++; else