Plan 9 from Bell Labs’s /usr/web/sources/contrib/uriel/changes/2006/0213/7

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


More consistent output.
 [rsc] --rw-rw-r-- M 913078 glenda sys 5706 Feb 13 12:51 sys/src/cmd/ls.c
	/n/sourcesdump/2006/0213/plan9/sys/src/cmd/ls.c:36,41 - 
	/n/sourcesdump/2006/0214/plan9/sys/src/cmd/ls.c:36,42
	  void	dowidths(Dir*);
	  void	format(Dir*, char*);
	  void	output(void);
	+ char*	xcleanname(char*);
	  ulong	clk;
	  int	swidth;			/* max width of -s size */
	  int	qwidth;			/* max width of -q version */
	/n/sourcesdump/2006/0213/plan9/sys/src/cmd/ls.c:106,112 - 
	/n/sourcesdump/2006/0214/plan9/sys/src/cmd/ls.c:107,113
	  		n = dirreadall(fd, &db);
	  		if(n < 0)
	  			goto error;
	- 		cleanname(s);
	+ 		xcleanname(s);
	  		growto(ndir+n);
	  		for(i=0; i<n; i++){
	  			dirbuf[ndir+i].d = db+i;
	/n/sourcesdump/2006/0213/plan9/sys/src/cmd/ls.c:119,125 - 
	/n/sourcesdump/2006/0214/plan9/sys/src/cmd/ls.c:120,126
	  		growto(ndir+1);
	  		dirbuf[ndir].d = db;
	  		dirbuf[ndir].prefix = 0;
	- 		cleanname(s);
	+ 		xcleanname(s);
	  		p = utfrrune(s, '/');
	  		if(p){
	  			dirbuf[ndir].prefix = s;
	/n/sourcesdump/2006/0213/plan9/sys/src/cmd/ls.c:304,306 - 
	/n/sourcesdump/2006/0214/plan9/sys/src/cmd/ls.c:305,324
	  	return buf;
	  }
	  
	+ /*
	+  * Compress slashes, remove trailing slash.  Don't worry about . and ..
	+  */
	+ char*
	+ xcleanname(char *name)
	+ {
	+ 	char *r, *w;
	+ 	
	+ 	for(r=w=name; *r; r++){
	+ 		if(*r=='/' && r>name && *(r-1)=='/')
	+ 			continue;
	+ 		*w++ = *r;
	+ 	}
	+ 	while(w-1>name && *(w-1)=='/')
	+ 		*--w = 0;
	+ 	return name;
	+ }
 [rsc] --rw-rw-r-- M 913078 glenda sys 5706 Feb 13 12:51 sys/src/cmd/ls.c


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.