Remove trailing whitespace
This commit is contained in:
parent
8d4268d190
commit
40608342cb
3 changed files with 5 additions and 5 deletions
|
@ -212,8 +212,7 @@ static std::string indent(std::string_view indentFirst, std::string_view indentR
|
|||
while (!s.empty()) {
|
||||
auto end = s.find('\n');
|
||||
if (!first) res += "\n";
|
||||
res += first ? indentFirst : indentRest;
|
||||
res += s.substr(0, end);
|
||||
res += chomp(std::string(first ? indentFirst : indentRest) + std::string(s.substr(0, end)));
|
||||
first = false;
|
||||
if (end == s.npos) break;
|
||||
s = s.substr(end + 1);
|
||||
|
|
|
@ -1249,7 +1249,7 @@ template StringSet tokenizeString(std::string_view s, const string & separators)
|
|||
template vector<string> tokenizeString(std::string_view s, const string & separators);
|
||||
|
||||
|
||||
string chomp(const string & s)
|
||||
string chomp(std::string_view s)
|
||||
{
|
||||
size_t i = s.find_last_not_of(" \n\r\t");
|
||||
return i == string::npos ? "" : string(s, 0, i + 1);
|
||||
|
|
|
@ -373,8 +373,9 @@ template<class C> Strings quoteStrings(const C & c)
|
|||
}
|
||||
|
||||
|
||||
/* Remove trailing whitespace from a string. */
|
||||
string chomp(const string & s);
|
||||
/* Remove trailing whitespace from a string. FIXME: return
|
||||
std::string_view. */
|
||||
string chomp(std::string_view s);
|
||||
|
||||
|
||||
/* Remove whitespace from the start and end of a string. */
|
||||
|
|
Loading…
Reference in a new issue