diff options
Diffstat (limited to 'main.c')
| -rw-r--r-- | main.c | 9 |
1 files changed, 4 insertions, 5 deletions
@@ -637,25 +637,24 @@ int search_next_regex(TxtLoc l, Str src, TxtLoc *out) { e.msg = str_printf(&e.scratch, "Regex error: %s", re_comp_strerror(err)); return 0; } - TxtLoc t = l; int match_found = 0; search_from_start: + TxtLoc t = l; re_search_start(&s, &re, &e.scratch); while (!at_end(t)) { - TxtLoc p = t; Str chnk = txt_next_chunk(&t); re_search_chunk(&s, chnk.s, chnk.n); if (at_end(t)) re_search_last_chunk(&s); ReMatch m; if (re_search_match(&s, &m)) { - while (m.extent.start--) p = bnext(p); - *out = p; + while (m.extent.start--) l = bnext(l); + *out = l; return 1; } } if (match_found == 0) { match_found = -1; - t = txt_start(t.t); + l = txt_start(l.t); goto search_from_start; } return 0; |
