summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2016-11-22 10:13:41 +0100
committerLars Knoll <lars.knoll@qt.io>2016-11-23 10:30:57 +0000
commitfd9e5d90333c385ad191a289b2e95e918c58b242 (patch)
tree85dc6eef992799a1bbc5b9d36a9fd2866d6a6b4a /src/corelib/codecs
parent7e9aca683abf1360e3d20dfebdd937b2594c94b2 (diff)
Clean up iconv configuration
Turn iconv off if ICU is being used (in line with codecs.pri) and get rid of the DEFINES += GNU_LIBICONV in the pri file. Change-Id: I6fbca975498adbb3e67f913ae9b1dd5cc53ee8da Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'src/corelib/codecs')
-rw-r--r--src/corelib/codecs/codecs.pri6
-rw-r--r--src/corelib/codecs/qiconvcodec.cpp14
-rw-r--r--src/corelib/codecs/qiconvcodec_p.h4
-rw-r--r--src/corelib/codecs/qtextcodec.cpp6
4 files changed, 12 insertions, 18 deletions
diff --git a/src/corelib/codecs/codecs.pri b/src/corelib/codecs/codecs.pri
index 4fa778d042..dc8974d13f 100644
--- a/src/corelib/codecs/codecs.pri
+++ b/src/corelib/codecs/codecs.pri
@@ -43,12 +43,8 @@ qtConfig(icu) {
qtConfig(iconv) {
HEADERS += codecs/qiconvcodec_p.h
SOURCES += codecs/qiconvcodec.cpp
- qtConfig(gnu-libiconv) {
- DEFINES += GNU_LIBICONV
+ qtConfig(gnu-libiconv): \
QMAKE_USE_PRIVATE += iconv
- } else: qtConfig(sun-libiconv) {
- DEFINES += GNU_LIBICONV
- }
}
win32 {
diff --git a/src/corelib/codecs/qiconvcodec.cpp b/src/corelib/codecs/qiconvcodec.cpp
index 845155dce0..8961d01eee 100644
--- a/src/corelib/codecs/qiconvcodec.cpp
+++ b/src/corelib/codecs/qiconvcodec.cpp
@@ -37,7 +37,9 @@
**
****************************************************************************/
-#ifndef QT_NO_ICONV
+#include <QtCore/private/qglobal_p.h>
+
+QT_REQUIRE_CONFIG(iconv);
#include "qiconvcodec_p.h"
#include "qtextcodec_p.h"
@@ -221,7 +223,7 @@ QString QIconvCodec::convertToUnicode(const char* chars, int len, ConverterState
IconvState *state = *pstate;
size_t inBytesLeft = len;
// best case assumption, each byte is converted into one UTF-16 character, plus 2 bytes for the BOM
-#ifdef GNU_LIBICONV
+#if !QT_CONFIG(posix_libiconv)
// GNU doesn't disagree with POSIX :/
const char *inBytes = chars;
#else
@@ -320,7 +322,7 @@ static bool setByteOrder(iconv_t cd)
size_t outBytesLeft = sizeof buf;
size_t inBytesLeft = sizeof bom;
-#if defined(GNU_LIBICONV)
+#if !QT_CONFIG(posix_libiconv)
const char **inBytesPtr = const_cast<const char **>(&inBytes);
#else
char **inBytesPtr = &inBytes;
@@ -342,7 +344,7 @@ QByteArray QIconvCodec::convertFromUnicode(const QChar *uc, int len, ConverterSt
char *outBytes;
size_t inBytesLeft;
-#if defined(GNU_LIBICONV)
+#if !QT_CONFIG(posix_libiconv)
const char **inBytesPtr = const_cast<const char **>(&inBytes);
#else
char **inBytesPtr = &inBytes;
@@ -472,7 +474,7 @@ iconv_t QIconvCodec::createIconv_t(const char *to, const char *from) const
init();
iconv_t cd = (iconv_t) -1;
-#if defined(__GLIBC__) || defined(GNU_LIBICONV) || defined(Q_OS_QNX)
+#if defined(__GLIBC__) || !QT_CONFIG(posix_libiconv) || defined(Q_OS_QNX)
#if defined(Q_OS_QNX)
// on QNX the default locale is UTF-8, and an empty string will cause iconv_open to fail
static const char empty_codeset[] = "UTF-8";
@@ -562,5 +564,3 @@ iconv_t QIconvCodec::createIconv_t(const char *to, const char *from) const
}
QT_END_NAMESPACE
-
-#endif /* #ifndef QT_NO_ICONV */
diff --git a/src/corelib/codecs/qiconvcodec_p.h b/src/corelib/codecs/qiconvcodec_p.h
index 238351bc81..d99e72f635 100644
--- a/src/corelib/codecs/qiconvcodec_p.h
+++ b/src/corelib/codecs/qiconvcodec_p.h
@@ -54,7 +54,7 @@
#include <QtCore/private/qglobal_p.h>
#include "qtextcodec.h"
-#if defined(Q_OS_UNIX) && !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
+QT_REQUIRE_CONFIG(iconv);
#ifdef Q_OS_MAC
typedef void * iconv_t;
@@ -100,6 +100,4 @@ public:
QT_END_NAMESPACE
-#endif // Q_OS_UNIX && !QT_NO_ICONV && !QT_BOOTSTRAPPED
-
#endif // QICONVCODEC_P_H
diff --git a/src/corelib/codecs/qtextcodec.cpp b/src/corelib/codecs/qtextcodec.cpp
index 5098ac4242..0c9036aadf 100644
--- a/src/corelib/codecs/qtextcodec.cpp
+++ b/src/corelib/codecs/qtextcodec.cpp
@@ -61,7 +61,7 @@
#if defined(QT_USE_ICU)
#include "qicucodec_p.h"
#else
-#if !defined(QT_NO_ICONV)
+#if QT_CONFIG(iconv)
# include "qiconvcodec_p.h"
#endif
#ifdef Q_OS_WIN
@@ -184,7 +184,7 @@ static QTextCodec *setupLocaleMapper()
if (charset)
locale = QTextCodec::codecForName(charset);
#endif
-#if !defined(QT_NO_ICONV) && !defined(QT_BOOTSTRAPPED)
+#if QT_CONFIG(iconv)
if (!locale) {
// no builtin codec for the locale found, let's try using iconv
(void) new QIconvCodec();
@@ -286,7 +286,7 @@ static void setup()
(void)new QBig5Codec;
(void)new QBig5hkscsCodec;
# endif // !QT_NO_BIG_CODECS && !Q_OS_INTEGRITY
-#if !defined(QT_NO_ICONV)
+#if QT_CONFIG(iconv)
(void) new QIconvCodec;
#endif
#if defined(Q_OS_WIN32)