]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - sys_sdl.c
div0 fixed the bug that caused huge console prints to the terminal to be truncated...
[xonotic/darkplaces.git] / sys_sdl.c
index 4187d529ed9c07792b04465463688eb7be037a31..3833fdad9308fec02e1e6d0419fd78f077205a35 100644 (file)
--- a/sys_sdl.c
+++ b/sys_sdl.c
@@ -49,7 +49,22 @@ void Sys_Error (const char *error, ...)
 
 void Sys_PrintToTerminal(const char *text)
 {
-       fprintf(stdout, "%s", text);
+#ifndef WIN32
+       // BUG: for some reason, NDELAY also affects stdout (1) when used on stdin (0).
+       int origflags = fcntl (1, F_GETFL, 0);
+       fcntl (1, F_SETFL, origflags & ~FNDELAY);
+#endif
+       while(*text)
+       {
+               ssize_t written = write(1, text, strlen(text));
+               if(written <= 0)
+                       break; // sorry, I cannot do anything about this error - without an output
+               text += written;
+       }
+#ifndef WIN32
+       fcntl (1, F_SETFL, origflags);
+#endif
+       //fprintf(stdout, "%s", text);
 }
 
 double Sys_DoubleTime (void)