summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorWormHeamer2026-01-01 21:37:44 -0500
committerWormHeamer2026-01-01 21:37:44 -0500
commit3b48035f5b9475293ff614c2d5193cf525e55a44 (patch)
tree7ebac8e75ff462b30fd09614ad7b3b8558b08d6e /main.c
parent4853268e16df1789541ea27586c7a4ec8c3786cb (diff)
make regex line ends more consistent across chunks
Diffstat (limited to 'main.c')
-rw-r--r--main.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/main.c b/main.c
index 71c7938..5df9e37 100644
--- a/main.c
+++ b/main.c
@@ -681,9 +681,10 @@ int search_next_regex(TxtLoc l, Str src, TxtLoc *out) {
return 0;
}
int match_found = 0;
-search_from_start:
+search_from_start:;
TxtLoc t = l;
re_search_start(&s, &re, &e.scratch);
+ if (at_start(t) || txt_chr(cprev(t)) == '\n') re_search_first_chunk(&s);
while (!at_end(t)) {
Str chnk = txt_next_chunk(&t);
re_search_chunk(&s, chnk.s, chnk.n);
@@ -720,6 +721,7 @@ search_from_end:
Arena a = e.scratch;
re_search_start(&s, &re, &e.scratch);
TxtLoc t = l;
+ if (at_start(t) || txt_chr(cprev(t)) == '\n') re_search_first_chunk(&s);
while (!at_end(t)) {
TxtLoc p = t;
Str chnk = txt_next_chunk(&t);