mirror of https://github.com/python/cpython
only support append_history if readline has it
This commit is contained in:
parent
810aa6db34
commit
d1e22ba7db
|
@ -43,6 +43,8 @@ class TestHistoryManipulation (unittest.TestCase):
|
||||||
|
|
||||||
self.assertEqual(readline.get_current_history_length(), 1)
|
self.assertEqual(readline.get_current_history_length(), 1)
|
||||||
|
|
||||||
|
@unittest.skipUnless(hasattr(readline, "append_history"),
|
||||||
|
"append_history not available")
|
||||||
def test_write_read_append(self):
|
def test_write_read_append(self):
|
||||||
hfile = tempfile.NamedTemporaryFile(delete=False)
|
hfile = tempfile.NamedTemporaryFile(delete=False)
|
||||||
hfile.close()
|
hfile.close()
|
||||||
|
|
|
@ -237,6 +237,7 @@ Save a readline history file.\n\
|
||||||
The default filename is ~/.history.");
|
The default filename is ~/.history.");
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef HAVE_RL_APPEND_HISTORY
|
||||||
/* Exported function to save part of a readline history file */
|
/* Exported function to save part of a readline history file */
|
||||||
|
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
@ -270,6 +271,7 @@ PyDoc_STRVAR(doc_append_history_file,
|
||||||
"append_history_file(nelements[, filename]) -> None\n\
|
"append_history_file(nelements[, filename]) -> None\n\
|
||||||
Append the last nelements of the history list to file.\n\
|
Append the last nelements of the history list to file.\n\
|
||||||
The default filename is ~/.history.");
|
The default filename is ~/.history.");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Set history length */
|
/* Set history length */
|
||||||
|
@ -782,7 +784,9 @@ static struct PyMethodDef readline_methods[] =
|
||||||
METH_VARARGS, doc_read_history_file},
|
METH_VARARGS, doc_read_history_file},
|
||||||
{"write_history_file", write_history_file,
|
{"write_history_file", write_history_file,
|
||||||
METH_VARARGS, doc_write_history_file},
|
METH_VARARGS, doc_write_history_file},
|
||||||
|
#ifdef HAVE_RL_APPEND_HISTORY
|
||||||
{"append_history_file", append_history_file,
|
{"append_history_file", append_history_file,
|
||||||
|
#endif
|
||||||
METH_VARARGS, doc_append_history_file},
|
METH_VARARGS, doc_append_history_file},
|
||||||
{"get_history_item", get_history_item,
|
{"get_history_item", get_history_item,
|
||||||
METH_VARARGS, doc_get_history_item},
|
METH_VARARGS, doc_get_history_item},
|
||||||
|
|
|
@ -14529,6 +14529,49 @@ rm -f conftest*
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for append_history in -lreadline" >&5
|
||||||
|
$as_echo_n "checking for append_history in -lreadline... " >&6; }
|
||||||
|
if ${ac_cv_lib_readline_append_history+:} false; then :
|
||||||
|
$as_echo_n "(cached) " >&6
|
||||||
|
else
|
||||||
|
ac_check_lib_save_LIBS=$LIBS
|
||||||
|
LIBS="-lreadline $READLINE_LIBS $LIBS"
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
/* Override any GCC internal prototype to avoid an error.
|
||||||
|
Use char because int might match the return type of a GCC
|
||||||
|
builtin and then its argument prototype would still apply. */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
#endif
|
||||||
|
char append_history ();
|
||||||
|
int
|
||||||
|
main ()
|
||||||
|
{
|
||||||
|
return append_history ();
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_link "$LINENO"; then :
|
||||||
|
ac_cv_lib_readline_append_history=yes
|
||||||
|
else
|
||||||
|
ac_cv_lib_readline_append_history=no
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext \
|
||||||
|
conftest$ac_exeext conftest.$ac_ext
|
||||||
|
LIBS=$ac_check_lib_save_LIBS
|
||||||
|
fi
|
||||||
|
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_append_history" >&5
|
||||||
|
$as_echo "$ac_cv_lib_readline_append_history" >&6; }
|
||||||
|
if test "x$ac_cv_lib_readline_append_history" = xyes; then :
|
||||||
|
|
||||||
|
$as_echo "#define HAVE_RL_APPEND_HISTORY 1" >>confdefs.h
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
# End of readline checks: restore LIBS
|
# End of readline checks: restore LIBS
|
||||||
LIBS=$LIBS_no_readline
|
LIBS=$LIBS_no_readline
|
||||||
|
|
||||||
|
|
|
@ -4308,6 +4308,10 @@ then
|
||||||
[Define if you can turn off readline's signal handling.]), )
|
[Define if you can turn off readline's signal handling.]), )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AC_CHECK_LIB(readline, append_history,
|
||||||
|
AC_DEFINE(HAVE_RL_APPEND_HISTORY, 1,
|
||||||
|
[Define if readline supports append_history]), ,$READLINE_LIBS)
|
||||||
|
|
||||||
# End of readline checks: restore LIBS
|
# End of readline checks: restore LIBS
|
||||||
LIBS=$LIBS_no_readline
|
LIBS=$LIBS_no_readline
|
||||||
|
|
||||||
|
|
|
@ -690,6 +690,9 @@
|
||||||
/* Define to 1 if you have the `renameat' function. */
|
/* Define to 1 if you have the `renameat' function. */
|
||||||
#undef HAVE_RENAMEAT
|
#undef HAVE_RENAMEAT
|
||||||
|
|
||||||
|
/* Define if readline supports append_history */
|
||||||
|
#undef HAVE_RL_APPEND_HISTORY
|
||||||
|
|
||||||
/* Define if you have readline 2.1 */
|
/* Define if you have readline 2.1 */
|
||||||
#undef HAVE_RL_CALLBACK
|
#undef HAVE_RL_CALLBACK
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue