X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Flib_setup.c;h=0b8aeba5a8cfa9ebc35115d1eed33040bf8d6d2e;hp=c2a481d7d91150b51e953edb86ac20e7e4eb04e0;hb=11dead39816318fe9601e27756b9497caf7ff490;hpb=c6540b9c89dda1a6a8bd681726831e8924176504 diff --git a/ncurses/tinfo/lib_setup.c b/ncurses/tinfo/lib_setup.c index c2a481d7..0b8aeba5 100644 --- a/ncurses/tinfo/lib_setup.c +++ b/ncurses/tinfo/lib_setup.c @@ -51,7 +51,7 @@ #include #endif -MODULE_ID("$Id: lib_setup.c,v 1.127 2010/01/23 17:57:43 tom Exp $") +MODULE_ID("$Id: lib_setup.c,v 1.128 2010/04/03 13:54:45 tom Exp $") /**************************************************************************** * @@ -278,25 +278,14 @@ _nc_get_screensize(SCREEN *sp, /* figure out the size of the screen */ T(("screen size: terminfo lines = %d columns = %d", lines, columns)); - if (!_nc_prescreen.use_env) { - *linep = (int) lines; - *colp = (int) columns; - } else { /* usually want to query LINES and COLUMNS from environment */ - int value; - - *linep = *colp = 0; + *linep = (int) lines; + *colp = (int) columns; - /* first, look for environment variables */ - if ((value = _nc_getenv_num("LINES")) > 0) { - *linep = value; - } - if ((value = _nc_getenv_num("COLUMNS")) > 0) { - *colp = value; - } - T(("screen size: environment LINES = %d COLUMNS = %d", *linep, *colp)); + if (_nc_prescreen.use_env) { + int value; #ifdef __EMX__ - if (*linep <= 0 || *colp <= 0) { + { int screendata[2]; _scrsize(screendata); *colp = screendata[0]; @@ -306,33 +295,41 @@ _nc_get_screensize(SCREEN *sp, } #endif #if HAVE_SIZECHANGE - /* if that didn't work, maybe we can try asking the OS */ - if (*linep <= 0 || *colp <= 0) { - if (isatty(cur_term->Filedes)) { - STRUCT_WINSIZE size; - - errno = 0; - do { - if (ioctl(cur_term->Filedes, IOCTL_WINSIZE, &size) < 0 - && errno != EINTR) - goto failure; - } while - (errno == EINTR); - - /* - * Solaris lets users override either dimension with an - * environment variable. - */ - if (*linep <= 0) - *linep = (sp != 0 && sp->_filtered) ? 1 : WINSIZE_ROWS(size); - if (*colp <= 0) + /* try asking the OS */ + if (isatty(cur_term->Filedes)) { + STRUCT_WINSIZE size; + + errno = 0; + do { + if (ioctl(cur_term->Filedes, IOCTL_WINSIZE, &size) >= 0) { + *linep = ((sp != 0 && sp->_filtered) + ? 1 + : WINSIZE_ROWS(size)); *colp = WINSIZE_COLS(size); - } - /* FALLTHRU */ - failure:; + T(("SYS screen size: environment LINES = %d COLUMNS = %d", + *linep, *colp)); + break; + } + } while + (errno == EINTR); } #endif /* HAVE_SIZECHANGE */ + /* + * Finally, look for environment variables. + * + * Solaris lets users override either dimension with an environment + * variable. + */ + if ((value = _nc_getenv_num("LINES")) > 0) { + *linep = value; + T(("screen size: environment LINES = %d", *linep)); + } + if ((value = _nc_getenv_num("COLUMNS")) > 0) { + *colp = value; + T(("screen size: environment COLUMNS = %d", *colp)); + } + /* if we can't get dynamic info about the size, use static */ if (*linep <= 0) { *linep = (int) lines;