diff --git a/configure.ac b/configure.ac index 8fe7d78..ac601a3 100644 --- a/configure.ac +++ b/configure.ac @@ -666,7 +666,7 @@ AM_CONDITIONAL([SQUATTER], AC_ARG_ENABLE(sieve, [AS_HELP_STRING([--disable-sieve], [disable Sieve support])],,[enable_sieve="yes";]) AC_ARG_ENABLE(pcre, - [AS_HELP_STRING([--disable-pcre], [disable PCRE library])],[cyrus_cv_pcre_utf8="$enableval"]) + [AS_HELP_STRING([--disable-pcre2], [disable PCRE library])],[cyrus_cv_pcre_utf8="$enableval"]) if test "$enable_sieve" != "no"; then AC_DEFINE(USE_SIEVE,[],[Build in Sieve support?]) @@ -692,25 +692,25 @@ fi AM_CONDITIONAL([SIEVE], [test "${enable_sieve}" != "no"]) -if test "$enable_pcre" != "no"; then - AC_CHECK_HEADER(pcreposix.h) - if test "$ac_cv_header_pcreposix_h" = "yes"; then - AC_MSG_CHECKING(for utf8 enabled pcre) - AC_CACHE_VAL(cyrus_cv_pcre_utf8, AC_TRY_CPP([#include -#ifndef REG_UTF8 +if test "$enable_pcre2" != "no"; then + AC_CHECK_HEADER(pcre2posix.h) + if test "$ac_cv_header_pcre2posix_h" = "yes"; then + AC_MSG_CHECKING(for utf8 enabled pcre2) + AC_CACHE_VAL(cyrus_cv_pcre_utf8, AC_TRY_CPP([#include +#ifndef REG_UTF #include -#endif],cyrus_cv_pcre_utf8=yes,cyrus_cv_pcre_utf8=no)) - AC_MSG_RESULT($cyrus_cv_pcre_utf8) +#endif],cyrus_cv_pcre2_utf8=yes,cyrus_cv_pcre2_utf8=no)) + AC_MSG_RESULT($cyrus_cv_pcre2_utf8) else - cyrus_cv_pcre_utf8="no" + cyrus_cv_pcre2_utf8="no" fi fi LIB_REGEX= -if test "$cyrus_cv_pcre_utf8" = "yes"; then - LIB_REGEX="-lpcre -lpcreposix"; +if test "$cyrus_cv_pcre2_utf8" = "yes"; then + LIB_REGEX="-lpcre2-posix"; AC_DEFINE(ENABLE_REGEX, [], [Do we have a regex library?]) - AC_DEFINE(HAVE_PCREPOSIX_H, [], [Do we have usable pcre library?]) + AC_DEFINE(HAVE_PCRE2POSIX_H, [], [Do we have usable pcre2 library?]) else AC_CHECK_HEADERS(rxposix.h) if test "$ac_cv_header_rxposix_h" = "yes"; then diff --git a/imap/cyr_buildinfo.c b/imap/cyr_buildinfo.c index d8c4a96..c2db3b0 100644 --- a/imap/cyr_buildinfo.c +++ b/imap/cyr_buildinfo.c @@ -181,7 +181,7 @@ static json_t *buildinfo() #else json_object_set_new(dependency, "jansson", json_false()); #endif -#if defined(ENABLE_REGEX) && defined(HAVE_PCREPOSIX_H) +#if defined(ENABLE_REGEX) && defined(HAVE_PCRE2POSIX_H) json_object_set_new(dependency, "pcre", json_true()); #else json_object_set_new(dependency, "pcre", json_false()); diff --git a/lib/util.h b/lib/util.h index 6ac085c..dbeef25 100644 --- a/lib/util.h +++ b/lib/util.h @@ -71,16 +71,17 @@ extern const char CYRUS_VERSION[]; #ifdef ENABLE_REGEX -# ifdef HAVE_PCREPOSIX_H -# include -# include -# else /* !HAVE_PCREPOSIX_H */ +# if defined(HAVE_PCRE2POSIX_H) && !defined(PCRE2_CODE_UNIT_WIDTH) +# define PCRE2_CODE_UNIT_WIDTH 8 +# include +# include +# elif !defined(HAVE_PCRE2POSIX_H) /* !HAVE_PCRE2POSIX_H */ # ifdef HAVE_RXPOSIX_H # include # else /* !HAVE_RXPOSIX_H */ # include # endif /* HAVE_RXPOSIX_H */ -# endif /* HAVE_PCREPOSIX_H */ +# endif /* HAVE_PCRE2POSIX_H */ #endif /* ENABLE_REGEX */ #ifdef HAVE_LIBUUID diff --git a/sieve/bc_eval.c b/sieve/bc_eval.c index f14a5d7..9c3d67c 100644 --- a/sieve/bc_eval.c +++ b/sieve/bc_eval.c @@ -316,9 +316,9 @@ static int regcomp_flags(int comparator, int requires) { int cflags = REG_EXTENDED; -#ifdef HAVE_PCREPOSIX_H +#ifdef HAVE_PCRE2POSIX_H /* support UTF8 comparisons */ - cflags |= REG_UTF8; + cflags |= REG_UTF; #endif if (comparator == B_ASCIICASEMAP) { diff --git a/sieve/comparator.h b/sieve/comparator.h index b043bc2..8ff05b0 100644 --- a/sieve/comparator.h +++ b/sieve/comparator.h @@ -47,16 +47,17 @@ #include #ifdef ENABLE_REGEX -# ifdef HAVE_PCREPOSIX_H -# include -# include -# else /* !HAVE_PCREPOSIX_H */ +# if defined(HAVE_PCRE2POSIX_H) && !defined(PCRE2_CODE_UNIT_WIDTH) +# define PCRE2_CODE_UNIT_WIDTH 8 +# include +# include +# elif !defined(HAVE_PCRE2POSIX_H) /* !HAVE_PCRE2POSIX_H */ # ifdef HAVE_RXPOSIX_H # include # else /* !HAVE_RXPOSIX_H */ # include # endif /* HAVE_RXPOSIX_H */ -# endif /* HAVE_PCREPOSIX_H */ +# endif /* HAVE_PCRE2POSIX_H */ #endif /* ENABLE_REGEX */ #include "sieve_interface.h" diff --git a/sieve/sieve.c b/sieve/sieve.c index d61f695..0e419b0 100644 --- a/sieve/sieve.c +++ b/sieve/sieve.c @@ -4965,7 +4965,7 @@ static int verify_regexlist(sieve_script_t *sscript, #ifdef HAVE_PCREPOSIX_H /* support UTF8 comparisons */ - cflags |= REG_UTF8; + cflags |= REG_UTF; #endif if (collation == B_ASCIICASEMAP) { diff --git a/sieve/sieve.y b/sieve/sieve.y index b080c26..8692fc1 100644 --- a/sieve/sieve.y +++ b/sieve/sieve.y @@ -2215,9 +2215,9 @@ static int verify_regexlist(sieve_script_t *sscript, regex_t reg; int cflags = REG_EXTENDED | REG_NOSUB; -#ifdef HAVE_PCREPOSIX_H +#ifdef HAVE_PCRE2POSIX_H /* support UTF8 comparisons */ - cflags |= REG_UTF8; + cflags |= REG_UTF; #endif if (collation == B_ASCIICASEMAP) {