From c17463bcae75a9f9b7108807745ec7bb2d472514 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Sat, 12 Apr 2014 22:51:10 +0200 Subject: Filter out newlines from error messages on Windows --- src/socketengine.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/socketengine.cpp') diff --git a/src/socketengine.cpp b/src/socketengine.cpp index 8af598b06..4a9a2ef10 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -265,7 +265,13 @@ std::string SocketEngine::LastError() DWORD dwErrorCode = WSAGetLastError(); if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwErrorCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPSTR)szErrorString, _countof(szErrorString), NULL) == 0) sprintf_s(szErrorString, _countof(szErrorString), "Error code: %u", dwErrorCode); - return szErrorString; + + std::string::size_type p; + std::string ret = szErrorString; + while ((p = ret.find_last_of("\r\n")) != std::string::npos) + ret.erase(p, 1); + + return ret; #endif } -- cgit v1.2.3