summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2016-11-30 18:26:44 +0100
committerOswald Buddenhagen <oswald.buddenhagen@qt.io>2018-03-29 18:15:16 +0000
commit85ae0f1f3e369e1d28af7b2ec963f63e177ecd11 (patch)
tree82846344d8ebf280a642e724bdfda26311ba461a /qmake
parente5d909d6d68055c057bbaeadb8f7a4078e6d54e8 (diff)
qmake: add text codec support to VFS
sync-up with qt-creator; no effect on qmake. Change-Id: I34b42bd19e0de973deb2291e91f306d1ca7c630e (cherry picked from qtcreator/15148d8e4454ff3277131ea52a4204c5fa0b7ab0) Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Diffstat (limited to 'qmake')
-rw-r--r--qmake/library/qmakevfs.cpp20
-rw-r--r--qmake/library/qmakevfs.h11
2 files changed, 30 insertions, 1 deletions
diff --git a/qmake/library/qmakevfs.cpp b/qmake/library/qmakevfs.cpp
index 16e21395ba..2239a2beec 100644
--- a/qmake/library/qmakevfs.cpp
+++ b/qmake/library/qmakevfs.cpp
@@ -35,6 +35,10 @@ using namespace QMakeInternal;
#include <qfile.h>
#include <qfileinfo.h>
+#ifndef QT_NO_TEXTCODEC
+#include <qtextcodec.h>
+#endif
+
#define fL1S(s) QString::fromLatin1(s)
QT_BEGIN_NAMESPACE
@@ -45,6 +49,9 @@ QMakeVfs::QMakeVfs()
, m_magicExisting(fL1S("existing"))
#endif
{
+#ifndef QT_NO_TEXTCODEC
+ m_textCodec = 0;
+#endif
}
#ifdef PROPARSER_THREAD_SAFE
@@ -211,7 +218,11 @@ QMakeVfs::ReadResult QMakeVfs::readFile(int id, QString *contents, QString *errS
*errStr = fL1S("Unexpected UTF-8 BOM");
return ReadOtherError;
}
- *contents = QString::fromLocal8Bit(bcont);
+ *contents =
+#ifndef QT_NO_TEXTCODEC
+ m_textCodec ? m_textCodec->toUnicode(bcont) :
+#endif
+ QString::fromLocal8Bit(bcont);
return ReadOk;
}
@@ -262,4 +273,11 @@ void QMakeVfs::invalidateContents()
}
#endif
+#ifndef QT_NO_TEXTCODEC
+void QMakeVfs::setTextCodec(const QTextCodec *textCodec)
+{
+ m_textCodec = textCodec;
+}
+#endif
+
QT_END_NAMESPACE
diff --git a/qmake/library/qmakevfs.h b/qmake/library/qmakevfs.h
index 3b69b60bee..1217225471 100644
--- a/qmake/library/qmakevfs.h
+++ b/qmake/library/qmakevfs.h
@@ -38,6 +38,10 @@
# include <qmutex.h>
#endif
+#ifndef QT_NO_TEXTCODEC
+QT_FORWARD_DECLARE_CLASS(QTextCodec)
+#endif
+
#ifdef PROEVALUATOR_DUAL_VFS
# ifndef PROEVALUATOR_CUMULATIVE
# error PROEVALUATOR_DUAL_VFS requires PROEVALUATOR_CUMULATIVE
@@ -85,6 +89,10 @@ public:
void invalidateContents();
#endif
+#ifndef QT_NO_TEXTCODEC
+ void setTextCodec(const QTextCodec *textCodec);
+#endif
+
private:
#ifdef PROEVALUATOR_THREAD_SAFE
static QMutex s_mutex;
@@ -117,6 +125,9 @@ private:
QString m_magicMissing;
QString m_magicExisting;
#endif
+#ifndef QT_NO_TEXTCODEC
+ const QTextCodec *m_textCodec;
+#endif
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QMakeVfs::VfsFlags)