scanclrmake/src/util.cxx
// ==========================================================================
// Trim whitespace from the beginning and end of s.
//
Trim whitespace from the beginning and end of s.
Trim whitespace from the beginning and end of s .
void trim(string &s)
{
    string::size_type sz = s.size();
    string::size_type first_nonspace = string::npos;
    string::size_type after_last_nonspace = 0;
    for (int i = 0; i < sz; i += 1) {
	if (!isspace(s.at(i))) {
	    after_last_nonspace = i + 1;
	    if (i < first_nonspace) {
		first_nonspace = i;
	    }
	}
    }
    s.erase(after_last_nonspace, sz - after_last_nonspace);
    if (first_nonspace != string::npos) {
	s.erase(0, first_nonspace);
    }
}
void trim ( string & s ) { string :: size_type sz = s . size ( ) ; string :: size_type first_nonspace = string :: npos ; string :: size_type after_last_nonspace = 0 ; for ( int i = 0 ; i < sz ; i += 1 ) { if ( ! isspace ( s . at ( i ) ) ) { after_last_nonspace = i + 1 ; if ( i < first_nonspace ) { first_nonspace = i ; } } } s . erase ( after_last_nonspace , sz - after_last_nonspace ) ; if ( first_nonspace != string :: npos ) { s . erase ( 0 , first_nonspace ) ; } }
Trim whitespace from the beginning and end of s.
Trim whitespace from the beginning and end of s .