Skip to content

Commit b8019bd

Browse files
authored
[FIX] Resolve output artifact on Linux/WSL (line clearing)
2 parents 9d921de + b7b1041 commit b8019bd

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

docs/CHANGES.TXT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
0.96.6 (unreleased)
22
-------------------
3+
- Fix: Clear status line output on Linux/WSL to prevent text artifacts (#2017)
34
- Fix: Prevent infinite loop on truncated MKV files
45
- Fix: Various memory safety and stability fixes in demuxers (MP4, PS, MKV, DVB)
56
- Fix: Delete empty output files instead of leaving 0-byte files (#1282)

src/lib_ccx/utility.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,16 +179,21 @@ void mprint(const char *fmt, ...)
179179
if (!ccx_options.messages_target)
180180
return;
181181
va_start(args, fmt);
182-
if (ccx_options.messages_target == CCX_MESSAGES_STDOUT)
183-
{
184-
vfprintf(stdout, fmt, args);
185-
fflush(stdout);
186-
}
187-
else
182+
183+
FILE *target = (ccx_options.messages_target == CCX_MESSAGES_STDOUT) ? stdout : stderr;
184+
185+
if (fmt[0] == '\r')
188186
{
189-
vfprintf(stderr, fmt, args);
190-
fflush(stderr);
187+
#ifndef _WIN32
188+
fprintf(target, "\r\033[K"); // Clear the line first
189+
fmt++; // Skip the '\r' so only the clean text gets printed next
190+
#endif
191191
}
192+
// Windows (legacy console) does not support ANSI sequences; fallback to standard \r; and vfprintf below handles it the old-fashioned way.
193+
194+
vfprintf(target, fmt, args);
195+
fflush(target);
196+
192197
va_end(args);
193198
}
194199

0 commit comments

Comments
 (0)