enigma: better musl-redirect.patch

Thanks to @chneukirchen. freopen(3) works with stdout and stderr,
just the assigment to *stdout and *stderr is not possible.
This commit is contained in:
Jürgen Buchmüller 2015-11-19 14:02:16 +01:00
parent 7023d57dfd
commit 1c8307e48f
2 changed files with 23 additions and 23 deletions

View file

@ -1,31 +1,31 @@
In musl libc stdout and stderr are const and can't be
set to different files, thus disable --redirect.
We can't assign to *stdout and *stderr with musl libc
because both file pointers are const.
--- src/main.cc 2014-12-19 22:24:38.000000000 +0100
+++ src/main.cc 2015-11-18 21:54:09.698790150 +0100
@@ -131,7 +131,9 @@
" --nomusic Disable music\n"
" --nosound Disable music and sound effects\n"
" --pref -p file Use filename or dirname for preferences\n"
+#if defined(__GLIBC__)
" --redirect Redirect stdout/stderr to files on user path\n"
+#endif
" --robinson avoid connections to the internet\n"
" --showfps Show the framerate (FPS) during the Game\n"
" --version Print the executable's version number\n"
@@ -298,6 +300,7 @@
#ifdef WIN32
ap.redirect = true;
#endif
+#if defined(__GLIBC__)
+++ src/main.cc 2015-11-19 13:53:23.419299858 +0100
@@ -301,21 +301,25 @@
if (ap.redirect) {
FILE *newfp;
newfp = std::freopen((userStdPath + "/Output.log").c_str(), "w", stdout);
@@ -318,6 +321,7 @@
+#if defined(__GLIBC__)
if ( newfp == NULL ) { // This happens on NT
newfp = fopen((userStdPath + "/Output.log").c_str(), "w");
if (newfp) { // in case stdout is a macro
*stdout = *newfp;
}
}
+#endif
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); // Line buffered
newfp = std::freopen((userStdPath + "/Error.log").c_str(), "w", stderr);
+#if defined(__GLIBC__)
if ( newfp == NULL ) { // This happens on NT
newfp = fopen((userStdPath + "/Error.log").c_str(), "w");
if (newfp) { // in case stderr is a macro
*stderr = *newfp;
}
}
+#endif
setbuf(stderr, NULL); // No buffering
}
+#endif
// initialize logfile -- needs ap
if (ap.do_log)

View file

@ -1,7 +1,7 @@
# Template file for 'enigma'
pkgname=enigma
version=1.21
revision=1
revision=2
build_style=gnu-configure
hostmakedepends="ImageMagick automake libtool gettext-devel SDL-devel pkg-config"
makedepends="libcurl-devel libxerces-c-devel SDL_mixer-devel SDL_image-devel SDL_ttf-devel"