From 712de82154b6770a472ae78386273c6fd8ddf9b1 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 20 Jul 2012 18:29:38 +0000 Subject: Process: Add sys::Process::FileDescriptorHasColors(). llvm-svn: 160557 --- llvm/lib/Support/Unix/Process.inc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'llvm/lib/Support/Unix') 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() { -- cgit v1.2.3