From nobody Mon Feb 28 12:51:18 2022 X-Original-To: dev-commits-ports-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id CF25919F3703; Mon, 28 Feb 2022 12:51:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4K6gHC5NqLz3hxB; Mon, 28 Feb 2022 12:51:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646052679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pn/xi+A84sX9gOEWiyr14aNHxU9SBva+q/su6w4G6y4=; b=LcBaBmRJHgJ9Xuszuer+sIZjLO5TEY+D7hjK46jrd90HjSChF1Z5vueBiy3zX59XkyZZzP su9Qwf1+MABErc74cmzRDNls+Tg34G0ITBhs6ZrjT+8fSnrAiSmNzL4bQLNuj2tJEyNWPF yOlRFlf2qYxzUciJXkiMtl+iLp4dGucfnCzekabn0ksenkRbMR7Vu6bqvaOxqZjo99gGjg yzZ5BQXMT3Z48v599eBALVnHXEcCDfv0q39pLoM3ZZlc+21rXsNFUu4a9egGEfUa667KB9 wfKi7ZocJpP9P5qRQwDmCyvnz8dkb/JEQ1XQ9P2XDFWNS8yZpyhPkvj6lfy+rA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D7A901BDCF; Mon, 28 Feb 2022 12:51:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21SCpIHR062936; Mon, 28 Feb 2022 12:51:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21SCpI5k062935; Mon, 28 Feb 2022 12:51:18 GMT (envelope-from git) Date: Mon, 28 Feb 2022 12:51:18 GMT Message-Id: <202202281251.21SCpI5k062935@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Po-Chuan Hsieh Subject: git: 114cacbfde6e - main - www/xapian-omega: Use PCRE2 instead of PCRE List-Id: Commit messages for all branches of the ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-all@freebsd.org X-BeenThere: dev-commits-ports-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: sunpoet X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 114cacbfde6ef5bbcec28ce2f3ec186bd398c075 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1646052679; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=pn/xi+A84sX9gOEWiyr14aNHxU9SBva+q/su6w4G6y4=; b=jF3xdq/hCk1UCKEJ6jOWDu0skbTwbdl4Gz8Ktmi3YtXxS/YYqG0hDJHBxXJ6H9BxtB6qUz WMx89Oqve5M/INeM64eojXQVpvI/7fL1124COju92KT/CEPcWhhz/Y9/O6O1CP3o2tWrC5 tGuti3dZbUJZkRPrN6j1rxeei6e4Ug/iXbRAUjS3eAOQEFEZw95GOhAnxlUpQDykGNvbcC csuIRhtcS2BOo6BZLDzWJOTdBY8clqWR3m2AJhzWQC/QjBzlTknxfqlFqvQqbaOt5E/KnV uLCibIbkzmnr4WMNgTgimctCtz0bNSKy1anlBzjkNCHRilxBICEz10/E7PGdwg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1646052679; a=rsa-sha256; cv=none; b=Dy/dCTpprr1a8GUTy7u9c0D/ZfLd3CWQ+XbxwMwmDOT5UFp5zXB7axvW2xTiWThi/Pt0od oqKaHxQYsalY/Qg3cla4vz3eeHIXZpt2RzWUElpMVfjA5SO4ht9HniqPbacJERIvHqqn99 hqHvWMWmpDtqvXBBaJ7YR4D2ww66bdmYhvhrTvBEV/n3bKiKUhbgHnPC+4XCwv8JV83X4o mCefZabrYNzoLVJg0hm+/47sC4CR2kc3K85tWDbaZRbi570tsu8GUpHfdHQC55NLGT3WCP ZLmV1HYxQ4iaUajFJrVhU8S8uOlqaIjQouQKtXAEI5MbO3YUeAq8AvtuCeyyGA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by sunpoet: URL: https://cgit.FreeBSD.org/ports/commit/?id=114cacbfde6ef5bbcec28ce2f3ec186bd398c075 commit 114cacbfde6ef5bbcec28ce2f3ec186bd398c075 Author: Po-Chuan Hsieh AuthorDate: 2022-02-28 09:34:01 +0000 Commit: Po-Chuan Hsieh CommitDate: 2022-02-28 12:46:05 +0000 www/xapian-omega: Use PCRE2 instead of PCRE - Bump PORTREVISION for dependency and package change Reference: https://git.xapian.org/?p=xapian;a=commit;h=fe7db763379cc5ac1649498d38446eb8fee32b56 https://github.com/xapian/xapian/commit/fe7db763379cc5ac1649498d38446eb8fee32b56 --- www/xapian-omega/Makefile | 8 +- www/xapian-omega/files/patch-pcre2 | 434 +++++++++++++++++++++++++++++++++++++ 2 files changed, 439 insertions(+), 3 deletions(-) diff --git a/www/xapian-omega/Makefile b/www/xapian-omega/Makefile index 0e5f37dc8063..bfa4518a1e56 100644 --- a/www/xapian-omega/Makefile +++ b/www/xapian-omega/Makefile @@ -2,6 +2,7 @@ PORTNAME= xapian-omega PORTVERSION= 1.4.19 +PORTREVISION= 1 CATEGORIES= www MASTER_SITES= https://oligarchy.co.uk/xapian/${PORTVERSION}/ \ LOCAL/sunpoet @@ -13,15 +14,16 @@ LICENSE= GPLv2 LICENSE_FILE= ${WRKSRC}/COPYING BUILD_DEPENDS= xapian-core>=${PORTVERSION}:databases/xapian-core -LIB_DEPENDS= libpcre.so:devel/pcre \ +LIB_DEPENDS= libpcre2-8.so:devel/pcre2 \ libxapian.so:databases/xapian-core USES= compiler:c++11-lang libtool localbase perl5 shebangfix tar:xz CONFIGURE_ARGS= --datarootdir=${DATADIR} --docdir=${DOCSDIR} \ ac_cv_func_snprintf=snprintf -CONFIGURE_ENV= PCRE_CONFIG=${LOCALBASE}/bin/pcre-config \ - XAPIAN_CONFIG=${LOCALBASE}/bin/xapian-config +#xCONFIGURE_ENV= PCRE2_CONFIG=${LOCALBASE}/bin/pcre2-config +#xCONFIGURE_ENV= PCRE2_CONFIG=${LOCALBASE}/bin/pcre2-config +CONFIGURE_ENV= XAPIAN_CONFIG=${LOCALBASE}/bin/xapian-config GNU_CONFIGURE= yes USE_CXXSTD= c++11 USE_LDCONFIG= yes diff --git a/www/xapian-omega/files/patch-pcre2 b/www/xapian-omega/files/patch-pcre2 new file mode 100644 index 000000000000..fcbcbe24212a --- /dev/null +++ b/www/xapian-omega/files/patch-pcre2 @@ -0,0 +1,434 @@ +Reference: https://git.xapian.org/?p=xapian;a=commit;h=fe7db763379cc5ac1649498d38446eb8fee32b56 + https://github.com/xapian/xapian/commit/fe7db763379cc5ac1649498d38446eb8fee32b56 + +--- Makefile.in.orig 2021-12-31 23:07:33 UTC ++++ Makefile.in +@@ -643,9 +643,9 @@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ + PACKAGE_URL = @PACKAGE_URL@ + PACKAGE_VERSION = @PACKAGE_VERSION@ + PATH_SEPARATOR = @PATH_SEPARATOR@ +-PCRE_CFLAGS = @PCRE_CFLAGS@ +-PCRE_CONFIG = @PCRE_CONFIG@ +-PCRE_LIBS = @PCRE_LIBS@ ++PCRE2_CFLAGS = @PCRE2_CFLAGS@ ++PCRE2_CONFIG = @PCRE2_CONFIG@ ++PCRE2_LIBS = @PCRE2_LIBS@ + PERL = @PERL@ + PKG_CONFIG = @PKG_CONFIG@ + RANLIB = @RANLIB@ +@@ -843,15 +843,15 @@ noinst_HEADERS = omega.h query.h cgiparam.h index_file + common/stringutils.h + AM_LDFLAGS = $(NO_UNDEFINED) $(MAGIC_LDFLAGS) + +-# We want to compile transform.cc with PCRE_CFLAGS, but if this adds a -I for ++# We want to compile transform.cc with PCRE2_CFLAGS, but if this adds a -I for + # a directory with a different version of iconv, then we get problems (this + # has been reported on macOS). We solve this using a technique suggested by + # the automake manual: compile each of transform.cc and utf8convert.cc into + # its own convenience library so each only gets its own CPPFLAGS. + noinst_LTLIBRARIES = libtransform.la libutf8convert.la + libtransform_la_SOURCES = transform.cc +-libtransform_la_CPPFLAGS = $(PCRE_CFLAGS) +-libtransform_la_LIBADD = $(PCRE_LIBS) ++libtransform_la_CPPFLAGS = $(PCRE2_CFLAGS) ++libtransform_la_LIBADD = $(PCRE2_LIBS) + libutf8convert_la_SOURCES = utf8convert.cc + libutf8convert_la_CPPFLAGS = $(AM_CPPFLAGS) $(INCICONV) + libutf8convert_la_LIBADD = $(XAPIAN_LIBS) $(LTLIBICONV) +--- configure.orig 2021-12-31 23:07:31 UTC ++++ configure +@@ -638,10 +638,10 @@ LTLIBOBJS + LIBOBJS + AUTOM4TE + AM_CXXFLAGS +-PCRE_LIBS +-PCRE_CFLAGS ++PCRE2_LIBS ++PCRE2_CFLAGS + PKG_CONFIG +-PCRE_CONFIG ++PCRE2_CONFIG + RST2HTML + HELP2MAN + PERL +@@ -828,7 +828,7 @@ XAPIAN_CONFIG + PERL + HELP2MAN + RST2HTML +-PCRE_CONFIG ++PCRE2_CONFIG + PKG_CONFIG' + + +@@ -1502,7 +1502,8 @@ Some influential environment variables: + PERL Perl interpreter + HELP2MAN help2man man page generator + RST2HTML reST to HTML convertor +- PCRE_CONFIG Location of pcre-config ++ PCRE2_CONFIG ++ Location of pcre2-config + PKG_CONFIG Location of pkg-config + + Use these variables to override the choices made by `configure' or to help +@@ -18921,12 +18922,12 @@ fi + + pcre_runtime_installed() { + for sfx in '' 32 64 ; do +- set /usr/lib$sfx/libpcre*.so.* +- if test "/usr/lib$sfx/libpcre?.so.*" != "$1" ; then ++ set /usr/lib$sfx/libpcre2-*.so.* ++ if test "/usr/lib$sfx/libpcre2-*.so.*" != "$1" ; then + if test -r /etc/debian_version ; then +- pkg="libpcre3-dev" ++ pkg="libpcre2-dev" + else +- pkg="pcre-devel" ++ pkg="pcre2-devel" + fi + as_fn_set_status 0 + fi +@@ -18934,8 +18935,9 @@ pcre_runtime_installed() { + as_fn_set_status 1 + } + ++PCRE2_LIBS_FLAG=--libs8 + +-if test -z "$PCRE_CONFIG" ; then ++if test -z "$PCRE2_CONFIG" ; then + + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args. +@@ -19036,28 +19038,29 @@ else + fi + + if test -n "$PKG_CONFIG" ; then +- pcre_try="$PKG_CONFIG libpcre" ++ pcre_try="$PKG_CONFIG libpcre2-8" + if $pcre_try 2>/dev/null ; then +- PCRE_CONFIG=$pcre_try ++ PCRE2_CONFIG=$pcre_try ++ PCRE2_LIBS_FLAG=--libs + else + if pcre_runtime_installed ; then +- as_fn_error $? "'$pcre_try' failed, but the PCRE runtime library seems to be installed. If you've installed PCRE from a package, you probably need to install an extra package called something like $pkg in order to be able to build $PACKAGE_NAME." "$LINENO" 5 ++ as_fn_error $? "'$pcre_try' failed, but the PCRE2 runtime library seems to be installed. If you've installed PCRE2 from a package, you probably need to install an extra package called something like $pkg in order to be able to build $PACKAGE_NAME." "$LINENO" 5 + else +- as_fn_error $? "'$pcre_try' failed. If the PCRE library is installed, you need to add PCRE_CONFIG=/path/to/pcre-config to your configure command." "$LINENO" 5 ++ as_fn_error $? "'$pcre_try' failed. If the PCRE2 library is installed, you need to add PCRE2_CONFIG=/path/to/pcre2-config to your configure command." "$LINENO" 5 + fi + fi + else + if test -n "$ac_tool_prefix"; then +- # Extract the first word of "${ac_tool_prefix}pcre-config", so it can be a program name with args. +-set dummy ${ac_tool_prefix}pcre-config; ac_word=$2 ++ # Extract the first word of "${ac_tool_prefix}pcre2-config", so it can be a program name with args. ++set dummy ${ac_tool_prefix}pcre2-config; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } +-if ${ac_cv_path_PCRE_CONFIG+:} false; then : ++if ${ac_cv_path_PCRE2_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 + else +- case $PCRE_CONFIG in ++ case $PCRE2_CONFIG in + [\\/]* | ?:[\\/]*) +- ac_cv_path_PCRE_CONFIG="$PCRE_CONFIG" # Let the user override the test with a path. ++ ac_cv_path_PCRE2_CONFIG="$PCRE2_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +@@ -19067,7 +19070,7 @@ do + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then +- ac_cv_path_PCRE_CONFIG="$as_dir/$ac_word$ac_exec_ext" ++ ac_cv_path_PCRE2_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +@@ -19078,10 +19081,10 @@ IFS=$as_save_IFS + ;; + esac + fi +-PCRE_CONFIG=$ac_cv_path_PCRE_CONFIG +-if test -n "$PCRE_CONFIG"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PCRE_CONFIG" >&5 +-$as_echo "$PCRE_CONFIG" >&6; } ++PCRE2_CONFIG=$ac_cv_path_PCRE2_CONFIG ++if test -n "$PCRE2_CONFIG"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PCRE2_CONFIG" >&5 ++$as_echo "$PCRE2_CONFIG" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + $as_echo "no" >&6; } +@@ -19089,18 +19092,18 @@ fi + + + fi +-if test -z "$ac_cv_path_PCRE_CONFIG"; then +- ac_pt_PCRE_CONFIG=$PCRE_CONFIG +- # Extract the first word of "pcre-config", so it can be a program name with args. +-set dummy pcre-config; ac_word=$2 ++if test -z "$ac_cv_path_PCRE2_CONFIG"; then ++ ac_pt_PCRE2_CONFIG=$PCRE2_CONFIG ++ # Extract the first word of "pcre2-config", so it can be a program name with args. ++set dummy pcre2-config; ac_word=$2 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 + $as_echo_n "checking for $ac_word... " >&6; } +-if ${ac_cv_path_ac_pt_PCRE_CONFIG+:} false; then : ++if ${ac_cv_path_ac_pt_PCRE2_CONFIG+:} false; then : + $as_echo_n "(cached) " >&6 + else +- case $ac_pt_PCRE_CONFIG in ++ case $ac_pt_PCRE2_CONFIG in + [\\/]* | ?:[\\/]*) +- ac_cv_path_ac_pt_PCRE_CONFIG="$ac_pt_PCRE_CONFIG" # Let the user override the test with a path. ++ ac_cv_path_ac_pt_PCRE2_CONFIG="$ac_pt_PCRE2_CONFIG" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +@@ -19110,7 +19113,7 @@ do + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then +- ac_cv_path_ac_pt_PCRE_CONFIG="$as_dir/$ac_word$ac_exec_ext" ++ ac_cv_path_ac_pt_PCRE2_CONFIG="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +@@ -19121,17 +19124,17 @@ IFS=$as_save_IFS + ;; + esac + fi +-ac_pt_PCRE_CONFIG=$ac_cv_path_ac_pt_PCRE_CONFIG +-if test -n "$ac_pt_PCRE_CONFIG"; then +- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PCRE_CONFIG" >&5 +-$as_echo "$ac_pt_PCRE_CONFIG" >&6; } ++ac_pt_PCRE2_CONFIG=$ac_cv_path_ac_pt_PCRE2_CONFIG ++if test -n "$ac_pt_PCRE2_CONFIG"; then ++ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PCRE2_CONFIG" >&5 ++$as_echo "$ac_pt_PCRE2_CONFIG" >&6; } + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 + $as_echo "no" >&6; } + fi + +- if test "x$ac_pt_PCRE_CONFIG" = x; then +- PCRE_CONFIG="" ++ if test "x$ac_pt_PCRE2_CONFIG" = x; then ++ PCRE2_CONFIG="" + else + case $cross_compiling:$ac_tool_warned in + yes:) +@@ -19139,23 +19142,23 @@ yes:) + $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} + ac_tool_warned=yes ;; + esac +- PCRE_CONFIG=$ac_pt_PCRE_CONFIG ++ PCRE2_CONFIG=$ac_pt_PCRE2_CONFIG + fi + else +- PCRE_CONFIG="$ac_cv_path_PCRE_CONFIG" ++ PCRE2_CONFIG="$ac_cv_path_PCRE2_CONFIG" + fi + +- if test -z $PCRE_CONFIG ; then ++ if test -z $PCRE2_CONFIG ; then + if pcre_runtime_installed ; then +- as_fn_error $? "Can't find pcre-config, although the PCRE runtime library seems to be installed. If you've installed PCRE from a package, you probably need to install an extra package called something like $pkg in order to be able to build $PACKAGE_NAME." "$LINENO" 5 ++ as_fn_error $? "Can't find pcre2-config, although the PCRE2 runtime library seems to be installed. If you've installed PCRE2 from a package, you probably need to install an extra package called something like $pkg in order to be able to build $PACKAGE_NAME." "$LINENO" 5 + else +- as_fn_error $? "Can't find pcre-config. If the PCRE library is installed, you need to add PCRE_CONFIG=/path/to/pcre-config to your configure command." "$LINENO" 5 ++ as_fn_error $? "Can't find pcre2-config. If the PCRE2 library is installed, you need to add PCRE2_CONFIG=/path/to/pcre2-config to your configure command." "$LINENO" 5 + fi + fi + fi + fi +-PCRE_CFLAGS=`$PCRE_CONFIG --cflags` +-PCRE_LIBS=`$PCRE_CONFIG --libs` ++PCRE2_CFLAGS=`$PCRE2_CONFIG --cflags` ++PCRE2_LIBS=`$PCRE2_CONFIG $PCRE2_LIBS_FLAG` + + + +--- transform.cc.orig 2021-12-31 23:06:40 UTC ++++ transform.cc +@@ -1,7 +1,7 @@ + /** @file + * @brief Implement OmegaScript $transform function. + */ +-/* Copyright (C) 2003,2009,2015 Olly Betts ++/* Copyright (C) 2003,2009,2015,2022 Olly Betts + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by +@@ -22,32 +22,44 @@ + + #include "transform.h" + +-#include ++#define PCRE2_CODE_UNIT_WIDTH 8 ++#include + ++#include + #include + #include + #include + + using namespace std; + +-static map, pcre *> re_cache; ++static map, pcre2_code*> re_cache; ++static pcre2_match_data* md = NULL; + +-static pcre * +-get_re(const string & pattern, int options) ++static pcre2_code* ++get_re(const string& pattern, uint32_t options) + { +- pair re_key = make_pair(pattern, options); ++ pair re_key = make_pair(pattern, options); + auto re_it = re_cache.find(re_key); + if (re_it != re_cache.end()) { + return re_it->second; + } + +- const char *error; +- int erroffset; +- pcre * re = +- pcre_compile(pattern.c_str(), options, &error, &erroffset, NULL); ++ if (!md) { ++ // Create lazily - here is a good point as it's a single place we ++ // have to pass through before executing a regex. ++ md = pcre2_match_data_create(10, NULL); ++ } ++ ++ int error_code; ++ PCRE2_SIZE erroffset; ++ auto re = pcre2_compile(PCRE2_SPTR8(pattern.data()), pattern.size(), ++ options, &error_code, &erroffset, NULL); + if (!re) { + string m = "$transform failed to compile its regular expression: "; +- m += error; ++ // pcre2api(3) says that "a buffer size of 120 code units is ample". ++ unsigned char buf[120]; ++ pcre2_get_error_message(error_code, buf, sizeof(buf)); ++ m += reinterpret_cast(buf); + throw m; + } + re_cache.insert(make_pair(re_key, re)); +@@ -57,35 +69,34 @@ get_re(const string & pattern, int options) + void + omegascript_match(string & value, const vector & args) + { +- int offsets[30]; +- int options = 0; ++ uint32_t options = PCRE2_UTF; + if (args.size() > 2) { + const string &opts = args[2]; +- for (string::const_iterator i = opts.begin(); i != opts.end(); ++i) { +- switch (*i) { ++ for (char ch : opts) { ++ switch (ch) { + case 'i': +- options |= PCRE_CASELESS; ++ options |= PCRE2_CASELESS; + break; + case 'm': +- options |= PCRE_MULTILINE; ++ options |= PCRE2_MULTILINE; + break; + case 's': +- options |= PCRE_DOTALL; ++ options |= PCRE2_DOTALL; + break; + case 'x': +- options |= PCRE_EXTENDED; ++ options |= PCRE2_EXTENDED; + break; + default: { + string m = "Unknown $match option character: "; +- m += *i; ++ m += ch; + throw m; + } + } + } + } +- pcre * re = get_re(args[0], options); +- int matches = pcre_exec(re, NULL, args[1].data(), args[1].size(), +- 0, 0, offsets, 30); ++ pcre2_code* re = get_re(args[0], options); ++ int matches = pcre2_match(re, PCRE2_SPTR8(args[1].data()), args[1].size(), ++ 0, 0, md, NULL); + if (matches > 0) { + value += "true"; + } +@@ -94,42 +105,42 @@ omegascript_match(string & value, const vector + void + omegascript_transform(string & value, const vector & args) + { +- int offsets[30]; + bool replace_all = false; +- int options = 0; ++ uint32_t options = PCRE2_UTF; + if (args.size() > 3) { + const string & opts = args[3]; +- for (string::const_iterator i = opts.begin(); i != opts.end(); ++i) { +- switch (*i) { ++ for (char ch : opts) { ++ switch (ch) { + case 'g': + replace_all = true; + break; + case 'i': +- options |= PCRE_CASELESS; ++ options |= PCRE2_CASELESS; + break; + case 'm': +- options |= PCRE_MULTILINE; ++ options |= PCRE2_MULTILINE; + break; + case 's': +- options |= PCRE_DOTALL; ++ options |= PCRE2_DOTALL; + break; + case 'x': +- options |= PCRE_EXTENDED; ++ options |= PCRE2_EXTENDED; + break; + default: { + string m = "Unknown $transform option character: "; +- m += *i; ++ m += ch; + throw m; + } + } + } + } + +- pcre * re = get_re(args[0], options); +- size_t start = 0; ++ pcre2_code* re = get_re(args[0], options); ++ PCRE2_SIZE start = 0; + do { +- int matches = pcre_exec(re, NULL, args[2].data(), args[2].size(), +- int(start), 0, offsets, 30); ++ int matches = pcre2_match(re, ++ PCRE2_SPTR8(args[2].data()), args[2].size(), ++ start, 0, md, NULL); + if (matches <= 0) { + // (matches == PCRE_ERROR_NOMATCH) is OK, otherwise this is an + // error. FIXME: should we report this rather than ignoring it? +@@ -137,9 +148,9 @@ omegascript_transform(string & value, const vector