patch 8.2.0594: MS-Windows: cannot build with WINVER set to 0x0501
Problem: MS-Windows: cannot build with WINVER set to 0x0501.
Solution: Only use inet_ntop() when available. (Ozaki Kiichi, closes #5946)
diff --git a/src/Make_cyg_ming.mak b/src/Make_cyg_ming.mak
index d767c79..750e940 100644
--- a/src/Make_cyg_ming.mak
+++ b/src/Make_cyg_ming.mak
@@ -625,6 +625,9 @@
ifeq ($(CHANNEL),yes)
DEFINES += -DFEAT_JOB_CHANNEL -DFEAT_IPV6
+ ifeq ($(shell expr "$(WINVER)" \>= 0x600),1)
+DEFINES += -DHAVE_INET_NTOP
+ endif
endif
ifeq ($(TERMINAL),yes)
diff --git a/src/Make_mvc.mak b/src/Make_mvc.mak
index e95a94a..ebc059f 100644
--- a/src/Make_mvc.mak
+++ b/src/Make_mvc.mak
@@ -317,6 +317,10 @@
CPU = ix86
!endif
+### Set the default $(WINVER) to make it work with VC++7.0 (VS.NET)
+!ifndef WINVER
+WINVER = 0x0501
+!endif
# Flag to turn on Win64 compatibility warnings for VC7.x and VC8.
WP64CHECK = /Wp64
@@ -468,6 +472,9 @@
CHANNEL_PRO = proto/channel.pro
CHANNEL_OBJ = $(OBJDIR)/channel.obj
CHANNEL_DEFS = -DFEAT_JOB_CHANNEL -DFEAT_IPV6
+! if $(WINVER) >= 0x600
+CHANNEL_DEFS = $(CHANNEL_DEFS) -DHAVE_INET_NTOP
+! endif
NETBEANS_LIB = WSock32.lib Ws2_32.lib
!endif
@@ -493,11 +500,6 @@
CON_LIB = $(CON_LIB) /DELAYLOAD:comdlg32.dll /DELAYLOAD:ole32.dll DelayImp.lib
!endif
-### Set the default $(WINVER) to make it work with VC++7.0 (VS.NET)
-!ifndef WINVER
-WINVER = 0x0501
-!endif
-
# If you have a fixed directory for $VIM or $VIMRUNTIME, other than the normal
# default, use these lines.
#VIMRCLOC = somewhere
diff --git a/src/auto/configure b/src/auto/configure
index 33bf663..e72cf70 100755
--- a/src/auto/configure
+++ b/src/auto/configure
@@ -7872,6 +7872,17 @@
if test "x$vim_cv_ipv6_networking" = "xyes"; then
$as_echo "#define FEAT_IPV6 1" >>confdefs.h
+ for ac_func in inet_ntop
+do :
+ ac_fn_c_check_func "$LINENO" "inet_ntop" "ac_cv_func_inet_ntop"
+if test "x$ac_cv_func_inet_ntop" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_INET_NTOP 1
+_ACEOF
+
+fi
+done
+
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostbyname in -lnsl" >&5
$as_echo_n "checking for gethostbyname in -lnsl... " >&6; }
diff --git a/src/channel.c b/src/channel.c
index 0d86423..9577f3d 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -996,9 +996,11 @@
for (addr = res; addr != NULL; addr = addr->ai_next)
{
- const char *dst = hostname;
- const void *src = NULL;
- char buf[NUMBUFLEN];
+ const char *dst = hostname;
+ const void *src = NULL;
+# ifdef HAVE_INET_NTOP
+ char buf[NUMBUFLEN];
+# endif
if (addr->ai_family == AF_INET6)
{
@@ -1014,12 +1016,16 @@
sai->sin_port = htons(port);
src = &sai->sin_addr;
}
+# ifdef HAVE_INET_NTOP
if (src != NULL)
{
dst = inet_ntop(addr->ai_family, src, buf, sizeof(buf));
- if (dst != NULL && STRCMP(hostname, dst) != 0)
+ if (dst == NULL)
+ dst = hostname;
+ else if (STRCMP(hostname, dst) != 0)
ch_log(channel, "Resolved %s to %s", hostname, dst);
}
+# endif
ch_log(channel, "Trying to connect to %s port %d", dst, port);
diff --git a/src/config.h.in b/src/config.h.in
index 166724c..8354930 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -174,6 +174,7 @@
#undef HAVE_GETTIMEOFDAY
#undef HAVE_GETWD
#undef HAVE_ICONV
+#undef HAVE_INET_NTOP
#undef HAVE_LOCALTIME_R
#undef HAVE_LSTAT
#undef HAVE_MEMSET
diff --git a/src/configure.ac b/src/configure.ac
index 47502a9..972337b 100644
--- a/src/configure.ac
+++ b/src/configure.ac
@@ -2077,6 +2077,7 @@
if test "x$vim_cv_ipv6_networking" = "xyes"; then
AC_DEFINE(FEAT_IPV6)
+ AC_CHECK_FUNCS(inet_ntop)
else
dnl On Solaris we need the nsl library.
AC_CHECK_LIB(nsl, gethostbyname)
diff --git a/src/version.c b/src/version.c
index c3a0a19..09dc678 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 594,
+/**/
593,
/**/
592,