diff options
| author | WormHeamer | 2026-01-01 17:50:03 -0500 |
|---|---|---|
| committer | WormHeamer | 2026-01-01 17:50:03 -0500 |
| commit | 82fb77ca52d097ebf399924e3b8b6231362885af (patch) | |
| tree | 21fe88777e6017f68d747c8e4f6cd84531027a23 | |
| parent | f06633322a5eb5985b02c71deb409e529908d5b0 (diff) | |
fix taking regex offset from the wrong chunk
| -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; |
