summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-12 11:28:57 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2010-01-12 11:28:57 (GMT)
commit2b50979c0a957ed1712a3becdd394f83e9b7f153 (patch)
tree8935a2807c4ed2f681c11447ee7085ef04266d4a /tools
parentb4067f455dca3007236a1043d641e92ecb8d3d54 (diff)
downloadQt-2b50979c0a957ed1712a3becdd394f83e9b7f153.zip
Qt-2b50979c0a957ed1712a3becdd394f83e9b7f153.tar.gz
Qt-2b50979c0a957ed1712a3becdd394f83e9b7f153.tar.bz2
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
Diffstat (limited to 'tools')
-rw-r--r--tools/linguist/shared/translator.cpp12
1 files changed, 12 insertions, 0 deletions
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 <stdio.h>
+#ifdef Q_OS_WIN
+#include <io.h> // required for _setmode, to avoid _O_TEXT streams...
+#include <fcntl.h> // for _O_BINARY
+#endif
#include <QtCore/QDebug>
#include <QtCore/QDir>
@@ -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()));