diff options
author | Jes Klinke <jbk@google.com> | 2020-07-31 09:58:49 -0700 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2020-08-03 05:12:23 +0000 |
commit | 683ac6f204a8ae464a7f671b53084c99a0abce45 (patch) | |
tree | 01dbdfb4abc571a4f581a64f248a1e8b4d44baef /src/lib/string.c | |
parent | e968e3762e54b940d61e3fde9f9fba28e1bccc59 (diff) |
lib/string: Add standard strstr() function
Adding implementation of standard library strstr()
See https://review.coreboot.org/c/coreboot/+/43741 for context.
Change-Id: I63e26e98ed2dd15542f81c0a3a5e353bb93b7350
Signed-off-by: jbk@chromium.org
Reviewed-on: https://review.coreboot.org/c/coreboot/+/44085
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'src/lib/string.c')
-rw-r--r-- | src/lib/string.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/lib/string.c b/src/lib/string.c index e8f72a28e8..9677520137 100644 --- a/src/lib/string.c +++ b/src/lib/string.c @@ -163,6 +163,16 @@ int strcspn(const char *str, const char *spn) return ret; } +char *strstr(const char *haystack, const char *needle) +{ + size_t needle_len = strlen(needle); + for (; *haystack; haystack++) { + if (!strncmp(haystack, needle, needle_len)) + return (char *)haystack; + } + return NULL; +} + char *strtok_r(char *str, const char *delim, char **ptr) { char *start; |