From 803acbc5efde19c0acacfc7fe4990841dbf31a3e Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Mon, 30 Jan 2012 10:14:10 -0500
Subject: [PATCH] Trim trailing "\r\n" from Windows FormatMessage() string for
 logging.

---
 indra/llcommon/llprocess.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/indra/llcommon/llprocess.cpp b/indra/llcommon/llprocess.cpp
index 2b7a534fb34..8c0e8fe65e5 100644
--- a/indra/llcommon/llprocess.cpp
+++ b/indra/llcommon/llprocess.cpp
@@ -261,11 +261,15 @@ static std::string WindowsErrorString(const std::string& operation)
 					   NULL)
 		!= 0) 
 	{
+        // convert from wide-char string to multi-byte string
 		char message[256];
 		wcstombs(message, error_str, sizeof(message));
 		message[sizeof(message)-1] = 0;
 		LocalFree(error_str);
-		return STRINGIZE(operation << " failed (" << result << "): " << message);
+		// convert to std::string to trim trailing whitespace
+		std::string mbsstr(message);
+		mbsstr.erase(mbsstr.find_last_not_of(" \t\r\n"));
+		return STRINGIZE(operation << " failed (" << result << "): " << mbsstr);
 	}
 	return STRINGIZE(operation << " failed (" << result
 					 << "), but FormatMessage() did not explain");
-- 
GitLab