regular expressions now use libpcre2-dev
--- a/src/configure.in
+++ b/src/configure.in
@@ -69,8 +69,10 @@
 AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h net/errno.h netdb.h netinet/in.h param.h pthread.h socks.h stdlib.h string.h strings.h sys/ioctl.h sys/param.h sys/ptem.h sys/socket.h sys/termio.h sys/time.h time.h unistd.h util.h pty.h stropts.h]) 
 AC_CHECK_HEADERS([zlib.h],,
 	[AC_MSG_ERROR([zlib header file not found, is the development part present])])
-AC_CHECK_HEADERS([pcre.h],,
-	[AC_MSG_ERROR([pcre header file not found, is the development part present])])
+AC_DEFINE([PCRE2_CODE_UNIT_WIDTH],8,[Define pcre2 unit size])
+AC_CHECK_HEADERS([pcre2.h],,
+	[AC_CHECK_HEADERS([pcre.h],,
+		[AC_MSG_ERROR([pcre header file not found, is the development part present])])])
 AC_CHECK_HEADERS([gnutls/gnutls.h],
 	[AC_DEFINE([HAVE_GNUTLS_H],,
 	[Define to 1 if you have <gnutls/gnutls.h>.])],
@@ -104,8 +106,9 @@
 AC_CHECK_LIB(nsl, gethostbyname)
 AC_CHECK_LIB(socket, rresvport)
 AC_CHECK_LIB(util, forkpty)
-AC_CHECK_LIB(pcre, pcre_compile,,
-	[AC_MSG_ERROR([pcre runtime library not working, is it AND the corresponding development (header) file installed])])
+AC_CHECK_LIB(pcre2-8, pcre2_compile_8,,
+ 	[AC_CHECK_LIB(pcre, pcre_compile,,
+ 	 	[AC_MSG_ERROR([pcre runtime library not working, is it AND the corresponding development (header) file installed])])])
 AC_CHECK_LIB(gnutls, gnutls_init)
 AC_CHECK_LIB(m, sqrt)
 
--- a/src/configure
+++ b/src/configure
@@ -3436,7 +3436,19 @@
 
 done
 
-for ac_header in pcre.h
+
+$as_echo "#define PCRE2_CODE_UNIT_WIDTH 8" >>confdefs.h
+
+for ac_header in pcre2.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "pcre2.h" "ac_cv_header_pcre2_h" "$ac_includes_default"
+if test "x$ac_cv_header_pcre2_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_PCRE2_H 1
+_ACEOF
+
+else
+  for ac_header in pcre.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "pcre.h" "ac_cv_header_pcre_h" "$ac_includes_default"
 if test "x$ac_cv_header_pcre_h" = xyes; then :
@@ -3450,6 +3462,10 @@
 
 done
 
+fi
+
+done
+
 for ac_header in gnutls/gnutls.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "gnutls/gnutls.h" "ac_cv_header_gnutls_gnutls_h" "$ac_includes_default"
@@ -4458,7 +4474,51 @@
 
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre2_compile_8 in -lpcre2-8" >&5
+$as_echo_n "checking for pcre2_compile_8 in -lpcre2-8... " >&6; }
+if ${ac_cv_lib_pcre2_8_pcre2_compile_8+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lpcre2-8  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pcre2_compile_8 ();
+int
+main ()
+{
+return pcre2_compile_8 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_pcre2_8_pcre2_compile_8=yes
+else
+  ac_cv_lib_pcre2_8_pcre2_compile_8=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pcre2_8_pcre2_compile_8" >&5
+$as_echo "$ac_cv_lib_pcre2_8_pcre2_compile_8" >&6; }
+if test "x$ac_cv_lib_pcre2_8_pcre2_compile_8" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPCRE2_8 1
+_ACEOF
+
+  LIBS="-lpcre2-8 $LIBS"
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pcre_compile in -lpcre" >&5
 $as_echo_n "checking for pcre_compile in -lpcre... " >&6; }
 if ${ac_cv_lib_pcre_pcre_compile+:} false; then :
   $as_echo_n "(cached) " >&6
@@ -4505,6 +4565,8 @@
   as_fn_error $? "pcre runtime library not working, is it AND the corresponding development (header) file installed" "$LINENO" 5
 fi
 
+fi
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gnutls_init in -lgnutls" >&5
 $as_echo_n "checking for gnutls_init in -lgnutls... " >&6; }
 if ${ac_cv_lib_gnutls_gnutls_init+:} false; then :
--- a/src/tintin.h
+++ b/src/tintin.h
@@ -31,7 +31,6 @@
 #include <zlib.h>
 #include <ctype.h>
 #include <termios.h>
-#include <pcre.h>
 #include <errno.h>
 #include <math.h>
 #include <stdarg.h>
@@ -105,6 +104,12 @@
 	#define SO_PEERCRED 17
 #endif
 
+#ifdef HAVE_PCRE2_H
+#include <pcre2.h>
+#else
+#include <pcre.h>
+#endif
+
 #ifndef __TINTIN_H__
 #define __TINTIN_H__
 
@@ -1053,7 +1058,11 @@
 	unsigned int            shots;
 	union
 	{
+#ifdef HAVE_PCRE2_H
+ 		pcre2_code        * regex;      // act, alias, gag, highlight, substitute
+#else
 		pcre              * regex;      // act, alias, gag, highlight, substitute
+#endif
 		char              * data;       // class
 		struct room_data  * room;       // terrain
 		long long           val64;      // delay, tick, path
@@ -1502,14 +1511,22 @@
 	int                     max;
 	unsigned short          stamp;
 	char                  * arg;
-	pcre                  * name;
 	int                     exit_size;
 	long long               exit_dirs;
 	char                  * exit_list;
+#ifdef HAVE_PCRE2_H
+	pcre2_code            * name;
+	pcre2_code            * desc;
+	pcre2_code            * area;
+	pcre2_code            * note;
+	pcre2_code            * terrain;
+#else
+	pcre                  * name;
 	pcre                  * desc;
 	pcre                  * area;
 	pcre                  * note;
 	pcre                  * terrain;
+#endif
 	long long               flag;
 	long long               galf;
 	char                  * id;
@@ -2916,12 +2933,19 @@
 extern int substitute(struct session *ses, char *string, char *result, int flags);
 extern int match(struct session *ses, char *str, char *exp, int flags);
 extern int find(struct session *ses, char *str, char *exp, int sub, int flag);
-extern int regexp_compare(struct session *ses, pcre *regex, char *str, char *exp, int option, int flag);
 extern int check_one_regexp(struct session *ses, struct listnode *node, char *line, char *original, int option);
 extern int tintin_regexp_check(struct session *ses, char *exp);
+#ifdef HAVE_PCRE2_H
+extern int regexp_compare(struct session *ses, pcre2_code *regex, char *str, char *exp, int option, int flag);
+extern int tintin_regexp(struct session *ses, pcre2_code *pcre, char *str, char *exp, int option, int flag);
+extern pcre2_code *regexp_compile(struct session *ses, char *exp, int option);
+extern pcre2_code *tintin_regexp_compile(struct session *ses, struct listnode *node, char *exp, int option);
+#else
+extern int regexp_compare(struct session *ses, pcre *regex, char *str, char *exp, int option, int flag);
 extern int tintin_regexp(struct session *ses, pcre *pcre, char *str, char *exp, int option, int flag);
 extern pcre *regexp_compile(struct session *ses, char *exp, int option);
 extern pcre *tintin_regexp_compile(struct session *ses, struct listnode *node, char *exp, int option);
+#endif
 extern void  tintin_macro_compile(char *input, char *output);
 
 #endif
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -82,6 +82,9 @@
 /* Define to 1 if you have the <param.h> header file. */
 #undef HAVE_PARAM_H
 
+/* Define to 1 if you have the <pcre2.h> header file. */
+#undef HAVE_PCRE2_H
+
 /* Define to 1 if you have the `popen' function. */
 #undef HAVE_POPEN
 
@@ -229,6 +232,9 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
+/* Define pcre2 unit size */
+#undef PCRE2_CODE_UNIT_WIDTH
+
 /* Define as the return type of signal handlers (`int' or `void'). */
 #undef RETSIGTYPE
 
--- a/src/trigger.c
+++ b/src/trigger.c
@@ -164,7 +164,11 @@
 	{
 		node = root->list[root->update];
 
+#ifdef HAVE_PCRE2_H
+		if (check_one_regexp(ses, node, line, line, PCRE2_ANCHORED))
+#else
 		if (check_one_regexp(ses, node, line, line, PCRE_ANCHORED))
+#endif
 		{
 			i = strlen(node->arg1);
 
--- a/src/mapper.c
+++ b/src/mapper.c
@@ -3725,7 +3725,11 @@
 	{
 		strcat(buf, "$");
 
+#ifdef HAVE_PCRE2_H
+		ses->map->search->name = tintin_regexp_compile(ses, NULL, buf, PCRE2_ANCHORED);
+#else
 		ses->map->search->name = tintin_regexp_compile(ses, NULL, buf, PCRE_ANCHORED);
+#endif
 	}
 	else
 	{
@@ -3809,7 +3813,11 @@
 	{
 		strcat(buf, "$");
 
+#ifdef HAVE_PCRE2_H
+		ses->map->search->desc = tintin_regexp_compile(ses, NULL, buf, PCRE2_ANCHORED|PCRE2_DOLLAR_ENDONLY|PCRE2_DOTALL);
+#else
 		ses->map->search->desc = tintin_regexp_compile(ses, NULL, buf, PCRE_ANCHORED|PCRE_DOLLAR_ENDONLY|PCRE_DOTALL);
+#endif
 	}
 	else
 	{
@@ -3829,7 +3837,11 @@
 	{
 		strcat(buf, "$");
 
+#ifdef HAVE_PCRE2_H
+		ses->map->search->area = tintin_regexp_compile(ses, NULL, buf, PCRE2_ANCHORED);
+#else
 		ses->map->search->area = tintin_regexp_compile(ses, NULL, buf, PCRE_ANCHORED);
+#endif
 	}
 	else
 	{
@@ -3849,7 +3861,11 @@
 	{
 		strcat(buf, "$");
 
+#ifdef HAVE_PCRE2_H
+		ses->map->search->note = tintin_regexp_compile(ses, NULL, buf, PCRE2_ANCHORED);
+#else
 		ses->map->search->note = tintin_regexp_compile(ses, NULL, buf, PCRE_ANCHORED);
+#endif
 	}
 	else
 	{
@@ -3869,7 +3885,11 @@
 	{
 		strcat(buf, "$");
 
+#ifdef HAVE_PCRE2_H
+		ses->map->search->terrain = tintin_regexp_compile(ses, NULL, buf, PCRE2_ANCHORED);
+#else
 		ses->map->search->terrain = tintin_regexp_compile(ses, NULL, buf, PCRE_ANCHORED);
+#endif
 	}
 	else
 	{
--- a/src/data.c
+++ b/src/data.c
@@ -92,7 +92,11 @@
 			switch (type)
 			{
 				case LIST_ALIAS:
+#ifdef HAVE_PCRE2_H
+					node->regex = tintin_regexp_compile(ses, node, node->arg1, PCRE2_ANCHORED);
+#else
 					node->regex = tintin_regexp_compile(ses, node, node->arg1, PCRE_ANCHORED);
+#endif
 					break;
 
 				case LIST_ACTION:
@@ -176,7 +180,11 @@
 	switch (root->type)
 	{
 		case LIST_ALIAS:
+#ifdef HAVE_PCRE2_H
+			node->regex = tintin_regexp_compile(root->ses, node, node->arg1, PCRE2_ANCHORED);
+#else
 			node->regex = tintin_regexp_compile(root->ses, node, node->arg1, PCRE_ANCHORED);
+#endif
 			break;
 
 		case LIST_ACTION:
@@ -361,7 +369,11 @@
 	{
 		if (node->regex)
 		{
+#ifdef HAVE_PCRE2_H
+			pcre2_code_free(node->regex);
+#else
 			free(node->regex);
+#endif
 		}
 	}
 
--- a/src/regex.c
+++ b/src/regex.c
@@ -24,7 +24,6 @@
 ******************************************************************************/
 
 #include <sys/types.h>
-#include <pcre.h>
 
 #include "tintin.h"
 
@@ -90,10 +89,21 @@
 	return ses;
 }
 
+#ifdef HAVE_PCRE2_H
+int regexp_compare(struct session *ses, pcre2_code *nodepcre, char *str, char *exp, int option, int flag)
+#else
 int regexp_compare(struct session *ses, pcre *nodepcre, char *str, char *exp, int option, int flag)
+#endif
 {
+#ifdef HAVE_PCRE2_H
+	pcre2_code *regex;
+	pcre2_match_data *matchdata;
+	PCRE2_SIZE *match = NULL;
+#else
 	pcre *regex;
-	int i, j, matches, match[303];
+	int match[303];
+#endif
+	int i, j, matches;
 
 	if (nodepcre == NULL)
 	{
@@ -109,6 +119,30 @@
 		return FALSE;
 	}
 
+#ifdef HAVE_PCRE2_H
+	matchdata = pcre2_match_data_create_from_pattern(regex, NULL);
+	if (matchdata == NULL)
+	{
+		if (nodepcre == NULL)
+		{
+			pcre2_code_free(regex);
+		}
+		return FALSE;
+	}
+
+	matches = pcre2_match(regex, (PCRE2_SPTR)str, strlen(str), 0, 0, matchdata, NULL);
+	match = pcre2_get_ovector_pointer(matchdata); // freeing matchdata frees match too
+
+	if ((matches <= 0) || (match == NULL))
+	{
+        pcre2_match_data_free(matchdata);
+		if (nodepcre == NULL)
+		{
+			pcre2_code_free(regex);
+		}
+		return FALSE;
+	}
+#else
 	matches = pcre_exec(regex, NULL, str, strlen(str), 0, 0, match, 303);
 
 	if (matches <= 0)
@@ -119,6 +153,7 @@
 		}
 		return FALSE;
 	}
+#endif
 
 	// REGEX_FLAG_FIX handles %1 to %99 usage. Backward compatibility.
 
@@ -181,14 +216,36 @@
 			break;
 	}
 
+#ifdef HAVE_PCRE2_H
+    pcre2_match_data_free(matchdata);
+	if (nodepcre == NULL)
+	{
+		pcre2_code_free(regex);
+	}
+#else
 	if (nodepcre == NULL)
 	{
 		free(regex);
 	}
+#endif
 
 	return TRUE;
 }
 
+#ifdef HAVE_PCRE2_H
+pcre2_code *regexp_compile(struct session *ses, char *exp, int option)
+{
+	int error;
+	size_t i;
+/*
+	if (HAS_BIT(ses->charset, CHARSET_FLAG_UTF8))
+	{
+		option |= PCRE2_UTF8|PCRE2_NO_UTF8_CHECK;
+	}
+*/
+	return pcre2_compile((PCRE2_SPTR)exp, PCRE2_ZERO_TERMINATED, option, &error, &i, NULL);
+}
+#else
 pcre *regexp_compile(struct session *ses, char *exp, int option)
 {
 	const char *error;
@@ -201,6 +258,7 @@
 */
 	return pcre_compile(exp, option, &error, &i, NULL);
 }
+#endif
 
 
 
@@ -455,7 +513,11 @@
 	return FALSE;
 }
 
+#ifdef HAVE_PCRE2_H
+int tintin_regexp(struct session *ses, pcre2_code *nodepcre, char *str, char *exp, int option, int flag)
+#else
 int tintin_regexp(struct session *ses, pcre *nodepcre, char *str, char *exp, int option, int flag)
+#endif
 {
 	char out[BUFFER_SIZE], *pti, *pto;
 	int arg = 1, var = 1, fix = 0;
@@ -816,7 +878,11 @@
 	return regexp_compare(ses, nodepcre, str, out, option, flag + fix);
 }
 
+#ifdef HAVE_PCRE2_H
+pcre2_code *tintin_regexp_compile(struct session *ses, struct listnode *node, char *exp, int option)
+#else
 pcre *tintin_regexp_compile(struct session *ses, struct listnode *node, char *exp, int option)
+#endif
 {
 	char out[BUFFER_SIZE], *pti, *pto;
 
