Column fix when stdout is redirected. Default to 80.

This commit is contained in:
Aaron Griffin 2006-12-28 17:20:41 +00:00
parent 23f0f778ef
commit d59585c24f
1 changed files with 6 additions and 0 deletions

View File

@ -54,6 +54,12 @@ extern int neednl;
/* gets the current screen column width */
int getcols()
{
if(!isatty(1)) {
/* We will default to 80 columns if we're not a tty
* this seems a fairly standard file width.
*/
return 80;
}
#ifdef TIOCGSIZE
struct ttysize win;
if(ioctl(1, TIOCGSIZE, &win) == 0) {