[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: user/1292: bad formatting in systat iostat (numbers)



The following reply was made to PR user/1292; it has been noted by GNATS.

From: Dan Harnett <danh_(_at_)_nfol_(_dot_)_com>
To: gnats_(_at_)_openbsd_(_dot_)_org
Cc:  Subject: Re: user/1292: bad formatting in systat iostat (numbers)
Date: Mon, 26 Jun 2000 18:58:59 -0400

 On Sun, Jun 25, 2000 at 10:02:02PM -0400, danh_(_at_)_nfol_(_dot_)_com wrote:
 > 
 > >Number:         1292
 > >Category:       user
 > >Synopsis:       bad formatting in systat iostat (numbers)
 > >Confidential:   no
 > >Severity:       non-critical
 > >Priority:       low
 > >Responsible:    bugs
 > >State:          open
 > >Class:          sw-bug
 > >Submitter-Id:   net
 > >Arrival-Date:   Sun Jun 25 20:10:02 MDT 2000
 > >Last-Modified:
 > >Originator:     Dan Harnett
 > >Organization:
 > net
 > >Release:        
 > >Environment:
 > 	
 > 	System      : OpenBSD 2.7
 > 	Architecture: OpenBSD.i386
 > 	Machine     : i386
 > >Description:
 > 	
 > 	In systat, when displaying iostat as numbers, the columns and
 > 	headers are aligned incorrectly.
 > 
 > >Fix:
 > 
 
 Actually, here is a better patch that increases COLWIDTH, and splits INSET into
 INSET and NUMINSET since INSET is also used by the 'bars' output.
 
 Index: iostat.c
 ===================================================================
 RCS file: /cvs/src/usr.bin/systat/iostat.c,v
 retrieving revision 1.10
 diff -u -p -r1.10 iostat.c
 --- iostat.c	1997/12/19 09:03:32	1.10
 +++ iostat.c	2000/06/26 22:53:25
 @@ -101,7 +101,8 @@ fetchiostat()
  	dkreadstats();
  }
  
 -#define	INSET	10
 +#define INSET		10
 +#define NUMINSET	12
  
  void
  labeliostat()
 @@ -133,8 +134,8 @@ numlabels(row)
  		mvwaddstr(wnd, row++, INSET, "No drives attached.");
  		return (row);
  	}
 -#define COLWIDTH	14
 -#define DRIVESPERLINE	((wnd->_maxx - INSET) / COLWIDTH)
 +#define COLWIDTH	17
 +#define DRIVESPERLINE	((wnd->_maxx - NUMINSET) / COLWIDTH)
  	for (ndrives = 0, i = 0; i < dk_ndrive; i++)
  		if (cur.dk_select[i])
  			ndrives++;
 @@ -149,16 +150,16 @@ numlabels(row)
  	 */
  	if (linesperregion < 3)
  		linesperregion = 3;
 -	col = 0;
 +	col = NUMINSET;
  	for (i = 0; i < dk_ndrive; i++)
  		if (cur.dk_select[i] /*&& cur.dk_bytes[i] != 0.0*/) {
  			if (col + COLWIDTH >= wnd->_maxx - INSET) {
 -				col = 0, row += linesperregion + 1;
 +				col = NUMINSET, row += linesperregion + 1;
  				if (row > wnd->_maxy - (linesperregion + 1))
  					break;
  			}
 -			mvwaddstr(wnd, row, col + 4, cur.dk_name[i]);
 -			mvwaddstr(wnd, row + 1, col, "Kps tps  sec");
 +			mvwaddstr(wnd, row, col + 6, cur.dk_name[i]);
 +			mvwaddstr(wnd, row + 1, col, "  Kps  tps  sec");
  			col += COLWIDTH;
  		}
  	if (col)
 @@ -227,7 +228,7 @@ showiostat()
  			}
  		return;
  	}
 -	col = 0;
 +	col = NUMINSET;
  	wmove(wnd, row + linesperregion, 0);
  	wdeleteln(wnd);
  	wmove(wnd, row + 3, 0);
 @@ -235,7 +236,7 @@ showiostat()
  	for (i = 0; i < dk_ndrive; i++)
  		if (cur.dk_select[i] /*&& cur.dk_bytes[i] != 0.0*/) {
  			if (col + COLWIDTH >= wnd->_maxx) {
 -				col = 0, row += linesperregion + 1;
 +				col = NUMINSET, row += linesperregion + 1;
  				if (row > wnd->_maxy - (linesperregion + 1))
  					break;
  				wmove(wnd, row + linesperregion, 0);
 @@ -260,7 +261,7 @@ stats(row, col, dn)
  
  	words = cur.dk_bytes[dn] / 1024.0;	/* # of K transferred */
  	if (numbers) {
 -		mvwprintw(wnd, row, col, "%3.0f%4.0f%5.1f",
 +		mvwprintw(wnd, row, col, "%5.0f%5.0f%5.1f",
  		    words / etime, cur.dk_xfer[dn] / etime, atime / etime);
  		return (row);
  	}
 -- 
  Dan Harnett <danh_(_at_)_nfol_(_dot_)_com>
 




Visit your host, monkey.org