Skip to content

Commit

Permalink
Fixed bug 3323 - SDL_LogOutput prints message twice on Windows when l…
Browse files Browse the repository at this point in the history
…inked with libc

Simon Hug

If SDL2 is compiled with HAVE_LIBC on Windows, the SDL_LogOutput function has two ways of printing a message. WriteConsole and fprintf.
  • Loading branch information
slouken committed Oct 1, 2016
1 parent 0b57696 commit 6f11545
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/SDL_log.c
Expand Up @@ -324,7 +324,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
size_t length;
LPTSTR tstr;

#ifndef __WINRT__
#if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
BOOL attachResult;
DWORD attachError;
unsigned long charsWritten;
Expand Down Expand Up @@ -356,7 +356,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
stderrHandle = GetStdHandle(STD_ERROR_HANDLE);
}
}
#endif /* ifndef __WINRT__ */
#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */

length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
output = SDL_stack_alloc(char, length);
Expand All @@ -366,7 +366,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
/* Output to debugger */
OutputDebugString(tstr);

#ifndef __WINRT__
#if !defined(HAVE_STDIO_H) && !defined(__WINRT__)
/* Screen output to stderr, if console was attached. */
if (consoleAttached == 1) {
if (!WriteConsole(stderrHandle, tstr, lstrlen(tstr), &charsWritten, NULL)) {
Expand All @@ -376,7 +376,7 @@ SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
}
}
}
#endif /* ifndef __WINRT__ */
#endif /* !defined(HAVE_STDIO_H) && !defined(__WINRT__) */

SDL_free(tstr);
SDL_stack_free(output);
Expand Down

0 comments on commit 6f11545

Please sign in to comment.