From 5554865ebb2c260e8d59161cde97580b88eb97ab Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Mon, 14 Oct 2013 23:54:25 -0700 Subject: [PATCH] Fix headless auto-compare when expected have \r's. --- headless/Compare.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/headless/Compare.cpp b/headless/Compare.cpp index c5f1710f4..9fb430eb1 100644 --- a/headless/Compare.cpp +++ b/headless/Compare.cpp @@ -53,7 +53,7 @@ struct BufferedLineReader { void Fill() { while (valid_ < MAX_BUFFER && HasMoreLines()) { - buffer_[valid_++] = ReadLine(); + buffer_[valid_++] = TrimNewlines(ReadLine()); } } @@ -128,6 +128,14 @@ protected: } } + static std::string TrimNewlines(const std::string &s) { + size_t p = s.find_last_not_of("\r\n"); + if (p == s.npos) { + return ""; + } + return s.substr(0, p + 1); + } + int valid_; std::string buffer_[MAX_BUFFER]; const std::string data_;