From 267196599b7ec2c80c47f1514b4f2f594fabe4af Mon Sep 17 00:00:00 2001 From: havoc Date: Thu, 23 Feb 2006 01:48:09 +0000 Subject: [PATCH] div0 fixed the bug that caused huge console prints to the terminal to be truncated, this bug has been bothering me for a long time, thanks div0! git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6005 d7cf8633-e32d-0410-b094-e92efae38249 --- sys_linux.c | 17 ++++++++++++++++- sys_sdl.c | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/sys_linux.c b/sys_linux.c index 0515c934..13bc04f4 100644 --- a/sys_linux.c +++ b/sys_linux.c @@ -51,7 +51,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) diff --git a/sys_sdl.c b/sys_sdl.c index 4187d529..3833fdad 100644 --- 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) -- 2.39.2