Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-117845: Detect libedit hook function signature in configure #117870

Merged
merged 7 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix building against recent libedit versions by detecting readline hook signatures in :program:`configure`.
4 changes: 2 additions & 2 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1041,7 +1041,7 @@ on_hook(PyObject *func)
}

static int
#if defined(_RL_FUNCTION_TYPEDEF)
#if defined(_RL_FUNCTION_TYPEDEF) || !defined(Py_RL_STARTUP_HOOK_TAKES_ARGS)
on_startup_hook(void)
#else
on_startup_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
Expand All @@ -1061,7 +1061,7 @@ on_startup_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))

#ifdef HAVE_RL_PRE_INPUT_HOOK
static int
#if defined(_RL_FUNCTION_TYPEDEF)
#if defined(_RL_FUNCTION_TYPEDEF) || !defined(Py_RL_STARTUP_HOOK_TAKES_ARGS)
on_pre_input_hook(void)
#else
on_pre_input_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
Expand Down
50 changes: 50 additions & 0 deletions configure

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -6340,6 +6340,21 @@ AS_VAR_IF([with_readline], [no], [
# in readline as well as newer editline (April 2023)
AC_CHECK_TYPES([rl_compdisp_func_t], [], [], [readline_includes])

# Some editline versions declare rl_startup_hook as taking no args, others
# declare it as taking 2.
AC_CACHE_CHECK([if rl_startup_hook takes arguments], [ac_cv_readline_rl_startup_hook_takes_args], [
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([readline_includes]
[extern int test_hook_func(const char *text, int state);],
[rl_startup_hook=test_hook_func;])],
[ac_cv_readline_rl_startup_hook_takes_args=yes],
[ac_cv_readline_rl_startup_hook_takes_args=no]
)
])
AS_VAR_IF([ac_cv_readline_rl_startup_hook_takes_args], [yes], [
AC_DEFINE([Py_RL_STARTUP_HOOK_TAKES_ARGS], [1], [Define if rl_startup_hook takes arguments])
sobolevn marked this conversation as resolved.
Show resolved Hide resolved
])

m4_undefine([readline_includes])
])dnl WITH_SAVE_ENV()
])
Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -1659,6 +1659,9 @@
SipHash13: 3, externally defined: 0 */
#undef Py_HASH_ALGORITHM

/* Define if rl_startup_hook takes arguments */
#undef Py_RL_STARTUP_HOOK_TAKES_ARGS

/* Define if you want to enable internal statistics gathering. */
#undef Py_STATS

Expand Down
Loading