Skip to content
Snippets Groups Projects
Commit ac5351c6 authored by dg's avatar dg
Browse files

Logfile should correctly flush when using --flush-stdout on windows

git-svn-id: http://svn.net-core.org/repos/t-engine4@4462 51575b47-30f0-44d4-a5cc-537603b46e54
parent 0124d484
No related branches found
No related tags found
No related merge requests found
......@@ -933,7 +933,9 @@ int main(int argc, char *argv[])
core_def->define(core_def, "te4core", -1, NULL, NULL, NULL, NULL, 0, NULL);
#ifdef SELFEXE_WINDOWS
freopen ("te4_log.txt", "w", stdout);
FILE *logfile;
logfile = freopen ("te4_log.txt", "w", stdout);
bool windows_autoflush = FALSE;
#endif
g_argc = argc;
......@@ -948,7 +950,14 @@ int main(int argc, char *argv[])
if (!strncmp(arg, "-u", 2)) core_def->reboot_name = strdup(arg+2);
if (!strncmp(arg, "-E", 2)) core_def->reboot_einfo = strdup(arg+2);
if (!strncmp(arg, "-n", 2)) core_def->reboot_new = 1;
if (!strncmp(arg, "--flush-stdout", 14)) setvbuf(stdout, (char *) NULL, _IOLBF, 0);;
if (!strncmp(arg, "--flush-stdout", 14))
{
setvbuf(stdout, (char *) NULL, _IOLBF, 0);
#ifdef SELFEXE_WINDOWS
setvbuf(logfile, NULL, _IONBF, 2);
windows_autoflush = TRUE;
#endif
}
if (!strncmp(arg, "--no-debug", 10)) no_debug = TRUE;
}
......@@ -1027,6 +1036,9 @@ int main(int argc, char *argv[])
{
if (!isActive || tickPaused) SDL_WaitEvent(NULL);
#ifdef SELFEXE_WINDOWS
if (windows_autoflush) _commit(_fileno(stdout));
#endif
/* handle the events in the queue */
while (SDL_PollEvent(&event))
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment