diff options
author | Daniel Dunbar <daniel@zuster.org> | 2012-07-20 18:29:38 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2012-07-20 18:29:38 +0000 |
commit | 712de82154b6770a472ae78386273c6fd8ddf9b1 (patch) | |
tree | c611a346fa53c53a3a896dbf81606d0945649a19 /llvm/lib/Support | |
parent | 2f529107a78348e510d54e386bf7da8ce4446785 (diff) | |
download | bcm5719-llvm-712de82154b6770a472ae78386273c6fd8ddf9b1.tar.gz bcm5719-llvm-712de82154b6770a472ae78386273c6fd8ddf9b1.zip |
Process: Add sys::Process::FileDescriptorHasColors().
llvm-svn: 160557
Diffstat (limited to 'llvm/lib/Support')
-rw-r--r-- | llvm/lib/Support/Unix/Process.inc | 14 | ||||
-rw-r--r-- | llvm/lib/Support/Windows/Process.inc | 12 |
2 files changed, 16 insertions, 10 deletions
diff --git a/llvm/lib/Support/Unix/Process.inc b/llvm/lib/Support/Unix/Process.inc index 4e1bd5db142..174112e8c2a 100644 --- a/llvm/lib/Support/Unix/Process.inc +++ b/llvm/lib/Support/Unix/Process.inc @@ -249,16 +249,18 @@ static bool terminalHasColors() { return false; } +bool Process::FileDescriptorHasColors(int fd) { + // A file descriptor has colors if it is displayed and the terminal has + // colors. + return FileDescriptorIsDisplayed(fd) && terminalHasColors(); +} + bool Process::StandardOutHasColors() { - if (!StandardOutIsDisplayed()) - return false; - return terminalHasColors(); + return FileDescriptorHasColors(STDOUT_FILENO); } bool Process::StandardErrHasColors() { - if (!StandardErrIsDisplayed()) - return false; - return terminalHasColors(); + return FileDescriptorHasColors(STDERR_FILENO); } bool Process::ColorNeedsFlush() { diff --git a/llvm/lib/Support/Windows/Process.inc b/llvm/lib/Support/Windows/Process.inc index 6a1270c2f30..43ba028a898 100644 --- a/llvm/lib/Support/Windows/Process.inc +++ b/llvm/lib/Support/Windows/Process.inc @@ -153,13 +153,17 @@ unsigned Process::StandardErrColumns() { return Columns; } -// It always has colors. -bool Process::StandardErrHasColors() { - return StandardErrIsDisplayed(); +// The terminal always has colors. +bool FileDescriptorHasColors(int fd) { + return FileDescriptorIsDisplayed(fd); } bool Process::StandardOutHasColors() { - return StandardOutIsDisplayed(); + return FileDescriptorHasColors(1); +} + +bool Process::StandardErrHasColors() { + return FileDescriptorHasColors(2); } namespace { |