From fb63e94110d271b1ab346fa598d318e458b9bbd7 Mon Sep 17 00:00:00 2001 From: Fritz Elfert Date: Thu, 26 Jul 2001 13:07:36 +0000 Subject: Configure check and support for readline 4.2 --- acconfig.h | 9 +++++++++ conf/m4/plptools/PLP_CHECK_READLINE.m4 | 28 ++++++++++++++++++++++++++++ plpftp/ftp.cc | 24 ++++++++++++++++++------ 3 files changed, 55 insertions(+), 6 deletions(-) diff --git a/acconfig.h b/acconfig.h index b3e338e..9c2812f 100644 --- a/acconfig.h +++ b/acconfig.h @@ -69,6 +69,15 @@ /* Define this to enable debugging code */ #undef DEBUG +/* Define this, if sys/int_types.h is on your system */ +#undef HAVE_SYS_INT_TYPES_H + +/* Define this, if your int-types have an underscore after the first u/s */ +#undef GNU_INTTYPES + +/* Define to 401 or 402, depending on readline version 4.1 or 4.2 */ +#define READLINE_VERSION 401 + @BOTTOM@ /* Some reasonable defaults */ diff --git a/conf/m4/plptools/PLP_CHECK_READLINE.m4 b/conf/m4/plptools/PLP_CHECK_READLINE.m4 index 1b99a19..3df8b5b 100644 --- a/conf/m4/plptools/PLP_CHECK_READLINE.m4 +++ b/conf/m4/plptools/PLP_CHECK_READLINE.m4 @@ -29,13 +29,41 @@ AC_DEFUN(PLP_CHECK_READLINE, ac_cv_addcurses=true AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE) AC_MSG_RESULT([yes, and needs libcurses]) + PLP_READLINE_402 ;; 1*) ac_cv_have_libreadline=true; AC_DEFINE_UNQUOTED(HAVE_LIBREADLINE) AC_MSG_RESULT(yes) + PLP_READLINE_402 ;; esac AM_CONDITIONAL(HAVE_LIBREADLINE, test x$ac_cv_have_libreadline = xtrue) AM_CONDITIONAL(ADD_LIBCURSES, test x$ac_cv_addcurses = xtrue) ]) + +dnl +dnl Check for readline version. +dnl Those readline developers change their API too frequently +dnl and don't provide a version number in the headers :-( +dnl +AC_DEFUN(PLP_READLINE_402, +[ + AC_MSG_CHECKING(for readline version) + saved_libs=$LIBS + if $ac_cv_addcurses ; then + LIBS="$LIBS -lreadline -lcurses" + else + LIBS="$LIBS -lreadline" + fi + rl42=false + AC_TRY_LINK(,[extern void rl_set_prompt(void); rl_set_prompt();],rl42=true) + LIBS="$saved_LIBS" + if $rl42 ; then + AC_MSG_RESULT(4.2 or greater) + AC_DEFINE_UNQUOTED(READLINE_VERSION,402) + else + AC_DEFINE_UNQUOTED(READLINE_VERSION,401) + AC_MSG_RESULT(4.1 or less) + fi +]) diff --git a/plpftp/ftp.cc b/plpftp/ftp.cc index e0de311..ab0492a 100644 --- a/plpftp/ftp.cc +++ b/plpftp/ftp.cc @@ -970,6 +970,18 @@ session(rfsv & a, rpcs & r, int xargc, char **xargv) } #if HAVE_LIBREADLINE +#if (READLINE_VERSION >= 402) +#define NULL_COMPLETION_RETTYPE char* +#define NULL_COMPLETION_RETVAL "" +#define FUNCAST(f) (CPFunction *)f +#define MATCHFUNCTION rl_completion_matches +#else +#define NULL_COMPLETION_RETTYPE int +#define NULL_COMPLETION_RETVAL 0 +#define FUNCAST(f) (Function *)f +#define MATCHFUNCTION completion_matches +#endif + static char *all_commands[] = { "pwd", "ren", "touch", "gtime", "test", "gattr", "sattr", "devs", "dir", "ls", "dircnt", "cd", "lcd", "get", "put", "mget", "mput", @@ -1045,9 +1057,9 @@ command_generator(char *text, int state) return NULL; } -static int +static NULL_COMPLETION_RETTYPE null_completion() { - return 0; + return NULL_COMPLETION_RETVAL; } static char ** @@ -1055,10 +1067,10 @@ do_completion(char *text, int start, int end) { char **matches = NULL; - rl_completion_entry_function = (Function *)null_completion; + rl_completion_entry_function = FUNCAST(null_completion); rl_completion_append_character = ' '; if (start == 0) - matches = completion_matches(text, cmdgen_ptr); + matches = MATCHFUNCTION(text, cmdgen_ptr); else { int idx = 0; char *name; @@ -1086,7 +1098,7 @@ do_completion(char *text, int start, int end) maskAttr = rfsv::PSI_A_DIR; } - matches = completion_matches(text, fnmgen_ptr); + matches = MATCHFUNCTION(text, fnmgen_ptr); } return matches; } @@ -1097,7 +1109,7 @@ initReadline(void) { #if HAVE_LIBREADLINE rl_readline_name = "plpftp"; - rl_completion_entry_function = (Function *)null_completion; + rl_completion_entry_function = FUNCAST(null_completion); rl_attempted_completion_function = (CPPFunction *)do_completion; rlcrap_setpointers(command_generator, filename_generator); #endif -- cgit v1.2.3