summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/dietlibc/lib/strstr.c
blob: 641d9d7aca230722aed22bf4b4b45810ccad954f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <sys/types.h>
#include <string.h>

char *strstr(const char *haystack, const char *needle) {
  int nl=strlen(needle);
  int hl=strlen(haystack);
  int i;
  if (nl>hl) return 0;
  for (i=hl-nl+1; i; --i) {
    if (!memcmp(haystack,needle,nl))
      return (char*)haystack;
    ++haystack;
  }
  return 0;
}