ci_environment/src/env_lib.cxx
// Value returned has leading and trailing whitespace removed.
Value returned has leading and trailing whitespace removed.
Value returned has leading and trailing whitespace removed .
string trimmed(const string &s) {
    int len = s.length();
    int leading_white = 0;
    int trailing_white = 0;
    for (int i = 0; i < len; i += 1) {
	if (isspace(s[i])) {
	    if (leading_white == i) {
		leading_white += 1;
	    }
	}
	else {
	    trailing_white = i + 1;
	}
    }
    if (trailing_white < leading_white) {
	return "";
    }
    else {
	return s.substr(leading_white, trailing_white - leading_white);
    }
}
string trimmed ( const string & s ) { int len = s . length ( ) ; int leading_white = 0 ; int trailing_white = 0 ; for ( int i = 0 ; i < len ; i += 1 ) { if ( isspace ( s [ i ] ) ) { if ( leading_white == i ) { leading_white += 1 ; } } else { trailing_white = i + 1 ; } } if ( trailing_white < leading_white ) { return " " ; } else { return s . substr ( leading_white , trailing_white - leading_white ) ; } }
Value returned has leading and trailing whitespace removed.
Value returned has leading and trailing whitespace removed .
// Leading_white is the number of leading whitespace bytes. // Trailing_white is the offset where trailing whitespace begins. // If the string is all whitespace, then the leading and trailing overlap.