summaryrefslogtreecommitdiff
path: root/src/util/WStringAPI.hxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2019-09-07 23:59:59 +0200
committerMax Kellermann <max@musicpd.org>2019-09-07 23:59:59 +0200
commit0b956cf9682da48174c0fa1dc415a48bdc0d8160 (patch)
tree13eccd2533f0d875f0a56f32b93aa24ef19ee5eb /src/util/WStringAPI.hxx
parent2c3eb5b8adf9482a2f30e94ac37437470993a41b (diff)
util/StringAPI: add memrchr() wrapper
Diffstat (limited to 'src/util/WStringAPI.hxx')
-rw-r--r--src/util/WStringAPI.hxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util/WStringAPI.hxx b/src/util/WStringAPI.hxx
index 58bc24c87..82864a9a5 100644
--- a/src/util/WStringAPI.hxx
+++ b/src/util/WStringAPI.hxx
@@ -92,6 +92,21 @@ StringFindLast(wchar_t *haystack, wchar_t needle) noexcept
gcc_pure gcc_nonnull_all
static inline const wchar_t *
+StringFindLast(const wchar_t *haystack, wchar_t needle, size_t size) noexcept
+{
+ /* there's no wmemrchr() unfortunately */
+ const auto *p = haystack + size;
+ while (p > haystack) {
+ --p;
+ if (*p == needle)
+ return p;
+ }
+
+ return nullptr;
+}
+
+gcc_pure gcc_nonnull_all
+static inline const wchar_t *
StringFindAny(const wchar_t *haystack, const wchar_t *accept) noexcept
{
return wcspbrk(haystack, accept);