Skip to content

Commit 353ae58

Browse files
committed
SF Patch #432457 by Jason Tishler: support for readline 4.2.
This patch allows the readline module to build cleanly with GNU readline 4.2 without breaking the build for earlier GNU readline versions. The configure script checks for the presence of rl_completion_matches in libreadline.
1 parent d854831 commit 353ae58

5 files changed

Lines changed: 70 additions & 11 deletions

File tree

Modules/readline.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
#include <readline/readline.h>
2222
#include <readline/history.h>
2323

24+
#ifdef HAVE_RL_COMPLETION_MATCHES
25+
#define completion_matches(x, y) rl_completion_matches((x), ((rl_compentry_func_t *)(y)))
26+
#endif
27+
2428
/* Pointers needed from outside (but not declared in a header file). */
2529
extern DL_IMPORT(int) (*PyOS_InputHook)(void);
2630
extern DL_IMPORT(char) *(*PyOS_ReadlineFunctionPointer)(char *);

acconfig.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@
8686
/* Define if you have GNU PTH threads */
8787
#undef HAVE_PTH
8888

89+
/* Define if you have readline 4.2 */
90+
#undef HAVE_RL_COMPLETION_MATCHES
91+
8992
/* Define if your compiler supports variable length function prototypes
9093
(e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h> */
9194
#undef HAVE_STDARG_PROTOTYPES

config.h.in

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@
148148
/* Define if you have GNU PTH threads */
149149
#undef HAVE_PTH
150150

151+
/* Define if you have readline 4.2 */
152+
#undef HAVE_RL_COMPLETION_MATCHES
153+
151154
/* Define if your compiler supports variable length function prototypes
152155
(e.g. void fprintf(FILE *, char *, ...);) *and* <stdarg.h> */
153156
#undef HAVE_STDARG_PROTOTYPES
@@ -296,9 +299,6 @@
296299
/* The number of bytes in a wchar_t. */
297300
#undef SIZEOF_WCHAR_T
298301

299-
/* Define if you have the _getpty function. */
300-
#undef HAVE__GETPTY
301-
302302
/* Define if you have the alarm function. */
303303
#undef HAVE_ALARM
304304

@@ -392,6 +392,9 @@
392392
/* Define if you have the getpid function. */
393393
#undef HAVE_GETPID
394394

395+
/* Define if you have the _getpty function. */
396+
#undef HAVE__GETPTY
397+
395398
/* Define if you have the getpwent function. */
396399
#undef HAVE_GETPWENT
397400

@@ -554,14 +557,14 @@
554557
/* Define if you have the waitpid function. */
555558
#undef HAVE_WAITPID
556559

557-
/* Define if you have the <db.h> header file. */
558-
#undef HAVE_DB_H
560+
/* Define if you have the <db_185.h> header file. */
561+
#undef HAVE_DB_185_H
559562

560563
/* Define if you have the <db1/ndbm.h> header file. */
561564
#undef HAVE_DB1_NDBM_H
562565

563-
/* Define if you have the <db_185.h> header file. */
564-
#undef HAVE_DB_185_H
566+
/* Define if you have the <db.h> header file. */
567+
#undef HAVE_DB_H
565568

566569
/* Define if you have the <dirent.h> header file. */
567570
#undef HAVE_DIRENT_H

configure

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22

3-
# From configure.in Revision: 1.222
3+
# From configure.in Revision: 1.224
44

55
# Guess values for system-dependent variables and create Makefiles.
66
# Generated automatically using autoconf version 2.13
@@ -6814,6 +6814,51 @@ EOF
68146814

68156815
fi
68166816

6817+
# check for readline 4.2
6818+
echo $ac_n "checking for rl_completion_matches in -lreadline""... $ac_c" 1>&6
6819+
echo "configure:6820: checking for rl_completion_matches in -lreadline" >&5
6820+
ac_lib_var=`echo readline'_'rl_completion_matches | sed 'y%./+-%__p_%'`
6821+
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
6822+
echo $ac_n "(cached) $ac_c" 1>&6
6823+
else
6824+
ac_save_LIBS="$LIBS"
6825+
LIBS="-lreadline -ltermcap $LIBS"
6826+
cat > conftest.$ac_ext <<EOF
6827+
#line 6828 "configure"
6828+
#include "confdefs.h"
6829+
/* Override any gcc2 internal prototype to avoid an error. */
6830+
/* We use char because int might match the return type of a gcc2
6831+
builtin and then its argument prototype would still apply. */
6832+
char rl_completion_matches();
6833+
6834+
int main() {
6835+
rl_completion_matches()
6836+
; return 0; }
6837+
EOF
6838+
if { (eval echo configure:6839: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
6839+
rm -rf conftest*
6840+
eval "ac_cv_lib_$ac_lib_var=yes"
6841+
else
6842+
echo "configure: failed program was:" >&5
6843+
cat conftest.$ac_ext >&5
6844+
rm -rf conftest*
6845+
eval "ac_cv_lib_$ac_lib_var=no"
6846+
fi
6847+
rm -f conftest*
6848+
LIBS="$ac_save_LIBS"
6849+
6850+
fi
6851+
if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then
6852+
echo "$ac_t""yes" 1>&6
6853+
cat >> confdefs.h <<\EOF
6854+
#define HAVE_RL_COMPLETION_MATCHES 1
6855+
EOF
6856+
6857+
else
6858+
echo "$ac_t""no" 1>&6
6859+
fi
6860+
6861+
68176862
# THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
68186863
# Add sys/socket.h to confdefs.h
68196864
cat >> confdefs.h <<\EOF
@@ -6822,12 +6867,12 @@ cat >> confdefs.h <<\EOF
68226867
#endif
68236868
EOF
68246869
echo $ac_n "checking for socklen_t""... $ac_c" 1>&6
6825-
echo "configure:6826: checking for socklen_t" >&5
6870+
echo "configure:6871: checking for socklen_t" >&5
68266871
if eval "test \"`echo '$''{'ac_cv_type_socklen_t'+set}'`\" = set"; then
68276872
echo $ac_n "(cached) $ac_c" 1>&6
68286873
else
68296874
cat > conftest.$ac_ext <<EOF
6830-
#line 6831 "configure"
6875+
#line 6876 "configure"
68316876
#include "confdefs.h"
68326877
#include <sys/types.h>
68336878
#if STDC_HEADERS
@@ -6876,7 +6921,7 @@ done
68766921

68776922
SRCDIRS="Parser Grammar Objects Python Modules"
68786923
echo $ac_n "checking for build directories""... $ac_c" 1>&6
6879-
echo "configure:6880: checking for build directories" >&5
6924+
echo "configure:6925: checking for build directories" >&5
68806925
for dir in $SRCDIRS; do
68816926
if test ! -d $dir; then
68826927
mkdir $dir

configure.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,6 +1661,10 @@ then
16611661
AC_DEFINE(HAVE_GETC_UNLOCKED)
16621662
fi
16631663

1664+
# check for readline 4.2
1665+
AC_CHECK_LIB(readline, rl_completion_matches,
1666+
AC_DEFINE(HAVE_RL_COMPLETION_MATCHES), , -ltermcap)
1667+
16641668
# THIS MUST BE LAST, IT CAN BREAK OTHER TESTS!
16651669
# Add sys/socket.h to confdefs.h
16661670
cat >> confdefs.h <<\EOF

0 commit comments

Comments
 (0)