Make IDN support conditional

[zj: rename HAVE_IDN to ENABLE_IDN]
This commit is contained in:
Waldemar Brodkorb 2017-06-15 17:44:59 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 42d3bf86bb
commit 6326a14326
2 changed files with 17 additions and 2 deletions

View File

@ -1049,6 +1049,15 @@ if test "$have_libidn2" != "yes"; then
fi
AM_CONDITIONAL(HAVE_LIBIDN, [test "$have_libidn" = "yes"])
# ------------------------------------------------------------------------------
have_idn=no
AC_ARG_ENABLE(idn, AS_HELP_STRING([--disable-idn], [disable IDN when printing host names]))
if test "x$enable_idn" != "xno"; then
have_idn=yes
AC_DEFINE(ENABLE_IDN, [1], [IDN is enabled])
fi
AM_CONDITIONAL(ENABLE_IDN, [test "$have_idn" = "yes"])
# ------------------------------------------------------------------------------
have_libiptc=no
AC_ARG_ENABLE(libiptc, AS_HELP_STRING([--disable-libiptc], [disable optional LIBIPTC support]))
@ -1742,6 +1751,7 @@ AC_MSG_RESULT([
libcurl: ${have_libcurl}
libidn2: ${have_libidn2}
libidn: ${have_libidn}
IDN: ${have_idn}
libiptc: ${have_libiptc}
ELFUTILS: ${have_elfutils}
binfmt: ${have_binfmt}

View File

@ -48,6 +48,12 @@
#include "utf8.h"
#include "util.h"
#ifdef ENABLE_IDN
# define IDN_FLAGS (NI_IDN|NI_IDN_USE_STD3_ASCII_RULES)
#else
# define IDN_FLAGS 0
#endif
int socket_address_parse(SocketAddress *a, const char *s) {
char *e, *n;
unsigned u;
@ -723,8 +729,7 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret)
assert(_ret);
r = getnameinfo(&sa->sa, salen, host, sizeof(host), NULL, 0,
NI_IDN|NI_IDN_USE_STD3_ASCII_RULES);
r = getnameinfo(&sa->sa, salen, host, sizeof(host), NULL, 0, IDN_FLAGS);
if (r != 0) {
int saved_errno = errno;