From a1093f660d14866deabbd178ad31a9b24bde74a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= Date: Thu, 7 Apr 2022 17:17:27 -0700 Subject: [PATCH] pcre2test: use the right header for libedit in FreeBSD with autoconf When `./configure --enable-pcre2test-libedit` is used in FreeBSD, the resulting test will succeed but won't set the necessary flag to distinguish between libedit and readline header files, therefore using readline's at built time (if installed) Consolidate all header tests into one and use instead the corresponding autogenerated defines to check for each possibility. --- configure.ac | 11 +++++------ src/pcre2test.c | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index caa4093..b123292 100644 --- a/configure.ac +++ b/configure.ac @@ -597,14 +597,14 @@ if test "$enable_pcre2test_libreadline" = "yes"; then fi fi - # Check for the availability of libedit. Different distributions put its # headers in different places. Try to cover the most common ones. if test "$enable_pcre2test_libedit" = "yes"; then - AC_CHECK_HEADERS([editline/readline.h], [HAVE_EDITLINE_READLINE_H=1], - [AC_CHECK_HEADERS([edit/readline/readline.h], [HAVE_READLINE_READLINE_H=1], - [AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_READLINE_H=1])])]) + AC_CHECK_HEADERS([editline/readline.h edit/readline/readline.h readline/readline.h], [ + HAVE_LIBEDIT_HEADER=1 + break + ]) AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"]) fi @@ -940,8 +940,7 @@ if test "$enable_pcre2test_libedit" = "yes"; then echo "** Cannot use both --enable-pcre2test-libedit and --enable-pcre2test-readline" exit 1 fi - if test "$HAVE_EDITLINE_READLINE_H" != "1" -a \ - "$HAVE_READLINE_READLINE_H" != "1"; then + if test -z "$HAVE_LIBEDIT_HEADER"; then echo "** Cannot --enable-pcre2test-libedit because neither editline/readline.h" echo "** nor readline/readline.h was found." exit 1 diff --git a/src/pcre2test.c b/src/pcre2test.c index 8e712c3..43cacdf 100644 --- a/src/pcre2test.c +++ b/src/pcre2test.c @@ -94,6 +94,8 @@ that first, falling back to readline/readline.h. */ #else #if defined(HAVE_EDITLINE_READLINE_H) #include +#elif defined(HAVE_EDIT_READLINE_READLINE_H) +#include #else #include #endif