From fba88859e1646e821e3b61700a02fe8c37ba324d Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 14 Jan 2017 01:27:55 +0000 Subject: [PATCH] Normalize CRLF newlines to LF when loading string resources. --- src/resource.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/resource.cpp b/src/resource.cpp index 423ae89..0b0319e 100644 --- a/src/resource.cpp +++ b/src/resource.cpp @@ -17,7 +17,15 @@ namespace SolveSpace { std::string LoadString(const std::string &name) { size_t size; const void *data = LoadResource(name, &size); - return std::string(static_cast(data), size); + std::string result(static_cast(data), size); + + // When editing resources under Windows, Windows newlines may sneak in. + // Any files with them won't be merged, but ignoring them during development + // helps external contributors. + result.erase(std::remove(result.begin(), result.end(), '\r'), + result.end()); + + return result; } std::string LoadStringFromGzip(const std::string &name) {