diff options
Diffstat (limited to 'strnstr.c')
-rw-r--r-- | strnstr.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/strnstr.c b/strnstr.c new file mode 100644 index 0000000..df8708b --- /dev/null +++ b/strnstr.c @@ -0,0 +1,17 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" + + +char * +libsimple_strnstr(const char *h_, const char *n, size_t len) +{ + char *h = *(char **)(void *)&h_; + size_t nn = strlen(n); + nn = MIN(nn, len); + if (!nn) + return h; + for (; *h && len--; h++) + if (!strncmp(h, n, nn)) + return h; + return NULL; +} |