From fafa797d33d1e6fd0fa0cee9a8cd7eb90ba85782 Mon Sep 17 00:00:00 2001 From: WormHeamer Date: Thu, 1 Jan 2026 04:20:20 -0500 Subject: regex error reporting --- main.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'main.c') diff --git a/main.c b/main.c index a1281a9..a6caab0 100644 --- a/main.c +++ b/main.c @@ -531,8 +531,9 @@ done:; int search_next_regex(TxtLoc l, Str src, TxtLoc *out) { RegEx re = { 0 }; ReSearch s = { 0 }; - if (re_comp_ex(&re, src, &e.scratch, &e.scratch, RE_COMP_NO_GROUPS)) { - /* TODO: report parse error */ + int err = re_comp_ex(&re, src, &e.scratch, &e.scratch, RE_COMP_NO_GROUPS); + if (err) { + e.msg = str_printf(&e.scratch, "Regex error: %s", re_comp_strerror(err)); return 0; } TxtLoc t = l; @@ -561,8 +562,9 @@ search_from_start: int search_prev_regex(TxtLoc start, Str src, TxtLoc *out) { RegEx re = { 0 }; ReSearch s = { 0 }; - if (re_comp_ex(&re, src, &e.scratch, &e.scratch, RE_COMP_NO_GROUPS)) { - /* TODO: report parse error */ + int err = re_comp_ex(&re, src, &e.scratch, &e.scratch, RE_COMP_NO_GROUPS); + if (err) { + e.msg = str_printf(&e.scratch, "Regex error: %s", re_comp_strerror(err)); return 0; } int match_found = 0; @@ -1251,4 +1253,4 @@ int main(int argc, const char **argv) { vui_fini(); arena_free(&e.scratch); return 0; -} \ No newline at end of file +} -- cgit v1.2.3