Remove last CR.

This commit is contained in:
Chao Shen 2018-02-01 17:12:36 +08:00
parent 490f52205f
commit 5b6945d909

View File

@ -52,6 +52,10 @@ std::string Trim(std::string s) {
TrimInPlace(s); TrimInPlace(s);
return s; return s;
} }
void RemoveLastCR(std::string& s) {
if (!s.empty() && *s.rbegin() == '\r')
s.pop_back();
}
uint64_t HashUsr(const std::string& s) { uint64_t HashUsr(const std::string& s) {
return HashUsr(s.c_str(), s.size()); return HashUsr(s.c_str(), s.size());
@ -334,6 +338,8 @@ std::vector<std::string> ToLines(const std::string& content,
while (getline(lines, line)) { while (getline(lines, line)) {
if (trim_whitespace) if (trim_whitespace)
TrimInPlace(line); TrimInPlace(line);
else
RemoveLastCR(line);
result.push_back(line); result.push_back(line);
} }