aboutsummaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorRobin Haberkorn <rhaberkorn@fmsbw.de>2026-06-29 19:14:03 +0200
committerRobin Haberkorn <rhaberkorn@fmsbw.de>2026-06-29 19:14:03 +0200
commitd71d7527a8be8654560867d761036598408bfe14 (patch)
tree57a3f056e8b1039b172a618aec264e8c172d4925 /regcomp.c
parent7c103ba4914cb47cb1e6c51cc9b8121aa5e6ef62 (diff)
downloadterex-d71d7527a8be8654560867d761036598408bfe14.tar.gz
implemented tere_set_is_interrupted_cb()
Allows you to set up a callback that's invoked repeatedly during matching. If it returns non-0 matching will abort and REG_EINTR is returned. Allows you to interrupt long-running regexp executions that would otherwise block the UI or hang the entire application.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index bd332dc..e6c9f94 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -273,6 +273,17 @@ static struct fns functions = {
};
/*
+ - tere_set_is_interrupted_cb - set is_interrupted callback
+ ^ void tere_set_is_interrupted_cb(regex_t *, int (*cb)(void));
+ */
+void
+tere_set_is_interrupted_cb(
+ regex_t *re, int (*cb)(void))
+{
+ ((struct fns *)re->re_fns)->is_interrupted = cb;
+}
+
+/*
- compile - compile regular expression
^ int compile(regex_t *, const chr *, size_t, int);
*/