aboutsummaryrefslogtreecommitdiffstats
path: root/src/util/StringUtil.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/StringUtil.cxx')
-rw-r--r--src/util/StringUtil.cxx15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/util/StringUtil.cxx b/src/util/StringUtil.cxx
index 4d538989f..107354b6e 100644
--- a/src/util/StringUtil.cxx
+++ b/src/util/StringUtil.cxx
@@ -96,6 +96,21 @@ StringEndsWith(const char *haystack, const char *needle)
needle, needle_length) == 0;
}
+const char *
+FindStringSuffix(const char *p, const char *suffix)
+{
+ const size_t p_length = strlen(p);
+ const size_t suffix_length = strlen(suffix);
+
+ if (p_length < suffix_length)
+ return nullptr;
+
+ const char *q = p + p_length - suffix_length;
+ return memcmp(q, suffix, suffix_length) == 0
+ ? q
+ : nullptr;
+}
+
char *
CopyString(char *gcc_restrict dest, const char *gcc_restrict src, size_t size)
{