plan 9 kernel history: overview | file list | diff list

2000/0308/port/parse.c (diff list | history)

1999/0316/sys/src/9/port/parse.c:5,272000/0308/sys/src/9/port/parse.c:5,10 (short | long | prev | next)
Replace parsefields with new library function getfields, now that getfields is thread-safe.
rsc Fri Mar 4 12:44:25 2005
1999/0316    
#include	"fns.h" 
#include	"../port/error.h" 
 
int 
parsefields(char *lp, char **fields, int n, char *sep) 
{ 
	int i; 
                 
	for(i=0; lp && *lp && i<n; i++){ 
		while(*lp && strchr(sep, *lp) != 0) 
			*lp++=0; 
		if(*lp == 0) 
			break; 
		fields[i]=lp; 
		while(*lp && strchr(sep, *lp) == 0) 
			lp++; 
	} 
	return i; 
} 
                 
/* 
 *  parse a command written to a device 
 */ 
1999/0316/sys/src/9/port/parse.c:38,442000/0308/sys/src/9/port/parse.c:21,27
1999/0316    
	if(n > 0 && cb->buf[n-1] == '\n') 
		n--; 
	cb->buf[n] = '\0'; 
	cb->nf = parsefields(cb->buf, cb->f, nelem(cb->f), " "); 
2000/0308    
	cb->nf = getfields(cb->buf, cb->f, nelem(cb->f), 1, " "); 
1999/0316    
	return cb; 
} 
 


source code copyright © 1990-2005 Lucent Technologies; see license
Plan 9 distribution
comments to russ cox (rsc@swtch.com)