void-packages/srcpkgs/enigma/patches/musl-redirect.patch
Jürgen Buchmüller 1c8307e48f 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.
2015-11-19 14:02:16 +01:00

31 lines
1.1 KiB
Diff

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-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);
+#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
}