Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_posix/sys/src/cmd/unix/drawterm/libc/getfields.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
 
4
int
5
getfields(char *str, char **args, int max, int mflag, char *set)
6
{
7
	Rune r;
8
	int nr, intok, narg;
9
 
10
	if(max <= 0)
11
		return 0;
12
 
13
	narg = 0;
14
	args[narg] = str;
15
	if(!mflag)
16
		narg++;
17
	intok = 0;
18
	for(;; str += nr) {
19
		nr = chartorune(&r, str);
20
		if(r == 0)
21
			break;
22
		if(utfrune(set, r)) {
23
			if(narg >= max)
24
				break;
25
			*str = 0;
26
			intok = 0;
27
			args[narg] = str + nr;
28
			if(!mflag)
29
				narg++;
30
		} else {
31
			if(!intok && mflag)
32
				narg++;
33
			intok = 1;
34
		}
35
	}
36
	return narg;
37
}