Query terminal width from STDOUT_FILENO

Rather than 0 (stdin). So it will work even if ninja's stdin isn't connected to
the terminal for whatever reason.
This commit is contained in:
David Emett 2015-09-20 14:22:26 +01:00
parent ca041d88f4
commit f56a832844

View File

@ -82,7 +82,7 @@ void LinePrinter::Print(string to_print, LineType type) {
// Limit output to width of the terminal if provided so we don't cause
// line-wrapping.
winsize size;
if ((ioctl(0, TIOCGWINSZ, &size) == 0) && size.ws_col) {
if ((ioctl(STDOUT_FILENO, TIOCGWINSZ, &size) == 0) && size.ws_col) {
to_print = ElideMiddle(to_print, size.ws_col);
}
printf("%s", to_print.c_str());