On Solaris at least, getpass() is not declared in <unistd.h> or <stdlib.h> if __EXTENSIONS__ is not defined. This fixes the autoconf test and the use of <unistd.h> in lib/getpass.h.
By the way, on all systems (including glibc), getpass() is declared by including <unistd.h>. I would propose to move its declaration in gnulib from "getpass.h" to <unistd.h>, and to drop getpass.h. (getpass.h was created in 2004, when we didn't have a <unistd.h> replacement.) Objections? 2010-11-26 Bruno Haible <[email protected]> getpass: Make sure to get system declaration on some platforms. * m4/getpass.m4 (gl_FUNC_GETPASS, gl_FUNC_GETPASS_GNU): Require gl_USE_SYSTEM_EXTENSIONS. * modules/getpass (Depends-on): Add extensions. --- m4/getpass.m4.orig Sat Nov 27 14:18:38 2010 +++ m4/getpass.m4 Sat Nov 27 14:14:39 2010 @@ -1,4 +1,4 @@ -# getpass.m4 serial 11 +# getpass.m4 serial 12 dnl Copyright (C) 2002-2003, 2005-2006, 2009-2010 Free Software Foundation, dnl Inc. dnl This file is free software; the Free Software Foundation @@ -8,6 +8,9 @@ # Provide a getpass() function if the system doesn't have it. AC_DEFUN([gl_FUNC_GETPASS], [ + dnl Persuade Solaris <unistd.h> and <stdlib.h> to declare getpass(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_REPLACE_FUNCS([getpass]) AC_CHECK_DECLS_ONCE([getpass]) if test $ac_cv_func_getpass = no; then @@ -19,6 +22,9 @@ # arbitrary length (not just 8 bytes as on HP-UX). AC_DEFUN([gl_FUNC_GETPASS_GNU], [ + dnl Persuade Solaris <unistd.h> and <stdlib.h> to declare getpass(). + AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) + AC_CHECK_DECLS_ONCE([getpass]) dnl TODO: Detect when GNU getpass() is already found in glibc. AC_LIBOBJ([getpass]) --- modules/getpass.orig Sat Nov 27 14:18:38 2010 +++ modules/getpass Sat Nov 27 14:12:35 2010 @@ -7,6 +7,7 @@ m4/getpass.m4 Depends-on: +extensions fseeko getline stdbool
