diff options
author | Mattias Andrée <maandree@operamail.com> | 2015-09-01 06:41:47 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2015-09-01 06:41:47 +0200 |
commit | b3c244eb6488d254183d7e41c5084a3cbf573548 (patch) | |
tree | 4e1e0e648c7f1885f2af99993207f54409aceecd /include | |
parent | add strstr functions (diff) | |
download | slibc-b3c244eb6488d254183d7e41c5084a3cbf573548.tar.gz slibc-b3c244eb6488d254183d7e41c5084a3cbf573548.tar.bz2 slibc-b3c244eb6488d254183d7e41c5084a3cbf573548.tar.xz |
add strspn functions
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to '')
-rw-r--r-- | include/string.h | 40 | ||||
-rw-r--r-- | include/wchar.h | 40 |
2 files changed, 80 insertions, 0 deletions
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 diff --git a/include/wchar.h b/include/wchar.h index 16644c8..31e985d 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -938,6 +938,46 @@ wchar_t* wmemmem(const wchar_t*, size_t, const wchar_t*, 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 + * wide characters. + * + * @param string The string. + * @param skipset Characters allowed in the substring. + * @return The length of the substring. + */ +size_t wcsspn(const wchar_t*, const wchar_t*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull))); + +/** + * Returns length of the initial substring + * that consists entirely of the complement + * of a set of specified wide characters. + * + * @param string The string. + * @param stopset Characters disallowed in the substring. + * @return The length of the substring. + */ +size_t wcscspn(const wchar_t*, const wchar_t*) + __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 + * wide character. + * + * @param string The string. + * @param stopset Bytes disallowed in the substring. + * @return A pointer to the first occurrence in + * `string` of a character found in `stopset`. + * `NULL` is returned if none is found. + */ +wchar_t* wcpbrk(const wchar_t*, const wchar_t*) + __GCC_ONLY(__attribute__((warn_unused_result, nonnull))); + + #endif #endif |