* ConsoleLogger.cs (no_colors): Rename to ..
authorAnkit Jain <radical@corewars.org>
Sun, 11 Oct 2009 01:23:54 +0000 (01:23 -0000)
committerAnkit Jain <radical@corewars.org>
Sun, 11 Oct 2009 01:23:54 +0000 (01:23 -0000)
(use_colors): .. this. Fix the case when XBUILD_COLORS
is not set.

svn path=/trunk/mcs/; revision=143903

mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ChangeLog
mcs/class/Microsoft.Build.Engine/Microsoft.Build.BuildEngine/ConsoleLogger.cs

index 515ef2e8441c70e0b6cae5c61d756fa8b176aa3f..7b36e548cf6aa69419819ccabd8b4994ae308137 100644 (file)
@@ -1,3 +1,9 @@
+2009-10-11  Ankit Jain  <jankit@novell.com>
+
+       * ConsoleLogger.cs (no_colors): Rename to ..
+       (use_colors): .. this. Fix the case when XBUILD_COLORS
+       is not set.
+
 2009-10-11  Ankit Jain  <jankit@novell.com>
 
        * ConsoleLogger.cs: Use ColorSetter and ColorResetter .
index b2bdfe7aba948a9617fc3698f4650f74b399351a..dfbea28174efbee7a274f267d843f14d69dd11af 100644 (file)
@@ -53,7 +53,7 @@ namespace Microsoft.Build.BuildEngine {
                ConsoleColor errorColor, warningColor, eventColor, messageColor, highMessageColor;
                ColorSetter colorSet;
                ColorResetter colorReset;
-               bool no_message_color, no_colors;
+               bool no_message_color, use_colors;
                
                public ConsoleLogger ()
                        : this (LoggerVerbosity.Normal, null, null, null)
@@ -97,31 +97,37 @@ namespace Microsoft.Build.BuildEngine {
                        // then don't use any color for it.
                        no_message_color = true;
 
-                       no_colors = true;
+                       use_colors = false;
                        if (colorSet == null || colorReset == null)
                                return;
 
                        // color support
                        string config = Environment.GetEnvironmentVariable ("XBUILD_COLORS");
-                       if (config != null && config != "disable") {
-                               no_colors = false;
-                               string [] pairs = config.Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
-                               foreach (string pair in pairs) {
-                                       string [] parts = pair.Split (new char[] {'='}, StringSplitOptions.RemoveEmptyEntries);
-                                       if (parts.Length != 2)
-                                               continue;
-
-                                       if (parts [0] == "errors")
-                                               TryParseConsoleColor (parts [1], ref errorColor);
-                                       else if (parts [0] == "warnings")
-                                               TryParseConsoleColor (parts [1], ref warningColor);
-                                       else if (parts [0] == "events")
-                                               TryParseConsoleColor (parts [1], ref eventColor);
-                                       else if (parts [0] == "messages") {
-                                               if (TryParseConsoleColor (parts [1], ref messageColor)) {
-                                                       highMessageColor = GetBrightColorFor (messageColor);
-                                                       no_message_color = false;
-                                               }
+                       if (config == null) {
+                               use_colors = true;
+                               return;
+                       }
+
+                       if (config == "disable")
+                               return;
+
+                       use_colors = true;
+                       string [] pairs = config.Split (new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
+                       foreach (string pair in pairs) {
+                               string [] parts = pair.Split (new char[] {'='}, StringSplitOptions.RemoveEmptyEntries);
+                               if (parts.Length != 2)
+                                       continue;
+
+                               if (parts [0] == "errors")
+                                       TryParseConsoleColor (parts [1], ref errorColor);
+                               else if (parts [0] == "warnings")
+                                       TryParseConsoleColor (parts [1], ref warningColor);
+                               else if (parts [0] == "events")
+                                       TryParseConsoleColor (parts [1], ref eventColor);
+                               else if (parts [0] == "messages") {
+                                       if (TryParseConsoleColor (parts [1], ref messageColor)) {
+                                               highMessageColor = GetBrightColorFor (messageColor);
+                                               no_message_color = false;
                                        }
                                }
                        }
@@ -375,13 +381,13 @@ namespace Microsoft.Build.BuildEngine {
 
                void SetColor (ConsoleColor color)
                {
-                       if (!no_colors)
+                       if (use_colors)
                                colorSet (color);
                }
 
                void ResetColor ()
                {
-                       if (!no_colors)
+                       if (use_colors)
                                colorReset ();
                }