From d0349880da4538efe4b792c1522f4c54ab897046 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 29 Oct 2018 14:21:58 +0100 Subject: [PATCH] util/StringCompare: add StringAfterPrefixIgnoreCase() --- src/util/StringCompare.hxx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/util/StringCompare.hxx b/src/util/StringCompare.hxx index 3a3184cd1..8ae7b0de2 100644 --- a/src/util/StringCompare.hxx +++ b/src/util/StringCompare.hxx @@ -81,6 +81,15 @@ StringStartsWithIgnoreCase(const char *haystack, StringView needle) noexcept return StringIsEqualIgnoreCase(haystack, needle.data, needle.size); } +gcc_pure gcc_nonnull_all +static inline const char * +StringAfterPrefixIgnoreCase(const char *haystack, StringView needle) noexcept +{ + return StringStartsWithIgnoreCase(haystack, needle) + ? haystack + needle.size + : nullptr; +} + /** * Check if the given string ends with the specified suffix. If yes, * returns the position of the suffix, and nullptr otherwise.