]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-105323: Update readline module to detect apple editline variant (gh-108665)
authorDonghee Na <donghee.na@python.org>
Fri, 29 Sep 2023 12:18:18 +0000 (21:18 +0900)
committerGitHub <noreply@github.com>
Fri, 29 Sep 2023 12:18:18 +0000 (21:18 +0900)
Doc/using/configure.rst
Modules/readline.c
configure
configure.ac
pyconfig.h.in

index 9403c19a695776ac9098f117b198a4f085ea5ac9..83b4c7aa0481e9a8faaa7da1d62217ff1694d7af 100644 (file)
@@ -758,11 +758,12 @@ Libraries options
 
    .. versionadded:: 3.3
 
-.. cmdoption:: --with-readline=editline
+.. cmdoption:: --with-readline=readline|editline
 
-   Use ``editline`` library for backend of the :mod:`readline` module.
+   Designate a backend library for the :mod:`readline` module.
 
-   Define the ``WITH_EDITLINE`` macro.
+   * readline: Use readline as the backend.
+   * editline: Use editline as the backend.
 
    .. versionadded:: 3.10
 
index aeae654162f13f49fb10d874c35dbf5355254cc3..4b473023c6e524dd702b63c95e26e1221395d4d2 100644 (file)
@@ -1018,6 +1018,8 @@ on_hook(PyObject *func)
 static int
 #if defined(_RL_FUNCTION_TYPEDEF)
 on_startup_hook(void)
+#elif defined(WITH_APPLE_EDITLINE)
+on_startup_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
 #else
 on_startup_hook(void)
 #endif
@@ -1033,6 +1035,8 @@ on_startup_hook(void)
 static int
 #if defined(_RL_FUNCTION_TYPEDEF)
 on_pre_input_hook(void)
+#elif defined(WITH_APPLE_EDITLINE)
+on_pre_input_hook(const char *Py_UNUSED(text), int Py_UNUSED(state))
 #else
 on_pre_input_hook(void)
 #endif
index 098def9aab08bf64393ea404c3ec4372158cb819..0e5f3f64c680b2064fb45c6297a5d27b658c9ab6 100755 (executable)
--- a/configure
+++ b/configure
@@ -23781,6 +23781,7 @@ fi
 
 
 
+
 # Check whether --with-readline was given.
 if test ${with_readline+y}
 then :
@@ -23803,6 +23804,22 @@ else $as_nop
 fi
 
 
+# gh-105323: Need to handle the macOS editline as an alias of readline.
+case $ac_sys_system/$ac_sys_release in #(
+  Darwin/*) :
+    ac_fn_c_check_type "$LINENO" "Function" "ac_cv_type_Function" "#include <readline/readline.h>
+"
+if test "x$ac_cv_type_Function" = xyes
+then :
+  printf "%s\n" "#define WITH_APPLE_EDITLINE 1" >>confdefs.h
+
+fi
+ ;; #(
+  *) :
+
+ ;;
+esac
+
 if test "x$with_readline" = xreadline
 then :
 
index 3e6cbc69c21009f565773e458c97d6eda7cdbba5..493868130414ee243a7d70677af7c52453795a06 100644 (file)
@@ -5832,6 +5832,7 @@ dnl library (tinfo ncursesw ncurses termcap). We now assume that libreadline
 dnl or readline.pc provide correct linker information.
 
 AH_TEMPLATE([WITH_EDITLINE], [Define to build the readline module against libedit.])
+AH_TEMPLATE([WITH_APPLE_EDITLINE], [Define to build the readline module against Apple BSD editline.])
 
 AC_ARG_WITH(
   [readline],
@@ -5848,6 +5849,15 @@ AC_ARG_WITH(
   [with_readline=readline]
 )
 
+# gh-105323: Need to handle the macOS editline as an alias of readline.
+AS_CASE([$ac_sys_system/$ac_sys_release],
+  [Darwin/*], [AC_CHECK_TYPE([Function],
+                             [AC_DEFINE([WITH_APPLE_EDITLINE])],
+                             [],
+                             [@%:@include <readline/readline.h>])],
+  []
+)
+
 AS_VAR_IF([with_readline], [readline], [
   PKG_CHECK_MODULES([LIBREADLINE], [readline], [
     LIBREADLINE=readline
index 86c72cc6b4e62a56c72208f9ded25eb894c2d22a..c2c75c96dcaad1821afa2130985c1a018fa4ab58 100644 (file)
 /* Define if WINDOW in curses.h offers a field _flags. */
 #undef WINDOW_HAS_FLAGS
 
+/* Define to build the readline module against Apple BSD editline. */
+#undef WITH_APPLE_EDITLINE
+
 /* Define if you want build the _decimal module using a coroutine-local rather
    than a thread-local context */
 #undef WITH_DECIMAL_CONTEXTVAR