aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/string/new.c34
-rw-r--r--src/wchar/new.c2
2 files changed, 33 insertions, 3 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)
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)