(TTYinfo): only call tgetent if we found it using autoconf

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@15581 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2005-07-07 20:55:18 +00:00
parent 68ab4175c6
commit 0ecc47dc71

View File

@@ -217,10 +217,6 @@ static void
TTYinfo(void) TTYinfo(void)
{ {
static int init; static int init;
const char *term;
char buff[2048];
char *bp;
char *tmp;
#if defined(TIOCGWINSZ) #if defined(TIOCGWINSZ)
struct winsize W; struct winsize W;
#endif /* defined(TIOCGWINSZ) */ #endif /* defined(TIOCGWINSZ) */
@@ -238,20 +234,28 @@ TTYinfo(void)
} }
init++; init++;
TTYwidth = TTYrows = 0; #ifdef HAVE_TGETENT
bp = &buff[0]; {
if ((term = getenv("TERM")) == NULL) char buff[2048];
term = "dumb"; char *tmp;
if (tgetent(buff, term) < 0) { char *bp;
TTYwidth = SCREEN_WIDTH; const char *term;
TTYrows = SCREEN_ROWS;
return; TTYwidth = TTYrows = 0;
bp = &buff[0];
if ((term = getenv("TERM")) == NULL)
term = "dumb";
if (tgetent(buff, term) >= 0) {
tmp = tgetstr("le", &bp);
if (tmp != NULL)
backspace = strdup(tmp);
TTYwidth = tgetnum("co");
TTYrows = tgetnum("li");
return;
}
} }
tmp = tgetstr("le", &bp); #endif
if (tmp != NULL)
backspace = strdup(tmp);
TTYwidth = tgetnum("co");
TTYrows = tgetnum("li");
#if defined(TIOCGWINSZ) #if defined(TIOCGWINSZ)
if (ioctl(0, TIOCGWINSZ, &W) >= 0) { if (ioctl(0, TIOCGWINSZ, &W) >= 0) {