From 4c5ce7e037cec0cd633e1f0648e3c9f5c928ae1d Mon Sep 17 00:00:00 2001 From: Dwayne Boone Date: Wed, 13 Feb 2008 16:06:44 -0330 Subject: minor change to trim --- cpp/src/IceUtil/StringUtil.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'cpp/src/IceUtil/StringUtil.cpp') diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp index 2d56cf06a93..e087e5586dc 100644 --- a/cpp/src/IceUtil/StringUtil.cpp +++ b/cpp/src/IceUtil/StringUtil.cpp @@ -371,13 +371,15 @@ string IceUtilInternal::trim(const string& s) { static const string delim = " \t\r\n"; - if(s.length() != 0) + string::size_type beg = s.find_first_not_of(delim); + if(beg == string::npos) { - string::size_type beg = s.find_first_not_of(delim); - string::size_type end = s.find_last_not_of(delim); - return s.substr(beg, end - beg + 1); + return ""; + } + else + { + return s.substr(beg, s.find_last_not_of(delim) - beg + 1); } - return s; } // -- cgit v1.2.3