Subject: bin/790: ls(1) assumes tabs are 8 characters
To: None <gnats-admin@NetBSD.ORG>
From: None <darcy@druid.com>
List: netbsd-bugs
Date: 02/08/1995 13:50:05
>Number:         790
>Category:       bin
>Synopsis:       ls(1) assumes that tabs are 8 characters
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Feb  8 13:50:03 1995
>Originator:     D'Arcy J.M. Cain
>Organization:
D'Arcy J.M. Cain (darcy@druid.com)  |   Democracy is three wolves and a
Planix, Inc., Toronto, Canada       |   sheep voting on what's for dinner.
+1 416 424 2871  (DoD#0082) (eNTP)  |
      -- Info on Planix can be found at http://www.planix.com --
>Release:        1.0
>Environment:
	
System: NetBSD druid 1.0 NetBSD 1.0 (DRUID) #1: Sat Nov 26 15:36:14 EST 1994 root@druid:/usr/src/sys/arch/i386/compile/DRUID i386


>Description:
	The ls(1) command assumes that tabs are always 8 characters.  This
	value is hard coded in the source.  It shows up in multi-column
	listings.  Also because of the use of tabs to separate file names
	the listing isn't as dense as it could be.  The changes below show
	the mods I made on my system to solve this.  Of course it means
	that listings send a few more characters per line to the terminal
	but it seems minor compared to the annoyance of messed up displays.
	If you find that the density is too high it is a simple change
	to give each file name more room but I like having more files
	on the screen at a time.

>How-To-Repeat:
	In fact there seems to be a problem with xterm as this shows
	up when you do "stty oxtabs" on an xterm and goes away with
	a "stty -oxtabs."  I haven't had a chance to look into the
	xterm problem but either way it seems that ls(1) is making
	an invalid assumption.  Anyway do an ls -C on a directory
	that has a 1 character name as the first file and some
	bigger files - 15 characters for example.  Make sure that
	oxtabs is on.  This doesn't happen on an rlogin session
	from another system on a regular terminal.
>Fix:
===================================================================
RCS file: /usr/src/bin/ls/RCS/print.c,v
retrieving revision 1.1
diff -r1.1 /usr/src/bin/ls/print.c
39c39
< static char rcsid[] = "$Id: print.c,v 1.1 1995/02/08 16:03:39 darcy Exp darcy $";
---
> static char rcsid[] = "$Id: print.c,v 1.10 1994/04/04 19:29:43 chopps Exp $";
131,132d130
< #define	TAB	8
< 
142c140
< 	int endcol, numcols, numrows, row;
---
> 	int numcols, numrows, row;
160c158
< 	colwidth = dp->maxlen;
---
> 	colwidth = dp->maxlen + 1;
168d165
< 	colwidth = (colwidth + TAB) & ~(TAB - 1);
178a176,178
> 	/* might as well spread out if possible */
> 	colwidth = termwidth / numcols;
> 
182,185c182,183
< 		endcol = colwidth;
< 		for (base = row, chcnt = col = 0; col < numcols; ++col) {
< 			chcnt += printaname(array[base], dp->s_inode,
< 			    dp->s_block);
---
> 		for (base = row, col = 0; col < numcols; ++col) {
> 			chcnt = printaname(array[base], dp->s_inode, dp->s_block);
188,192c186,187
< 			while ((cnt = (chcnt + TAB & ~(TAB - 1))) <= endcol) {
< 				(void)putchar('\t');
< 				chcnt = cnt;
< 			}
< 			endcol += colwidth;
---
> 			for (; chcnt < colwidth; chcnt++)
> 				(void)putchar(' ');
>Audit-Trail:
>Unformatted: