diff options
Diffstat (limited to 'strncasestr.c')
-rw-r--r-- | strncasestr.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/strncasestr.c b/strncasestr.c new file mode 100644 index 0000000..cd7fd8a --- /dev/null +++ b/strncasestr.c @@ -0,0 +1,17 @@ +/* See LICENSE file for copyright and license details. */ +#include "libsimple.h" + + +char * +libsimple_strncasestr(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 (!strncasecmp(h, n, nn)) + return h; + return NULL; +} |