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>
bb10
Lars Knoll 2016-11-22 10:13:41 +01:00
parent 7e9aca683a
commit fd9e5d9033
6 changed files with 17 additions and 22 deletions

View File

@ -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 {

View File

@ -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 */

View File

@ -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

View File

@ -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)

View File

@ -245,21 +245,21 @@
"label": "iconv",
"purpose": "Provides internationalization on Unix.",
"section": "Internationalization",
"condition": "features.posix-libiconv || features.sun-libiconv || features.gnu-libiconv",
"condition": "!features.icu && (features.posix-libiconv || features.sun-libiconv || features.gnu-libiconv)",
"output": [ "privateFeature", "feature" ]
},
"posix-libiconv": {
"label": "POSIX iconv",
"enable": "input.iconv == 'posix'",
"disable": "input.iconv == 'sun' || input.iconv == 'gnu' || input.iconv == 'no'",
"condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && tests.posix-iconv"
"condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && tests.posix-iconv",
"output": [ "privateFeature" ]
},
"sun-libiconv": {
"label": "SUN iconv",
"enable": "input.iconv == 'sun'",
"disable": "input.iconv == 'posix' || input.iconv == 'gnu' || input.iconv == 'no'",
"condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && !features.posix-libiconv && tests.sun-iconv",
"output": [ "privateFeature", "publicQtConfig" ]
"condition": "!config.win32 && !config.qnx && !config.android && !config.darwin && !features.posix-libiconv && tests.sun-iconv"
},
"gnu-libiconv": {
"label": "GNU iconv",

View File

@ -68,6 +68,7 @@
#define QT_CRYPTOGRAPHICHASH_ONLY_SHA1
#define QT_NO_DATASTREAM
#define QT_FEATURE_iconv -1
#define QT_NO_LIBRARY
#define QT_FEATURE_library -1
#define QT_NO_QOBJECT