# HG changeset patch # User Matti Hamalainen # Date 1579171828 -7200 # Node ID cc9ec51b487502d4561e72a9b983b73996ed8dd0 # Parent d895b0fd6ad684fd299cc0cf6b45e0c132269ba7 Add some comments and debug messages. diff -r d895b0fd6ad6 -r cc9ec51b4875 th_regex.c --- 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