diff options
author | Christian Kandeler <christian.kandeler@qt.io> | 2019-09-27 15:29:47 +0200 |
---|---|---|
committer | Christian Kandeler <christian.kandeler@qt.io> | 2019-09-30 09:09:01 +0000 |
commit | 37ef97bfa812a9a6f90b0513d31bd83bf7ce2a87 (patch) | |
tree | f43adaa166e0234251ff039212a0c75772e3b978 /src/app/qbs | |
parent | fd88c40291275032f730693facee6f7758bf5992 (diff) | |
download | qbs-37ef97bfa812a9a6f90b0513d31bd83bf7ce2a87.tar.gz |
JSON API: Force binary mode for stdout on Windows
Otherwise, the line feed character will get expanded to \r\n.
Change-Id: I90e83d80625c59978986541fb2d04f49e75afaf0
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/app/qbs')
-rw-r--r-- | src/app/qbs/session.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/app/qbs/session.cpp b/src/app/qbs/session.cpp index 0b93aff49..30e71dfd5 100644 --- a/src/app/qbs/session.cpp +++ b/src/app/qbs/session.cpp @@ -71,6 +71,14 @@ #include <iostream> #include <memory> +#ifdef Q_OS_WIN32 +#include <cerrno> +#include <cstdio> +#include <cstring> +#include <fcntl.h> +#include <io.h> +#endif + namespace qbs { namespace Internal { @@ -175,6 +183,13 @@ void startSession() Session::Session() { +#ifdef Q_OS_WIN32 + // Make sure the line feed character appears as itself. + if (_setmode(_fileno(stdout), _O_BINARY) == -1) { + std::cerr << "Failed to set stdout to binary mode: " << std::strerror(errno) << std::endl; + qApp->exit(EXIT_FAILURE); + } +#endif sendPacket(SessionPacket::helloMessage()); connect(&m_logSink, &SessionLogSink::newMessage, this, &Session::sendPacket); connect(&m_packetReader, &SessionPacketReader::errorOccurred, |