git: 9front

ref: 800334cb8d11b5fe1bd4ef40bdc53fac49a2ee21
dir: /sys/src/libc/port/utfrrune.c/

View raw version
#include <u.h>
#include <libc.h>

char*
utfrrune(char *s, long c)
{
	Rune r;
	int n;
	char *p;
	char buf[UTFmax + 1] = {0};

	if(c < Runesync)		/* not part of utf sequence */
		return strrchr(s, c);

	r = c;
	n = runetochar(buf, &r);
	p = nil;
	while(s = strstr(s, buf)){
		p = s;
		s += n;
	}
	return p;
}