aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFritz Elfert <felfert@to.com>2001-07-26 13:07:36 +0000
committerFritz Elfert <felfert@to.com>2001-07-26 13:07:36 +0000
commitfb63e94110d271b1ab346fa598d318e458b9bbd7 (patch)
treee0828f649bed27ef54f388e81c01d790da37ab40
parent24f74bf9c5c97f8b3ee4f6658e9dac41f93f41a4 (diff)
downloadplptools-fb63e94110d271b1ab346fa598d318e458b9bbd7.tar.gz
plptools-fb63e94110d271b1ab346fa598d318e458b9bbd7.tar.bz2
plptools-fb63e94110d271b1ab346fa598d318e458b9bbd7.zip
Configure check and support for readline 4.2
-rw-r--r--acconfig.h9
-rw-r--r--conf/m4/plptools/PLP_CHECK_READLINE.m428
-rw-r--r--plpftp/ftp.cc24
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