aboutsummaryrefslogtreecommitdiff
path: root/src/userspace/libc/string/strstr.c
blob: c87f3fcbaccfa555b230974f3d342b5a411e2642 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <stdint.h>
#include <string.h>

char *strstr(char *in, char *str)
{
	char c;
	u32 len;

	c = *str++;
	if (!c)
		return (char *)in;

	len = strlen(str);
	do {
		char sc;

		do {
			sc = *in++;
			if (!sc)
				return (char *)0;
		} while (sc != c);
	} while (strncmp(in, str, len) != 0);

	return (char *)(in - 1);
}