summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/libutil.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-14 18:14:26 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-14 18:14:26 +0000
commit9fc1df65621c76cb9edbb781df61fabb21f61342 (patch)
treef6d2e8a707dc19ce7d99496f85652908a4e0f72a /crawl-ref/source/libutil.cc
parent6a4da2697718db5497d17b552c11448ee47ef52a (diff)
downloadcrawl-ref-9fc1df65621c76cb9edbb781df61fabb21f61342.tar.gz
crawl-ref-9fc1df65621c76cb9edbb781df61fabb21f61342.zip
Remember choice of Beogh in character selection.
Some code reindenting and housekeeping. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1587 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/libutil.cc')
-rw-r--r--crawl-ref/source/libutil.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/crawl-ref/source/libutil.cc b/crawl-ref/source/libutil.cc
index bee74bab03..27d28e6e7a 100644
--- a/crawl-ref/source/libutil.cc
+++ b/crawl-ref/source/libutil.cc
@@ -180,17 +180,24 @@ std::string make_stringf(const char *s, ...)
return (buf);
}
-void uppercase(std::string &s)
+std::string &uppercase(std::string &s)
{
- /* yes, this is bad, but std::transform() has its own problems */
- for (unsigned int i = 0; i < s.size(); ++i)
+ for (unsigned i = 0, sz = s.size(); i < sz; ++i)
s[i] = toupper(s[i]);
+ return (s);
}
-void lowercase(std::string &s)
+std::string &lowercase(std::string &s)
{
- for (unsigned int i = 0; i < s.size(); ++i)
+ for (unsigned i = 0, sz = s.size(); i < sz; ++i)
s[i] = tolower(s[i]);
+ return (s);
+}
+
+std::string lowercase_string(std::string s)
+{
+ lowercase(s);
+ return (s);
}
bool ends_with(const std::string &s, const std::string &suffix)
@@ -461,7 +468,7 @@ std::string trimmed_string( std::string s )
}
// also used with macros
-std::string & trim_string( std::string &str )
+std::string &trim_string( std::string &str )
{
str.erase( 0, str.find_first_not_of( " \t\n\r" ) );
str.erase( str.find_last_not_of( " \t\n\r" ) + 1 );