From 639a93dd3e0c2698b037f1405dea18854d9f3e24 Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Fri, 1 Aug 2025 12:17:36 +0300 Subject: [PATCH] lib-dovecot: Add lib-regex --- configure.ac | 5 +++-- src/Makefile.am | 2 +- src/lib-dcrypt/Makefile.am | 1 + src/lib-dict-extra/Makefile.am | 1 + src/lib-dict/Makefile.am | 1 + src/lib-dns-client/Makefile.am | 1 + src/lib-dovecot/Makefile.am | 1 + src/lib-fs/Makefile.am | 1 + src/lib-http/Makefile.am | 2 ++ src/lib-imap-client/Makefile.am | 1 + src/lib-login/Makefile.am | 2 ++ src/lib-master/Makefile.am | 1 + src/lib-oauth2/Makefile.am | 2 ++ src/lib-program-client/Makefile.am | 1 + src/lib-regex/test-regex.c | 15 +++++++++++++++ src/lib-settings/Makefile.am | 1 + src/lib-smtp/Makefile.am | 2 ++ src/lib-ssl-iostream/Makefile.am | 1 + src/lib-var-expand-crypt/Makefile.am | 1 + src/lib-var-expand/Makefile.am | 2 ++ 20 files changed, 41 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index c113617f5e..0f56c3036c 100644 --- a/configure.ac +++ b/configure.ac @@ -595,6 +595,7 @@ LIBDOVECOT_LA_LIBS='\ $(top_builddir)/src/lib-ssl-iostream/libssl_iostream.la \ $(top_builddir)/src/lib-dcrypt/libdcrypt.la \ $(top_builddir)/src/lib-json/libjson.la \ + $(top_builddir)/src/lib-regex/libdregex.la \ $(top_builddir)/src/lib-test/libtest.la \ $(top_builddir)/src/lib/liblib.la' # This is used in dovecot-config, which is grepped in dovecot.m4, @@ -605,7 +606,7 @@ LIBDOVECOT_LUA='' if test "$want_shared_libs" = "yes"; then LIBDOVECOT_DEPS='$(top_builddir)/src/lib-dovecot/libdovecot.la' - LIBDOVECOT="$LIBDOVECOT_DEPS \$(MODULE_LIBS)" + LIBDOVECOT="$LIBDOVECOT_DEPS \$(MODULE_LIBS) \$(LIBPCRE_LIBS)" LIBDOVECOT_STORAGE_DEPS='$(top_builddir)/src/lib-storage/libdovecot-storage.la $(top_builddir)/src/lib-imap-storage/libimap-storage.la' LIBDOVECOT_LOGIN='$(top_builddir)/src/login-common/libdovecot-login.la' LIBDOVECOT_LDA='$(top_builddir)/src/lib-lda/libdovecot-lda.la' @@ -614,7 +615,7 @@ if test "$want_shared_libs" = "yes"; then fi else LIBDOVECOT_DEPS="$LIBDOVECOT_LA_LIBS" - LIBDOVECOT="$LIBDOVECOT_DEPS \$(MODULE_LIBS)" + LIBDOVECOT="$LIBDOVECOT_DEPS \$(MODULE_LIBS) \$(LIBPCRE_LIBS)" LIBDOVECOT_STORAGE_DEPS='$(top_builddir)/src/lib-storage/libstorage.la' LIBDOVECOT_LOGIN='$(top_builddir)/src/login-common/liblogin.la' LIBDOVECOT_LDA='$(top_builddir)/src/lib-lda/liblda.la' diff --git a/src/Makefile.am b/src/Makefile.am index 85064133ae..8fb76b7fcf 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -11,6 +11,7 @@ endif LIBDOVECOT_SUBDIRS = \ lib-test \ lib \ + lib-regex \ lib-var-expand \ lib-dns \ lib-settings \ @@ -44,7 +45,6 @@ SUBDIRS = \ lib-dovecot \ $(LIB_LDAP) \ $(LIB_LUA) \ - lib-regex \ lib-language \ lib-imap-client \ lib-imap-urlauth \ diff --git a/src/lib-dcrypt/Makefile.am b/src/lib-dcrypt/Makefile.am index b3d85b813a..294730a0b4 100644 --- a/src/lib-dcrypt/Makefile.am +++ b/src/lib-dcrypt/Makefile.am @@ -56,6 +56,7 @@ check-local: LIBDOVECOT_TEST_DEPS = \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-ssl-iostream/libssl_iostream.la \ ../lib-json/libjson.la \ ../lib-settings/libsettings.la \ diff --git a/src/lib-dict-extra/Makefile.am b/src/lib-dict-extra/Makefile.am index 83b84504ae..e7b783109a 100644 --- a/src/lib-dict-extra/Makefile.am +++ b/src/lib-dict-extra/Makefile.am @@ -35,6 +35,7 @@ test_libs = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib/liblib.la test_dict_fs_SOURCES = test-dict-fs.c diff --git a/src/lib-dict/Makefile.am b/src/lib-dict/Makefile.am index 74ce3e481f..68539db32f 100644 --- a/src/lib-dict/Makefile.am +++ b/src/lib-dict/Makefile.am @@ -57,6 +57,7 @@ test_libs = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la diff --git a/src/lib-dns-client/Makefile.am b/src/lib-dns-client/Makefile.am index c16b3d8b57..2e882d80ab 100644 --- a/src/lib-dns-client/Makefile.am +++ b/src/lib-dns-client/Makefile.am @@ -27,6 +27,7 @@ test_libs = \ ../lib-dns/libdns.la \ ../lib-test/libtest.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib/liblib.la test_dns_lookup_SOURCES = test-dns-lookup.c diff --git a/src/lib-dovecot/Makefile.am b/src/lib-dovecot/Makefile.am index b39cf26720..d22c9bb0ac 100644 --- a/src/lib-dovecot/Makefile.am +++ b/src/lib-dovecot/Makefile.am @@ -5,6 +5,7 @@ libdovecot_la_SOURCES = libdovecot_la_LIBADD = \ $(LIBDOVECOT_LA_LIBS) \ $(MODULE_LIBS) \ + $(LIBPCRE_LIBS) \ $(RELRO_LDFLAGS) libdovecot_la_DEPENDENCIES = $(LIBDOVECOT_LA_LIBS) diff --git a/src/lib-fs/Makefile.am b/src/lib-fs/Makefile.am index c663688896..dc129f32bf 100644 --- a/src/lib-fs/Makefile.am +++ b/src/lib-fs/Makefile.am @@ -54,6 +54,7 @@ test_deps = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la diff --git a/src/lib-http/Makefile.am b/src/lib-http/Makefile.am index a492e16889..0d4328b0bf 100644 --- a/src/lib-http/Makefile.am +++ b/src/lib-http/Makefile.am @@ -83,6 +83,7 @@ test_libs = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la \ $(MODULE_LIBS) @@ -93,6 +94,7 @@ test_deps = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib/liblib.la test_http_url_SOURCES = test-http-url.c diff --git a/src/lib-imap-client/Makefile.am b/src/lib-imap-client/Makefile.am index 6c6a84bc6e..0e4b7c6ea4 100644 --- a/src/lib-imap-client/Makefile.am +++ b/src/lib-imap-client/Makefile.am @@ -47,6 +47,7 @@ test_deps = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la diff --git a/src/lib-login/Makefile.am b/src/lib-login/Makefile.am index 08a2f30ee1..c12e47d1ea 100644 --- a/src/lib-login/Makefile.am +++ b/src/lib-login/Makefile.am @@ -37,6 +37,7 @@ test_libs = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la \ $(MODULE_LIBS) @@ -51,6 +52,7 @@ test_deps = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la diff --git a/src/lib-master/Makefile.am b/src/lib-master/Makefile.am index f4b22d1484..fbc748b222 100644 --- a/src/lib-master/Makefile.am +++ b/src/lib-master/Makefile.am @@ -57,6 +57,7 @@ test_deps = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib-dns-client/libdns-client.la \ ../lib-dns/libdns.la \ diff --git a/src/lib-oauth2/Makefile.am b/src/lib-oauth2/Makefile.am index 3f5c577e19..f5172198aa 100644 --- a/src/lib-oauth2/Makefile.am +++ b/src/lib-oauth2/Makefile.am @@ -47,6 +47,7 @@ test_libs = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la \ $(MODULE_LIBS) @@ -65,6 +66,7 @@ test_deps = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la diff --git a/src/lib-program-client/Makefile.am b/src/lib-program-client/Makefile.am index b2dd804463..c7081b7aa8 100644 --- a/src/lib-program-client/Makefile.am +++ b/src/lib-program-client/Makefile.am @@ -40,6 +40,7 @@ test_libs = \ ../lib-dns/libdns.la \ ../lib-charset/libcharset.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib/liblib.la \ $(MODULE_LIBS) diff --git a/src/lib-regex/test-regex.c b/src/lib-regex/test-regex.c index ef2d3bd8cf..10b393e409 100644 --- a/src/lib-regex/test-regex.c +++ b/src/lib-regex/test-regex.c @@ -112,6 +112,13 @@ static void test_dregex_match(void) MATCH_CASE("^.{2,3}$", "hel"), MATCH_CASE("^.+$", "hello"), MATCH_CASE_FULL("^.+$", "", NULL, 0, 0), + /* Groups */ + MATCH_CASE( + "the (.*) jumped over a (.*) dog", + "the fox jumped over a lazy dog" + ), + MATCH_CASE("the (a) of (b)", "the a of b"), + MATCH_CASE("the \\(a\\) of \\(b\\)", "the (a) of (b)"), /* Alternation and grouping */ MATCH_CASE("^(hello|world)$", "hello"), MATCH_CASE("^(hello|world)$", "world"), @@ -175,6 +182,14 @@ static void test_dregex_match(void) 0, 0 ), + { + .pattern = "the (.*) jumps off the (.*)", + .subject = "the cat jumps off the table", + .error = NULL, + .flags = (DREGEX_ICASE|DREGEX_ASCII_ONLY), + .compile_ret = 0, + .match_ret = 1, + }, MATCH_CASE("<(.*)@", ""), MATCH_CASE("^\\[(.*)\\] (.*)$", "[acme-users] [fwd]: hello, world"), MATCH_CASE_END diff --git a/src/lib-settings/Makefile.am b/src/lib-settings/Makefile.am index 5154ddf93e..25616a7333 100644 --- a/src/lib-settings/Makefile.am +++ b/src/lib-settings/Makefile.am @@ -40,6 +40,7 @@ noinst_PROGRAMS = $(test_programs) test_libs = \ libsettings.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-dns/libdns.la \ ../lib-test/libtest.la \ ../lib/liblib.la diff --git a/src/lib-smtp/Makefile.am b/src/lib-smtp/Makefile.am index a93bee4d51..a281f5bd0c 100644 --- a/src/lib-smtp/Makefile.am +++ b/src/lib-smtp/Makefile.am @@ -118,6 +118,7 @@ test_libs = \ ../lib-otp/libotp.la \ ../lib-json/libjson.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la \ $(MODULE_LIBS) @@ -138,6 +139,7 @@ test_deps = \ ../lib-auth/libauth.la \ ../lib-json/libjson.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la diff --git a/src/lib-ssl-iostream/Makefile.am b/src/lib-ssl-iostream/Makefile.am index 0a25aa8e66..b1c680e77e 100644 --- a/src/lib-ssl-iostream/Makefile.am +++ b/src/lib-ssl-iostream/Makefile.am @@ -47,6 +47,7 @@ test_libs = \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la diff --git a/src/lib-var-expand-crypt/Makefile.am b/src/lib-var-expand-crypt/Makefile.am index e56727fc9c..74bc05a799 100644 --- a/src/lib-var-expand-crypt/Makefile.am +++ b/src/lib-var-expand-crypt/Makefile.am @@ -25,6 +25,7 @@ test_libs = \ $(module_LTLIBRARIES) \ ../lib-dcrypt/libdcrypt.la \ ../lib-var-expand/libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-json/libjson.la \ ../lib-settings/libsettings.la \ ../lib-dns/libdns.la \ diff --git a/src/lib-var-expand/Makefile.am b/src/lib-var-expand/Makefile.am index 68c04c5212..172057788e 100644 --- a/src/lib-var-expand/Makefile.am +++ b/src/lib-var-expand/Makefile.am @@ -19,6 +19,7 @@ YACC=/bin/false AM_CPPFLAGS = \ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/lib-test \ + -I$(top_srcdir)/src/lib-regex \ -Wno-error=unused-function \ -DVAR_EXPAND_MODULE_DIR=\"$(moduledir)\" @@ -59,6 +60,7 @@ noinst_PROGRAMS = $(test_programs) test_libs = \ libvar_expand.la \ + ../lib-regex/libdregex.la \ ../lib-test/libtest.la \ ../lib/liblib.la \ $(MODULE_LIBS) -- 2.47.3