summaryrefslogtreecommitdiffstats
path: root/src/corelib/codecs
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/codecs')
-rw-r--r--src/corelib/codecs/codecs.pri6
-rw-r--r--src/corelib/codecs/qiconvcodec.cpp56
-rw-r--r--src/corelib/codecs/qiconvcodec_p.h8
-rw-r--r--src/corelib/codecs/qsimplecodec_p.h10
-rw-r--r--src/corelib/codecs/qtextcodec.cpp6
5 files changed, 18 insertions, 68 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..e4fb359f2c 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"
@@ -62,7 +64,7 @@
#elif defined(Q_OS_AIX)
# define NO_BOM
# define UTF16 "UCS-2"
-#elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC)
+#elif defined(Q_OS_FREEBSD)
# define NO_BOM
# if Q_BYTE_ORDER == Q_BIG_ENDIAN
# define UTF16 "UTF-16BE"
@@ -73,19 +75,6 @@
# define UTF16 "UTF-16"
#endif
-#if defined(Q_OS_MAC)
-#ifndef GNU_LIBICONV
-#define GNU_LIBICONV
-#endif
-typedef iconv_t (*Ptr_iconv_open) (const char*, const char*);
-typedef size_t (*Ptr_iconv) (iconv_t, const char **, size_t *, char **, size_t *);
-typedef int (*Ptr_iconv_close) (iconv_t);
-
-static Ptr_iconv_open ptr_iconv_open = 0;
-static Ptr_iconv ptr_iconv = 0;
-static Ptr_iconv_close ptr_iconv_close = 0;
-#endif
-
QT_BEGIN_NAMESPACE
QIconvCodec::QIconvCodec()
@@ -103,33 +92,6 @@ void QIconvCodec::init() const
fprintf(stderr, "QIconvCodec::convertToUnicode: internal error, UTF-16 codec not found\n");
utf16Codec = reinterpret_cast<QTextCodec *>(~0);
}
-#if defined(Q_OS_MAC)
- if (ptr_iconv_open == 0) {
- QLibrary libiconv(QLatin1String("/usr/lib/libiconv"));
- libiconv.setLoadHints(QLibrary::ExportExternalSymbolsHint);
-
- ptr_iconv_open = reinterpret_cast<Ptr_iconv_open>(libiconv.resolve("libiconv_open"));
- if (!ptr_iconv_open)
- ptr_iconv_open = reinterpret_cast<Ptr_iconv_open>(libiconv.resolve("iconv_open"));
- ptr_iconv = reinterpret_cast<Ptr_iconv>(libiconv.resolve("libiconv"));
- if (!ptr_iconv)
- ptr_iconv = reinterpret_cast<Ptr_iconv>(libiconv.resolve("iconv"));
- ptr_iconv_close = reinterpret_cast<Ptr_iconv_close>(libiconv.resolve("libiconv_close"));
- if (!ptr_iconv_close)
- ptr_iconv_close = reinterpret_cast<Ptr_iconv_close>(libiconv.resolve("iconv_close"));
-
- Q_ASSERT_X(ptr_iconv_open && ptr_iconv && ptr_iconv_close,
- "QIconvCodec::QIconvCodec()",
- "internal error, could not resolve the iconv functions");
-
-# undef iconv_open
-# define iconv_open ptr_iconv_open
-# undef iconv
-# define iconv ptr_iconv
-# undef iconv_close
-# define iconv_close ptr_iconv_close
- }
-#endif
}
QIconvCodec::~QIconvCodec()
@@ -221,7 +183,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 +282,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 +304,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 +434,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 +524,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..9b8500538b 100644
--- a/src/corelib/codecs/qiconvcodec_p.h
+++ b/src/corelib/codecs/qiconvcodec_p.h
@@ -54,13 +54,9 @@
#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;
-#else
#include <iconv.h>
-#endif
QT_BEGIN_NAMESPACE
@@ -100,6 +96,4 @@ public:
QT_END_NAMESPACE
-#endif // Q_OS_UNIX && !QT_NO_ICONV && !QT_BOOTSTRAPPED
-
#endif // QICONVCODEC_P_H
diff --git a/src/corelib/codecs/qsimplecodec_p.h b/src/corelib/codecs/qsimplecodec_p.h
index d268a9f5b8..188c3f3cb4 100644
--- a/src/corelib/codecs/qsimplecodec_p.h
+++ b/src/corelib/codecs/qsimplecodec_p.h
@@ -67,12 +67,12 @@ public:
explicit QSimpleTextCodec(int);
~QSimpleTextCodec();
- QString convertToUnicode(const char *, int, ConverterState *) const;
- QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const;
+ QString convertToUnicode(const char *, int, ConverterState *) const override;
+ QByteArray convertFromUnicode(const QChar *, int, ConverterState *) const override;
- QByteArray name() const;
- QList<QByteArray> aliases() const;
- int mibEnum() const;
+ QByteArray name() const override;
+ QList<QByteArray> aliases() const override;
+ int mibEnum() const override;
private:
int forwardIndex;
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)