http://bugs.winehq.org/show_bug.cgi?id=58665
Bug ID: 58665 Summary: cmd incorrectly wraps text containing ANSI escape sequences Product: Wine Version: 10.14 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: cmd Assignee: wine-bugs@winehq.org Reporter: forestix@gaga.casa Distribution: ---
Created attachment 79250 --> http://bugs.winehq.org/attachment.cgi?id=79250 reproducer: should print 3 lines; wine prints 4 lines
Wine's cmd.exe prematurely inserts line breaks when a program's output contains non-printable ANSI escape sequences, such as those used to change colors.
It looks as though Wine is counting not only the printable characters in the program's output, but also the non-printable ones, and using the total to decide where to insert a line break. Text that fits entirely on one line in a real Windows console is sometimes broken midway through the line, or followed by a blank line that should not be there, when run in an xterm using Wine.
I am attaching a batch file that reproduces the problem. It should print 3 lines. The second line is identical to the others with the addition of some non-printable escape sequences. These characters should either occupy no width in the terminal (making the line length match the others) or be rendered as visible placeholder characters (as older Windows versions do). To see Wine handling it incorrectly, run it in an 80-column xterm or a similar terminal.
Ideally, the output should look like this, with the head of line 2 in red:
79 chars _123456789_123456789_123456789_123456789_123456789_123456789_123456789 79 chars _123456789_123456789_123456789_123456789_123456789_123456789_123456789 79 chars _123456789_123456789_123456789_123456789_123456789_123456789_123456789
In wine, the output looks like this:
79 chars _123456789_123456789_123456789_123456789_123456789_123456789_123456789 79 chars _123456789_123456789_123456789_123456789_123456789_123456789_12 3456789 79 chars _123456789_123456789_123456789_123456789_123456789_123456789_123456789
Bug 49780 is related, but IMHO does not excuse this behavior. Regardless of whether virtual terminal sequences are supported, Wine should either print a character or not count it toward the length of a line when deciding where to wrap it.