mirror of
https://github.com/Relintai/sdl2_frt.git
synced 2025-01-12 05:41:10 +01:00
WIN_SetErrorFromHRESULT: kill CR/LF that FormatMessage sticks at the end
Fixes: https://github.com/libsdl-org/SDL_mixer/issues/320
This commit is contained in:
parent
8fb95034e8
commit
3da6d2cdde
@ -44,8 +44,17 @@ WIN_SetErrorFromHRESULT(const char *prefix, HRESULT hr)
|
|||||||
{
|
{
|
||||||
TCHAR buffer[1024];
|
TCHAR buffer[1024];
|
||||||
char *message;
|
char *message;
|
||||||
|
TCHAR *p = buffer;
|
||||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0,
|
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, hr, 0,
|
||||||
buffer, SDL_arraysize(buffer), NULL);
|
buffer, SDL_arraysize(buffer), NULL);
|
||||||
|
/* kill CR/LF that FormatMessage() sticks at the end */
|
||||||
|
while (*p) {
|
||||||
|
if (*p == '\r') {
|
||||||
|
*p = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++p;
|
||||||
|
}
|
||||||
message = WIN_StringToUTF8(buffer);
|
message = WIN_StringToUTF8(buffer);
|
||||||
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
|
SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
|
||||||
SDL_free(message);
|
SDL_free(message);
|
||||||
|
Loading…
Reference in New Issue
Block a user