Skip to content

Commit

Permalink
[Support] Delete ioctl TIOCGWINSZ
Browse files Browse the repository at this point in the history
D61326 essentially disabled `ioctl(FileID, TIOCGWINSZ, &ws)`.  Nobody
has complained for one year. So let's just delete the code.
  • Loading branch information
MaskRay committed Mar 31, 2020
1 parent 7ea64ae commit a3eb3d3
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions llvm/lib/Support/Unix/Process.inc
Expand Up @@ -280,39 +280,31 @@ bool Process::FileDescriptorIsDisplayed(int fd) {
#endif
}

static unsigned getColumns(int FileID) {
static unsigned getColumns() {
// If COLUMNS is defined in the environment, wrap to that many columns.
if (const char *ColumnsStr = std::getenv("COLUMNS")) {
int Columns = std::atoi(ColumnsStr);
if (Columns > 0)
return Columns;
}

unsigned Columns = 0;

#if defined(HAVE_SYS_IOCTL_H) && defined(HAVE_TERMIOS_H) \
&& !(defined(_XOPEN_SOURCE) || defined(_POSIX_C_SOURCE))
// Try to determine the width of the terminal.
struct winsize ws;
if (ioctl(FileID, TIOCGWINSZ, &ws) == 0)
Columns = ws.ws_col;
#endif

return Columns;
// We used to call ioctl TIOCGWINSZ to determine the width. It is considered
// unuseful.
return 0;
}

unsigned Process::StandardOutColumns() {
if (!StandardOutIsDisplayed())
return 0;

return getColumns(1);
return getColumns();
}

unsigned Process::StandardErrColumns() {
if (!StandardErrIsDisplayed())
return 0;

return getColumns(2);
return getColumns();
}

#ifdef HAVE_TERMINFO
Expand Down

0 comments on commit a3eb3d3

Please sign in to comment.