From 6a752bd9a145cf3443a7b16fa7614bd7a214c92a Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Thu, 19 Nov 2015 05:54:05 +0100 Subject: doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/string/new.c | 34 ++++++++++++++++++++++++++++++++-- src/wchar/new.c | 2 +- 2 files changed, 33 insertions(+), 3 deletions(-) (limited to 'src') 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) diff --git a/src/wchar/new.c b/src/wchar/new.c index 5e8914d..e1d9c52 100644 --- a/src/wchar/new.c +++ b/src/wchar/new.c @@ -51,7 +51,7 @@ wchar_t* (wcsnchr)(const wchar_t* string, wchar_t c, size_t maxlen) /* slibc: co return NULL; } -wchar_t* (wcsnchrnul)(const wchar_t* string, wchar_t c, size_t maxlen) /* slibc+gnu: completeness */ +wchar_t* (wcsnchrnul)(const wchar_t* string, wchar_t c, size_t maxlen) /* slibc: completeness */ { for (;; string++) if (*string == c) -- cgit v1.2.3-70-g09d2