Merge pull request #201 from JohanEngelen/fix_win_EOL

Fix EOL output on Windows. Stdout has to be set to binary mode.
This commit is contained in:
Brian Schott 2016-01-12 16:26:54 -08:00
commit 9f81f0e13e
1 changed files with 16 additions and 0 deletions

View File

@ -110,6 +110,22 @@ else
return 1;
File output = stdout;
version(Windows)
{
// On Windows, set stdout to binary mode (needed for correct EOL writing)
// See Phobos' stdio.File.rawWrite
{
import std.stdio;
immutable fd = fileno(output.getFP());
setmode(fd, _O_BINARY);
version(CRuntime_DigitalMars)
{
import core.atomic : atomicOp;
atomicOp!"&="(__fhnd_info[fd], ~FHND_TEXT);
}
}
}
ubyte[] buffer;
if (readFromStdin)