From 2b50979c0a957ed1712a3becdd394f83e9b7f153 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Tue, 12 Jan 2010 12:28:57 +0100 Subject: QFile cannot deal with crlf-translated stdio, so use binary mode of course, this will break if somebody actually pipes in windows files. oh, well. Suggested-by: joao --- tools/linguist/shared/translator.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tools/linguist/shared/translator.cpp b/tools/linguist/shared/translator.cpp index 8a071d3..2d92dd5 100644 --- a/tools/linguist/shared/translator.cpp +++ b/tools/linguist/shared/translator.cpp @@ -44,6 +44,10 @@ #include "simtexth.h" #include +#ifdef Q_OS_WIN +#include // required for _setmode, to avoid _O_TEXT streams... +#include // for _O_BINARY +#endif #include #include @@ -207,6 +211,10 @@ bool Translator::load(const QString &filename, ConversionData &cd, const QString QFile file; if (filename.isEmpty() || filename == QLatin1String("-")) { +#ifdef Q_OS_WIN + // QFile is broken for text files + ::_setmode(0, _O_BINARY); +#endif if (!file.open(stdin, QIODevice::ReadOnly)) { cd.appendError(QString::fromLatin1("Cannot open stdin!? (%1)") .arg(file.errorString())); @@ -243,6 +251,10 @@ bool Translator::save(const QString &filename, ConversionData &cd, const QString { QFile file; if (filename.isEmpty() || filename == QLatin1String("-")) { +#ifdef Q_OS_WIN + // QFile is broken for text files + ::_setmode(1, _O_BINARY); +#endif if (!file.open(stdout, QIODevice::WriteOnly)) { cd.appendError(QString::fromLatin1("Cannot open stdout!? (%1)") .arg(file.errorString())); -- cgit v0.12