Dear fellow members,
tisdag den 6 december 2011 klockan 10:48 skrev Alfred M. Szmidt detta:
> Simon's comments were spot on.
I am in a particular good mood now as you will soon see.
As it turned out I followed another route than in the
previous suggestion. The new patch is attached for your
reviewing. The build artifacts are as follows:
Full builds:
Debian Squeeze GNU/Linux (i386)
Debian Sid GNU/Linux (i386)
Debian Sid GNU/kFreeBSD (amd64)
FreeBSD 8.0 (i386)
OpenBSD 4.6 (i386) and 5.0 (qemu-i386)
NetBSD 5.1 (qemu-i386)
Partial builds:
GNU/OpenSolaris NexentaCore 3.1 (i386)
OpenIndiana oi_151a (i386)
Both have "talk" and "talkd" disabled: no header file.
Only build failures are "src/rshd" and "src/rlogind", since
iruserok(3) is not available in their Libc implementation.
The rest builds manually.
The new patch text is based on two principles, and a half:
* Accept whatever "am/libcurses.am" claims about libncurses.
* When having a choice, prefer libtermcap over libcurses for
providing tgetent(3). This is true to the dichotomy that
actually is implemented in the sets libtermcap/libtinfo/libcurses
that are known to me.
The patch switches test order for termcap versus curses,
and adds macros for book-keeping and for code conditionals.
* Prepare later augmentation for libterminfo. (No systems are
known to me!)
Best regards,
Mats
diff --git a/am/libcurses.m4 b/am/libcurses.m4
index 3dd1259..fe09781 100644
--- a/am/libcurses.m4
+++ b/am/libcurses.m4
@@ -88,19 +88,37 @@ AC_DEFUN([IU_LIB_TERMCAP], [
if test "$LIBNCURSES"; then
LIBTERMCAP="$LIBNCURSES"
else
- AC_CHECK_LIB(curses, tgetent, LIBTERMCAP=-lcurses)
- if test "$ac_cv_lib_curses_tgetent" = no; then
- AC_CHECK_LIB(termcap, tgetent, LIBTERMCAP=-ltermcap)
+ AC_CHECK_LIB(termcap, tgetent, LIBTERMCAP=-ltermcap)
+ AC_CHECK_HEADERS([termcap.h])
+ if test "$ac_cv_lib_termcap_tgetent" = yes \
+ || test "$ac_cv_header_termcap_h" = yes; then
+ AC_DEFINE([HAVE_TERMCAP_TGETENT], 1,
+ [Define to 1 if tgetent() exists in <termcap.h>.])
+ else
+ AC_CHECK_LIB(curses, tgetent, LIBTERMCAP=-lcurses)
fi
- if test "$ac_cv_lib_termcap_tgetent" = no; then
+ if test "$ac_cv_lib_curses_tgetent" = yes \
+ && test "$ac_cv_lib_termcap_tgetent" = no; then
+ AC_DEFINE([HAVE_CURSES_TGETENT], 1,
+ [Define to 1 if tgetent() exists in <curses.h>.])
+ fi
+ if test "$ac_cv_lib_curses_tgetent" = no \
+ && test "$ac_cv_lib_termcap_tgetent" = no; then
AC_CHECK_LIB(termlib, tgetent, LIBTERMCAP=-ltermlib)
+ if "$ac_cv_lib_termlib_tgetent" = yes; then
+ AC_DEFINE([HAVE_TERMINFO_TGETENT], 1,
+ [Define to 1 if tgetent() exists in libterminfo.])
+ fi
+ fi
+ if test -n "$LIBTERMCAP"; then
+ AC_DEFINE([HAVE_TGETENT], 1, [Define to 1 if tgetent() exists.])
fi
fi
AC_SUBST(LIBTERMCAP)])dnl
-dnl IU_LIB_CURSES -- checke for curses, and associated libraries
+dnl IU_LIB_CURSES -- check for curses, and associated libraries
dnl
-dnl Checks for varions libraries implementing the curses interface, and if
+dnl Checks for various libraries implementing the curses interface, and if
dnl found, defines LIBCURSES to be the appropriate linker specification,
dnl *including* any termcap libraries if needed (some versions of curses
dnl don't need termcap).
diff --git a/am/readline.m4 b/am/readline.m4
index b7ce9e4..1279c00 100644
--- a/am/readline.m4
+++ b/am/readline.m4
@@ -53,6 +53,20 @@ AC_DEFUN([gl_FUNC_READLINE],
LIBS="$am_save_LIBS"
])
+ dnl In case of failure, examine whether libedit can act
+ dnl as replacement. Small NetBSD systems use editline
+ dnl as wrapper for readline.
+ if test "$gl_cv_lib_readline" = no; then
+ am_save_LIBS="$LIBS"
+ LIBS="$am_save_LIBS -ledit"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>
+#include <readline/readline.h>]],
+ [[readline((char*)0);]])],
+ [gl_cv_lib_readline="yes"])
+ LIBS="$am_save_LIBS"
+ LIBREADLINE=-ledit
+ fi
+
if test "$gl_cv_lib_readline" != no; then
AC_DEFINE([HAVE_READLINE], [1], [Define if you have the readline library.])
extra_lib=`echo "$gl_cv_lib_readline" | sed -n -e 's/yes, requires //p'`
diff --git a/telnet/telnet.c b/telnet/telnet.c
index c5b4b19..d0e33d3 100644
--- a/telnet/telnet.c
+++ b/telnet/telnet.c
@@ -73,7 +73,9 @@
#include "types.h"
#include "general.h"
-#ifdef HAVE_READLINE
+#ifdef HAVE_TERMCAP_TGETENT
+# include <termcap.h>
+#elif defined HAVE_CURSES_TGETENT
# include <curses.h>
# include <term.h>
#endif
@@ -729,7 +731,7 @@ int
init_term (char *tname, int fd, int *errp)
{
int err = -1;
-#ifdef HAVE_READLINE
+#ifdef HAVE_TGETENT
err = tgetent (termbuf, tname);
#endif
if (err == 1)
diff --git a/telnetd/utility.c b/telnetd/utility.c
index c9dbeeb..0101331 100644
--- a/telnetd/utility.c
+++ b/telnetd/utility.c
@@ -37,7 +37,9 @@
# define NET_ENCRYPT()
#endif
-#ifdef HAVE_READLINE
+#ifdef HAVE_TERMCAP_TGETENT
+# include <termcap.h>
+#elif defined HAVE_CURSES_TGETENT
# include <curses.h>
# include <term.h>
#endif
@@ -830,7 +832,7 @@ terminaltypeok (char *s)
if (terminaltype == NULL)
return 1;
-#ifdef HAVE_READLINE
+#ifdef HAVE_TGETENT
if (tgetent (buf, s) == 0)
#endif
return 0;