]> granicus.if.org Git - neomutt/commitdiff
build: fix a bunch of idn2-related problems
authorRichard Russon <rich@flatcap.org>
Sat, 23 Mar 2019 01:00:13 +0000 (01:00 +0000)
committerRichard Russon <rich@flatcap.org>
Sun, 28 Apr 2019 10:13:56 +0000 (11:13 +0100)
- hide code if IDN is disabled
- fix build tests
- add travis dependency

.travis.yml
address/idna.c
auto.def
test/idna/main.c
test/idna/mutt_idna_intl_to_local.c
test/idna/mutt_idna_local_to_intl.c
test/idna/mutt_idna_print_version.c
test/idna/mutt_idna_to_ascii_lz.c

index c55a85d93dbe9625753c594d120297bb5c7c8768..439c39dd371c0ff59c3540896e9a38f4ce256e56 100644 (file)
@@ -19,6 +19,7 @@ addons:
       - libgnutls-dev
       - libgpgme11-dev
       - libgss-dev
+      - libidn2-0-dev
       - libkyotocabinet-dev
       - liblmdb-dev
       - liblua5.2-dev
index 539b35aafe4d5363477f025e85e45a4e74dcd46a..ef7861e8d137caec0057d4bde431877ffb6df896 100644 (file)
@@ -38,6 +38,7 @@
 #include <idn/stringprep.h>
 #endif
 #ifdef HAVE_IDN2_H
+#include <idna.h>
 #include <idn2.h>
 #elif defined(HAVE_IDN_IDN2_H)
 #include <idn/idn2.h>
@@ -106,6 +107,9 @@ static bool check_idn(char *domain)
  */
 int mutt_idna_to_ascii_lz(const char *input, char **output, int flags)
 {
+  if (!input || !output)
+    return 1;
+
   return idna_to_ascii_lz(input, output, flags);
 }
 #endif /* HAVE_LIBIDN */
index 298756a1d0d655b922eec672c312dfe4a94f3e5c..54f432cb62906e49e05c6b8daa51d347bf65e40f 100644 (file)
--- a/auto.def
+++ b/auto.def
@@ -717,6 +717,7 @@ if {[get-define want-idn]} {
   cc-with [list -cflags -I$idn_prefix/include -libs -L$idn_prefix/lib] {
     set idn2 [cc-check-includes idn2.h]
     incr idn2 [cc-check-includes idn/idn2.h]
+    set  sprcv [cc-check-function-in-lib stringprep_check_version idn]
     set lu8  [cc-check-function-in-lib idn2_lookup_u8 idn2]
     if {$idn2 == 0 || $lu8 == 0} {
       user-error "Unable to find GNU libidn2"
index 88fd31178ce7050e9329048e7e8ed99e96cc22f2..929b9bb4da92749aa6d25e8911653610e1a984fc 100644 (file)
  * Add your test cases to this list.
  *****************************************************************************/
 #define NEOMUTT_TEST_LIST                                                      \
-  NEOMUTT_TEST_ITEM(mutt_idna_intl_to_local)                                   \
-  NEOMUTT_TEST_ITEM(mutt_idna_local_to_intl)                                   \
-  NEOMUTT_TEST_ITEM(mutt_idna_print_version)                                   \
-  NEOMUTT_TEST_ITEM(mutt_idna_to_ascii_lz)
+  NEOMUTT_TEST_ITEM(test_mutt_idna_intl_to_local)                              \
+  NEOMUTT_TEST_ITEM(test_mutt_idna_local_to_intl)                              \
+  NEOMUTT_TEST_ITEM(test_mutt_idna_print_version)                              \
+  NEOMUTT_TEST_ITEM(test_mutt_idna_to_ascii_lz)
 
 /******************************************************************************
  * You probably don't need to touch what follows.
index a6e0e6d0e4f6532d75876d93d947af2b65e7fb07..bd41e7c80e8c461c26ba615b6059b17f82ff52cf 100644 (file)
@@ -30,6 +30,7 @@ void test_mutt_idna_intl_to_local(void)
 {
   // char * mutt_idna_intl_to_local(const char *user, const char *domain, int flags);
 
+#ifdef HAVE_LIBIDN
   {
     TEST_CHECK(!mutt_idna_intl_to_local(NULL, "banana", 0));
   }
@@ -37,4 +38,5 @@ void test_mutt_idna_intl_to_local(void)
   {
     TEST_CHECK(!mutt_idna_intl_to_local("apple", NULL, 0));
   }
+#endif
 }
index 63657cd7ad1f9cd9fe03c20ca9c4e7867f442dd8..342f49f5ef20675f1df5e76925391f644de9a0c7 100644 (file)
@@ -30,6 +30,7 @@ void test_mutt_idna_local_to_intl(void)
 {
   // char * mutt_idna_local_to_intl(const char *user, const char *domain);
 
+#ifdef HAVE_LIBIDN
   {
     TEST_CHECK(!mutt_idna_local_to_intl(NULL, "banana"));
   }
@@ -37,4 +38,5 @@ void test_mutt_idna_local_to_intl(void)
   {
     TEST_CHECK(!mutt_idna_local_to_intl("apple", NULL));
   }
+#endif
 }
index a477e7029ad15a0250a4e7faaf2dea0928773bb2..e296ed9a272b01b8aeca6af5aea8ad2d2dc1d2f8 100644 (file)
@@ -29,4 +29,6 @@
 void test_mutt_idna_print_version(void)
 {
   // const char *mutt_idna_print_version(void);
+#ifdef HAVE_LIBIDN
+#endif
 }
index bf45b32d8f45afcac4fa5fa84f18f1c82609a44d..3abf7f64401cbc8d0fa8c9f38ca09573df733cf2 100644 (file)
@@ -30,12 +30,14 @@ void test_mutt_idna_to_ascii_lz(void)
 {
   // int mutt_idna_to_ascii_lz(const char *input, char **output, int flags);
 
+#ifdef HAVE_LIBIDN
   {
     char *out = NULL;
-    TEST_CHECK(mutt_idna_to_ascii_lz(NULL, &out, 0) == -1);
+    TEST_CHECK(mutt_idna_to_ascii_lz(NULL, &out, 0) != 0);
   }
 
   {
-    TEST_CHECK(mutt_idna_to_ascii_lz("apple", NULL, 0) == -1);
+    TEST_CHECK(mutt_idna_to_ascii_lz("apple", NULL, 0) != 0);
   }
+#endif
 }