Merge pull request #2216 from akoeplinger/fix-array-sort
[mono.git] / mcs / class / corlib / System / Console.cs
index 08f8a4c1da1bfe92ecd879883d42b60b86374e1e..206c3429d8d5632e17fc9fca10d52920a5a03b68 100644 (file)
@@ -125,11 +125,11 @@ namespace System
                                // UTF-8 ZWNBSP (zero-width non-breaking space).
                                //
                                int code_page = 0;
-                               Encoding.InternalCodePage (ref code_page);
+                               EncodingHelper.InternalCodePage (ref code_page);
 
                                if (code_page != -1 && ((code_page & 0x0fffffff) == 3 // UTF8Encoding.UTF8_CODE_PAGE
                                        || ((code_page & 0x10000000) != 0)))
-                                       inputEncoding = outputEncoding = Encoding.UTF8Unmarked;
+                                       inputEncoding = outputEncoding = EncodingHelper.UTF8Unmarked;
                                else
                                        inputEncoding = outputEncoding = Encoding.Default;
                        }
@@ -141,35 +141,32 @@ namespace System
                {
 #if !NET_2_1
                        if (!Environment.IsRunningOnWindows && ConsoleDriver.IsConsole) {
-                               StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
+                               StreamWriter w = new CStreamWriter (OpenStandardOutput (0), outputEncoding, true);
                                w.AutoFlush = true;
-                               stdout = TextWriter.Synchronized (w, true);
+                               stdout = TextWriter.Synchronized (w);
 
-                               w = new CStreamWriter (OpenStandardOutput (0), outputEncoding);
+                               w = new CStreamWriter (OpenStandardOutput (0), outputEncoding, true);
                                w.AutoFlush = true;
-                               stderr = TextWriter.Synchronized (w, true);
+                               stderr = TextWriter.Synchronized (w);
                                
                                stdin = new CStreamReader (OpenStandardInput (0), inputEncoding);
                        } else {
 #endif
-// FULL_AOT_RUNTIME is used (instead of MONOTOUCH) since we only want this code when running on 
-// iOS (simulator or devices) and *not* when running tools (e.g. btouch #12179) that needs to use 
-// the mscorlib.dll shipped with Xamarin.iOS
-#if MONOTOUCH && FULL_AOT_RUNTIME
+#if MONOTOUCH
                                stdout = new NSLogWriter ();
 #else
                                stdout = new UnexceptionalStreamWriter (OpenStandardOutput (0), outputEncoding);
                                ((StreamWriter)stdout).AutoFlush = true;
 #endif
-                               stdout = TextWriter.Synchronized (stdout, true);
+                               stdout = TextWriter.Synchronized (stdout);
 
-#if MONOTOUCH && FULL_AOT_RUNTIME
+#if MONOTOUCH
                                stderr = new NSLogWriter ();
 #else
                                stderr = new UnexceptionalStreamWriter (OpenStandardError (0), outputEncoding); 
                                ((StreamWriter)stderr).AutoFlush = true;
 #endif
-                               stderr = TextWriter.Synchronized (stderr, true);
+                               stderr = TextWriter.Synchronized (stderr);
 
                                stdin = new UnexceptionalStreamReader (OpenStandardInput (0), inputEncoding);
                                stdin = TextReader.Synchronized (stdin);
@@ -210,9 +207,10 @@ namespace System
                private static Stream Open (IntPtr handle, FileAccess access, int bufferSize)
                {
                        try {
-                               return new FileStream (handle, access, false, bufferSize, false, bufferSize == 0);
+                               // TODO: Should use __ConsoleStream from reference sources
+                               return new FileStream (handle, access, false, bufferSize, false, true);
                        } catch (IOException) {
-                               return new NullStream ();
+                               return Stream.Null;
                        }
                }
 
@@ -661,7 +659,6 @@ namespace System
                        set { ConsoleDriver.WindowWidth = value; }
                }
 
-#if NET_4_5
                public static bool IsErrorRedirected {
                        get {
                                return ConsoleDriver.IsErrorRedirected;
@@ -679,7 +676,6 @@ namespace System
                                return ConsoleDriver.IsInputRedirected;
                        }
                }
-#endif
 
                public static void Beep ()
                {