Commit 831e78e0 authored by Peter Eisentraut's avatar Peter Eisentraut

Better coding of readline tests

parent 1b7332fb
This diff is collapsed.
...@@ -612,9 +612,8 @@ fi ...@@ -612,9 +612,8 @@ fi
AC_CHECK_LIB(sfio, main) AC_CHECK_LIB(sfio, main)
AC_CHECK_LIB(ncurses, main, [], [AC_CHECK_LIB(curses, main)]) AC_CHECK_LIB(ncurses, main, [], [AC_CHECK_LIB(curses, main)])
AC_CHECK_LIB(termcap, main) AC_CHECK_LIB(termcap, main)
AC_CHECK_LIB(readline, main) AC_CHECK_LIB(readline, readline)
AC_CHECK_LIB(readline, using_history, AC_DEFINE(HAVE_HISTORY_IN_READLINE), AC_SEARCH_LIBS(using_history, history, [AC_DEFINE(HAVE_HISTORY_FUNCTIONS)])
AC_CHECK_LIB(history, main) )
if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha" if test "$PORTNAME" != "aix" -a "$PORTNAME" != "alpha"
then then
...@@ -832,24 +831,39 @@ AC_CHECK_FUNC(rint, ...@@ -832,24 +831,39 @@ AC_CHECK_FUNC(rint,
AC_DEFINE(HAVE_RINT), AC_DEFINE(HAVE_RINT),
AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB)) AC_CHECK_LIB(m, rint, AC_DEFINE(HAVE_RINT), , $HPUXMATHLIB))
dnl Some old versions of libreadline don't have rl_completion_append_character
AC_EGREP_HEADER(rl_completion_append_character, readline.h, # Readline versions < 2.1 don't have rl_completion_append_character
AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER), AC_MSG_CHECKING([for rl_completion_append_character])
[AC_EGREP_HEADER(rl_completion_append_character, readline/readline.h, AC_TRY_LINK([#include <stdio.h>
AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER))]) #ifdef HAVE_READLINE_H
AC_SUBST(HAVE_RL_COMPLETION_APPEND_CHARACTER) # include <readline.h>
#endif
dnl Check for readline's filename_completion_function. #ifdef HAVE_READLINE_READLINE_H
dnl Some versions have it but it's not in the headers, so we have to take # include <readline/readline.h>
dnl care of that, too. #endif],
AC_CHECK_FUNCS(filename_completion_function, [rl_completion_append_character = 'x';],
AC_EGREP_HEADER(filename_completion_function, readline.h, [AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL), AC_DEFINE(HAVE_RL_COMPLETION_APPEND_CHARACTER)],
[AC_EGREP_HEADER(filename_completion_function, readline/readline.h, [AC_MSG_RESULT(no)])
AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL))])
)
AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION) # Check whether readline's filename_completion_function is declared.
AC_SUBST(HAVE_FILENAME_COMPLETION_FUNCTION_DECL) # Some prehistoric versions of readline, in particular those shipped
# with earlier Cygwins don't have this declared, although it's in the
# library.
AC_MSG_CHECKING([whether filename_completion_function is declared])
if test "$ac_cv_header_readline_h" = yes; then
_readline_header='readline.h'
elif test "$ac_cv_header_readline_readline_h" = yes; then
_readline_header='readline/readline.h'
else
_readline_header='xxx'
fi
AC_EGREP_HEADER([filename_completion_function], [$_readline_header],
[AC_DEFINE(HAVE_FILENAME_COMPLETION_FUNCTION_DECL)
AC_MSG_RESULT(yes)],
[AC_MSG_RESULT(no)])
dnl Cannot use AC_CHECK_FUNC because finite may be a macro dnl Cannot use AC_CHECK_FUNC because finite may be a macro
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.10 2000/04/12 17:16:22 momjian Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/input.h,v 1.11 2000/10/03 19:50:20 petere Exp $
*/ */
#ifndef INPUT_H #ifndef INPUT_H
#define INPUT_H #define INPUT_H
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#endif #endif
#endif #endif
#if defined(HAVE_LIBHISTORY) || (defined(HAVE_LIBREADLINE) && defined(HAVE_HISTORY_IN_READLINE)) #if defined(HAVE_HISTORY_FUNCTIONS)
#if defined(HAVE_READLINE_HISTORY_H) #if defined(HAVE_READLINE_HISTORY_H)
#include <readline/history.h> #include <readline/history.h>
#define USE_HISTORY 1 #define USE_HISTORY 1
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright 2000 by PostgreSQL Global Development Group * Copyright 2000 by PostgreSQL Global Development Group
* *
* $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.20 2000/06/25 14:25:51 petere Exp $ * $Header: /cvsroot/pgsql/src/bin/psql/tab-complete.c,v 1.21 2000/10/03 19:50:20 petere Exp $
*/ */
/*---------------------------------------------------------------------- /*----------------------------------------------------------------------
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
#include "common.h" #include "common.h"
#include "settings.h" #include "settings.h"
#if defined(HAVE_FILENAME_COMPLETION_FUNCTION) && !defined(HAVE_FILENAME_COMPLETION_FUNCTION_DECL) #ifndef HAVE_FILENAME_COMPLETION_FUNCTION_DECL
char *filename_completion_function(char *, int); char *filename_completion_function(char *, int);
#endif #endif
...@@ -699,17 +699,7 @@ psql_completion(char *text, int start, int end) ...@@ -699,17 +699,7 @@ psql_completion(char *text, int start, int end)
strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0 strcmp(prev_wd, "\\w") == 0 || strcmp(prev_wd, "\\write") == 0
) )
{ {
#ifdef HAVE_FILENAME_COMPLETION_FUNCTION
matches = completion_matches(text, filename_completion_function); matches = completion_matches(text, filename_completion_function);
#else
/*
* This will probably have the same effect, but you never know
* what the heck some readline incarnation out there is going to
* do.
*/
matches = NULL;
#endif
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* or in config.h afterwards. Of course, if you edit config.h, then your * or in config.h afterwards. Of course, if you edit config.h, then your
* changes will be overwritten the next time you run configure. * changes will be overwritten the next time you run configure.
* *
* $Id: config.h.in,v 1.139 2000/10/03 03:11:23 momjian Exp $ * $Id: config.h.in,v 1.140 2000/10/03 19:50:21 petere Exp $
*/ */
#ifndef CONFIG_H #ifndef CONFIG_H
...@@ -384,8 +384,8 @@ ...@@ -384,8 +384,8 @@
/* Define if you have the stricmp function. */ /* Define if you have the stricmp function. */
#undef HAVE_STRICMP #undef HAVE_STRICMP
/* Set to 1 if you have libreadline and it includes history functions */ /* Set to 1 if you have history functions (either in libhistory or libreadline) */
#undef HAVE_HISTORY_IN_READLINE #undef HAVE_HISTORY_FUNCTIONS
/* Set to 1 if you have <pwd.h> */ /* Set to 1 if you have <pwd.h> */
#undef HAVE_PWD_H #undef HAVE_PWD_H
...@@ -547,10 +547,7 @@ extern void srandom(unsigned int seed); ...@@ -547,10 +547,7 @@ extern void srandom(unsigned int seed);
/* Set to 1 if your libreadline defines rl_completion_append_character */ /* Set to 1 if your libreadline defines rl_completion_append_character */
#undef HAVE_RL_COMPLETION_APPEND_CHARACTER #undef HAVE_RL_COMPLETION_APPEND_CHARACTER
/* Set to 1 if your libreadline has filename_completion_function */ /* Set to 1 if filename_completion_function is declared in the readline header */
#undef HAVE_FILENAME_COMPLETION_FUNCTION
/* Set to 1 if your readline headers actually declare the above */
#undef HAVE_FILENAME_COMPLETION_FUNCTION_DECL #undef HAVE_FILENAME_COMPLETION_FUNCTION_DECL
/* Set to 1 if you have getopt_long() (GNU long options) */ /* Set to 1 if you have getopt_long() (GNU long options) */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment