]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-regex: Only use pcre2_substitute_callout_block() if it's available
authorAki Tuomi <aki.tuomi@open-xchange.com>
Mon, 1 Sep 2025 12:20:48 +0000 (15:20 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Tue, 2 Sep 2025 07:28:21 +0000 (07:28 +0000)
m4/want_pcre.m4
src/lib-regex/regex.c

index ccf10ceb71d0e97f468a89bca09aa6fcb17775bf..f013aaad82b3166ffc06aeaa79fbb86f64b83752 100644 (file)
@@ -12,6 +12,10 @@ AC_DEFUN([DOVECOT_WANT_PCRE], [
   ])
 
   AS_IF([test "$have_pcre" != "no"], [
+    old_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $LIBPCRE_CFLAGS"
+    AC_CHECK_FUNCS([pcre2_substitute_callout_block])
+    CFLAGS="$old_CFLAGS"
     AC_DEFINE(HAVE_LIBPCRE,, [Define if you have libpcre2 backed regular expressions])
   ])
 
index b8be11afa12fe4494ee763d770c9920244b3b615..66c5f6238e4cb8bc10f12fa729cf6d3a19155a7c 100644 (file)
@@ -54,11 +54,13 @@ static int dregex_code_callout(pcre2_callout_block *block ATTR_UNUSED, void *ctx
        return 0;
 }
 
+#ifdef HAVE_PCRE2_SUBSTITUTE_CALLOUT_BLOCK
 static int
 dregex_code_substitute_callout(pcre2_substitute_callout_block *block ATTR_UNUSED, void *ctx)
 {
        return dregex_code_callout(NULL, ctx);
 }
+#endif
 
 static int dregex_code_guard(uint depth, void *ctx)
 {
@@ -78,7 +80,9 @@ static void dregex_code_init(struct dregex_code *code)
        pcre2_set_compile_recursion_guard(code->cctx, dregex_code_guard, code);
        /* these are used to ensure that CPU time isn't exceeded */
        pcre2_set_callout(code->mctx, dregex_code_callout, code);
+#ifdef HAVE_PCRE2_SUBSTITUTE_CALLOUT_BLOCK
        pcre2_set_substitute_callout(code->mctx, dregex_code_substitute_callout, code);
+#endif
 
        /* Set some limits */
        pcre2_set_match_limit(code->mctx, code->max_capture_groups);