From cb73d7adb8e9cdd4e3d5fb1202400524809280fb Mon Sep 17 00:00:00 2001 From: christos Date: Wed, 22 Jan 2003 03:24:21 +0000 Subject: not all windows have 80 columns. --- progress.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/progress.c b/progress.c index 5db052e..23c075b 100644 --- a/progress.c +++ b/progress.c @@ -1,4 +1,4 @@ -/* $NetBSD: progress.c,v 1.2 2003/01/22 03:13:32 enami Exp $ */ +/* $NetBSD: progress.c,v 1.3 2003/01/22 03:24:21 christos Exp $ */ /*- * Copyright (c) 2003 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ #include #ifndef lint -__RCSID("$NetBSD: progress.c,v 1.2 2003/01/22 03:13:32 enami Exp $"); +__RCSID("$NetBSD: progress.c,v 1.3 2003/01/22 03:24:21 christos Exp $"); #endif /* not lint */ #include @@ -89,6 +89,7 @@ main(int argc, char *argv[]) int lflag = 0, zflag = 0; ssize_t nr, nw, off; struct stat statb; + struct ttysize ts; setprogname(argv[0]); @@ -179,7 +180,12 @@ main(int argc, char *argv[]) bytes = 0; progress = 1; ttyout = stdout; - ttywidth = 80; + + if (ioctl(fileno(ttyout), TIOCGSIZE, &ts) == -1) { + warn("could not get tty window size"); + ttywidth = 80; + } else + ttywidth = ts.ts_cols; if (pipe(outpipe) < 0) err(1, "output pipe"); -- cgit v1.2.3-56-ge451