blob: a6cd9b465f3b26f2b46b7cef23ce1bab3e592d16 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
/* ISC license. */
#include <skalibs/sysdeps.h>
#ifdef SKALIBS_HASSTRCASESTR
#include <skalibs/nonposix.h>
#include <string.h>
#include <skalibs/bytestr.h>
size_t case_str (char const *haystack, char const *needle)
{
register char *p = strcasestr(haystack, needle) ;
return p ? p - haystack : strlen(haystack) ;
}
#else
#include <sys/types.h>
#include <string.h>
#include <skalibs/bytestr.h>
size_t case_str (char const *haystack, char const *needle)
{
size_t nlen = strlen(needle) ;
char const *p = haystack ;
if (!nlen) return 0 ;
for (; *p ; p++)
if (!case_diffb(p, nlen, needle)) return p - haystack ;
return strlen(haystack) ;
}
#endif
|