@@ -116,6 +116,20 @@ bool Services_Common::GetControl(
116116 return found;
117117}
118118
119+ static std::string trim (const std::string& str)
120+ {
121+ const std::string whitespace (" \t " );
122+ const auto start = str.find_first_not_of (whitespace);
123+ const auto end = str.find_last_not_of (whitespace);
124+
125+ if ( start == std::string::npos || end == std::string::npos )
126+ {
127+ return " " ;
128+ }
129+
130+ return str.substr (start, end - start + 1 );
131+ }
132+
119133bool Services_Common::GetControlFromFile (
120134 const std::string& fileName,
121135 const std::string& controlName,
@@ -151,11 +165,9 @@ bool Services_Common::GetControlFromFile(
151165 size_t pos = s.find (' =' );
152166 if ( pos != std::string::npos )
153167 {
154- std::string var = s.substr ( 0 , pos );
155- var.erase (std::remove_if (var.begin (), var.end (), ::isspace), var.end ());
156-
157- std::string value = s.substr ( pos + 1 );
158- value.erase (std::remove_if (value.begin (), value.end (), ::isspace), value.end ());
168+ const std::string whitespace (" \t " );
169+ std::string var = trim (s.substr ( 0 , pos ));
170+ std::string value = trim (s.substr ( pos + 1 ));
159171
160172 if ( var == controlName )
161173 {
0 commit comments