summaryrefslogtreecommitdiffstats
path: root/Source/cmSystemTools.cxx
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-11-11 05:00:35 (GMT)
committerPeter Collingbourne <peter@pcc.me.uk>2012-02-02 23:04:38 (GMT)
commit2cd36550b073fd4f559f7edc5a5170af534f1068 (patch)
tree95d4cdfc97909ca66b2e58095bdda74848801f5e /Source/cmSystemTools.cxx
parente8584401852a871b6cda57e570b7bb04b6dacf74 (diff)
downloadCMake-2cd36550b073fd4f559f7edc5a5170af534f1068.zip
CMake-2cd36550b073fd4f559f7edc5a5170af534f1068.tar.gz
CMake-2cd36550b073fd4f559f7edc5a5170af534f1068.tar.bz2
Add cmSystemTools::TrimWhitespace function
Diffstat (limited to 'Source/cmSystemTools.cxx')
-rw-r--r--Source/cmSystemTools.cxx14
1 files changed, 14 insertions, 0 deletions
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 02060ca..3e927cf 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -196,6 +196,20 @@ std::string cmSystemTools::EscapeQuotes(const char* str)
return result;
}
+std::string cmSystemTools::TrimWhitespace(const std::string& s)
+{
+ std::string::const_iterator start = s.begin();
+ while(start != s.end() && *start == ' ')
+ ++start;
+ if (start == s.end())
+ return "";
+
+ std::string::const_iterator stop = s.end()-1;
+ while(*stop == ' ')
+ --stop;
+ return std::string(start, stop+1);
+}
+
void cmSystemTools::Error(const char* m1, const char* m2,
const char* m3, const char* m4)
{