diff --git a/docs/CHANGES.TXT b/docs/CHANGES.TXT index ad2e6d45d..b0890de2e 100644 --- a/docs/CHANGES.TXT +++ b/docs/CHANGES.TXT @@ -1,5 +1,6 @@ 0.96.6 (unreleased) ------------------- +- Fix: Clear status line output on Linux/WSL to prevent text artifacts (#2017) - Fix: Prevent infinite loop on truncated MKV files - Fix: Various memory safety and stability fixes in demuxers (MP4, PS, MKV, DVB) - Fix: Delete empty output files instead of leaving 0-byte files (#1282) diff --git a/src/lib_ccx/utility.c b/src/lib_ccx/utility.c index 8729c0db8..00f213414 100644 --- a/src/lib_ccx/utility.c +++ b/src/lib_ccx/utility.c @@ -179,16 +179,21 @@ void mprint(const char *fmt, ...) if (!ccx_options.messages_target) return; va_start(args, fmt); - if (ccx_options.messages_target == CCX_MESSAGES_STDOUT) - { - vfprintf(stdout, fmt, args); - fflush(stdout); - } - else + + FILE *target = (ccx_options.messages_target == CCX_MESSAGES_STDOUT) ? stdout : stderr; + + if (fmt[0] == '\r') { - vfprintf(stderr, fmt, args); - fflush(stderr); +#ifndef _WIN32 + fprintf(target, "\r\033[K"); // Clear the line first + fmt++; // Skip the '\r' so only the clean text gets printed next +#endif } + // Windows (legacy console) does not support ANSI sequences; fallback to standard \r; and vfprintf below handles it the old-fashioned way. + + vfprintf(target, fmt, args); + fflush(target); + va_end(args); }