[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#237990: Fixing before 3.3?



Hi

Why not just remove the dlopen and link at compile time? Here is a patch that 
do just that. Build-dep on libidn11-dev and run "make -f Makefile.cvs" before 
building.

Regards
	Martin
diff -Nrua kdelibs-3.2.2/kdecore/kidna.cpp kdelibs-patched/kdecore/kidna.cpp
--- kdelibs-3.2.2/kdecore/kidna.cpp	2004-02-04 12:43:34.000000000 +0100
+++ kdelibs-patched/kdecore/kidna.cpp	2004-04-12 16:56:30.000000000 +0200
@@ -1,6 +1,7 @@
 /*
     This file is part of the KDE libraries
 
+    Copyright (c) 2004 Martin Juhlin <martin.juhlin@home.se>
     Copyright (c) 2003 Waldo Bastian <bastian@kde.org>
 
     This library is free software; you can redistribute it and/or
@@ -17,169 +18,99 @@
     along with this library; see the file COPYING.LIB.  If not, write to
     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
     Boston, MA 02111-1307, USA.
+
+    Modifications:
+    2004-04-12   martin: Removed dynamic linking.
 */
 
 #include "kidna.h"
-
-#include <kdebug.h>
-
-#include "ltdl.h"
+#include <idna.h>
 #include <stdlib.h>
 
-#define IDNA_SUCCESS 0
-
-static lt_dlhandle KIDNA_lib; // = 0
-static bool KIDNA_lib_load_failed; // = false
-
-typedef int (*KIDNA_utf8_to_ace_t)(const char *, char **, int);
-typedef int (*KIDNA_utf8ace_to_utf8_t)(const char *, char **, int);
-
-static KIDNA_utf8_to_ace_t KIDNA_utf8_to_ace; // = 0
-static KIDNA_utf8ace_to_utf8_t KIDNA_utf8ace_to_utf8; // = 0
-
-static void KIDNA_load_lib()
-{
-   KIDNA_lib_load_failed = true; // Unless proven otherwise
-   KIDNA_lib = lt_dlopen("/usr/local/lib/libidn.la");
-   if (!KIDNA_lib) 
-   {
-      KIDNA_lib = lt_dlopen("/usr/lib/libidn.la");
-   }
-   
-   if (!KIDNA_lib) 
-      return; // Error
-
-   KIDNA_utf8_to_ace = (KIDNA_utf8_to_ace_t) lt_dlsym(KIDNA_lib, "idna_to_ascii_8z");
-   if (!KIDNA_utf8_to_ace)
-   {
-      kdWarning() << "Symbol idna_utf8_to_ace not found." << endl;   
-      return; // Error
-   }
-         
-   KIDNA_utf8ace_to_utf8 = (KIDNA_utf8ace_to_utf8_t) lt_dlsym(KIDNA_lib, "idna_to_unicode_8z8z");
-   if (!KIDNA_utf8ace_to_utf8)
-   {
-      kdWarning() << "Symbol idna_utf8ace_to_utf8 not found." << endl;   
-      return; // Error
-   }
-   KIDNA_lib_load_failed = false; // Succes
-}
-
 QCString KIDNA::toAsciiCString(const QString &idna)
 {
-   int l = idna.length();
-   const QChar *u = idna.unicode();
-   bool needConversion = false;
-   for(;l--;)
-   {
-      if ((*u++).unicode() > 127)
-      {
-          needConversion = true;
-          break;
-      }
-   }
-   if (!needConversion)
-      return idna.lower().latin1();
-
-   if (!KIDNA_lib && !KIDNA_lib_load_failed)
-   {
-      KIDNA_load_lib();
-   }
-
-   if (KIDNA_lib_load_failed)
-   {
-      return 0; // Can't convert
-   }
-   else 
-   {
-      // Also handle names that start with "." even though libidn
-      // doesn't like those
-      bool bStartsWithDot = (idna[0] == '.');
-      char *pOutput;
-      if ((*KIDNA_utf8_to_ace)(idna.utf8().data()+(bStartsWithDot ? 1: 0), &pOutput, 0) == IDNA_SUCCESS)
-      {
-         QCString result = pOutput;
-         free(pOutput);
-         if (bStartsWithDot)
-            return "."+result;
-         return result;
-      }
-      else
-      {
-         return 0; // Can't convert
-      }
-   }
+    int l = idna.length();
+    const QChar *u = idna.unicode();
+    bool needConversion = false;
+    for(;l--;)
+    {
+        if ((*u++).unicode() > 127)
+        {
+            needConversion = true;
+            break;
+        }
+    }
+    if (!needConversion)
+        return idna.lower().latin1();
+
+    // Also handle names that start with "." even though libidn
+    // doesn't like those
+    bool bStartsWithDot = (idna[0] == '.');
+    char *pOutput;
+
+    if (idna_to_ascii_8z(idna.utf8().data() + (bStartsWithDot ? 1 : 0), &pOutput, 0) == IDNA_SUCCESS)
+    {
+        QCString result = pOutput;
+        free(pOutput);
+        if (bStartsWithDot)
+            return "." + result;
+        return result;
+    }
+    else
+    {
+        // Can't convert
+        return 0;
+    }
 }
 
 QString KIDNA::toAscii(const QString &idna)
 {
-   int l = idna.length();
-   const QChar *u = idna.unicode();
-   bool needConversion = false;
-   for(;l--;)
-   {
-      if ((*u++).unicode() > 127)
-      {
-          needConversion = true;
-          break;
-      }
-   }
-   if (!needConversion)
-      return idna.lower();
-
-   if (!KIDNA_lib && !KIDNA_lib_load_failed)
-   {
-      KIDNA_load_lib();
-   }
-
-   if (KIDNA_lib_load_failed)
-   {
-      return QString::null; // Can't convert
-   }
-   else 
-   {
-      // Also handle names that start with "." even though libidn
-      // doesn't like those
-      bool bStartsWithDot = (idna[0] == '.');
-      char *pOutput;
-      if ((*KIDNA_utf8_to_ace)(idna.utf8().data()+(bStartsWithDot ? 1: 0), &pOutput, 0) == IDNA_SUCCESS)
-      {
-         QString result(pOutput);
-         free(pOutput);
-         if (bStartsWithDot)
-            return "."+result;
-         return result;
-      }
-      else
-      {
-         return QString::null; // Can't convert
-      }
-   }
+    int l = idna.length();
+    const QChar *u = idna.unicode();
+    bool needConversion = false;
+    for(;l--;)
+    {
+        if ((*u++).unicode() > 127)
+        {
+            needConversion = true;
+            break;
+        }
+    }
+    if (!needConversion)
+        return idna.lower();
+
+    // Also handle names that start with "." even though libidn
+    // doesn't like those
+    bool bStartsWithDot = (idna[0] == '.');
+    char *pOutput;
+
+    if (idna_to_ascii_8z(idna.utf8().data() + (bStartsWithDot ? 1 : 0), &pOutput, 0) == IDNA_SUCCESS)
+    {
+        QString result(pOutput);
+        free(pOutput);
+        if (bStartsWithDot)
+            return "." + result;
+        return result;
+    }
+    else
+    {
+        // Can't convert
+        return QString::null;
+    }
 }
 
 QString KIDNA::toUnicode(const QString &idna)
 {
-   if (!KIDNA_lib && !KIDNA_lib_load_failed)
-   {
-      KIDNA_load_lib();
-   }
-
-   if (KIDNA_lib_load_failed)
-   {
-      return idna.lower(); // Return as is
-   }
-   else 
-   {
-      char *pOutput;
-      if ((*KIDNA_utf8ace_to_utf8)(idna.utf8(), &pOutput, 0) == IDNA_SUCCESS)
-      {
-         QString result = QString::fromUtf8(pOutput);
-         free(pOutput);
-         return result;
-      }
-      else
-      {
-         return idna.lower(); // Return as is.
-      }
-   }
+    char * pOutput;
+    if (idna_to_unicode_8z8z(idna.utf8(), &pOutput, 0) == IDNA_SUCCESS)
+    {
+        QString ret = QString::fromUtf8(pOutput);
+	free(pOutput);
+	return ret;
+    }
+    else
+    {
+        // failed, return as is
+	return idna.lower();
+    }
 }
diff -Nrua kdelibs-3.2.2/kdecore/Makefile.am kdelibs-patched/kdecore/Makefile.am
--- kdelibs-3.2.2/kdecore/Makefile.am	2003-11-21 13:06:53.000000000 +0100
+++ kdelibs-patched/kdecore/Makefile.am	2004-04-12 16:55:34.000000000 +0200
@@ -110,7 +110,7 @@
 	kuser.cpp kconfigskeleton.cpp kconfigdialogmanager.cpp
 
 libkdecore_la_LDFLAGS = $(QT_LDFLAGS) $(KDE_RPATH) $(KDE_MT_LDFLAGS) $(X_LDFLAGS) $(USER_LDFLAGS) -version-info 6:0:2 -no-undefined
-libkdecore_la_LIBADD = malloc/libklmalloc.la $(SVGICON_LIB) ../dcop/libDCOP.la ../libltdl/libltdlc.la $(LIB_XEXT) $(LIBRESOLV) $(LIBUTIL) $(LIBART_LIBS) ../kdefx/libkdefx.la
+libkdecore_la_LIBADD = malloc/libklmalloc.la $(SVGICON_LIB) ../dcop/libDCOP.la ../libltdl/libltdlc.la $(LIB_XEXT) $(LIBRESOLV) $(LIBUTIL) $(LIBART_LIBS) ../kdefx/libkdefx.la -lidn 
 libkdecore_la_NMCHECK = $(srcdir)/libkdecore.nmcheck
 libkdecore_la_NMCHECKWEAK = $(srcdir)/libkdecore_weak.nmcheck $(srcdir)/libqt-mt_weak.nmcheck \
 	$(top_srcdir)/dcop/libDCOP_weak.nmcheck $(top_srcdir)/kdecore/standard_weak.nmcheck

Reply to: