From 99cefbb5d34d27a74992440d1116cbb0530b6984 Mon Sep 17 00:00:00 2001 From: Meep-Eep Date: Sun, 23 Dec 2007 06:11:46 +0000 Subject: [PATCH] Make the logfile unbuffered by default on Windows CE. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2886 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/port.h | 14 ++++++++++++++ sc2/src/starcon2.c | 3 +++ 2 files changed, 17 insertions(+) diff --git a/sc2/src/port.h b/sc2/src/port.h index 07475e2f0..f5ee575df 100644 --- a/sc2/src/port.h +++ b/sc2/src/port.h @@ -498,5 +498,19 @@ typedef unsigned int wint_t; # define _NORETURN #endif +// Buffered vs. unbuffered logfile +// stderr is normally unbuffered when connected to a terminal, but it +// will be buffered when connected to a file, when a --logfile argument +// is passed to uqm. +// Buffered output is slower, which can be significant if much debug output +// is requested, but after a crash occurs the logfile will still be up to +// date. +// On platforms where there is no console, having up-to-date log files +// after a crash is valuable enough to make the logfile unbuffered by +// default there. +#if defined(_WIN32_WCE) +# define UNBUFFERED_LOGFILE +#endif + #endif /* _PORT_H */ diff --git a/sc2/src/starcon2.c b/sc2/src/starcon2.c index dd04e98b9..35ef17e3f 100644 --- a/sc2/src/starcon2.c +++ b/sc2/src/starcon2.c @@ -154,6 +154,9 @@ main (int argc, char *argv[]) { int i; freopen (options.logFile, "w", stderr); +#ifdef UNBUFFERED_LOGFILE + setbuf (stderr, NULL); +#endif for (i = 0; i < argc; ++i) log_add (log_User, "argv[%d] = [%s]", i, argv[i]); }