source: trunk/sys/dietlibc/strstr.c @ 5

Last change on this file since 5 was 1, checked in by alain, 8 years ago

First import

File size: 352 bytes
RevLine 
[1]1#include <string.h>
2
3char *strstr(const char *haystack, const char *needle) {
4  size_t nl=strlen(needle);
5  size_t hl=strlen(haystack);
6  size_t i;
7  if (!nl) goto found;
8  if (nl>hl) return 0;
9  for (i=hl-nl+1; i; --i) {
10    if (*haystack==*needle && !memcmp(haystack,needle,nl))
11found:
12      return (char*)haystack;
13    ++haystack;
14  }
15  return 0;
16}
Note: See TracBrowser for help on using the repository browser.