SDL: Don't write garbage to output if it is redirected

This commit is contained in:
Cacodemon345 2021-03-21 15:05:12 +06:00 committed by alexey.lysiuk
parent 0c776e3acd
commit 3b50f7dfa6

View file

@ -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);
@ -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);
}