Skip to content

Commit

Permalink
Change stdout/stderr to binary mode on Windows
Browse files Browse the repository at this point in the history
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=#19334
R=kustermann@google.com

Review URL: https://codereview.chromium.org//1228053002.
  • Loading branch information
sgjesse committed Jul 10, 2015
1 parent fe2c4c5 commit 4205b29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
1 change: 1 addition & 0 deletions runtime/bin/file_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ File* File::OpenStdio(int fd) {
default:
UNREACHABLE();
}
_setmode(fd, _O_BINARY);
return new File(new FileHandle(fd));
}

Expand Down
9 changes: 2 additions & 7 deletions tests/standalone/io/stdio_nonblocking_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
}

0 comments on commit 4205b29

Please sign in to comment.