use a printErr() function instead of std::cerr like in lupdate
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>
Wed, 1 Jun 2011 10:34:59 +0000 (12:34 +0200)
committerQt by Nokia <qt-info@nokia.com>
Mon, 12 Sep 2011 15:29:43 +0000 (17:29 +0200)
(cherry picked from commit 0b92d6cc61a18ae18d254ac6ee463e74cb570db4)

Change-Id: I14834ad295109a979dd5e3e41b814543c68f3d35
Reviewed-on: http://codereview.qt-project.org/4603
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
src/linguist/lrelease/main.cpp

index e5892c7..73414b0 100644 (file)
@@ -56,8 +56,6 @@
 #include <QtCore/QTextStream>
 #include <QtCore/QLibraryInfo>
 
-#include <iostream>
-
 QT_USE_NAMESPACE
 
 #ifdef QT_BOOTSTRAPPED
@@ -85,6 +83,12 @@ static void printOut(const QString & out)
     stream << out;
 }
 
+static void printErr(const QString & out)
+{
+    QTextStream stream(stderr);
+    stream << out;
+}
+
 static void printUsage()
 {
     printOut(LR::tr(
@@ -120,7 +124,7 @@ static bool loadTsFile(Translator &tor, const QString &tsFileName, bool /* verbo
     ConversionData cd;
     bool ok = tor.load(tsFileName, cd, QLatin1String("auto"));
     if (!ok) {
-        std::cerr << qPrintable(LR::tr("lrelease error: %1").arg(cd.error()));
+        printErr(LR::tr("lrelease error: %1").arg(cd.error()));
     } else {
         if (!cd.errors().isEmpty())
             printOut(cd.error());
@@ -144,7 +148,7 @@ static bool releaseTranslator(Translator &tor, const QString &qmFileName,
 
     QFile file(qmFileName);
     if (!file.open(QIODevice::WriteOnly)) {
-        std::cerr << qPrintable(LR::tr("lrelease error: cannot create '%1': %2\n")
+        printErr(LR::tr("lrelease error: cannot create '%1': %2\n")
                                 .arg(qmFileName, file.errorString()));
         return false;
     }
@@ -154,7 +158,7 @@ static bool releaseTranslator(Translator &tor, const QString &qmFileName,
     file.close();
 
     if (!ok) {
-        std::cerr << qPrintable(LR::tr("lrelease error: cannot save '%1': %2")
+        printErr(LR::tr("lrelease error: cannot save '%1': %2")
                                 .arg(qmFileName, cd.error()));
     } else if (!cd.errors().isEmpty()) {
         printOut(cd.error());
@@ -275,13 +279,13 @@ int main(int argc, char **argv)
             visitor.setVerbose(cd.isVerbose());
 
             if (!visitor.queryProFile(&pro)) {
-                std::cerr << qPrintable(LR::tr(
+                printErr(LR::tr(
                           "lrelease error: cannot read project file '%1'.\n")
                           .arg(inputFile));
                 continue;
             }
             if (!visitor.accept(&pro)) {
-                std::cerr << qPrintable(LR::tr(
+                printErr(LR::tr(
                           "lrelease error: cannot process project file '%1'.\n")
                           .arg(inputFile));
                 continue;
@@ -289,7 +293,7 @@ int main(int argc, char **argv)
 
             QStringList translations = visitor.values(QLatin1String("TRANSLATIONS"));
             if (translations.isEmpty()) {
-                std::cerr << qPrintable(LR::tr(
+                printErr(LR::tr(
                           "lrelease warning: Met no 'TRANSLATIONS' entry in project file '%1'\n")
                           .arg(inputFile));
             } else {