Skip to content

Commit

Permalink
SDL: Don't write garbage to output if it is redirected
Browse files Browse the repository at this point in the history
  • Loading branch information
Cacodemon345 authored and alexey-lysiuk committed Mar 21, 2021
1 parent 0c776e3 commit 3b50f7d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/common/platform/posix/sdl/i_system.cpp
Expand Up @@ -175,10 +175,11 @@ void I_PrintStr(const char *cp)
{
const char * srcp = cp;
FString printData = "";
bool terminal = isatty(STDOUT_FILENO);

while (*srcp != 0)
{
if (*srcp == 0x1c && con_printansi)
if (*srcp == 0x1c && con_printansi && terminal)
{
srcp += 1;
EColorRange range = V_ParseFontColor((const uint8_t*&)srcp, CR_UNTRANSLATED, CR_YELLOW);
Expand Down Expand Up @@ -224,7 +225,7 @@ void I_PrintStr(const char *cp)

if (StartScreen) CleanProgressBar();
fputs(printData.GetChars(),stdout);
fputs("\033[0m",stdout);
if (terminal) fputs("\033[0m",stdout);
if (StartScreen) RedrawProgressBar(ProgressBarCurPos,ProgressBarMaxPos);
}

Expand Down

0 comments on commit 3b50f7d

Please sign in to comment.