From b3c244eb6488d254183d7e41c5084a3cbf573548 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Tue, 1 Sep 2015 06:41:47 +0200 Subject: add strspn functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- include/string.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'include/string.h') diff --git a/include/string.h b/include/string.h index 8034973..676a721 100644 --- a/include/string.h +++ b/include/string.h @@ -973,6 +973,46 @@ void* memmem(const void*, size_t, const void*, size_t) /* TODO Add case right-to-left substring searching functions. */ +/** + * Returns length of the initial substring + * that consists entirely of a set of specified + * bytes. + * + * @param string The string. + * @param skipset Bytes allowed in the substring. + * @return The length of the substring. + */ +size_t strspn(const char*, const char*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull))); + +/** + * Returns length of the initial substring + * that consists entirely of the complement + * of a set of specified bytes. + * + * @param string The string. + * @param stopset Bytes disallowed in the substring. + * @return The length of the substring. + */ +size_t strcspn(const char*, const char*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull))); + +/** + * This function works like `strcspn`, + * except it returns the pointer to the + * location of the first found non-matching + * byte. + * + * @param string The string. + * @param stopset Bytes disallowed in the substring. + * @return A pointer to the first occurrence in + * `string` of a byte found in `stopset`. + * `NULL` is returned if none is found. + */ +char* stpbrk(const char*, const char*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull))); + + #endif -- cgit v1.2.3-70-g09d2