Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit faf5e4d

Browse files
committed
Patch 659834 by Magnus Lie Hetland:
Check for readline 2.2 features. This should make it possible to compile readline.c again with GNU readline versions 2.0 or 2.1; this ability was removed in readline.c rev. 2.49. Apparently the older versions are still in widespread deployment on older Solaris installations. With an older readline, completion behavior is subtly different (a space is always added).
1 parent 1fb22bb commit faf5e4d

4 files changed

Lines changed: 71 additions & 3 deletions

File tree

Modules/readline.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,9 @@ setup_readline(void)
574574
rl_completer_word_break_characters =
575575
strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?");
576576
/* All nonalphanums except '.' */
577+
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
577578
rl_completion_append_character ='\0';
579+
#endif
578580

579581
begidx = PyInt_FromLong(0L);
580582
endidx = PyInt_FromLong(0L);
@@ -626,7 +628,9 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
626628
if (sys_stdin != rl_instream || sys_stdout != rl_outstream) {
627629
rl_instream = sys_stdin;
628630
rl_outstream = sys_stdout;
631+
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
629632
rl_prep_terminal (1);
633+
#endif
630634
}
631635

632636
p = readline(prompt);

configure

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# From configure.in Revision: 1.378 .
2+
# From configure.in Revision: 1.380 .
33
# Guess values for system-dependent variables and create Makefiles.
44
# Generated by GNU Autoconf 2.53 for python 2.3.
55
#
@@ -908,7 +908,7 @@ esac
908908
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
909909
# absolute.
910910
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
911-
ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
911+
ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd`
912912
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
913913
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
914914
@@ -16228,6 +16228,56 @@ _ACEOF
1622816228
1622916229
fi
1623016230
16231+
# check for readline 2.2
16232+
cat >conftest.$ac_ext <<_ACEOF
16233+
#line $LINENO "configure"
16234+
#include "confdefs.h"
16235+
#include <readline/readline.h>
16236+
_ACEOF
16237+
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
16238+
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
16239+
ac_status=$?
16240+
egrep -v '^ *\+' conftest.er1 >conftest.err
16241+
rm -f conftest.er1
16242+
cat conftest.err >&5
16243+
echo "$as_me:$LINENO: \$? = $ac_status" >&5
16244+
(exit $ac_status); } >/dev/null; then
16245+
if test -s conftest.err; then
16246+
ac_cpp_err=$ac_c_preproc_warn_flag
16247+
else
16248+
ac_cpp_err=
16249+
fi
16250+
else
16251+
ac_cpp_err=yes
16252+
fi
16253+
if test -z "$ac_cpp_err"; then
16254+
have_readline=yes
16255+
else
16256+
echo "$as_me: failed program was:" >&5
16257+
cat conftest.$ac_ext >&5
16258+
have_readline=no
16259+
fi
16260+
rm -f conftest.err conftest.$ac_ext
16261+
if test $have_readline = yes
16262+
then
16263+
cat >conftest.$ac_ext <<_ACEOF
16264+
#line $LINENO "configure"
16265+
#include "confdefs.h"
16266+
#include <readline/readline.h>
16267+
16268+
_ACEOF
16269+
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
16270+
egrep "extern int rl_completion_append_character;" >/dev/null 2>&1; then
16271+
16272+
cat >>confdefs.h <<\_ACEOF
16273+
#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1
16274+
_ACEOF
16275+
16276+
fi
16277+
rm -f conftest*
16278+
16279+
fi
16280+
1623116281
# check for readline 4.0
1623216282
echo "$as_me:$LINENO: checking for rl_pre_input_hook in -lreadline" >&5
1623316283
echo $ECHO_N "checking for rl_pre_input_hook in -lreadline... $ECHO_C" >&6
@@ -17418,7 +17468,7 @@ esac
1741817468
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
1741917469
# absolute.
1742017470
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
17421-
ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
17471+
ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd`
1742217472
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
1742317473
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
1742417474

configure.in

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2381,6 +2381,17 @@ then
23812381
[Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
23822382
fi
23832383

2384+
# check for readline 2.2
2385+
AC_TRY_CPP([#include <readline/readline.h>],
2386+
have_readline=yes, have_readline=no)
2387+
if test $have_readline = yes
2388+
then
2389+
AC_EGREP_HEADER([extern int rl_completion_append_character;],
2390+
[readline/readline.h],
2391+
AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
2392+
[Define if you have readline 2.2]), )
2393+
fi
2394+
23842395
# check for readline 4.0
23852396
AC_CHECK_LIB(readline, rl_pre_input_hook,
23862397
AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@
333333
/* Define to 1 if you have the `readlink' function. */
334334
#undef HAVE_READLINK
335335

336+
/* Define if you have readline 2.2 */
337+
#undef HAVE_RL_COMPLETION_APPEND_CHARACTER
338+
336339
/* Define if you have readline 4.2 */
337340
#undef HAVE_RL_COMPLETION_MATCHES
338341

0 commit comments

Comments
 (0)