]> git-server-git.apps.pok.os.sepia.ceph.com Git - googletest.git/commitdiff
Simplify ColoredPrintf to rely on ShouldUseColor
authorGaspard Petit <gpetit@eidosmontreal.com>
Mon, 30 May 2022 17:34:17 +0000 (13:34 -0400)
committerGaspard Petit <gpetit@eidosmontreal.com>
Mon, 30 May 2022 18:19:50 +0000 (14:19 -0400)
Use ShouldUseColor to set use_color instead of having a separate check for the windows mobile cases; these cases are now moved directly to `DoIsATTY`

googletest/include/gtest/internal/gtest-port.h
googletest/src/gtest.cc

index 7162e6e1833b68a31dde52b7649121dac8d6ec31..e52d8a78c29198b93dd8eed19985068bc4a38348 100644 (file)
@@ -1965,7 +1965,8 @@ inline int StrCaseCmp(const char* s1, const char* s2) {
 }
 inline char* StrDup(const char* src) { return strdup(src); }
 #else  // !__BORLANDC__
-#if GTEST_OS_WINDOWS_MOBILE
+#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \
+    GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined(ESP_PLATFORM)
 inline int DoIsATTY(int /* fd */) { return 0; }
 #else
 inline int DoIsATTY(int fd) { return _isatty(fd); }
index 1acad59a73ecc2e8a580bf75b9f77ef5e9e31331..54aae939686ab8ce44ccecb6114e571e7d26abf5 100644 (file)
@@ -3278,14 +3278,8 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
   va_list args;
   va_start(args, fmt);
 
-#if GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS || GTEST_OS_IOS || \
-    GTEST_OS_WINDOWS_PHONE || GTEST_OS_WINDOWS_RT || defined(ESP_PLATFORM)
-  const bool use_color = AlwaysFalse();
-#else
-  static const bool in_color_mode =
-      ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
+  static const bool in_color_mode = ShouldUseColor(posix::IsATTY(posix::FileNo(stdout)) != 0);
   const bool use_color = in_color_mode && (color != GTestColor::kDefault);
-#endif  // GTEST_OS_WINDOWS_MOBILE || GTEST_OS_ZOS
 
   if (!use_color) {
     vprintf(fmt, args);