From 31b6aa76491e85b569119d0778809afe18c3384e Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Mon, 9 Oct 2023 14:21:20 +0100 Subject: [PATCH] [3.11] gh-109191: Fix build with newer editline (gh-110239). (cherry picked from commit f4cb0d27cc08f490c42a22e646eb73cc7072d54a) Co-authored-by: Bo Anderson --- ...23-10-05-11-46-20.gh-issue-109191.imUkVN.rst | 1 + Modules/readline.c | 2 +- configure | 17 +++++++++++++++++ configure.ac | 14 ++++++++++++++ pyconfig.h.in | 3 +++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Build/2023-10-05-11-46-20.gh-issue-109191.imUkVN.rst diff --git a/Misc/NEWS.d/next/Build/2023-10-05-11-46-20.gh-issue-109191.imUkVN.rst b/Misc/NEWS.d/next/Build/2023-10-05-11-46-20.gh-issue-109191.imUkVN.rst new file mode 100644 index 00000000000000..27e5df790bc0c6 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2023-10-05-11-46-20.gh-issue-109191.imUkVN.rst @@ -0,0 +1 @@ +Fix compile error when building with recent versions of libedit. diff --git a/Modules/readline.c b/Modules/readline.c index 27b89de7279464..8c7f526d418f82 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -440,7 +440,7 @@ readline_set_completion_display_matches_hook_impl(PyObject *module, default completion display. */ rl_completion_display_matches_hook = readlinestate_global->completion_display_matches_hook ? -#if defined(_RL_FUNCTION_TYPEDEF) +#if defined(HAVE_RL_COMPDISP_FUNC_T) (rl_compdisp_func_t *)on_completion_display_matches_hook : 0; #else (VFunction *)on_completion_display_matches_hook : 0; diff --git a/configure b/configure index af4a5bbfdfa1a4..b294f93a5564b4 100755 --- a/configure +++ b/configure @@ -21289,6 +21289,23 @@ if eval test \"x\$"$as_ac_Lib"\" = x"yes"; then : $as_echo "#define HAVE_RL_APPEND_HISTORY 1" >>confdefs.h +fi + + + # in readline as well as newer editline (April 2023) + ac_fn_c_check_type "$LINENO" "rl_compdisp_func_t" "ac_cv_type_rl_compdisp_func_t" " +#include /* Must be first for Gnu Readline */ +#ifdef WITH_EDITLINE +# include +#else +# include +#endif + +" +if test "x$ac_cv_type_rl_compdisp_func_t" = xyes; then : + +$as_echo "#define HAVE_RL_COMPDISP_FUNC_T 1" >>confdefs.h + fi fi diff --git a/configure.ac b/configure.ac index e1cbb7c7fbe9d9..629b7b76c3c315 100644 --- a/configure.ac +++ b/configure.ac @@ -5918,6 +5918,20 @@ if test "$py_cv_lib_readline" = yes; then AC_CHECK_LIB($LIBREADLINE, append_history, AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1, [Define if readline supports append_history]),,$READLINE_LIBS) + + # in readline as well as newer editline (April 2023) + AC_CHECK_TYPE([rl_compdisp_func_t], + [AC_DEFINE([HAVE_RL_COMPDISP_FUNC_T], [1], + [Define if readline supports rl_compdisp_func_t])], + [], + [ +#include /* Must be first for Gnu Readline */ +#ifdef WITH_EDITLINE +# include +#else +# include +#endif + ]) fi # End of readline checks: restore LIBS diff --git a/pyconfig.h.in b/pyconfig.h.in index 0536047f573ce6..94d02e14c444ac 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -968,6 +968,9 @@ /* Define if you can turn off readline's signal handling. */ #undef HAVE_RL_CATCH_SIGNAL +/* Define if readline supports rl_compdisp_func_t */ +#undef HAVE_RL_COMPDISP_FUNC_T + /* Define if you have readline 2.2 */ #undef HAVE_RL_COMPLETION_APPEND_CHARACTER