[PATCH] D42055: Fallback option for colorized output when terminfo isn't available

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 19 09:14:41 PST 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL322962: Fallback option for colorized output when terminfo isn't available (authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D42055?vs=130548&id=130634#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D42055

Files:
  llvm/trunk/lib/Support/Unix/Process.inc


Index: llvm/trunk/lib/Support/Unix/Process.inc
===================================================================
--- llvm/trunk/lib/Support/Unix/Process.inc
+++ llvm/trunk/lib/Support/Unix/Process.inc
@@ -369,6 +369,21 @@
   // Return true if we found a color capabilities for the current terminal.
   if (HasColors)
     return true;
+#else
+  // When the terminfo database is not available, check if the current terminal
+  // is one of terminals that are known to support ANSI color escape codes.
+  if (const char *TermStr = std::getenv("TERM")) {
+    return StringSwitch<bool>(TermStr)
+      .Case("ansi", true)
+      .Case("cygwin", true)
+      .Case("linux", true)
+      .StartsWith("screen", true)
+      .StartsWith("xterm", true)
+      .StartsWith("vt100", true)
+      .StartsWith("rxvt", true)
+      .EndsWith("color", true)
+      .Default(false);
+  }
 #endif
 
   // Otherwise, be conservative.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42055.130634.patch
Type: text/x-patch
Size: 919 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180119/38bfc732/attachment.bin>


More information about the llvm-commits mailing list