diff options
author | Simon Glass <sjg@chromium.org> | 2017-05-18 20:09:28 -0600 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2017-06-01 07:03:12 -0600 |
commit | 6b45ba45fbcd1acc11c88ee1c15ed5fcb49f9e32 (patch) | |
tree | b4f0c569dbbe93e4723f2add9e26ae48a232c3fc /lib/string.c | |
parent | a4b8e372d5b15d7dd302cac667e87049b59b13c7 (diff) | |
download | u-boot-6b45ba45fbcd1acc11c88ee1c15ed5fcb49f9e32.tar.gz u-boot-6b45ba45fbcd1acc11c88ee1c15ed5fcb49f9e32.tar.bz2 u-boot-6b45ba45fbcd1acc11c88ee1c15ed5fcb49f9e32.zip |
string: Add strchrnul()
This functions works like strchr() but returns the end of the string if
the character is not found. Add an implementation of this.
Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'lib/string.c')
-rw-r--r-- | lib/string.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c index e94021c468..e6e749b80b 100644 --- a/lib/string.c +++ b/lib/string.c @@ -230,6 +230,14 @@ char * strchr(const char * s, int c) } #endif +const char *strchrnul(const char *s, int c) +{ + for (; *s != (char)c; ++s) + if (*s == '\0') + break; + return s; +} + #ifndef __HAVE_ARCH_STRRCHR /** * strrchr - Find the last occurrence of a character in a string |