Improve oneline.

GitOrigin-RevId: 6cec8e407f0f5eedb367aea25864033a69e1d1e5
This commit is contained in:
levlam 2020-10-22 12:09:32 +03:00
parent f9009cbc01
commit 1ad0b068cd

View File

@ -48,7 +48,7 @@ string oneline(Slice str) {
result.reserve(str.size());
bool after_new_line = true;
for (auto c : str) {
if (c != '\n') {
if (c != '\n' && c != '\r') {
if (after_new_line) {
if (c == ' ') {
continue;
@ -56,7 +56,7 @@ string oneline(Slice str) {
after_new_line = false;
}
result += c;
} else {
} else if (!after_new_line) {
after_new_line = true;
result += ' ';
}