1
0
mirror of git://sigrok.org/libserialport synced 2023-08-10 21:13:24 +03:00

windows: Strip CR/LF from end of system error messages.

This fixes bug #585.
This commit is contained in:
Martin Ling 2015-05-06 16:12:27 +01:00 committed by Uwe Hermann
parent 480d750c59
commit 9a0c4bbdbe

View File

@ -2287,10 +2287,10 @@ SP_API char *sp_last_error_message(void)
TRACE_VOID(); TRACE_VOID();
#ifdef _WIN32 #ifdef _WIN32
LPVOID message; TCHAR *message;
DWORD error = GetLastError(); DWORD error = GetLastError();
FormatMessage( DWORD length = FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, FORMAT_MESSAGE_IGNORE_INSERTS,
@ -2300,6 +2300,9 @@ SP_API char *sp_last_error_message(void)
(LPTSTR) &message, (LPTSTR) &message,
0, NULL ); 0, NULL );
if (length >= 2 && message[length - 2] == '\r')
message[length - 2] = '\0';
RETURN_STRING(message); RETURN_STRING(message);
#else #else
RETURN_STRING(strerror(errno)); RETURN_STRING(strerror(errno));