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.
This commit is contained in:
Carlo Marcelo Arenas Belón 2022-04-07 17:17:27 -07:00
parent f11c26842d
commit a1093f660d
2 changed files with 7 additions and 6 deletions

View File

@ -597,14 +597,14 @@ if test "$enable_pcre2test_libreadline" = "yes"; then
fi fi
fi fi
# Check for the availability of libedit. Different distributions put its # Check for the availability of libedit. Different distributions put its
# headers in different places. Try to cover the most common ones. # headers in different places. Try to cover the most common ones.
if test "$enable_pcre2test_libedit" = "yes"; then if test "$enable_pcre2test_libedit" = "yes"; then
AC_CHECK_HEADERS([editline/readline.h], [HAVE_EDITLINE_READLINE_H=1], AC_CHECK_HEADERS([editline/readline.h edit/readline/readline.h readline/readline.h], [
[AC_CHECK_HEADERS([edit/readline/readline.h], [HAVE_READLINE_READLINE_H=1], HAVE_LIBEDIT_HEADER=1
[AC_CHECK_HEADERS([readline/readline.h], [HAVE_READLINE_READLINE_H=1])])]) break
])
AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"]) AC_CHECK_LIB([edit], [readline], [LIBEDIT="-ledit"])
fi fi
@ -940,8 +940,7 @@ if test "$enable_pcre2test_libedit" = "yes"; then
echo "** Cannot use both --enable-pcre2test-libedit and --enable-pcre2test-readline" echo "** Cannot use both --enable-pcre2test-libedit and --enable-pcre2test-readline"
exit 1 exit 1
fi fi
if test "$HAVE_EDITLINE_READLINE_H" != "1" -a \ if test -z "$HAVE_LIBEDIT_HEADER"; then
"$HAVE_READLINE_READLINE_H" != "1"; then
echo "** Cannot --enable-pcre2test-libedit because neither editline/readline.h" echo "** Cannot --enable-pcre2test-libedit because neither editline/readline.h"
echo "** nor readline/readline.h was found." echo "** nor readline/readline.h was found."
exit 1 exit 1

View File

@ -94,6 +94,8 @@ that first, falling back to readline/readline.h. */
#else #else
#if defined(HAVE_EDITLINE_READLINE_H) #if defined(HAVE_EDITLINE_READLINE_H)
#include <editline/readline.h> #include <editline/readline.h>
#elif defined(HAVE_EDIT_READLINE_READLINE_H)
#include <edit/readline/readline.h>
#else #else
#include <readline/readline.h> #include <readline/readline.h>
#endif #endif