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/utfrune.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
char*
5
utfrune(char *s, long c)
6
{
7
	long c1;
8
	Rune r;
9
	int n;
10
 
11
	if(c < Runesync)		/* not part of utf sequence */
12
		return strchr(s, c);
13
 
14
	for(;;) {
15
		c1 = *(uchar*)s;
16
		if(c1 < Runeself) {	/* one byte rune */
17
			if(c1 == 0)
18
				return 0;
19
			if(c1 == c)
20
				return s;
21
			s++;
22
			continue;
23
		}
24
		n = chartorune(&r, s);
25
		if(r == c)
26
			return s;
27
		s += n;
28
	}
29
	return 0;
30
}