Remove all checking for the various terminfo headers (term.h and

curses.h). Finding these headers is next to impossible. For example, on
Debian systems libtinfo-dev provides the terminfo reading library we
want, but *not* term.h. For the header, you have to use libncurses-dev.
And libncursesw-dev provides a *different* term.h in a different
location!

These headers aren't worth it. We want two functions the signatures of
which are clearly spec'ed in sys-v and other documentation. Just declare
them ourselves and call them. This should fix some debian builders and
provide better support for "minimal" debian systems that do want color
autodetection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188165 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth
2013-08-12 10:40:11 +00:00
parent dfb5ceae90
commit 3729d7d62b
6 changed files with 11 additions and 252 deletions
+10 -24
View File
@@ -38,28 +38,6 @@
# include <termios.h>
#endif
// Pull in the headers we found to go with the terminfo reading library (tinfo,
// curses, whatever it may be). We have to pull in the 'curses.h' header as the
// SysV spec only provides certain values and defines from that header even
// though we work hard to not link against all of the curses implementation
// when avoidable.
#ifdef HAVE_TERMINFO
# if defined(HAVE_CURSES_H)
# include <curses.h>
# elif defined(HAVE_NCURSES_H)
# include <ncurses.h>
# elif defined(HAVE_NCURSESW_H)
# include <ncursesw.h>
# elif defined(HAVE_NCURSES_CURSES_H)
# include <ncurses/curses.h>
# elif defined(HAVE_NCURSESW_CURSES_H)
# include <ncursesw/curses.h>
# endif
# if defined(HAVE_TERM_H)
# include <term.h>
# endif
#endif
//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only generic UNIX code that
//=== is guaranteed to work on *all* UNIX variants.
@@ -269,6 +247,14 @@ unsigned Process::StandardErrColumns() {
return getColumns(2);
}
#ifdef HAVE_TERMINFO
// We manually declare these two extern functions because finding the correct
// headers from various terminfo, curses, or other sources is harder than
// writing their specs down.
extern "C" int setupterm(char *term, int filedes, int *errret);
extern "C" int tigetnum(char *capname);
#endif
static bool terminalHasColors(int fd) {
#ifdef HAVE_TERMINFO
// First, acquire a global lock because these C routines are thread hostile.
@@ -276,7 +262,7 @@ static bool terminalHasColors(int fd) {
MutexGuard G(M);
int errret = 0;
if (setupterm((char *)0, fd, &errret) != OK)
if (setupterm((char *)0, fd, &errret) != 0)
// Regardless of why, if we can't get terminfo, we shouldn't try to print
// colors.
return false;
@@ -294,7 +280,7 @@ static bool terminalHasColors(int fd) {
//
// The 'tigetnum' routine returns -2 or -1 on errors, and might return 0 if
// the terminfo says that no colors are supported.
if (tigetnum("colors") > 0)
if (tigetnum((char *)"colors") > 0)
return true;
#endif