1 #include <u.h> 2 #include <libc.h> 3 4 /* 5 * Return pointer to first occurrence of s2 in s1, 6 * 0 if none 7 */ 8 Rune* runestrstr(Rune * s1,Rune * s2)9runestrstr(Rune *s1, Rune *s2) 10 { 11 Rune *p, *pa, *pb; 12 int c0, c; 13 14 c0 = *s2; 15 if(c0 == 0) 16 return s1; 17 s2++; 18 for(p=runestrchr(s1, c0); p; p=runestrchr(p+1, c0)) { 19 pa = p; 20 for(pb=s2;; pb++) { 21 c = *pb; 22 if(c == 0) 23 return p; 24 if(c != *++pa) 25 break; 26 } 27 } 28 return 0; 29 } 30