Add support for QNX iconv implementation
authorRafael Roquetto <rafael.roquetto@kdab.com>
Thu, 2 Feb 2012 15:06:05 +0000 (16:06 +0100)
committerQt by Nokia <qt-info@nokia.com>
Fri, 3 Feb 2012 12:14:06 +0000 (13:14 +0100)
QNX implements the POSIX version of iconv (with non-const function
signatures). However, it is still necessary to link with libiconv, unlike most
cases. Also, its iconv_open does not know how to handle an empty string.

Change-Id: I8654703e46b9c64503aca5521ce7fae1c97d7968
Reviewed-by: Mark Brand <mabrand@mabrand.nl>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
config.tests/unix/iconv/iconv.pro
configure
src/corelib/codecs/codecs.pri
src/corelib/codecs/qiconvcodec.cpp

index d642da2..ec573ce 100644 (file)
@@ -1,3 +1,3 @@
 SOURCES = iconv.cpp
 CONFIG -= qt dylib app_bundle
-mac|win32-g++*:LIBS += -liconv
+mac|win32-g++*|blackberry-*-qcc:LIBS += -liconv
index dd014ef..46bebb1 100755 (executable)
--- a/configure
+++ b/configure
@@ -5056,8 +5056,8 @@ fi
 
 # auto-detect iconv(3) support
 if [ "$CFG_ICONV" != "no" ]; then
-    if [ "$PLATFORM_QWS" = "yes" -o "$PLATFORM_QPA" = "yes" -o "$XPLATFORM_MINGW" = "yes" ]; then
-       CFG_ICONV=no
+    if [ "$PLATFORM_QWS" = "yes" -o "$XPLATFORM_MINGW" = "yes" ] || [ "$PLATFORM_QPA" = "yes" -a "$CFG_ICONV" = "auto" ]; then
+        CFG_ICONV=no
     elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/iconv" "POSIX iconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
         CFG_ICONV=yes
     elif "$unixtests/compile.test" "$XQMAKESPEC" "$QMAKE_CONFIG" "$OPT_VERBOSE" "$relpath" "$outpath" "config.tests/unix/sun-libiconv" "SUN libiconv" $L_FLAGS $I_FLAGS $l_FLAGS $MAC_CONFIG_TEST_COMMANDLINE; then
index d0bafc3..c3a15ab 100644 (file)
@@ -38,6 +38,7 @@ unix {
         contains(QT_CONFIG,iconv) {
                 HEADERS += codecs/qiconvcodec_p.h
                 SOURCES += codecs/qiconvcodec.cpp
+                blackberry-*-qcc:LIBS_PRIVATE *= -liconv
         } else:contains(QT_CONFIG,gnu-libiconv) {
                 HEADERS += codecs/qiconvcodec_p.h
                 SOURCES += codecs/qiconvcodec.cpp
index 98dc377..1941b70 100644 (file)
@@ -462,8 +462,13 @@ iconv_t QIconvCodec::createIconv_t(const char *to, const char *from)
 
     iconv_t cd = (iconv_t) -1;
 #if defined(__GLIBC__) || defined(GNU_LIBICONV)
+#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";
+#else
     // both GLIBC and libgnuiconv will use the locale's encoding if from or to is an empty string
     static const char empty_codeset[] = "";
+#endif
     const char *codeset = empty_codeset;
     cd = iconv_open(to ? to : codeset, from ? from : codeset);
 #else