From 6448b31b11f54cf46a81a6651ff5f15ab6b06656 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 18 Jul 2018 15:59:41 +0200 Subject: [PATCH] util/StringAPI: add strpbrk() wrapper --- src/util/StringAPI.hxx | 7 +++++++ src/util/WStringAPI.hxx | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/util/StringAPI.hxx b/src/util/StringAPI.hxx index b94a4566f..febaabbc7 100644 --- a/src/util/StringAPI.hxx +++ b/src/util/StringAPI.hxx @@ -94,6 +94,13 @@ StringFindLast(char *haystack, char needle) noexcept return strrchr(haystack, needle); } +gcc_pure gcc_nonnull_all +static inline const char * +StringFindAny(const char *haystack, const char *accept) noexcept +{ + return strpbrk(haystack, accept); +} + static inline char * StringToken(char *str, const char *delim) noexcept { diff --git a/src/util/WStringAPI.hxx b/src/util/WStringAPI.hxx index 6e3aa204d..efe8205ea 100644 --- a/src/util/WStringAPI.hxx +++ b/src/util/WStringAPI.hxx @@ -90,6 +90,13 @@ StringFindLast(wchar_t *haystack, wchar_t needle) noexcept return wcsrchr(haystack, needle); } +gcc_pure gcc_nonnull_all +static inline const wchar_t * +StringFindAny(const wchar_t *haystack, const wchar_t *accept) noexcept +{ + return wcspbrk(haystack, accept); +} + gcc_nonnull_all static inline void UnsafeCopyString(wchar_t *dest, const wchar_t *src) noexcept