---
 Source/kwsys/SystemTools.cxx    |   15 +++++++++++++++
 Source/kwsys/SystemTools.hxx.in |    5 +++++
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 1bf19c0..c14eb38 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -1195,6 +1195,21 @@ kwsys_stl::string SystemTools::UpperCase(const 
kwsys_stl::string& s)
   return n;
 }
 
+// Returns a string that has whitespace removed from the start and the end.
+kwsys_stl::string SystemTools::TrimWhitespace(const kwsys_stl::string& s)
+{
+  kwsys_stl::string::const_iterator start = s.begin();
+  while(start != s.end() && *start == ' ')
+    ++start;
+  if (start == s.end())
+    return "";
+
+  kwsys_stl::string::const_iterator stop = s.end()-1;
+  while(*stop == ' ')
+    --stop;
+  return kwsys_stl::string(start, stop+1);
+}
+
 // Count char in string
 size_t SystemTools::CountChar(const char* str, char c)
 {
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index 04f1978..c03b8bc 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -129,6 +129,11 @@ public:
   static kwsys_stl::string UpperCase(const kwsys_stl::string&);
   
   /**
+   * Returns a string that has whitespace removed from the start and the end.
+   */
+  static kwsys_stl::string TrimWhitespace(const kwsys_stl::string& s);
+
+  /**
    * Count char in string
    */
   static size_t CountChar(const char* str, char c);
-- 
1.7.5.3

--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers

Reply via email to