Simon Josefsson wrote: > I've tested it better now It was still apparently tested only on few systems. As you can see from doc/posix-functions/inet*.texi, the functions inet_ntop and inet_pton need to be declared also on HP-UX 11, OSF/1 4.0, Solaris 2.5.1. So the gnulib <arpa/inet.h> must be used in these cases as well (at least). And it must include the system's <arpa/inet.h>, which the present mingw-only replacement didn't do.
Also, in the GNULIB_POSIXCHECK-conditionalized warnings, it is misleading to say "inet_pton doesn't exist on mingw" when in fact it does not exist on a couple of Unix systems either. (See doc/posix-functions/inet*.texi for reference.) mingw is one of gnulib's target platforms, but not its primary one. I committed this. 2008-04-29 Bruno Haible <[EMAIL PROTECTED]> * lib/arpa_inet.in.h: Include system's <arpa/inet.h> if it exists. (inet_ntop, inet_pton): Change portability warning's wording. * m4/arpa_inet_h.m4 (gl_HEADER_ARPA_INET): Set HAVE_ARPA_INET_H. Invoke gl_CHECK_NEXT_HEADERS. (gl_ARPA_INET_H_DEFAULTS): Initialize ARPA_INET_H. * m4/inet_ntop.m4 (gl_INET_NTOP): Require gl_ARPA_INET_H_DEFAULTS and set ARPA_INET_H. * m4/inet_pton.m4 (gl_INET_PTON): Likewise. * modules/arpa_inet (Description): No longer only for systems that lack it. (Depends-on): Add include_next. (Makeile.am): Substitute INCLUDE_NEXT, NEXT_ARPA_INET_H, HAVE_ARPA_INET_H. *** lib/arpa_inet.in.h.orig 2008-04-29 13:24:54.000000000 +0200 --- lib/arpa_inet.in.h 2008-04-29 13:16:51.000000000 +0200 *************** *** 1,5 **** ! /* Provide a arpa/inet header file for systems lacking it (read: MinGW) ! Copyright (C) 2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by --- 1,6 ---- ! /* A GNU-like <arpa/inet.h>. ! ! Copyright (C) 2005-2006, 2008 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by *************** *** 16,27 **** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _GL_ARPA_INET_H - #define _GL_ARPA_INET_H /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc under MinGW. */ #include <sys/socket.h> #if @GNULIB_INET_NTOP@ # if [EMAIL PROTECTED]@ /* Converts an internet address from internal format to a printable, --- 17,37 ---- Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef _GL_ARPA_INET_H /* Gnulib's sys/socket.h is responsible for pulling in winsock2.h etc under MinGW. */ #include <sys/socket.h> + #if @HAVE_ARPA_INET_H@ + + /* The include_next requires a split double-inclusion guard. */ + # @INCLUDE_NEXT@ @NEXT_ARPA_INET_H@ + + #endif + + #ifndef _GL_ARPA_INET_H + #define _GL_ARPA_INET_H + #if @GNULIB_INET_NTOP@ # if [EMAIL PROTECTED]@ /* Converts an internet address from internal format to a printable, *************** *** 44,51 **** # endif #elif defined GNULIB_POSIXCHECK # undef inet_ntop ! # define inet_ntop(af,src,dst,cnt) \ ! (GL_LINK_WARNING ("inet_ntop doesn't exist on mingw - " \ "use gnulib module inet_ntop for portability"), \ inet_ntop (af, src, dst, cnt)) #endif --- 54,61 ---- # endif #elif defined GNULIB_POSIXCHECK # undef inet_ntop ! # define inet_ntop(af,src,dst,cnt) \ ! (GL_LINK_WARNING ("inet_ntop is unportable - " \ "use gnulib module inet_ntop for portability"), \ inet_ntop (af, src, dst, cnt)) #endif *************** *** 56,65 **** # endif #elif defined GNULIB_POSIXCHECK # undef inet_pton ! # define inet_pton(af,src,dst) \ ! (GL_LINK_WARNING ("inet_pton doesn't exist on mingw - " \ ! "use gnulib module inet_pton for portability"), \ inet_pton (af, src, dst)) #endif #endif /* _GL_ARPA_INET_H */ --- 66,76 ---- # endif #elif defined GNULIB_POSIXCHECK # undef inet_pton ! # define inet_pton(af,src,dst) \ ! (GL_LINK_WARNING ("inet_pton is unportable - " \ ! "use gnulib module inet_pton for portability"), \ inet_pton (af, src, dst)) #endif #endif /* _GL_ARPA_INET_H */ + #endif /* _GL_ARPA_INET_H */ *** m4/arpa_inet_h.m4.orig 2008-04-29 13:24:54.000000000 +0200 --- m4/arpa_inet_h.m4 2008-04-29 13:22:28.000000000 +0200 *************** *** 1,10 **** ! # arpa_inet_h.m4 serial 2 dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. ! dnl Written by Simon Josefsson AC_DEFUN([gl_HEADER_ARPA_INET], [ --- 1,10 ---- ! # arpa_inet_h.m4 serial 3 dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. ! dnl Written by Simon Josefsson and Bruno Haible AC_DEFUN([gl_HEADER_ARPA_INET], [ *************** *** 14,24 **** AC_CHECK_HEADERS_ONCE([arpa/inet.h]) if test $ac_cv_header_arpa_inet_h = yes; then ! ARPA_INET_H='' else ARPA_INET_H='arpa/inet.h' fi ! AC_SUBST(ARPA_INET_H) ]) AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR], --- 14,29 ---- AC_CHECK_HEADERS_ONCE([arpa/inet.h]) if test $ac_cv_header_arpa_inet_h = yes; then ! HAVE_ARPA_INET_H=1 else ARPA_INET_H='arpa/inet.h' + HAVE_ARPA_INET_H=0 fi ! AC_SUBST([HAVE_ARPA_INET_H]) ! dnl Execute this unconditionally, because ARPA_INET_H may be set by other ! dnl modules, after this code is executed. ! gl_CHECK_NEXT_HEADERS([arpa/inet.h]) ! ]) AC_DEFUN([gl_ARPA_INET_MODULE_INDICATOR], *************** *** 35,38 **** --- 40,44 ---- dnl Assume proper GNU behavior unless another module says otherwise. HAVE_DECL_INET_NTOP=1; AC_SUBST([HAVE_DECL_INET_NTOP]) HAVE_DECL_INET_PTON=1; AC_SUBST([HAVE_DECL_INET_PTON]) + ARPA_INET_H=''; AC_SUBST([ARPA_INET_H]) ]) *** m4/inet_ntop.m4.orig 2008-04-29 13:24:54.000000000 +0200 --- m4/inet_ntop.m4 2008-04-29 13:09:22.000000000 +0200 *************** *** 1,4 **** ! # inet_ntop.m4 serial 4 dnl Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # inet_ntop.m4 serial 5 dnl Copyright (C) 2005, 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 6,11 **** --- 6,14 ---- AC_DEFUN([gl_INET_NTOP], [ + AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) + ARPA_INET_H='arpa/inet.h' + AC_REPLACE_FUNCS(inet_ntop) gl_PREREQ_INET_NTOP ]) *** m4/inet_pton.m4.orig 2008-04-29 13:24:54.000000000 +0200 --- m4/inet_pton.m4 2008-04-29 13:09:22.000000000 +0200 *************** *** 1,4 **** ! # inet_pton.m4 serial 3 dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, --- 1,4 ---- ! # inet_pton.m4 serial 4 dnl Copyright (C) 2006, 2008 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, *************** *** 6,11 **** --- 6,14 ---- AC_DEFUN([gl_INET_PTON], [ + AC_REQUIRE([gl_ARPA_INET_H_DEFAULTS]) + ARPA_INET_H='arpa/inet.h' + AC_REPLACE_FUNCS(inet_pton) gl_PREREQ_INET_PTON ]) *** modules/arpa_inet.orig 2008-04-29 13:24:54.000000000 +0200 --- modules/arpa_inet 2008-04-29 13:18:56.000000000 +0200 *************** *** 1,11 **** Description: ! A <arpa/inet.h> for systems lacking it (e.g., Mingw). Files: lib/arpa_inet.in.h m4/arpa_inet_h.m4 Depends-on: sys_socket configure.ac: --- 1,12 ---- Description: ! A GNU-like <arpa/inet.h>. Files: lib/arpa_inet.in.h m4/arpa_inet_h.m4 Depends-on: + include_next sys_socket configure.ac: *************** *** 21,27 **** @MKDIR_P@ arpa rm -f [EMAIL PROTECTED] $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ ! sed \ -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \ -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \ -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \ --- 22,30 ---- @MKDIR_P@ arpa rm -f [EMAIL PROTECTED] $@ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ ! sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ ! -e 's|@''NEXT_ARPA_INET_H''@|$(NEXT_ARPA_INET_H)|g' \ ! -e 's|@''HAVE_ARPA_INET_H''@|$(HAVE_ARPA_INET_H)|g' \ -e 's|@''GNULIB_INET_NTOP''@|$(GNULIB_INET_NTOP)|g' \ -e 's|@''GNULIB_INET_PTON''@|$(GNULIB_INET_PTON)|g' \ -e 's|@''HAVE_DECL_INET_NTOP''@|$(HAVE_DECL_INET_NTOP)|g' \