diff --git a/src/ChangeLog b/src/ChangeLog index aebf2f9c3..f56501a2c 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2012-08-30 Alexander V. Lukyanov + + * lftp_tinfo.cc: fixed termcap coredump. + 2012-08-27 Alexander V. Lukyanov * DHT.cc, DHT.h: add rate limit; improve FindNodes by checking diff --git a/src/lftp_tinfo.cc b/src/lftp_tinfo.cc index 5529bec57..152704210 100644 --- a/src/lftp_tinfo.cc +++ b/src/lftp_tinfo.cc @@ -40,10 +40,9 @@ extern "C" { # include #endif } - +#include #include "lftp_tinfo.h" -#if defined(HAVE_TIGETSTR) static bool terminfo_ok = true; static void init_terminfo() { @@ -51,21 +50,27 @@ static void init_terminfo() if(initted) return; initted = true; +#if defined(HAVE_TIGETSTR) int errret=0; if(setupterm(NULL, 1, &errret) == ERR) terminfo_ok = false; -} +#elif defined(HAVE_TGETSTR) + static char buf[2048]; + if(tgetent(buf,getenv("TERM")) == -1) + terminfo_ok = false; #endif +} const char *get_string_term_cap(const char *terminfo_cap, const char *tcap_cap) { -#if defined(HAVE_TIGETSTR) init_terminfo(); - if(terminfo_ok) { - /* Cast to work around missing const def in some ncurses installations: */ - const char *ret = tigetstr(const_cast(terminfo_cap)); - if(ret && ret != (char *)-1) return ret; - } + if(!terminfo_ok) + return 0; + +#if defined(HAVE_TIGETSTR) + /* Cast to work around missing const def in some ncurses installations: */ + const char *ret = tigetstr(const_cast(terminfo_cap)); + if(ret && ret != (char *)-1) return ret; #elif defined(HAVE_TGETSTR) const char *ret = tgetstr(const_cast(tcap_cap), 0); if(ret && ret != (const char *)-1)