aboutsummaryrefslogtreecommitdiffstats
path: root/src/string
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2015-11-19 05:54:05 +0100
committerMattias Andrée <maandree@operamail.com>2015-11-19 05:54:05 +0100
commit6a752bd9a145cf3443a7b16fa7614bd7a214c92a (patch)
treefb96ba37bc2fc6b8215e055f0185c91a0b902eae /src/string
parentreorder new functions (diff)
downloadslibc-6a752bd9a145cf3443a7b16fa7614bd7a214c92a.tar.gz
slibc-6a752bd9a145cf3443a7b16fa7614bd7a214c92a.tar.bz2
slibc-6a752bd9a145cf3443a7b16fa7614bd7a214c92a.tar.xz
doc
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/string')
-rw-r--r--src/string/new.c34
1 files changed, 32 insertions, 2 deletions
diff --git a/src/string/new.c b/src/string/new.c
index f407cb3..50b47cf 100644
--- a/src/string/new.c
+++ b/src/string/new.c
@@ -86,7 +86,21 @@ size_t strstrnlen(const char* string, const char* stop, size_t maxlen)
return end ? (size_t)(end - string) : maxlen;
}
-char* (strnchr)(const char* string, int c, size_t maxlen) /* slibc: completeness */
+/**
+ * Variant of `strchr` that only inspects the beginning
+ * of a string.
+ *
+ * This is a slibc extension added for completeness.
+ *
+ * @param string The string to search.
+ * The terminating NUL character is
+ * considered a part of the string.
+ * @param c The sought after character.
+ * @param maxlen The number of bytes to inspect, at most.
+ * @return Pointer to the first occurrence of `c`,
+ * `NULL` if none were found.
+ */
+char* (strnchr)(const char* string, int c, size_t maxlen)
{
for (;;)
if (*string == c)
@@ -95,7 +109,23 @@ char* (strnchr)(const char* string, int c, size_t maxlen) /* slibc: completeness
return NULL;
}
-char* (strnchrnul)(const char* string, int c, size_t maxlen) /* slibc+gnu: completeness */
+/**
+ * Variant of `strchrnul` that only inspects the beginning
+ * of a string.
+ *
+ * This is a slibc extension added for completeness.
+ *
+ * @param string The string to search.
+ * The terminating NUL character is
+ * considered a part of the string.
+ * @param c The sought after character.
+ * @param maxlen The number of bytes to inspect, at most.
+ * @return The end of the string (or end of inspected
+ * part of the sring) if non were found. If the
+ * whole string was inspected, the returned
+ * pointer will point to a NUL byte.
+ */
+char* (strnchrnul)(const char* string, int c, size_t maxlen)
{
for (;; string++)
if (*string == c)