mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-24 10:40:46 +00:00
Factor "pipe standard outputs to files" code into baselayer.c.
The SDL and Windows layers had slightly different code: the latter would dereference a NULL pointer if stdout.txt failed being write-opened. git-svn-id: https://svn.eduke32.com/eduke32@3377 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
1e91bf1800
commit
a959b998bd
4 changed files with 27 additions and 33 deletions
|
@ -181,6 +181,7 @@ void wm_setapptitle(char *name);
|
|||
int32_t baselayer_init();
|
||||
|
||||
void makeasmwriteable(void);
|
||||
void maybe_redirect_outputs(void);
|
||||
|
||||
#ifdef EXTERNC
|
||||
}
|
||||
|
|
|
@ -476,3 +476,27 @@ void makeasmwriteable(void)
|
|||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void maybe_redirect_outputs(void)
|
||||
{
|
||||
#if !(defined __APPLE__ && defined __BIG_ENDIAN__)
|
||||
char *argp;
|
||||
|
||||
// pipe standard outputs to files
|
||||
if ((argp = Bgetenv("BUILD_LOGSTDOUT")) != NULL)
|
||||
if (!Bstrcasecmp(argp, "TRUE"))
|
||||
{
|
||||
FILE *fp = freopen("stdout.txt", "w", stdout);
|
||||
|
||||
if (!fp)
|
||||
fp = fopen("stdout.txt", "w");
|
||||
|
||||
if (fp)
|
||||
{
|
||||
setvbuf(fp, 0, _IONBF, 0);
|
||||
*stdout = *fp;
|
||||
*stderr = *fp;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -206,7 +206,6 @@ int32_t main(int32_t argc, char *argv[])
|
|||
{
|
||||
int32_t r;
|
||||
char *argp;
|
||||
FILE *fp;
|
||||
|
||||
buildkeytranslationtable();
|
||||
|
||||
|
@ -229,24 +228,7 @@ int32_t main(int32_t argc, char *argv[])
|
|||
_buildargc = argc;
|
||||
_buildargv = (const char **)argv;
|
||||
|
||||
#if !(defined __APPLE__ && defined __BIG_ENDIAN__)
|
||||
// pipe standard outputs to files
|
||||
if ((argp = Bgetenv("BUILD_LOGSTDOUT")) != NULL)
|
||||
if (!Bstrcasecmp(argp, "TRUE"))
|
||||
{
|
||||
fp = freopen("stdout.txt", "w", stdout);
|
||||
|
||||
if (!fp)
|
||||
fp = fopen("stdout.txt", "w");
|
||||
|
||||
if (fp)
|
||||
{
|
||||
setvbuf(fp, 0, _IONBF, 0);
|
||||
*stdout = *fp;
|
||||
*stderr = *fp;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
maybe_redirect_outputs();
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
if ((argp = Bgetenv("BUILD_NOFOG")) != NULL)
|
||||
|
|
|
@ -316,7 +316,6 @@ int32_t WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, in
|
|||
{
|
||||
int32_t r;
|
||||
char *argp;
|
||||
FILE *fp;
|
||||
HDC hdc;
|
||||
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
@ -419,19 +418,7 @@ int32_t WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, in
|
|||
}
|
||||
}
|
||||
|
||||
// pipe standard outputs to files
|
||||
if ((argp = Bgetenv("BUILD_LOGSTDOUT")) != NULL)
|
||||
if (!Bstrcasecmp(argp, "TRUE"))
|
||||
{
|
||||
fp = freopen("stdout.txt", "w", stdout);
|
||||
if (!fp)
|
||||
{
|
||||
fp = fopen("stdout.txt", "w");
|
||||
}
|
||||
if (fp) setvbuf(fp, 0, _IONBF, 0);
|
||||
*stdout = *fp;
|
||||
*stderr = *fp;
|
||||
}
|
||||
maybe_redirect_outputs();
|
||||
|
||||
#ifdef USE_OPENGL
|
||||
if ((argp = Bgetenv("BUILD_NOFOG")) != NULL)
|
||||
|
|
Loading…
Reference in a new issue