diff options
author | sghctoma <sghctoma@gmail.com> | 2018-09-03 08:57:17 +0200 |
---|---|---|
committer | sghctoma <sghctoma@gmail.com> | 2018-09-03 08:57:17 +0200 |
commit | df730a88919b078093dbc322926ada219a60d036 (patch) | |
tree | f2837f24092c7be5dfccdf448e47062cb5718549 /common | |
parent | 67188b7cba2a985926647e049ed32c72b6ee98c8 (diff) | |
parent | c9276f04c9fae7a211164003bc9cb8b4369db5fd (diff) |
Merge remote-tracking branch 'upstream/master' into fix-freebsd-build
Diffstat (limited to 'common')
-rw-r--r-- | common/stringop.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/common/stringop.c b/common/stringop.c index d9ae9925..d2c91c24 100644 --- a/common/stringop.c +++ b/common/stringop.c @@ -401,3 +401,17 @@ char *argsep(char **stringp, const char *delim) { found: return start; } + +const char *strcasestr(const char *haystack, const char *needle) { + size_t needle_len = strlen(needle); + const char *pos = haystack; + const char *end = pos + strlen(haystack) - needle_len; + + while (pos <= end) { + if (strncasecmp(pos, needle, needle_len) == 0) { + return pos; + } + ++pos; + } + return NULL; +} |