From 4205b2997e01f2cea8e2f44c6f46ed6259ab7277 Mon Sep 17 00:00:00 2001 From: Soren Gjesse Date: Fri, 10 Jul 2015 13:57:15 +0200 Subject: [PATCH] Change stdout/stderr to binary mode on Windows Every other file opened in Windows is in binary mode, and there is no way of opening a file in text mode. This is a breaking change if one is relying on the CR insertion when writing to stdout/stderr on Windows. BUG=https://github.com/dart-lang/sdk/issues/19334 R=kustermann@google.com Review URL: https://codereview.chromium.org//1228053002. --- runtime/bin/file_win.cc | 1 + tests/standalone/io/stdio_nonblocking_test.dart | 9 ++------- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/runtime/bin/file_win.cc b/runtime/bin/file_win.cc index 8ba4a30b042f..54cd64d37d5e 100644 --- a/runtime/bin/file_win.cc +++ b/runtime/bin/file_win.cc @@ -196,6 +196,7 @@ File* File::OpenStdio(int fd) { default: UNREACHABLE(); } + _setmode(fd, _O_BINARY); return new File(new FileHandle(fd)); } diff --git a/tests/standalone/io/stdio_nonblocking_test.dart b/tests/standalone/io/stdio_nonblocking_test.dart index 0740dbe72672..05f5fde4a2a1 100644 --- a/tests/standalone/io/stdio_nonblocking_test.dart +++ b/tests/standalone/io/stdio_nonblocking_test.dart @@ -17,12 +17,7 @@ void main() { print(result.stdout); print(result.stderr); Expect.equals(1, result.exitCode); - if (Platform.isWindows) { - Expect.equals('stdout\r\n\r\ntuodts\r\nABCDEFGHIJKLM\r\n', result.stdout); - Expect.equals('stderr\r\n\r\nrredts\r\nABCDEFGHIJKLM\r\n', result.stderr); - } else { - Expect.equals('stdout\n\ntuodts\nABCDEFGHIJKLM\n', result.stdout); - Expect.equals('stderr\n\nrredts\nABCDEFGHIJKLM\n', result.stderr); - } + Expect.equals('stdout\n\ntuodts\nABCDEFGHIJKLM\n', result.stdout); + Expect.equals('stderr\n\nrredts\nABCDEFGHIJKLM\n', result.stderr); }); }