summaryrefslogtreecommitdiff
path: root/lib/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/string.c')
-rw-r--r--lib/string.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/string.c b/lib/string.c
index e660de079a57..d2f23f2c1e69 100644
--- a/lib/string.c
+++ b/lib/string.c
@@ -273,6 +273,22 @@ char * strrchr(const char * s, int c)
}
#endif
+#ifndef __HAVE_ARCH_STRNCHR
+/**
+ * strnchr - Find a character in a length limited string
+ * @s: The string to be searched
+ * @count: The number of characters to be searched
+ * @c: The character to search for
+ */
+char *strnchr(const char *s, size_t count, int c)
+{
+ for (; count-- && *s != '\0'; ++s)
+ if (*s == (char) c)
+ return (char *) s;
+ return NULL;
+}
+#endif
+
#ifndef __HAVE_ARCH_STRLEN
/**
* strlen - Find the length of a string