From: Jakub Kulik <kulikjak@gmail.com>
Date: Thu, 26 Jun 2025 10:39:32 +0000 (+0200)
Subject: Fix detection and use of pcre2.h from a subdirectory
X-Git-Url: http://www.privoxy.org/gitweb/%22https:/developer-manual/man-page/@default-cgi@/user-manual/faq/static/gitweb.js?a=commitdiff_plain;p=privoxy.git

Fix detection and use of pcre2.h from a subdirectory

SF bug #946.
---

diff --git a/configure.in b/configure.in
index 094ccaa6..a363a601 100644
--- a/configure.in
+++ b/configure.in
@@ -887,8 +887,8 @@ AC_CHECK_LIB(pcre2-8, pcre2_compile_8, [
       AC_EGREP_HEADER(pcre2_pattern_info, pcre2.h,[have_pcre2=yes; AC_DEFINE(HAVE_PCRE2)], [AC_MSG_WARN([[pcre2 old version installed]]); have_pcre2=no])
    ], [
       AC_CHECK_HEADER(pcre2/pcre2.h, [
-         AC_EGREP_HEADER(pcre2_pattern_info, pcre2/pcre2.h, [have_pcre2=yes; AC_DEFINE(PCRE2_H_IN_SUBDIR)], [AC_MSG_WARN([[pcre2 old version installed]]); have_pcre2=no])
-      ], [have_pcre2=no])
+         AC_EGREP_HEADER(pcre2_pattern_info, pcre2/pcre2.h, [have_pcre2=yes; AC_DEFINE(HAVE_PCRE2) AC_DEFINE(PCRE2_H_IN_SUBDIR)], [AC_MSG_WARN([[pcre2 old version installed]]); have_pcre2=no])
+      ], [have_pcre2=no], [#define PCRE2_CODE_UNIT_WIDTH 8])
    ], [#define PCRE2_CODE_UNIT_WIDTH 8])
 ], [have_pcre2=no])
 
diff --git a/pcrs.h b/pcrs.h
index 8e2fb968..507d6970 100644
--- a/pcrs.h
+++ b/pcrs.h
@@ -36,7 +36,11 @@
 #define PCRE2_CODE_UNIT_WIDTH 8
 #define PCREn(x) PCRE2_ ## x
 #ifndef _PCRE2_H
-#include <pcre2.h>
+#  ifdef PCRE2_H_IN_SUBDIR
+#    include <pcre2/pcre2.h>
+#  else
+#    include <pcre2.h>
+#  endif
 #endif
 
 /*