diff options
Diffstat (limited to 'strcasestr.c')
-rw-r--r-- | strcasestr.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/strcasestr.c b/strcasestr.c index a3a98fc..4ffbde2 100644 --- a/strcasestr.c +++ b/strcasestr.c @@ -1,24 +1,24 @@ /* See LICENSE file for copyright and license details. */ #include "libsimple.h" +#ifndef TEST char * libsimple_strcasestr(const char *h_, const char *n) { char *h = *(char **)(void *)&h_; - size_t hn = strlen(h); size_t nn = strlen(n); - if (hn < nn) - return NULL; - for (hn -= nn; hn--; h++) - if (!strcasecmp(h, n)) + if (!nn) + return h; + for (; *h; h++) + if (!strncasecmp(h, n, nn)) return h; return NULL; } -#ifdef TEST -#include <assert.h> +#else +#include "test.h" int main(void) |