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 | 7d83658140cb99871a43a08715a45c84aa66f3cc (patch) | |
tree | 1dc801549e135220329cef898daf42221fde5bdf /lib/Support | |
parent | b1a464279623768a3d04ff6726c99dce35d2f360 (diff) | |
download | external_llvm-7d83658140cb99871a43a08715a45c84aa66f3cc.zip external_llvm-7d83658140cb99871a43a08715a45c84aa66f3cc.tar.gz external_llvm-7d83658140cb99871a43a08715a45c84aa66f3cc.tar.bz2 |
Process: Add sys::Process::FileDescriptorHasColors().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160557 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support')
-rw-r--r-- | lib/Support/Unix/Process.inc | 14 | ||||
-rw-r--r-- | lib/Support/Windows/Process.inc | 12 |
2 files changed, 16 insertions, 10 deletions
diff --git a/lib/Support/Unix/Process.inc b/lib/Support/Unix/Process.inc index 4e1bd5d..174112e 100644 --- a/lib/Support/Unix/Process.inc +++ b/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/lib/Support/Windows/Process.inc b/lib/Support/Windows/Process.inc index 6a1270c..43ba028 100644 --- a/lib/Support/Windows/Process.inc +++ b/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 { |