diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-10 08:32:25 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2006-12-10 08:32:25 +0000 |
commit | 16c8c1117fda477278eaf4983d93df1fa83e603a (patch) | |
tree | 5d4ce9f6f49c7a7881f776223cdc2bb114a898a9 /crawl-ref/source/libutil.cc | |
parent | 4ac70419ee6014d865b26f38d9c3a4fa08bdb2c2 (diff) | |
download | crawl-ref-16c8c1117fda477278eaf4983d93df1fa83e603a.tar.gz crawl-ref-16c8c1117fda477278eaf4983d93df1fa83e603a.zip |
Allow spaces, dashes and periods in character names.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@607 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/libutil.cc')
-rw-r--r-- | crawl-ref/source/libutil.cc | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc index 30bfc1b32c..181dd180bf 100644 --- a/crawl-ref/source/libutil.cc +++ b/crawl-ref/source/libutil.cc @@ -70,6 +70,11 @@ void play_sound( const char *file ) #endif } +std::string strip_filename_unsafe_chars(const std::string &s) +{ + return replace_all_of(s, " .", ""); +} + std::string make_stringf(const char *s, ...) { va_list args; @@ -96,7 +101,7 @@ void lowercase(std::string &s) s[i] = tolower(s[i]); } -std::string replace_all(std::string s, +std::string replace_all_of(std::string s, const std::string &tofind, const std::string &replacement) { @@ -105,7 +110,7 @@ std::string replace_all(std::string s, while ((found = s.find_first_of(tofind, start)) != std::string::npos) { - s.replace( found, tofind.length(), replacement ); + s.replace( found, 1, replacement ); start = found + replacement.length(); } |