summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/libutil.cc
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/libutil.cc')
-rw-r--r--crawl-ref/source/libutil.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc
index a2fa623530..6bf33921ba 100644
--- a/crawl-ref/source/libutil.cc
+++ b/crawl-ref/source/libutil.cc
@@ -193,6 +193,25 @@ void lowercase(std::string &s)
s[i] = tolower(s[i]);
}
+bool ends_with(const std::string &s, const std::string &suffix)
+{
+ if (s.length() < suffix.length())
+ return false;
+ return (s.substr(s.length() - suffix.length()) == suffix);
+}
+
+int ends_with(const std::string &s, const char *suffixes[])
+{
+ if (!suffixes)
+ return (0);
+ for (int i = 0; suffixes[i]; ++i)
+ {
+ if (ends_with(s, suffixes[i]))
+ return (1 + i);
+ }
+ return (0);
+}
+
std::string replace_all(std::string s,
const std::string &find,
const std::string &repl)