From 9fc1df65621c76cb9edbb781df61fabb21f61342 Mon Sep 17 00:00:00 2001 From: dshaligram Date: Thu, 14 Jun 2007 18:14:26 +0000 Subject: 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 --- crawl-ref/source/libutil.cc | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'crawl-ref/source/libutil.cc') 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 ); -- cgit v1.2.3-54-g00ecf