Skip to content

Commit

Permalink
Patch 659834 by Magnus Lie Hetland:
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
gvanrossum committed Dec 30, 2002
1 parent 1fb22bb commit faf5e4d
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
4 changes: 4 additions & 0 deletions Modules/readline.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,9 @@ setup_readline(void)
rl_completer_word_break_characters =
strdup(" \t\n`~!@#$%^&*()-=+[{]}\\|;:'\",<>/?");
/* All nonalphanums except '.' */
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
rl_completion_append_character ='\0';
#endif

begidx = PyInt_FromLong(0L);
endidx = PyInt_FromLong(0L);
Expand Down Expand Up @@ -626,7 +628,9 @@ call_readline(FILE *sys_stdin, FILE *sys_stdout, char *prompt)
if (sys_stdin != rl_instream || sys_stdout != rl_outstream) {
rl_instream = sys_stdin;
rl_outstream = sys_stdout;
#ifdef HAVE_RL_COMPLETION_APPEND_CHARACTER
rl_prep_terminal (1);
#endif
}

p = readline(prompt);
Expand Down
56 changes: 53 additions & 3 deletions configure
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /bin/sh
# From configure.in Revision: 1.378 .
# From configure.in Revision: 1.380 .
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.53 for python 2.3.
#
Expand Down Expand Up @@ -908,7 +908,7 @@ esac
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
# absolute.
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd`
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
Expand Down Expand Up @@ -16228,6 +16228,56 @@ _ACEOF
fi
# check for readline 2.2
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <readline/readline.h>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
egrep -v '^ *\+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
have_readline=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
have_readline=no
fi
rm -f conftest.err conftest.$ac_ext
if test $have_readline = yes
then
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <readline/readline.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
egrep "extern int rl_completion_append_character;" >/dev/null 2>&1; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_RL_COMPLETION_APPEND_CHARACTER 1
_ACEOF
fi
rm -f conftest*
fi
# check for readline 4.0
echo "$as_me:$LINENO: checking for rl_pre_input_hook in -lreadline" >&5
echo $ECHO_N "checking for rl_pre_input_hook in -lreadline... $ECHO_C" >&6
Expand Down Expand Up @@ -17418,7 +17468,7 @@ esac
# Don't blindly perform a `cd "$ac_dir"/$ac_foo && pwd` since $ac_foo can be
# absolute.
ac_abs_builddir=`cd "$ac_dir" && cd $ac_builddir && pwd`
ac_abs_top_builddir=`cd "$ac_dir" && cd ${ac_top_builddir}. && pwd`
ac_abs_top_builddir=`cd "$ac_dir" && cd $ac_top_builddir && pwd`
ac_abs_srcdir=`cd "$ac_dir" && cd $ac_srcdir && pwd`
ac_abs_top_srcdir=`cd "$ac_dir" && cd $ac_top_srcdir && pwd`
Expand Down
11 changes: 11 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -2381,6 +2381,17 @@ then
[Define this if you have flockfile(), getc_unlocked(), and funlockfile()])
fi

# check for readline 2.2
AC_TRY_CPP([#include <readline/readline.h>],
have_readline=yes, have_readline=no)
if test $have_readline = yes
then
AC_EGREP_HEADER([extern int rl_completion_append_character;],
[readline/readline.h],
AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER, 1,
[Define if you have readline 2.2]), )
fi

# check for readline 4.0
AC_CHECK_LIB(readline, rl_pre_input_hook,
AC_DEFINE(HAVE_RL_PRE_INPUT_HOOK, 1,
Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,9 @@
/* Define to 1 if you have the `readlink' function. */
#undef HAVE_READLINK

/* Define if you have readline 2.2 */
#undef HAVE_RL_COMPLETION_APPEND_CHARACTER

/* Define if you have readline 4.2 */
#undef HAVE_RL_COMPLETION_MATCHES

Expand Down

0 comments on commit faf5e4d

Please sign in to comment.